list mirror (unofficial, one of many)
 help / color / Atom feed
From: Hironao OTSUBO <>
Cc:, Hironao OTSUBO <>
Subject: [PATCH] subtree: die if failed to find existing splits
Date: Wed, 14 Feb 2018 13:38:21 +0900
Message-ID: <> (raw)

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 <>

    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.

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

diff --git a/contrib/subtree/ b/contrib/subtree/
index dec085a23..81ad6e716 100755
--- a/contrib/subtree/
+++ b/contrib/subtree/
@@ -693,7 +693,7 @@ cmd_split () {
-		unrevs="$(find_existing_splits "$dir" "$revs")"
+		unrevs="$(find_existing_splits "$dir" "$revs")" || die "could not find existing splits"
 	# We can't restrict rev-list to only $dir here, because some of our
diff --git a/contrib/subtree/t/ b/contrib/subtree/t/
index d05c613c9..fb3d73acf 100755
--- a/contrib/subtree/t/
+++ b/contrib/subtree/t/
@@ -493,6 +493,24 @@ test_expect_success 'split "sub dir"/ with --branch for an incompatible branch'
+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

                 reply index

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

Reply instructions:

You may reply publically 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:

  List information:

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

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror
	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:

 note: .onion URLs require Tor:

AGPL code for this site: git clone public-inbox