threads / rfc / 29555

RFC patchgit-new-workdir: add option --rsync

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

## tl;dr

One message between Feb 5, 2012 and Feb 5, 2012. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Michael Schubert· Feb 5, 2012, 16:27 UTC · lore

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(-)
Show changes to contrib/workdir/git-new-workdir +29 −2
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

← back to recent threads