{"thread":{"id":"47835","subject":"[PATCH] subtree: die if failed to find existing splits","startedAt":"2018-02-14T04:39:01Z","lastAt":"2018-02-14T04:39:01Z","messageCount":1,"participants":["Hironao OTSUBO"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"339259","messageId":"20180214043821.13900-1-motemen@gmail.com","threadId":"47835","inReplyTo":null,"subject":"[PATCH] subtree: die if failed to find existing splits","fromName":"Hironao OTSUBO","fromEmail":"motemen@gmail.com","sentAt":"2018-02-14T04:38:21Z","receivedAt":"2018-02-14T04:39:01Z","isPatch":true,"sender":{"key":"motemen@gmail.com","avatar":null},"body":"When using git-subtree with --squash option, you may not have commits\nindicated by git-subtree-split: at hand.\n\nfind_existing_splits dies on such situation, but the caller cmd_split\nignored it and produce unwanted output, i.e. a history that does not\ncontain commits from subproject. This patch fixes it.\n\nSigned-off-by: Hironao OTSUBO <motemen@gmail.com>\n---\n\nNotes:\n    I know there was a discussion [1] about moving git-subtree development to\n    GitHub, but don't know where the actual repository is, so I am sending this\n    patch to the mailing list.\n    \n    [1]: https://public-inbox.org/git/87mv7kf369.fsf@waller.obbligato.org/\n\n contrib/subtree/git-subtree.sh     |  2 +-\n contrib/subtree/t/t7900-subtree.sh | 18 ++++++++++++++++++\n 2 files changed, 19 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex dec085a23..81ad6e716 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -693,7 +693,7 @@ cmd_split () {\n \tthen\n \t\tunrevs=\n \telse\n-\t\tunrevs=\"$(find_existing_splits \"$dir\" \"$revs\")\"\n+\t\tunrevs=\"$(find_existing_splits \"$dir\" \"$revs\")\" || die \"could not find existing splits\"\n \tfi\n \n \t# We can't restrict rev-list to only $dir here, because some of our\ndiff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh\nindex d05c613c9..fb3d73acf 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -493,6 +493,24 @@ test_expect_success 'split \"sub dir\"/ with --branch for an incompatible branch'\n \t)\n '\n \n+next_test\n+test_expect_success 'split fails without squashed commits existing' '\n+\tsubtree_test_create_repo \"$subtree_test_count\" &&\n+\tsubtree_test_create_repo \"$subtree_test_count/sub proj\" &&\n+\ttest_create_commit \"$subtree_test_count\" main1 &&\n+\ttest_create_commit \"$subtree_test_count/sub proj\" sub1 &&\n+\t\tcommit1=$( cd \"$subtree_test_count/sub proj\" && git rev-parse HEAD ) &&\n+\ttest_create_commit \"$subtree_test_count/sub proj\" sub2 &&\n+\t(\n+\t\tcd \"$subtree_test_count\" &&\n+\t\tgit fetch ./\"sub proj\" master &&\n+\t\tgit subtree add --prefix=\"sub dir\" --squash FETCH_HEAD &&\n+\t\tgit gc --prune=all &&\n+\t\t! git rev-parse -q --verify \"$commit1^{commit}\" &&\n+\t\ttest_must_fail git subtree split --prefix=\"sub dir\"\n+\t)\n+'\n+\n #\n # Validity checking\n #\n-- \n2.16.1\n\n"}]}