git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: David Greene <greened@obbligato.org>
To: git@vger.kernel.org
Cc: techlivezheng@gmail.com, alex.crezoff@gmail.com,
	davvid@gmail.com, cbailey32@bloomberg.net, danny0838@gmail.com,
	prohaska@zib.de, th.acker@arcor.de, sschuberth@gmail.com,
	peff@peff.net, gitter.spiros@gmail.com, nod.helm@gmail.com,
	"David A . Greene" <greened@obbligato.org>
Subject: [PATCH 7/7] contrib/subtree: Handle '--prefix' argument with a slash appended
Date: Thu,  5 Nov 2015 21:35:03 -0600	[thread overview]
Message-ID: <1446780903-22156-8-git-send-email-greened@obbligato.org> (raw)
In-Reply-To: <1446780903-22156-1-git-send-email-greened@obbligato.org>

From: Techlive Zheng <techlivezheng@gmail.com>

'git subtree merge' will fail if the argument of '--prefix' has a slash
appended.

Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
 contrib/subtree/git-subtree.sh     |  2 +-
 contrib/subtree/t/t7900-subtree.sh | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 308b777..edf36f8 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -90,7 +90,7 @@ while [ $# -gt 0 ]; do
 		--annotate) annotate="$1"; shift ;;
 		--no-annotate) annotate= ;;
 		-b) branch="$1"; shift ;;
-		-P) prefix="$1"; shift ;;
+		-P) prefix="${1%/}"; shift ;;
 		-m) message="$1"; shift ;;
 		--no-prefix) prefix= ;;
 		--onto) onto="$1"; shift ;;
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 2683d7d..751aee3 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -257,6 +257,26 @@ test_expect_success 'merge the added subproj again, should do nothing' '
 	)
 '
 
+next_test
+test_expect_success 'merge new subproj history into subdir/ with a slash appended to the argument of --prefix' '
+	test_create_repo "$test_count" &&
+	test_create_repo "$test_count/subproj" &&
+	test_create_commit "$test_count" main1 &&
+	test_create_commit "$test_count/subproj" sub1 &&
+	(
+		cd "$test_count" &&
+		git fetch ./subproj master &&
+		git subtree add --prefix=subdir/ FETCH_HEAD
+	) &&
+	test_create_commit "$test_count/subproj" sub2 &&
+	(
+		cd "$test_count" &&
+		git fetch ./subproj master &&
+		git subtree merge --prefix=subdir/ FETCH_HEAD &&
+		check_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\''"
+	)
+'
+
 #
 # Tests for 'git subtree split'
 #
-- 
2.6.1

  parent reply	other threads:[~2015-11-06  4:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-06  3:34 (unknown), David Greene
2015-11-06  3:34 ` [PATCH 1/7] contrib/subtree: Clean and refactor test code David Greene
2015-11-11  2:52   ` David A. Greene
2015-11-06  3:34 ` [PATCH 2/7] contrib/subtree: Add test for missing subtree David Greene
2015-11-06  3:34 ` [PATCH 3/7] contrib/subtree: Add tests for subtree add David Greene
2015-11-06  3:35 ` [PATCH 4/7] contrib/subtree: Add merge tests David Greene
2015-11-06  3:35 ` [PATCH 5/7] contrib/subtree: Add split tests David Greene
2015-11-06  3:35 ` [PATCH 6/7] contrib/subtree: Make each test self-contained David Greene
2015-11-06  3:35 ` David Greene [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-11-13  2:32 [PATCH 0/7] contrib/subtree: Testsuite cleanup David Greene
2015-11-13  2:32 ` [PATCH 7/7] contrib/subtree: Handle '--prefix' argument with a slash appended David Greene

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=1446780903-22156-8-git-send-email-greened@obbligato.org \
    --to=greened@obbligato.org \
    --cc=alex.crezoff@gmail.com \
    --cc=cbailey32@bloomberg.net \
    --cc=danny0838@gmail.com \
    --cc=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitter.spiros@gmail.com \
    --cc=nod.helm@gmail.com \
    --cc=peff@peff.net \
    --cc=prohaska@zib.de \
    --cc=sschuberth@gmail.com \
    --cc=techlivezheng@gmail.com \
    --cc=th.acker@arcor.de \
    /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).