git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC/PATCH] git-new-workdir: add option --rsync

From
MSMichael Schubert <mschub@elegosoft.com>
Date
Feb 5, 2012, 16:27 UTC
Message-ID
<4F2EADF7.5000907@elegosoft.com>

Currently, git-new-workdir doesn't allow you to rather duplicate your old workdir instead of creating a new one based on a branch. This can be annoying when you are used to carry untracked helper scripts in your workdir (e.g. test.sh).

Add a new option -s | --rsync to allow users to "sync" the new workdir.
Signed-off-by: Michael Schubert <mschub@elegosoft.com>
---

Maybe we even want to stop after rsync'ing without doing the checkout -f. Opinions?

 contrib/workdir/git-new-workdir |   31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir
index 75e8b25..bac75f9 100755
--- a/contrib/workdir/git-new-workdir
+++ b/contrib/workdir/git-new-workdir
@@ -10,9 +10,30 @@ die () {
 	exit 128
 }
 
-if test $# -lt 2 || test $# -gt 3
+if test $# -lt 2
 then
-	usage "$0 <repository> <new_workdir> [<branch>]"
+	usage "$0 [-s | --rsync] <repository> <new_workdir> [<branch>]"
+fi
+
+rsync=
+
+while test $# != 0
+do
+  case "$1" in
+  -s|--rsync)
+    rsync=t ;;
+  *)
+    break ;;
+  esac
+  shift
+done
+
+if test -n "$rsync"
+then
+  if ! $(hash rsync 2>/dev/null)
+  then
+   die "cannot find rsync"
+  fi
 fi
 
 orig_git=$1
@@ -77,6 +98,12 @@ done
 cd "$new_workdir"
 # copy the HEAD from the original repository as a default branch
 cp "$git_dir/HEAD" .git/HEAD
+
+if test -n "$rsync"
+then
+  rsync --archive --exclude '.*' "../$orig_git/" .
+fi
+
 # checkout the branch (either the same as HEAD from the original repository, or
 # the one that was asked for)
 git checkout -f $branch
-- 
1.7.9.230.gbd302
Message 1 of 1 in “git-new-workdir: add option --rsync”
  1. git-new-workdir: add option --rsyncMichael Schubert, Feb 5, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.