git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
* [PATCH] subtree: die if failed to find existing splits
@ 2018-02-14  4:38 Hironao OTSUBO
  0 siblings, 0 replies; 1+ messages in thread
From: Hironao OTSUBO @ 2018-02-14  4:38 UTC (permalink / raw)
  To: git; +Cc: greened, Hironao OTSUBO

When using git-subtree with --squash option, you may not have commits
indicated by git-subtree-split: at hand.

find_existing_splits dies on such situation, but the caller cmd_split
ignored it and produce unwanted output, i.e. a history that does not
contain commits from subproject. This patch fixes it.

Signed-off-by: Hironao OTSUBO <motemen@gmail.com>
---

Notes:
    I know there was a discussion [1] about moving git-subtree development to
    GitHub, but don't know where the actual repository is, so I am sending this
    patch to the mailing list.
    
    [1]: https://public-inbox.org/git/87mv7kf369.fsf@waller.obbligato.org/

 contrib/subtree/git-subtree.sh     |  2 +-
 contrib/subtree/t/t7900-subtree.sh | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index dec085a23..81ad6e716 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -693,7 +693,7 @@ cmd_split () {
 	then
 		unrevs=
 	else
-		unrevs="$(find_existing_splits "$dir" "$revs")"
+		unrevs="$(find_existing_splits "$dir" "$revs")" || die "could not find existing splits"
 	fi
 
 	# We can't restrict rev-list to only $dir here, because some of our
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index d05c613c9..fb3d73acf 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -493,6 +493,24 @@ test_expect_success 'split "sub dir"/ with --branch for an incompatible branch'
 	)
 '
 
+next_test
+test_expect_success 'split fails without squashed commits existing' '
+	subtree_test_create_repo "$subtree_test_count" &&
+	subtree_test_create_repo "$subtree_test_count/sub proj" &&
+	test_create_commit "$subtree_test_count" main1 &&
+	test_create_commit "$subtree_test_count/sub proj" sub1 &&
+		commit1=$( cd "$subtree_test_count/sub proj" && git rev-parse HEAD ) &&
+	test_create_commit "$subtree_test_count/sub proj" sub2 &&
+	(
+		cd "$subtree_test_count" &&
+		git fetch ./"sub proj" master &&
+		git subtree add --prefix="sub dir" --squash FETCH_HEAD &&
+		git gc --prune=all &&
+		! git rev-parse -q --verify "$commit1^{commit}" &&
+		test_must_fail git subtree split --prefix="sub dir"
+	)
+'
+
 #
 # Validity checking
 #
-- 
2.16.1


^ permalink raw reply	[flat|nested] 1+ messages in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-14  4:38 [PATCH] subtree: die if failed to find existing splits Hironao OTSUBO

git@vger.kernel.org mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox