git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Schubert <mschub@elegosoft.com>
To: git <git@vger.kernel.org>
Subject: [RFC/PATCH] git-new-workdir: add option --rsync
Date: Sun, 05 Feb 2012 17:27:35 +0100	[thread overview]
Message-ID: <4F2EADF7.5000907@elegosoft.com> (raw)

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

                 reply	other threads:[~2012-02-05 16:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F2EADF7.5000907@elegosoft.com \
    --to=mschub@elegosoft.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).