git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Paul Campbell <pcampbell@kemitix.net>
To: git@vger.kernel.org
Cc: "David A. Greene" <greened@obbligato.org>,
	Michael Schubert <mschub@elegosoft.com>
Subject: [PATCH 2/4] contrib/subtree: Allow stale .gitsubtree entries to be replaced
Date: Tue, 12 Feb 2013 23:23:14 +0000	[thread overview]
Message-ID: <CALeLG_=t1E9uemehqPD48r+2JrRSToJJcSBuOQn=Qz7730=4-w@mail.gmail.com> (raw)

Should .gitsubtree have a <prefix> listed that doesn't exist on disk, allow
it to be replaced/updated by a git subtree add.

Ideally I would have aborted the operation if there was an existing entry
and required the user to edit the .gitsubtree file by hand, but that
behaviour broke a lot of the tests.

Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
 contrib/subtree/git-subtree.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 02aae30..4f21902 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -490,7 +490,13 @@ ensure_clean()

 subtree_memorize()
 {
-	if [ $# -eq 1 ] ; then
+	if ( grep "^$dir " .gitsubtree ); then
+		# remove $dir from .gitsubtree - there's probably a clever way to
do this with sed
+		grep -v "^$dir " .gitsubtree > .gitsubtree.temp
+		rm .gitsubtree
+		mv .gitsubtree.temp .gitsubtree
+	fi
+	if [ $# -eq 1 ]; then
 		echo "$dir . $@" >> .gitsubtree
 	elif [ $# -eq 2 ]; then
 		echo "$dir $@" >> .gitsubtree
-- 
1.8.1.3.566.gaa39828

                 reply	other threads:[~2013-02-12 23:23 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to='CALeLG_=t1E9uemehqPD48r+2JrRSToJJcSBuOQn=Qz7730=4-w@mail.gmail.com' \
    --to=pcampbell@kemitix.net \
    --cc=git@vger.kernel.org \
    --cc=greened@obbligato.org \
    --cc=mschub@elegosoft.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).