{"thread":{"id":"29555","subject":"[RFC/PATCH] git-new-workdir: add option --rsync","startedAt":"2012-02-05T16:27:35Z","lastAt":"2012-02-05T16:27:35Z","messageCount":1,"participants":["Michael Schubert"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"183904","messageId":"4F2EADF7.5000907@elegosoft.com","threadId":"29555","inReplyTo":null,"subject":"[RFC/PATCH] git-new-workdir: add option --rsync","fromName":"Michael Schubert","fromEmail":"mschub@elegosoft.com","sentAt":"2012-02-05T16:27:35Z","receivedAt":"2012-02-05T16:27:35Z","isPatch":true,"sender":{"key":"mschub@elegosoft.com","avatar":null},"body":"Currently, git-new-workdir doesn't allow you to rather duplicate your\nold workdir instead of creating a new one based on a branch. This can be\nannoying when you are used to carry untracked helper scripts in your\nworkdir (e.g. test.sh).\n\nAdd a new option -s | --rsync to allow users to \"sync\" the new workdir.\n\nSigned-off-by: Michael Schubert <mschub@elegosoft.com>\n---\n\nMaybe we even want to stop after rsync'ing without doing the checkout -f.\nOpinions?\n\n contrib/workdir/git-new-workdir |   31 +++++++++++++++++++++++++++++--\n 1 file changed, 29 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir\nindex 75e8b25..bac75f9 100755\n--- a/contrib/workdir/git-new-workdir\n+++ b/contrib/workdir/git-new-workdir\n@@ -10,9 +10,30 @@ die () {\n \texit 128\n }\n \n-if test $# -lt 2 || test $# -gt 3\n+if test $# -lt 2\n then\n-\tusage \"$0 <repository> <new_workdir> [<branch>]\"\n+\tusage \"$0 [-s | --rsync] <repository> <new_workdir> [<branch>]\"\n+fi\n+\n+rsync=\n+\n+while test $# != 0\n+do\n+  case \"$1\" in\n+  -s|--rsync)\n+    rsync=t ;;\n+  *)\n+    break ;;\n+  esac\n+  shift\n+done\n+\n+if test -n \"$rsync\"\n+then\n+  if ! $(hash rsync 2>/dev/null)\n+  then\n+   die \"cannot find rsync\"\n+  fi\n fi\n \n orig_git=$1\n@@ -77,6 +98,12 @@ done\n cd \"$new_workdir\"\n # copy the HEAD from the original repository as a default branch\n cp \"$git_dir/HEAD\" .git/HEAD\n+\n+if test -n \"$rsync\"\n+then\n+  rsync --archive --exclude '.*' \"../$orig_git/\" .\n+fi\n+\n # checkout the branch (either the same as HEAD from the original repository, or\n # the one that was asked for)\n git checkout -f $branch\n-- \n1.7.9.230.gbd302\n"}]}