{"thread":{"id":"32611","subject":"[PATCH/RFC 0/7] mutiple improvements","startedAt":"2013-01-13T01:52:31Z","lastAt":"2013-01-14T03:52:21Z","messageCount":18,"participants":["Techlive Zheng","郑文辉 (Techlive Zheng)"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"206633","messageId":"1358041958-1998-1-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":null,"subject":"[PATCH/RFC 0/7] mutiple improvements","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-13T01:52:31Z","receivedAt":"2013-01-13T01:52:31Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"* refactor tests for 'git subtree'\n  * rearrange some tests\n  * clean up unnecessary quotes\n  * make each test self-contained\n* keep commit intact after the split by using '%B'\n* handle '--prefix' argument with slash appended correctly\n\nDavid A. Greene (1):\n  contrib/subtree: Remove test number comments\n\nTechlive Zheng (6):\n  contrib/subtree: Add vim modeline\n  contrib/subtree: Ignore testing directory\n  contrib/subtree: Code cleaning and refactoring\n  contrib/subtree: Make each test self-contained\n  contrib/subtree: Use %B for the split commit message\n  contrib/subtree: Handle '--prefix' argument with a slash appended\n\n contrib/subtree/.gitignore         |    5 +-\n contrib/subtree/git-subtree.sh     |   83 ++-\n contrib/subtree/git-subtree.txt    |   13 +\n contrib/subtree/t/t7900-subtree.sh | 1233 +++++++++++++++++++++++-------------\n 4 files changed, 872 insertions(+), 462 deletions(-)\n\n-- \n1.8.1\n"},{"id":"206634","messageId":"1358041958-1998-2-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358041958-1998-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC 1/7] contrib/subtree: Add vim modeline","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-13T01:52:32Z","receivedAt":"2013-01-13T01:52:32Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>\n---\n contrib/subtree/git-subtree.sh     | 2 ++\n contrib/subtree/t/t7900-subtree.sh | 2 ++\n 2 files changed, 4 insertions(+)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex 920c664..138e1e0 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -710,3 +710,5 @@ cmd_push()\n }\n \n \"cmd_$command\" \"$@\"\n+\n+# vim: set ts=4 sw=4 noet\ndiff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh\nindex bc2eeb0..3e02aeb 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -506,3 +506,5 @@ test_expect_success 'verify one file change per commit' '\n '\n \n test_done\n+\n+# vim: set et ts=4 sw=4\n-- \n1.8.1\n"},{"id":"206636","messageId":"1358041958-1998-3-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358041958-1998-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC 2/7] contrib/subtree: Ignore testing directory","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-13T01:52:33Z","receivedAt":"2013-01-13T01:52:33Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>\n---\n contrib/subtree/.gitignore | 5 ++---\n 1 file changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/subtree/.gitignore b/contrib/subtree/.gitignore\nindex 91360a3..59aeeb4 100644\n--- a/contrib/subtree/.gitignore\n+++ b/contrib/subtree/.gitignore\n@@ -1,6 +1,5 @@\n *~\n git-subtree\n-git-subtree.xml\n git-subtree.1\n-mainline\n-subproj\n+git-subtree.xml\n+t/trash\\ directory.*\n-- \n1.8.1\n"},{"id":"206635","messageId":"1358041958-1998-4-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358041958-1998-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC 3/7] contrib/subtree: Remove test number comments","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-13T01:52:34Z","receivedAt":"2013-01-13T01:52:34Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"From: \"David A. Greene\" <greened@obbligato.org>\n\nDelete the comments indicating test numbers as it causes maintenance\nheadaches.  t*.sh -i will help us find any broken tests.\n\nSigned-off-by: David A. Greene <greened@obbligato.org>\nSigned-off-by: Techlive Zheng <techlivezheng@gmail.com>\n---\n contrib/subtree/t/t7900-subtree.sh | 55 --------------------------------------\n 1 file changed, 55 deletions(-)\n\ndiff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh\nindex 3e02aeb..abdcddb 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -60,7 +60,6 @@ last_commit_message()\n \tgit log --pretty=format:%s -1\n }\n \n-# 1\n test_expect_success 'init subproj' '\n         test_create_repo subproj\n '\n@@ -68,7 +67,6 @@ test_expect_success 'init subproj' '\n # To the subproject!\n cd subproj\n \n-# 2\n test_expect_success 'add sub1' '\n         create sub1 &&\n         git commit -m \"sub1\" &&\n@@ -76,14 +74,12 @@ test_expect_success 'add sub1' '\n         git branch -m master subproj\n '\n \n-# 3\n test_expect_success 'add sub2' '\n         create sub2 &&\n         git commit -m \"sub2\" &&\n         git branch sub2\n '\n \n-# 4\n test_expect_success 'add sub3' '\n         create sub3 &&\n         git commit -m \"sub3\" &&\n@@ -93,7 +89,6 @@ test_expect_success 'add sub3' '\n # Back to mainline\n cd ..\n \n-# 5\n test_expect_success 'add main4' '\n         create main4 &&\n         git commit -m \"main4\" &&\n@@ -101,101 +96,85 @@ test_expect_success 'add main4' '\n         git branch subdir\n '\n \n-# 6\n test_expect_success 'fetch subproj history' '\n         git fetch ./subproj sub1 &&\n         git branch sub1 FETCH_HEAD\n '\n \n-# 7\n test_expect_success 'no subtree exists in main tree' '\n         test_must_fail git subtree merge --prefix=subdir sub1\n '\n \n-# 8\n test_expect_success 'no pull from non-existant subtree' '\n         test_must_fail git subtree pull --prefix=subdir ./subproj sub1\n '\n \n-# 9\n test_expect_success 'check if --message works for add' '\n         git subtree add --prefix=subdir --message=\"Added subproject\" sub1 &&\n         check_equal ''\"$(last_commit_message)\"'' \"Added subproject\" &&\n         undo\n '\n \n-# 10\n test_expect_success 'check if --message works as -m and --prefix as -P' '\n         git subtree add -P subdir -m \"Added subproject using git subtree\" sub1 &&\n         check_equal ''\"$(last_commit_message)\"'' \"Added subproject using git subtree\" &&\n         undo\n '\n \n-# 11\n test_expect_success 'check if --message works with squash too' '\n         git subtree add -P subdir -m \"Added subproject with squash\" --squash sub1 &&\n         check_equal ''\"$(last_commit_message)\"'' \"Added subproject with squash\" &&\n         undo\n '\n \n-# 12\n test_expect_success 'add subproj to mainline' '\n         git subtree add --prefix=subdir/ FETCH_HEAD &&\n         check_equal ''\"$(last_commit_message)\"'' \"Add '\"'subdir/'\"' from commit '\"'\"'''\"$(git rev-parse sub1)\"'''\"'\"'\"\n '\n \n-# 13\n # this shouldn't actually do anything, since FETCH_HEAD is already a parent\n test_expect_success 'merge fetched subproj' '\n         git merge -m \"merge -s -ours\" -s ours FETCH_HEAD\n '\n \n-# 14\n test_expect_success 'add main-sub5' '\n         create subdir/main-sub5 &&\n         git commit -m \"main-sub5\"\n '\n \n-# 15\n test_expect_success 'add main6' '\n         create main6 &&\n         git commit -m \"main6 boring\"\n '\n \n-# 16\n test_expect_success 'add main-sub7' '\n         create subdir/main-sub7 &&\n         git commit -m \"main-sub7\"\n '\n \n-# 17\n test_expect_success 'fetch new subproj history' '\n         git fetch ./subproj sub2 &&\n         git branch sub2 FETCH_HEAD\n '\n \n-# 18\n test_expect_success 'check if --message works for merge' '\n         git subtree merge --prefix=subdir -m \"Merged changes from subproject\" sub2 &&\n         check_equal ''\"$(last_commit_message)\"'' \"Merged changes from subproject\" &&\n         undo\n '\n \n-# 19\n test_expect_success 'check if --message for merge works with squash too' '\n         git subtree merge --prefix subdir -m \"Merged changes from subproject using squash\" --squash sub2 &&\n         check_equal ''\"$(last_commit_message)\"'' \"Merged changes from subproject using squash\" &&\n         undo\n '\n \n-# 20\n test_expect_success 'merge new subproj history into subdir' '\n         git subtree merge --prefix=subdir FETCH_HEAD &&\n         git branch pre-split &&\n         check_equal ''\"$(last_commit_message)\"'' \"Merge commit '\"'\"'\"$(git rev-parse sub2)\"'\"'\"' into mainline\"\n '\n \n-# 21\n test_expect_success 'Check that prefix argument is required for split' '\n         echo \"You must provide the --prefix option.\" > expected &&\n         test_must_fail git subtree split > actual 2>&1 &&\n@@ -207,7 +186,6 @@ test_expect_success 'Check that prefix argument is required for split' '\n         rm -f expected actual\n '\n \n-# 22\n test_expect_success 'Check that the <prefix> exists for a split' '\n         echo \"'\"'\"'non-existent-directory'\"'\"'\" does not exist\\; use \"'\"'\"'git subtree add'\"'\"'\" > expected &&\n         test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&\n@@ -219,7 +197,6 @@ test_expect_success 'Check that the <prefix> exists for a split' '\n #        rm -f expected actual\n '\n \n-# 23\n test_expect_success 'check if --message works for split+rejoin' '\n         spl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n         git branch spl1 \"$spl1\" &&\n@@ -227,7 +204,6 @@ test_expect_success 'check if --message works for split+rejoin' '\n         undo\n '\n \n-# 24\n test_expect_success 'check split with --branch' '\n         spl1=$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin) &&\n         undo &&\n@@ -235,7 +211,6 @@ test_expect_success 'check split with --branch' '\n         check_equal ''\"$(git rev-parse splitbr1)\"'' \"$spl1\"\n '\n \n-# 25\n test_expect_success 'check split with --branch for an existing branch' '\n         spl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n         undo &&\n@@ -244,13 +219,10 @@ test_expect_success 'check split with --branch for an existing branch' '\n         check_equal ''\"$(git rev-parse splitbr2)\"'' \"$spl1\"\n '\n \n-# 26\n test_expect_success 'check split with --branch for an incompatible branch' '\n         test_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir\n '\n \n-\n-# 27\n test_expect_success 'check split+rejoin' '\n         spl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n         undo &&\n@@ -258,7 +230,6 @@ test_expect_success 'check split+rejoin' '\n         check_equal ''\"$(last_commit_message)\"'' \"Split '\"'\"'subdir/'\"'\"' into commit '\"'\"'\"$spl1\"'\"'\"'\"\n '\n \n-# 28\n test_expect_success 'add main-sub8' '\n         create subdir/main-sub8 &&\n         git commit -m \"main-sub8\"\n@@ -267,14 +238,12 @@ test_expect_success 'add main-sub8' '\n # To the subproject!\n cd ./subproj\n \n-# 29\n test_expect_success 'merge split into subproj' '\n         git fetch .. spl1 &&\n         git branch spl1 FETCH_HEAD &&\n         git merge FETCH_HEAD\n '\n \n-# 30\n test_expect_success 'add sub9' '\n         create sub9 &&\n         git commit -m \"sub9\"\n@@ -283,19 +252,16 @@ test_expect_success 'add sub9' '\n # Back to mainline\n cd ..\n \n-# 31\n test_expect_success 'split for sub8' '\n         split2=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir/ --rejoin)\"''\n         git branch split2 \"$split2\"\n '\n \n-# 32\n test_expect_success 'add main-sub10' '\n         create subdir/main-sub10 &&\n         git commit -m \"main-sub10\"\n '\n \n-# 33\n test_expect_success 'split for sub10' '\n         spl3=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --rejoin)\"'' &&\n         git branch spl3 \"$spl3\"\n@@ -304,7 +270,6 @@ test_expect_success 'split for sub10' '\n # To the subproject!\n cd ./subproj\n \n-# 34\n test_expect_success 'merge split into subproj' '\n         git fetch .. spl3 &&\n         git branch spl3 FETCH_HEAD &&\n@@ -318,13 +283,11 @@ chkms_sub=$(echo $chkms | multiline | sed 's,^,subdir/,' | fixnl)\n chks=\"sub1 sub2 sub3 sub9\"\n chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)\n \n-# 35\n test_expect_success 'make sure exactly the right set of files ends up in the subproj' '\n         subfiles=''\"$(git ls-files | fixnl)\"'' &&\n         check_equal \"$subfiles\" \"$chkms $chks\"\n '\n \n-# 36\n test_expect_success 'make sure the subproj history *only* contains commits that affect the subdir' '\n         allchanges=''\"$(git log --name-only --pretty=format:'\"''\"' | sort | fixnl)\"'' &&\n         check_equal \"$allchanges\" \"$chkms $chks\"\n@@ -333,20 +296,17 @@ test_expect_success 'make sure the subproj history *only* contains commits that\n # Back to mainline\n cd ..\n \n-# 37\n test_expect_success 'pull from subproj' '\n         git fetch ./subproj subproj-merge-spl3 &&\n         git branch subproj-merge-spl3 FETCH_HEAD &&\n         git subtree pull --prefix=subdir ./subproj subproj-merge-spl3\n '\n \n-# 38\n test_expect_success 'make sure exactly the right set of files ends up in the mainline' '\n         mainfiles=''\"$(git ls-files | fixnl)\"'' &&\n         check_equal \"$mainfiles\" \"$chkm $chkms_sub $chks_sub\"\n '\n \n-# 39\n test_expect_success 'make sure each filename changed exactly once in the entire history' '\n         # main-sub?? and /subdir/main-sub?? both change, because those are the\n         # changes that were split into their own history.  And subdir/sub?? never\n@@ -355,12 +315,10 @@ test_expect_success 'make sure each filename changed exactly once in the entire\n         check_equal \"$allchanges\" ''\"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)\"''\n '\n \n-# 40\n test_expect_success 'make sure the --rejoin commits never make it into subproj' '\n         check_equal ''\"$(git log --pretty=format:'\"'%s'\"' HEAD^2 | grep -i split)\"'' \"\"\n '\n \n-# 41\n test_expect_success 'make sure no \"git subtree\" tagged commits make it into subproj' '\n         # They are meaningless to subproj since one side of the merge refers to the mainline\n         check_equal ''\"$(git log --pretty=format:'\"'%s%n%b'\"' HEAD^2 | grep \"git-subtree.*:\")\"'' \"\"\n@@ -370,14 +328,12 @@ test_expect_success 'make sure no \"git subtree\" tagged commits make it into subp\n mkdir test2\n cd test2\n \n-# 42\n test_expect_success 'init main' '\n         test_create_repo main\n '\n \n cd main\n \n-# 43\n test_expect_success 'add main1' '\n         create main1 &&\n         git commit -m \"main1\"\n@@ -385,14 +341,12 @@ test_expect_success 'add main1' '\n \n cd ..\n \n-# 44\n test_expect_success 'init sub' '\n         test_create_repo sub\n '\n \n cd sub\n \n-# 45\n test_expect_success 'add sub2' '\n         create sub2 &&\n         git commit -m \"sub2\"\n@@ -402,7 +356,6 @@ cd ../main\n \n # check if split can find proper base without --onto\n \n-# 46\n test_expect_success 'add sub as subdir in main' '\n         git fetch ../sub master &&\n         git branch sub2 FETCH_HEAD &&\n@@ -411,7 +364,6 @@ test_expect_success 'add sub as subdir in main' '\n \n cd ../sub\n \n-# 47\n test_expect_success 'add sub3' '\n         create sub3 &&\n         git commit -m \"sub3\"\n@@ -419,20 +371,17 @@ test_expect_success 'add sub3' '\n \n cd ../main\n \n-# 48\n test_expect_success 'merge from sub' '\n         git fetch ../sub master &&\n         git branch sub3 FETCH_HEAD &&\n         git subtree merge --prefix subdir sub3\n '\n \n-# 49\n test_expect_success 'add main-sub4' '\n         create subdir/main-sub4 &&\n         git commit -m \"main-sub4\"\n '\n \n-# 50\n test_expect_success 'split for main-sub4 without --onto' '\n         git subtree split --prefix subdir --branch mainsub4\n '\n@@ -442,19 +391,16 @@ test_expect_success 'split for main-sub4 without --onto' '\n # have been sub3, but it was not, because its cache was not set to\n # itself)\n \n-# 51\n test_expect_success 'check that the commit parent is sub3' '\n         check_equal ''\"$(git log --pretty=format:%P -1 mainsub4)\"'' ''\"$(git rev-parse sub3)\"''\n '\n \n-# 52\n test_expect_success 'add main-sub5' '\n         mkdir subdir2 &&\n         create subdir2/main-sub5 &&\n         git commit -m \"main-sub5\"\n '\n \n-# 53\n test_expect_success 'split for main-sub5 without --onto' '\n         # also test that we still can split out an entirely new subtree\n         # if the parent of the first commit in the tree is not empty,\n@@ -487,7 +433,6 @@ joincommits()\n \techo \"$commit $all\"\n }\n \n-# 54\n test_expect_success 'verify one file change per commit' '\n         x= &&\n         list=''\"$(git log --pretty=format:'\"'commit: %H'\"' | joincommits)\"'' &&\n-- \n1.8.1\n"},{"id":"206637","messageId":"1358041958-1998-5-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358041958-1998-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC 4/7] contrib/subtree: Code cleaning and refactoring","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-13T01:52:35Z","receivedAt":"2013-01-13T01:52:35Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"Mostly prepare for the later tests refactoring.\n\nSigned-off-by: Techlive Zheng <techlivezheng@gmail.com>\n---\n contrib/subtree/git-subtree.sh     |  66 ++++-----\n contrib/subtree/t/t7900-subtree.sh | 283 +++++++++++++++++++------------------\n 2 files changed, 179 insertions(+), 170 deletions(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex 138e1e0..91e6e87 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -5,7 +5,7 @@\n # Copyright (C) 2009 Avery Pennarun <apenwarr@gmail.com>\n #\n if [ $# -eq 0 ]; then\n-    set -- -h\n+\tset -- -h\n fi\n OPTS_SPEC=\"\\\n git subtree add   --prefix=<prefix> <commit>\n@@ -110,9 +110,9 @@ if [ -z \"$prefix\" ]; then\n fi\n \n case \"$command\" in\n-\tadd) [ -e \"$prefix\" ] && \n+\tadd) [ -e \"$prefix\" ] &&\n \t\tdie \"prefix '$prefix' already exists.\" ;;\n-\t*)   [ -e \"$prefix\" ] || \n+\t*)   [ -e \"$prefix\" ] ||\n \t\tdie \"'$prefix' does not exist; use 'git subtree add'\" ;;\n esac\n \n@@ -181,8 +181,8 @@ cache_set()\n \toldrev=\"$1\"\n \tnewrev=\"$2\"\n \tif [ \"$oldrev\" != \"latest_old\" \\\n-\t     -a \"$oldrev\" != \"latest_new\" \\\n-\t     -a -e \"$cachedir/$oldrev\" ]; then\n+\t\t-a \"$oldrev\" != \"latest_new\" \\\n+\t\t-a -e \"$cachedir/$oldrev\" ]; then\n \t\tdie \"cache for $oldrev already exists!\"\n \tfi\n \techo \"$newrev\" >\"$cachedir/$oldrev\"\n@@ -327,7 +327,7 @@ add_msg()\n \tfi\n \tcat <<-EOF\n \t\t$commit_message\n-\t\t\n+\n \t\tgit-subtree-dir: $dir\n \t\tgit-subtree-mainline: $latest_old\n \t\tgit-subtree-split: $latest_new\n@@ -355,7 +355,7 @@ rejoin_msg()\n \tfi\n \tcat <<-EOF\n \t\t$commit_message\n-\t\t\n+\n \t\tgit-subtree-dir: $dir\n \t\tgit-subtree-mainline: $latest_old\n \t\tgit-subtree-split: $latest_new\n@@ -368,7 +368,7 @@ squash_msg()\n \toldsub=\"$2\"\n \tnewsub=\"$3\"\n \tnewsub_short=$(git rev-parse --short \"$newsub\")\n-\t\n+\n \tif [ -n \"$oldsub\" ]; then\n \t\toldsub_short=$(git rev-parse --short \"$oldsub\")\n \t\techo \"Squashed '$dir/' changes from $oldsub_short..$newsub_short\"\n@@ -378,7 +378,7 @@ squash_msg()\n \telse\n \t\techo \"Squashed '$dir/' content from commit $newsub_short\"\n \tfi\n-\t\n+\n \techo\n \techo \"git-subtree-dir: $dir\"\n \techo \"git-subtree-split: $newsub\"\n@@ -427,7 +427,7 @@ new_squash_commit()\n \tnewsub=\"$3\"\n \ttree=$(toptree_for_commit $newsub) || exit $?\n \tif [ -n \"$old\" ]; then\n-\t\tsquash_msg \"$dir\" \"$oldsub\" \"$newsub\" | \n+\t\tsquash_msg \"$dir\" \"$oldsub\" \"$newsub\" |\n \t\t\tgit commit-tree \"$tree\" -p \"$old\" || exit $?\n \telse\n \t\tsquash_msg \"$dir\" \"\" \"$newsub\" |\n@@ -455,7 +455,7 @@ copy_or_skip()\n \t\telse\n \t\t\tnonidentical=\"$parent\"\n \t\tfi\n-\t\t\n+\n \t\t# sometimes both old parents map to the same newparent;\n \t\t# eliminate duplicates\n \t\tis_new=1\n@@ -470,7 +470,7 @@ copy_or_skip()\n \t\t\tp=\"$p -p $parent\"\n \t\tfi\n \tdone\n-\t\n+\n \tif [ -n \"$identical\" ]; then\n \t\techo $identical\n \telse\n@@ -495,14 +495,14 @@ cmd_add()\n \tfi\n \n \tensure_clean\n-\t\n+\n \tif [ $# -eq 1 ]; then\n \t\t\"cmd_add_commit\" \"$@\"\n \telif [ $# -eq 2 ]; then\n \t\t\"cmd_add_repository\" \"$@\"\n \telse\n-\t    say \"error: parameters were '$@'\"\n-\t    die \"Provide either a refspec or a repository and refspec.\"\n+\t\tsay \"error: parameters were '$@'\"\n+\t\tdie \"Provide either a refspec or a repository and refspec.\"\n \tfi\n }\n \n@@ -522,19 +522,19 @@ cmd_add_commit()\n \trevs=$(git rev-parse $default --revs-only \"$@\") || exit $?\n \tset -- $revs\n \trev=\"$1\"\n-\t\n+\n \tdebug \"Adding $dir as '$rev'...\"\n \tgit read-tree --prefix=\"$dir\" $rev || exit $?\n \tgit checkout -- \"$dir\" || exit $?\n \ttree=$(git write-tree) || exit $?\n-\t\n+\n \theadrev=$(git rev-parse HEAD) || exit $?\n \tif [ -n \"$headrev\" -a \"$headrev\" != \"$rev\" ]; then\n \t\theadp=\"-p $headrev\"\n \telse\n \t\theadp=\n \tfi\n-\t\n+\n \tif [ -n \"$squash\" ]; then\n \t\trev=$(new_squash_commit \"\" \"\" \"$rev\") || exit $?\n \t\tcommit=$(add_squashed_msg \"$rev\" \"$dir\" |\n@@ -544,7 +544,7 @@ cmd_add_commit()\n \t\t\t git commit-tree $tree $headp -p \"$rev\") || exit $?\n \tfi\n \tgit reset \"$commit\" || exit $?\n-\t\n+\n \tsay \"Added dir '$dir'\"\n }\n \n@@ -552,7 +552,7 @@ cmd_split()\n {\n \tdebug \"Splitting $dir...\"\n \tcache_setup || exit $?\n-\t\n+\n \tif [ -n \"$onto\" ]; then\n \t\tdebug \"Reading history for --onto=$onto...\"\n \t\tgit rev-list $onto |\n@@ -563,13 +563,13 @@ cmd_split()\n \t\t\tcache_set $rev $rev\n \t\tdone\n \tfi\n-\t\n+\n \tif [ -n \"$ignore_joins\" ]; then\n \t\tunrevs=\n \telse\n \t\tunrevs=\"$(find_existing_splits \"$dir\" \"$revs\")\"\n \tfi\n-\t\n+\n \t# We can't restrict rev-list to only $dir here, because some of our\n \t# parents have the $dir contents the root, and those won't match.\n \t# (and rev-list --follow doesn't seem to solve this)\n@@ -591,12 +591,12 @@ cmd_split()\n \t\tdebug \"  parents: $parents\"\n \t\tnewparents=$(cache_get $parents)\n \t\tdebug \"  newparents: $newparents\"\n-\t\t\n+\n \t\ttree=$(subtree_for_commit $rev \"$dir\")\n \t\tdebug \"  tree is: $tree\"\n \n \t\tcheck_parents $parents\n-\t\t\n+\n \t\t# ugly.  is there no better way to tell if this is a subtree\n \t\t# vs. a mainline commit?  Does it matter?\n \t\tif [ -z $tree ]; then\n@@ -617,7 +617,7 @@ cmd_split()\n \tif [ -z \"$latest_new\" ]; then\n \t\tdie \"No new revisions were found\"\n \tfi\n-\t\n+\n \tif [ -n \"$rejoin\" ]; then\n \t\tdebug \"Merging split branch into HEAD...\"\n \t\tlatest_old=$(cache_get latest_old)\n@@ -645,13 +645,13 @@ cmd_merge()\n {\n \trevs=$(git rev-parse $default --revs-only \"$@\") || exit $?\n \tensure_clean\n-\t\n+\n \tset -- $revs\n \tif [ $# -ne 1 ]; then\n \t\tdie \"You must provide exactly one revision.  Got: '$revs'\"\n \tfi\n \trev=\"$1\"\n-\t\n+\n \tif [ -n \"$squash\" ]; then\n \t\tfirst_split=\"$(find_latest_squash \"$dir\")\"\n \t\tif [ -z \"$first_split\" ]; then\n@@ -697,15 +697,15 @@ cmd_pull()\n cmd_push()\n {\n \tif [ $# -ne 2 ]; then\n-\t    die \"You must provide <repository> <refspec>\"\n+\t\tdie \"You must provide <repository> <refspec>\"\n \tfi\n \tif [ -e \"$dir\" ]; then\n-\t    repository=$1\n-\t    refspec=$2\n-\t    echo \"git push using: \" $repository $refspec\n-\t    git push $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec\n+\t\trepository=$1\n+\t\trefspec=$2\n+\t\techo \"git push using: \" $repository $refspec\n+\t\tgit push $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec\n \telse\n-\t    die \"'$dir' must already exist. Try 'git subtree add'.\"\n+\t\tdie \"'$dir' must already exist. Try 'git subtree add'.\"\n \tfi\n }\n \ndiff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh\nindex abdcddb..bb4fd1f 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -4,7 +4,7 @@\n #\n test_description='Basic porcelain support for subtrees\n \n-This test verifies the basic operation of the merge, pull, add\n+This test verifies the basic operation of the add, pull, merge\n and split subcommands of git subtree.\n '\n \n@@ -14,50 +14,73 @@ export TEST_DIRECTORY=$(pwd)/../../../t\n \n create()\n {\n-\techo \"$1\" >\"$1\"\n-\tgit add \"$1\"\n+    echo \"$1\" >\"$1\"\n+    git add \"$1\"\n }\n \n+fixnl()\n+{\n+    t=\"\"\n+    while read x; do\n+        t=\"$t$x \"\n+    done\n+    echo $t\n+}\n \n-check_equal()\n+multiline()\n {\n-\ttest_debug 'echo'\n-\ttest_debug \"echo \\\"check a:\\\" \\\"{$1}\\\"\"\n-\ttest_debug \"echo \\\"      b:\\\" \\\"{$2}\\\"\"\n-\tif [ \"$1\" = \"$2\" ]; then\n-\t\treturn 0\n-\telse\n-\t\treturn 1\n-\tfi\n+    while read x; do\n+        set -- $x\n+        for d in \"$@\"; do\n+            echo \"$d\"\n+        done\n+    done\n }\n \n-fixnl()\n+undo()\n {\n-\tt=\"\"\n-\twhile read x; do\n-\t\tt=\"$t$x \"\n-\tdone\n-\techo $t\n+    git reset --hard HEAD~\n }\n \n-multiline()\n+test_equal()\n {\n-\twhile read x; do\n-\t\tset -- $x\n-\t\tfor d in \"$@\"; do\n-\t\t\techo \"$d\"\n-\t\tdone\n-\tdone\n+    test_debug 'echo'\n+    test_debug \"echo \\\"check a:\\\" \\\"{$1}\\\"\"\n+    test_debug \"echo \\\"      b:\\\" \\\"{$2}\\\"\"\n+    if [ \"$1\" = \"$2\" ]; then\n+        return 0\n+    else\n+        return 1\n+    fi\n }\n \n-undo()\n+# Make sure no patch changes more than one file.\n+# The original set of commits changed only one file each.\n+# A multi-file change would imply that we pruned commits\n+# too aggressively.\n+join_commits()\n {\n-\tgit reset --hard HEAD~\n+    commit=\n+    all=\n+    while read x y; do\n+        if [ -z \"$x\" ]; then\n+            continue\n+        elif [ \"$x\" = \"commit:\" ]; then\n+            if [ -n \"$commit\" ]; then\n+                echo \"$commit $all\"\n+                all=\n+            fi\n+            commit=\"$y\"\n+        else\n+            all=\"$all $y\"\n+        fi\n+    done\n+    echo \"$commit $all\"\n }\n \n last_commit_message()\n {\n-\tgit log --pretty=format:%s -1\n+    git log --pretty=format:%s -1\n }\n \n test_expect_success 'init subproj' '\n@@ -93,7 +116,7 @@ test_expect_success 'add main4' '\n         create main4 &&\n         git commit -m \"main4\" &&\n         git branch -m master mainline &&\n-        git branch subdir\n+        git branch init\n '\n \n test_expect_success 'fetch subproj history' '\n@@ -101,40 +124,43 @@ test_expect_success 'fetch subproj history' '\n         git branch sub1 FETCH_HEAD\n '\n \n-test_expect_success 'no subtree exists in main tree' '\n-        test_must_fail git subtree merge --prefix=subdir sub1\n-'\n-\n test_expect_success 'no pull from non-existant subtree' '\n         test_must_fail git subtree pull --prefix=subdir ./subproj sub1\n '\n \n-test_expect_success 'check if --message works for add' '\n-        git subtree add --prefix=subdir --message=\"Added subproject\" sub1 &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Added subproject\" &&\n+test_expect_success 'no merge from non-existant subtree' '\n+        test_must_fail git subtree merge --prefix=subdir FETCH_HEAD\n+'\n+\n+test_expect_success 'add subproj as subtree into subdir/ with --prefix' '\n+        git subtree add --prefix=subdir FETCH_HEAD &&\n+        test_equal \"$(last_commit_message)\" \"Add '\\''subdir/'\\'' from commit '\\''$(git rev-parse FETCH_HEAD)'\\''\" &&\n         undo\n '\n \n-test_expect_success 'check if --message works as -m and --prefix as -P' '\n-        git subtree add -P subdir -m \"Added subproject using git subtree\" sub1 &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Added subproject using git subtree\" &&\n+test_expect_success 'add subproj as subtree into subdir/ with --prefix and --message' '\n+        git subtree add --prefix=subdir --message=\"Added subproject\" FETCH_HEAD &&\n+        test_equal \"$(last_commit_message)\" \"Added subproject\" &&\n         undo\n '\n \n-test_expect_success 'check if --message works with squash too' '\n-        git subtree add -P subdir -m \"Added subproject with squash\" --squash sub1 &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Added subproject with squash\" &&\n+test_expect_success 'add subproj as subtree into subdir/ with --prefix as -P and --message as -m' '\n+        git subtree add -P subdir -m \"Added subproject\" FETCH_HEAD &&\n+        test_equal \"$(last_commit_message)\" \"Added subproject\" &&\n         undo\n '\n \n-test_expect_success 'add subproj to mainline' '\n-        git subtree add --prefix=subdir/ FETCH_HEAD &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Add '\"'subdir/'\"' from commit '\"'\"'''\"$(git rev-parse sub1)\"'''\"'\"'\"\n+test_expect_success 'add subproj as subtree into subdir/ with --squash and --prefix and --message' '\n+        git subtree add --prefix=subdir --message=\"Added subproject with squash\" --squash FETCH_HEAD &&\n+        test_equal \"$(last_commit_message)\" \"Added subproject with squash\" &&\n+        undo\n '\n \n-# this shouldn't actually do anything, since FETCH_HEAD is already a parent\n-test_expect_success 'merge fetched subproj' '\n-        git merge -m \"merge -s -ours\" -s ours FETCH_HEAD\n+test_expect_success 'merge the added subproj again, should do nothing' '\n+        git subtree add --prefix=subdir FETCH_HEAD &&\n+        # this shouldn not actually do anything, since FETCH_HEAD\n+        # is already a parent\n+        git merge -s ours -m \"merge -s -ours\" FETCH_HEAD\n '\n \n test_expect_success 'add main-sub5' '\n@@ -157,25 +183,30 @@ test_expect_success 'fetch new subproj history' '\n         git branch sub2 FETCH_HEAD\n '\n \n-test_expect_success 'check if --message works for merge' '\n-        git subtree merge --prefix=subdir -m \"Merged changes from subproject\" sub2 &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Merged changes from subproject\" &&\n+test_expect_success 'merge new subproj history into subdir/ with --prefix' '\n+        git subtree merge --prefix=subdir FETCH_HEAD &&\n+        test_equal \"$(last_commit_message)\" \"Merge commit '\\''$(git rev-parse FETCH_HEAD)'\\'' into mainline\" &&\n+        undo\n+'\n+\n+test_expect_success 'merge new subproj history into subdir/ with --prefix and --message' '\n+        git subtree merge --prefix=subdir --message=\"Merged changes from subproject\" FETCH_HEAD &&\n+        test_equal \"$(last_commit_message)\" \"Merged changes from subproject\" &&\n         undo\n '\n \n-test_expect_success 'check if --message for merge works with squash too' '\n-        git subtree merge --prefix subdir -m \"Merged changes from subproject using squash\" --squash sub2 &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Merged changes from subproject using squash\" &&\n+test_expect_success 'merge new subproj history into subdir/ with --squash and --prefix and --message' '\n+        git subtree merge --prefix=subdir --message=\"Merged changes from subproject using squash\" --squash FETCH_HEAD &&\n+        test_equal \"$(last_commit_message)\" \"Merged changes from subproject using squash\" &&\n         undo\n '\n \n-test_expect_success 'merge new subproj history into subdir' '\n+test_expect_success 'merge new subproj history into subdir/' '\n         git subtree merge --prefix=subdir FETCH_HEAD &&\n-        git branch pre-split &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Merge commit '\"'\"'\"$(git rev-parse sub2)\"'\"'\"' into mainline\"\n+        git branch pre-split\n '\n \n-test_expect_success 'Check that prefix argument is required for split' '\n+test_expect_success 'split requires option --prefix' '\n         echo \"You must provide the --prefix option.\" > expected &&\n         test_must_fail git subtree split > actual 2>&1 &&\n         test_debug \"echo -n expected: \" &&\n@@ -186,48 +217,52 @@ test_expect_success 'Check that prefix argument is required for split' '\n         rm -f expected actual\n '\n \n-test_expect_success 'Check that the <prefix> exists for a split' '\n-        echo \"'\"'\"'non-existent-directory'\"'\"'\" does not exist\\; use \"'\"'\"'git subtree add'\"'\"'\" > expected &&\n+test_expect_success 'split requires path given by option --prefix must exist' '\n+        echo \"'\\''non-existent-directory'\\'' does not exist; use '\\''git subtree add'\\''\" > expected &&\n         test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&\n         test_debug \"echo -n expected: \" &&\n         test_debug \"cat expected\" &&\n         test_debug \"echo -n actual: \" &&\n         test_debug \"cat actual\" &&\n-        test_cmp expected actual\n-#        rm -f expected actual\n+        test_cmp expected actual &&\n+        rm -f expected actual\n '\n \n-test_expect_success 'check if --message works for split+rejoin' '\n-        spl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n+test_expect_success 'split subdir/ with --rejoin' '\n+        spl1=$(git subtree split --prefix=subdir --annotate=\"*\") &&\n         git branch spl1 \"$spl1\" &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Split & rejoin\" &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --rejoin &&\n+        test_equal \"$(last_commit_message)\" \"Split '\\''subdir/'\\'' into commit '\\''$spl1'\\''\" &&\n         undo\n '\n \n-test_expect_success 'check split with --branch' '\n-        spl1=$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin) &&\n+test_expect_success 'split subdir/ with --rejoin and --message' '\n+        git subtree split --prefix=subdir --message=\"Split & rejoin\" --annotate=\"*\" --rejoin &&\n+        test_equal \"$(last_commit_message)\" \"Split & rejoin\" &&\n+        undo\n+'\n+\n+test_expect_success 'split subdir/ with --branch' '\n+        spl1=$(git subtree split --prefix=subdir --message=\"Split & rejoin\" --annotate=\"*\" --rejoin) &&\n         undo &&\n-        git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --branch splitbr1 &&\n-        check_equal ''\"$(git rev-parse splitbr1)\"'' \"$spl1\"\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch splitbr1 &&\n+        test_equal \"$(git rev-parse splitbr1)\" \"$spl1\"\n '\n \n-test_expect_success 'check split with --branch for an existing branch' '\n-        spl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n+test_expect_success 'split subdir/ with --branch for an existing branch' '\n+        spl1=$(git subtree split --prefix=subdir --annotate=\"*\" --message=\"Split & rejoin\" --rejoin) &&\n         undo &&\n         git branch splitbr2 sub1 &&\n-        git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --branch splitbr2 &&\n-        check_equal ''\"$(git rev-parse splitbr2)\"'' \"$spl1\"\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch splitbr2 &&\n+        test_equal \"$(git rev-parse splitbr2)\" \"$spl1\"\n '\n \n-test_expect_success 'check split with --branch for an incompatible branch' '\n-        test_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir\n+test_expect_success 'split subdir/ with --branch for an incompatible branch' '\n+        test_must_fail git subtree split --prefix=subdir --branch init\n '\n \n-test_expect_success 'check split+rejoin' '\n-        spl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n-        undo &&\n-        git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --rejoin &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Split '\"'\"'subdir/'\"'\"' into commit '\"'\"'\"$spl1\"'\"'\"'\"\n+test_expect_success 'split and rejoin' '\n+        git subtree split --prefix=subdir --annotate=\"*\" --rejoin\n '\n \n test_expect_success 'add main-sub8' '\n@@ -253,8 +288,8 @@ test_expect_success 'add sub9' '\n cd ..\n \n test_expect_success 'split for sub8' '\n-        split2=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir/ --rejoin)\"''\n-        git branch split2 \"$split2\"\n+        spl2=$(git subtree split --prefix=subdir/ --annotate=\"*\" --rejoin) &&\n+        git branch spl2 \"$spl2\"\n '\n \n test_expect_success 'add main-sub10' '\n@@ -263,7 +298,7 @@ test_expect_success 'add main-sub10' '\n '\n \n test_expect_success 'split for sub10' '\n-        spl3=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --rejoin)\"'' &&\n+        spl3=$(git subtree split --prefix=subdir --annotate=\"*\" --rejoin) &&\n         git branch spl3 \"$spl3\"\n '\n \n@@ -284,13 +319,13 @@ chks=\"sub1 sub2 sub3 sub9\"\n chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)\n \n test_expect_success 'make sure exactly the right set of files ends up in the subproj' '\n-        subfiles=''\"$(git ls-files | fixnl)\"'' &&\n-        check_equal \"$subfiles\" \"$chkms $chks\"\n+        subfiles=$(git ls-files | fixnl) &&\n+        test_equal \"$subfiles\" \"$chkms $chks\"\n '\n \n-test_expect_success 'make sure the subproj history *only* contains commits that affect the subdir' '\n-        allchanges=''\"$(git log --name-only --pretty=format:'\"''\"' | sort | fixnl)\"'' &&\n-        check_equal \"$allchanges\" \"$chkms $chks\"\n+test_expect_success 'make sure the subproj *only* contains commits that affect the subdir' '\n+        allchanges=$(git log --name-only --pretty=format:\"\" | sort | fixnl) &&\n+        test_equal \"$allchanges\" \"$chkms $chks\"\n '\n \n # Back to mainline\n@@ -303,25 +338,25 @@ test_expect_success 'pull from subproj' '\n '\n \n test_expect_success 'make sure exactly the right set of files ends up in the mainline' '\n-        mainfiles=''\"$(git ls-files | fixnl)\"'' &&\n-        check_equal \"$mainfiles\" \"$chkm $chkms_sub $chks_sub\"\n+        mainfiles=$(git ls-files | fixnl) &&\n+        test_equal \"$mainfiles\" \"$chkm $chkms_sub $chks_sub\"\n '\n \n test_expect_success 'make sure each filename changed exactly once in the entire history' '\n         # main-sub?? and /subdir/main-sub?? both change, because those are the\n         # changes that were split into their own history.  And subdir/sub?? never\n         # change, since they were *only* changed in the subtree branch.\n-        allchanges=''\"$(git log --name-only --pretty=format:'\"''\"' | sort | fixnl)\"'' &&\n-        check_equal \"$allchanges\" ''\"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)\"''\n+        allchanges=$(git log --name-only --pretty=format:\"\" | sort | fixnl) &&\n+        test_equal \"$allchanges\" \"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)\"\n '\n \n test_expect_success 'make sure the --rejoin commits never make it into subproj' '\n-        check_equal ''\"$(git log --pretty=format:'\"'%s'\"' HEAD^2 | grep -i split)\"'' \"\"\n+        test_equal \"$(git log --pretty=format:\"%s\" HEAD^2 | grep -i split)\" \"\"\n '\n \n test_expect_success 'make sure no \"git subtree\" tagged commits make it into subproj' '\n         # They are meaningless to subproj since one side of the merge refers to the mainline\n-        check_equal ''\"$(git log --pretty=format:'\"'%s%n%b'\"' HEAD^2 | grep \"git-subtree.*:\")\"'' \"\"\n+        test_equal \"$(git log --pretty=format:\"%s%n%b\" HEAD^2 | grep \"git-subtree.*:\")\" \"\"\n '\n \n # prepare second pair of repositories\n@@ -359,7 +394,7 @@ cd ../main\n test_expect_success 'add sub as subdir in main' '\n         git fetch ../sub master &&\n         git branch sub2 FETCH_HEAD &&\n-        git subtree add --prefix subdir sub2\n+        git subtree add --prefix=subdir sub2\n '\n \n cd ../sub\n@@ -374,7 +409,7 @@ cd ../main\n test_expect_success 'merge from sub' '\n         git fetch ../sub master &&\n         git branch sub3 FETCH_HEAD &&\n-        git subtree merge --prefix subdir sub3\n+        git subtree merge --prefix=subdir sub3\n '\n \n test_expect_success 'add main-sub4' '\n@@ -383,7 +418,7 @@ test_expect_success 'add main-sub4' '\n '\n \n test_expect_success 'split for main-sub4 without --onto' '\n-        git subtree split --prefix subdir --branch mainsub4\n+        git subtree split --prefix=subdir --branch mainsub4\n '\n \n # at this point, the new commit parent should be sub3 if it is not,\n@@ -392,7 +427,7 @@ test_expect_success 'split for main-sub4 without --onto' '\n # itself)\n \n test_expect_success 'check that the commit parent is sub3' '\n-        check_equal ''\"$(git log --pretty=format:%P -1 mainsub4)\"'' ''\"$(git rev-parse sub3)\"''\n+        test_equal \"$(git log --pretty=format:%P -1 mainsub4)\" \"$(git rev-parse sub3)\"\n '\n \n test_expect_success 'add main-sub5' '\n@@ -405,49 +440,23 @@ test_expect_success 'split for main-sub5 without --onto' '\n         # also test that we still can split out an entirely new subtree\n         # if the parent of the first commit in the tree is not empty,\n         # then the new subtree has accidently been attached to something\n-        git subtree split --prefix subdir2 --branch mainsub5 &&\n-        check_equal ''\"$(git log --pretty=format:%P -1 mainsub5)\"'' \"\"\n+        git subtree split --prefix=subdir2 --branch mainsub5 &&\n+        test_equal \"$(git log --pretty=format:%P -1 mainsub5)\" \"\"\n '\n \n-# make sure no patch changes more than one file.  The original set of commits\n-# changed only one file each.  A multi-file change would imply that we pruned\n-# commits too aggressively.\n-joincommits()\n-{\n-\tcommit=\n-\tall=\n-\twhile read x y; do\n-\t\t#echo \"{$x}\" >&2\n-\t\tif [ -z \"$x\" ]; then\n-\t\t\tcontinue\n-\t\telif [ \"$x\" = \"commit:\" ]; then\n-\t\t\tif [ -n \"$commit\" ]; then\n-\t\t\t\techo \"$commit $all\"\n-\t\t\t\tall=\n-\t\t\tfi\n-\t\t\tcommit=\"$y\"\n-\t\telse\n-\t\t\tall=\"$all $y\"\n-\t\tfi\n-\tdone\n-\techo \"$commit $all\"\n-}\n-\n test_expect_success 'verify one file change per commit' '\n         x= &&\n-        list=''\"$(git log --pretty=format:'\"'commit: %H'\"' | joincommits)\"'' &&\n-#        test_debug \"echo HERE\" &&\n-#        test_debug \"echo ''\"$list\"''\" &&\n-        (git log --pretty=format:'\"'commit: %H'\"' | joincommits |\n-        (       while read commit a b; do\n-\t\t        test_debug \"echo Verifying commit \"''\"$commit\"''\n-\t\t        test_debug \"echo a: \"''\"$a\"''\n-\t\t        test_debug \"echo b: \"''\"$b\"''\n-\t\t        check_equal \"$b\" \"\"\n-\t\t        x=1\n-\t        done\n-\t        check_equal \"$x\" 1\n-        ))\n+        git log --pretty=format:\"commit: %H\" | join_commits |\n+        (\n+            while read commit a b; do\n+                test_debug \"echo Verifying commit $commit\"\n+                test_debug \"echo a: $a\"\n+                test_debug \"echo b: $b\"\n+                test_equal \"$b\" \"\"\n+                x=1\n+            done\n+            test_equal \"$x\" 1\n+        )\n '\n \n test_done\n-- \n1.8.1\n"},{"id":"206638","messageId":"1358041958-1998-6-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358041958-1998-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC 5/7] contrib/subtree: Make each test self-contained","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-13T01:52:36Z","receivedAt":"2013-01-13T01:52:36Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>\n---\n contrib/subtree/t/t7900-subtree.sh | 865 ++++++++++++++++++++++++++-----------\n 1 file changed, 614 insertions(+), 251 deletions(-)\n\ndiff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh\nindex bb4fd1f..ece2064 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -12,12 +12,6 @@ export TEST_DIRECTORY=$(pwd)/../../../t\n \n . ../../../t/test-lib.sh\n \n-create()\n-{\n-    echo \"$1\" >\"$1\"\n-    git add \"$1\"\n-}\n-\n fixnl()\n {\n     t=\"\"\n@@ -37,11 +31,6 @@ multiline()\n     done\n }\n \n-undo()\n-{\n-    git reset --hard HEAD~\n-}\n-\n test_equal()\n {\n     test_debug 'echo'\n@@ -78,373 +67,746 @@ join_commits()\n     echo \"$commit $all\"\n }\n \n+test_create_commit() (\n+    repo=$1\n+    commit=$2\n+    cd \"$repo\"\n+    mkdir -p \"$(dirname \"$commit\")\"\n+    echo \"$commit\" > \"$commit\"\n+    git add \"$commit\"\n+    git commit -m \"$commit\"\n+)\n+\n last_commit_message()\n {\n     git log --pretty=format:%s -1\n }\n \n-test_expect_success 'init subproj' '\n-        test_create_repo subproj\n-'\n-\n-# To the subproject!\n-cd subproj\n-\n-test_expect_success 'add sub1' '\n-        create sub1 &&\n-        git commit -m \"sub1\" &&\n-        git branch sub1 &&\n-        git branch -m master subproj\n-'\n-\n-test_expect_success 'add sub2' '\n-        create sub2 &&\n-        git commit -m \"sub2\" &&\n-        git branch sub2\n-'\n-\n-test_expect_success 'add sub3' '\n-        create sub3 &&\n-        git commit -m \"sub3\" &&\n-        git branch sub3\n-'\n-\n-# Back to mainline\n-cd ..\n-\n-test_expect_success 'add main4' '\n-        create main4 &&\n-        git commit -m \"main4\" &&\n-        git branch -m master mainline &&\n-        git branch init\n-'\n-\n-test_expect_success 'fetch subproj history' '\n-        git fetch ./subproj sub1 &&\n-        git branch sub1 FETCH_HEAD\n-'\n+#\n+# Tests for 'git subtree add'\n+#\n \n test_expect_success 'no pull from non-existant subtree' '\n-        test_must_fail git subtree pull --prefix=subdir ./subproj sub1\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        test_must_fail git subtree pull --prefix=subdir ./subproj master\n+    )\n '\n \n test_expect_success 'no merge from non-existant subtree' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n         test_must_fail git subtree merge --prefix=subdir FETCH_HEAD\n+    )\n '\n \n test_expect_success 'add subproj as subtree into subdir/ with --prefix' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n         git subtree add --prefix=subdir FETCH_HEAD &&\n-        test_equal \"$(last_commit_message)\" \"Add '\\''subdir/'\\'' from commit '\\''$(git rev-parse FETCH_HEAD)'\\''\" &&\n-        undo\n+        test_equal \"$(last_commit_message)\" \"Add '\\''subdir/'\\'' from commit '\\''$(git rev-parse FETCH_HEAD)'\\''\"\n+    )\n '\n \n test_expect_success 'add subproj as subtree into subdir/ with --prefix and --message' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n         git subtree add --prefix=subdir --message=\"Added subproject\" FETCH_HEAD &&\n-        test_equal \"$(last_commit_message)\" \"Added subproject\" &&\n-        undo\n+        test_equal \"$(last_commit_message)\" \"Added subproject\"\n+    )\n '\n \n test_expect_success 'add subproj as subtree into subdir/ with --prefix as -P and --message as -m' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n         git subtree add -P subdir -m \"Added subproject\" FETCH_HEAD &&\n-        test_equal \"$(last_commit_message)\" \"Added subproject\" &&\n-        undo\n+        test_equal \"$(last_commit_message)\" \"Added subproject\"\n+    )\n '\n \n test_expect_success 'add subproj as subtree into subdir/ with --squash and --prefix and --message' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n         git subtree add --prefix=subdir --message=\"Added subproject with squash\" --squash FETCH_HEAD &&\n-        test_equal \"$(last_commit_message)\" \"Added subproject with squash\" &&\n-        undo\n+        test_equal \"$(last_commit_message)\" \"Added subproject with squash\"\n+    )\n '\n \n test_expect_success 'merge the added subproj again, should do nothing' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n         git subtree add --prefix=subdir FETCH_HEAD &&\n         # this shouldn not actually do anything, since FETCH_HEAD\n         # is already a parent\n         git merge -s ours -m \"merge -s -ours\" FETCH_HEAD\n+    )\n '\n \n-test_expect_success 'add main-sub5' '\n-        create subdir/main-sub5 &&\n-        git commit -m \"main-sub5\"\n-'\n-\n-test_expect_success 'add main6' '\n-        create main6 &&\n-        git commit -m \"main6 boring\"\n-'\n-\n-test_expect_success 'add main-sub7' '\n-        create subdir/main-sub7 &&\n-        git commit -m \"main-sub7\"\n-'\n-\n-test_expect_success 'fetch new subproj history' '\n-        git fetch ./subproj sub2 &&\n-        git branch sub2 FETCH_HEAD\n-'\n+#\n+# Tests for 'git subtree merge'\n+#\n \n test_expect_success 'merge new subproj history into subdir/ with --prefix' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n         git subtree merge --prefix=subdir FETCH_HEAD &&\n-        test_equal \"$(last_commit_message)\" \"Merge commit '\\''$(git rev-parse FETCH_HEAD)'\\'' into mainline\" &&\n-        undo\n+        test_equal \"$(last_commit_message)\" \"Merge commit '\\''$(git rev-parse FETCH_HEAD)'\\''\"\n+    )\n '\n \n test_expect_success 'merge new subproj history into subdir/ with --prefix and --message' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n         git subtree merge --prefix=subdir --message=\"Merged changes from subproject\" FETCH_HEAD &&\n-        test_equal \"$(last_commit_message)\" \"Merged changes from subproject\" &&\n-        undo\n+        test_equal \"$(last_commit_message)\" \"Merged changes from subproject\"\n+    )\n '\n \n test_expect_success 'merge new subproj history into subdir/ with --squash and --prefix and --message' '\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_repo \"$test_count\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n         git subtree merge --prefix=subdir --message=\"Merged changes from subproject using squash\" --squash FETCH_HEAD &&\n-        test_equal \"$(last_commit_message)\" \"Merged changes from subproject using squash\" &&\n-        undo\n+        test_equal \"$(last_commit_message)\" \"Merged changes from subproject using squash\"\n+    )\n '\n \n-test_expect_success 'merge new subproj history into subdir/' '\n-        git subtree merge --prefix=subdir FETCH_HEAD &&\n-        git branch pre-split\n-'\n+#\n+# Tests for 'git subtree split'\n+#\n \n test_expect_success 'split requires option --prefix' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD &&\n         echo \"You must provide the --prefix option.\" > expected &&\n         test_must_fail git subtree split > actual 2>&1 &&\n         test_debug \"echo -n expected: \" &&\n         test_debug \"cat expected\" &&\n         test_debug \"echo -n actual: \" &&\n         test_debug \"cat actual\" &&\n-        test_cmp expected actual &&\n-        rm -f expected actual\n+        test_cmp expected actual\n+    )\n '\n \n test_expect_success 'split requires path given by option --prefix must exist' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD &&\n         echo \"'\\''non-existent-directory'\\'' does not exist; use '\\''git subtree add'\\''\" > expected &&\n         test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&\n         test_debug \"echo -n expected: \" &&\n         test_debug \"cat expected\" &&\n         test_debug \"echo -n actual: \" &&\n         test_debug \"cat actual\" &&\n-        test_cmp expected actual &&\n-        rm -f expected actual\n+        test_cmp expected actual\n+    )\n '\n \n test_expect_success 'split subdir/ with --rejoin' '\n-        spl1=$(git subtree split --prefix=subdir --annotate=\"*\") &&\n-        git branch spl1 \"$spl1\" &&\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub1 &&\n+    test_create_commit \"$test_count\" main2 &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    test_create_commit \"$test_count\" subdir/main-sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree merge --prefix=subdir FETCH_HEAD &&\n+        split_hash=$(git subtree split --prefix=subdir --annotate=\"*\") &&\n         git subtree split --prefix=subdir --annotate=\"*\" --rejoin &&\n-        test_equal \"$(last_commit_message)\" \"Split '\\''subdir/'\\'' into commit '\\''$spl1'\\''\" &&\n-        undo\n+        test_equal \"$(last_commit_message)\" \"Split '\\''subdir/'\\'' into commit '\\''$split_hash'\\''\"\n+    )\n '\n \n test_expect_success 'split subdir/ with --rejoin and --message' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub1 &&\n+    test_create_commit \"$test_count\" main2 &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    test_create_commit \"$test_count\" subdir/main-sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree merge --prefix=subdir FETCH_HEAD &&\n         git subtree split --prefix=subdir --message=\"Split & rejoin\" --annotate=\"*\" --rejoin &&\n-        test_equal \"$(last_commit_message)\" \"Split & rejoin\" &&\n-        undo\n+        test_equal \"$(last_commit_message)\" \"Split & rejoin\"\n+    )\n '\n \n test_expect_success 'split subdir/ with --branch' '\n-        spl1=$(git subtree split --prefix=subdir --message=\"Split & rejoin\" --annotate=\"*\" --rejoin) &&\n-        undo &&\n-        git subtree split --prefix=subdir --annotate=\"*\" --branch splitbr1 &&\n-        test_equal \"$(git rev-parse splitbr1)\" \"$spl1\"\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub1 &&\n+    test_create_commit \"$test_count\" main2 &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    test_create_commit \"$test_count\" subdir/main-sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree merge --prefix=subdir FETCH_HEAD &&\n+        split_hash=$(git subtree split --prefix=subdir --annotate=\"*\") &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br &&\n+        test_equal \"$(git rev-parse subproj-br)\" \"$split_hash\"\n+    )\n '\n \n test_expect_success 'split subdir/ with --branch for an existing branch' '\n-        spl1=$(git subtree split --prefix=subdir --annotate=\"*\" --message=\"Split & rejoin\" --rejoin) &&\n-        undo &&\n-        git branch splitbr2 sub1 &&\n-        git subtree split --prefix=subdir --annotate=\"*\" --branch splitbr2 &&\n-        test_equal \"$(git rev-parse splitbr2)\" \"$spl1\"\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git branch subproj-br FETCH_HEAD &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub1 &&\n+    test_create_commit \"$test_count\" main2 &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    test_create_commit \"$test_count\" subdir/main-sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree merge --prefix=subdir FETCH_HEAD &&\n+        split_hash=$(git subtree split --prefix=subdir --annotate=\"*\") &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br &&\n+        test_equal \"$(git rev-parse subproj-br)\" \"$split_hash\"\n+    )\n '\n \n test_expect_success 'split subdir/ with --branch for an incompatible branch' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git branch init HEAD &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub1 &&\n+    test_create_commit \"$test_count\" main2 &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    test_create_commit \"$test_count\" subdir/main-sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree merge --prefix=subdir FETCH_HEAD &&\n         test_must_fail git subtree split --prefix=subdir --branch init\n+    )\n '\n \n-test_expect_success 'split and rejoin' '\n-        git subtree split --prefix=subdir --annotate=\"*\" --rejoin\n-'\n-\n-test_expect_success 'add main-sub8' '\n-        create subdir/main-sub8 &&\n-        git commit -m \"main-sub8\"\n-'\n-\n-# To the subproject!\n-cd ./subproj\n-\n-test_expect_success 'merge split into subproj' '\n-        git fetch .. spl1 &&\n-        git branch spl1 FETCH_HEAD &&\n-        git merge FETCH_HEAD\n-'\n-\n-test_expect_success 'add sub9' '\n-        create sub9 &&\n-        git commit -m \"sub9\"\n-'\n-\n-# Back to mainline\n-cd ..\n-\n-test_expect_success 'split for sub8' '\n-        spl2=$(git subtree split --prefix=subdir/ --annotate=\"*\" --rejoin) &&\n-        git branch spl2 \"$spl2\"\n-'\n-\n-test_expect_success 'add main-sub10' '\n-        create subdir/main-sub10 &&\n-        git commit -m \"main-sub10\"\n-'\n-\n-test_expect_success 'split for sub10' '\n-        spl3=$(git subtree split --prefix=subdir --annotate=\"*\" --rejoin) &&\n-        git branch spl3 \"$spl3\"\n-'\n-\n-# To the subproject!\n-cd ./subproj\n-\n-test_expect_success 'merge split into subproj' '\n-        git fetch .. spl3 &&\n-        git branch spl3 FETCH_HEAD &&\n-        git merge FETCH_HEAD &&\n-        git branch subproj-merge-spl3\n-'\n-\n-chkm=\"main4 main6\"\n-chkms=\"main-sub10 main-sub5 main-sub7 main-sub8\"\n-chkms_sub=$(echo $chkms | multiline | sed 's,^,subdir/,' | fixnl)\n-chks=\"sub1 sub2 sub3 sub9\"\n-chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)\n+#\n+# Validity checking\n+#\n \n test_expect_success 'make sure exactly the right set of files ends up in the subproj' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub1 &&\n+    test_create_commit \"$test_count\" main2 &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    test_create_commit \"$test_count\" subdir/main-sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree merge --prefix=subdir FETCH_HEAD &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub3 &&\n+    test_create_commit \"$test_count\" subdir/main-sub3 &&\n+    (\n+        cd \"$test_count/subproj\" &&\n+        git fetch .. subproj-br && git merge FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub4 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub4 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    (\n+        cd \"$test_count/subproj\" &&\n+        git fetch .. subproj-br && git merge FETCH_HEAD &&\n+\n+        chks=\"sub1 sub2 sub3 sub4\" &&\n+        chks_sub=$(echo $chks | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+        chkms=\"main-sub1 main-sub2 main-sub3 main-sub4\" &&\n+        chkms_sub=$(echo $chkms | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+\n         subfiles=$(git ls-files | fixnl) &&\n         test_equal \"$subfiles\" \"$chkms $chks\"\n+    )\n '\n \n test_expect_success 'make sure the subproj *only* contains commits that affect the subdir' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub1 &&\n+    test_create_commit \"$test_count\" main2 &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    test_create_commit \"$test_count\" subdir/main-sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree merge --prefix=subdir FETCH_HEAD &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub3 &&\n+    test_create_commit \"$test_count\" subdir/main-sub3 &&\n+    (\n+        cd \"$test_count/subproj\" &&\n+        git fetch .. subproj-br && git merge FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub4 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub4 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    (\n+        cd \"$test_count/subproj\" &&\n+        git fetch .. subproj-br && git merge FETCH_HEAD &&\n+\n+        chks=\"sub1 sub2 sub3 sub4\" &&\n+        chks_sub=$(echo $chks | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+        chkms=\"main-sub1 main-sub2 main-sub3 main-sub4\" &&\n+        chkms_sub=$(echo $chkms | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+\n         allchanges=$(git log --name-only --pretty=format:\"\" | sort | fixnl) &&\n         test_equal \"$allchanges\" \"$chkms $chks\"\n-'\n-\n-# Back to mainline\n-cd ..\n-\n-test_expect_success 'pull from subproj' '\n-        git fetch ./subproj subproj-merge-spl3 &&\n-        git branch subproj-merge-spl3 FETCH_HEAD &&\n-        git subtree pull --prefix=subdir ./subproj subproj-merge-spl3\n+    )\n '\n \n test_expect_success 'make sure exactly the right set of files ends up in the mainline' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub1 &&\n+    test_create_commit \"$test_count\" main2 &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    test_create_commit \"$test_count\" subdir/main-sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree merge --prefix=subdir FETCH_HEAD &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub3 &&\n+    test_create_commit \"$test_count\" subdir/main-sub3 &&\n+    (\n+        cd \"$test_count/subproj\" &&\n+        git fetch .. subproj-br && git merge FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub4 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub4 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    (\n+        cd \"$test_count/subproj\" &&\n+        git fetch .. subproj-br && git merge FETCH_HEAD\n+    ) &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree pull --prefix=subdir ./subproj master &&\n+\n+        chkm=\"main1 main2\" &&\n+        chks=\"sub1 sub2 sub3 sub4\" &&\n+        chks_sub=$(echo $chks | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+        chkms=\"main-sub1 main-sub2 main-sub3 main-sub4\" &&\n+        chkms_sub=$(echo $chkms | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+\n         mainfiles=$(git ls-files | fixnl) &&\n         test_equal \"$mainfiles\" \"$chkm $chkms_sub $chks_sub\"\n+    )\n '\n \n test_expect_success 'make sure each filename changed exactly once in the entire history' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub1 &&\n+    test_create_commit \"$test_count\" main2 &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    test_create_commit \"$test_count\" subdir/main-sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree merge --prefix=subdir FETCH_HEAD &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub3 &&\n+    test_create_commit \"$test_count\" subdir/main-sub3 &&\n+    (\n+        cd \"$test_count/subproj\" &&\n+        git fetch .. subproj-br && git merge FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub4 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub4 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    (\n+        cd \"$test_count/subproj\" &&\n+        git fetch .. subproj-br && git merge FETCH_HEAD\n+    ) &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree pull --prefix=subdir ./subproj master &&\n+\n+        chkm=\"main1 main2\" &&\n+        chks=\"sub1 sub2 sub3 sub4\" &&\n+        chks_sub=$(echo $chks | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+        chkms=\"main-sub1 main-sub2 main-sub3 main-sub4\" &&\n+        chkms_sub=$(echo $chkms | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+\n         # main-sub?? and /subdir/main-sub?? both change, because those are the\n         # changes that were split into their own history.  And subdir/sub?? never\n         # change, since they were *only* changed in the subtree branch.\n         allchanges=$(git log --name-only --pretty=format:\"\" | sort | fixnl) &&\n         test_equal \"$allchanges\" \"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)\"\n+    )\n '\n \n test_expect_success 'make sure the --rejoin commits never make it into subproj' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub1 &&\n+    test_create_commit \"$test_count\" main2 &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    test_create_commit \"$test_count\" subdir/main-sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree merge --prefix=subdir FETCH_HEAD &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub3 &&\n+    test_create_commit \"$test_count\" subdir/main-sub3 &&\n+    (\n+        cd \"$test_count/subproj\" &&\n+        git fetch .. subproj-br && git merge FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub4 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub4 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    (\n+        cd \"$test_count/subproj\" &&\n+        git fetch .. subproj-br && git merge FETCH_HEAD\n+    ) &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree pull --prefix=subdir ./subproj master &&\n+\n         test_equal \"$(git log --pretty=format:\"%s\" HEAD^2 | grep -i split)\" \"\"\n+    )\n '\n \n test_expect_success 'make sure no \"git subtree\" tagged commits make it into subproj' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub1 &&\n+    test_create_commit \"$test_count\" main2 &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    test_create_commit \"$test_count\" subdir/main-sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree merge --prefix=subdir FETCH_HEAD &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub3 &&\n+    test_create_commit \"$test_count\" subdir/main-sub3 &&\n+    (\n+        cd \"$test_count/subproj\" &&\n+        git fetch .. subproj-br && git merge FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub4 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub4 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+    ) &&\n+    (\n+        cd \"$test_count/subproj\" &&\n+        git fetch .. subproj-br && git merge FETCH_HEAD\n+    ) &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree pull --prefix=subdir ./subproj master &&\n+\n         # They are meaningless to subproj since one side of the merge refers to the mainline\n         test_equal \"$(git log --pretty=format:\"%s%n%b\" HEAD^2 | grep \"git-subtree.*:\")\" \"\"\n+    )\n '\n \n-# prepare second pair of repositories\n-mkdir test2\n-cd test2\n-\n-test_expect_success 'init main' '\n-        test_create_repo main\n-'\n-\n-cd main\n-\n-test_expect_success 'add main1' '\n-        create main1 &&\n-        git commit -m \"main1\"\n-'\n-\n-cd ..\n-\n-test_expect_success 'init sub' '\n-        test_create_repo sub\n-'\n-\n-cd sub\n-\n-test_expect_success 'add sub2' '\n-        create sub2 &&\n-        git commit -m \"sub2\"\n-'\n-\n-cd ../main\n-\n-# check if split can find proper base without --onto\n-\n-test_expect_success 'add sub as subdir in main' '\n-        git fetch ../sub master &&\n-        git branch sub2 FETCH_HEAD &&\n-        git subtree add --prefix=subdir sub2\n-'\n-\n-cd ../sub\n-\n-test_expect_success 'add sub3' '\n-        create sub3 &&\n-        git commit -m \"sub3\"\n-'\n-\n-cd ../main\n-\n-test_expect_success 'merge from sub' '\n-        git fetch ../sub master &&\n-        git branch sub3 FETCH_HEAD &&\n-        git subtree merge --prefix=subdir sub3\n-'\n-\n-test_expect_success 'add main-sub4' '\n-        create subdir/main-sub4 &&\n-        git commit -m \"main-sub4\"\n-'\n-\n-test_expect_success 'split for main-sub4 without --onto' '\n-        git subtree split --prefix=subdir --branch mainsub4\n-'\n-\n-# at this point, the new commit parent should be sub3 if it is not,\n-# something went wrong (the \"newparent\" of \"master~\" commit should\n-# have been sub3, but it was not, because its cache was not set to\n-# itself)\n-\n-test_expect_success 'check that the commit parent is sub3' '\n-        test_equal \"$(git log --pretty=format:%P -1 mainsub4)\" \"$(git rev-parse sub3)\"\n-'\n+#\n+# A new set of tests\n+#\n \n-test_expect_success 'add main-sub5' '\n-        mkdir subdir2 &&\n-        create subdir2/main-sub5 &&\n-        git commit -m \"main-sub5\"\n-'\n+test_expect_success 'make sure \"git subtree split\" find the correct parent' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git branch subproj-ref FETCH_HEAD &&\n+        git subtree merge --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir --branch subproj-br &&\n+\n+        # at this point, the new commit parent should be subproj-ref, if it is\n+        # not, something went wrong (the \"newparent\" of \"master~\" commit should\n+        # have been sub2, but it was not, because its cache was not set to\n+        # itself)\n+        test_equal \"$(git log --pretty=format:%P -1 subproj-br)\" \"$(git rev-parse subproj-ref)\"\n+    )\n+'\n+\n+test_expect_success 'split a new subtree without --onto option' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree merge --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir --branch subproj-br\n+    ) &&\n+    test_create_commit \"$test_count\" subdir2/main-sub2 &&\n+    (\n+        cd \"$test_count\" &&\n \n-test_expect_success 'split for main-sub5 without --onto' '\n         # also test that we still can split out an entirely new subtree\n         # if the parent of the first commit in the tree is not empty,\n         # then the new subtree has accidently been attached to something\n-        git subtree split --prefix=subdir2 --branch mainsub5 &&\n-        test_equal \"$(git log --pretty=format:%P -1 mainsub5)\" \"\"\n+        git subtree split --prefix=subdir2 --branch subproj2-br &&\n+        test_equal \"$(git log --pretty=format:%P -1 subproj2-br)\" \"\"\n+    )\n '\n \n test_expect_success 'verify one file change per commit' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git branch sub1 FETCH_HEAD &&\n+        git subtree add --prefix=subdir sub1\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree merge --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir --branch subproj-br\n+    ) &&\n+    test_create_commit \"$test_count\" subdir2/main-sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git subtree split --prefix=subdir2 --branch subproj2-br &&\n+\n         x= &&\n         git log --pretty=format:\"commit: %H\" | join_commits |\n         (\n@@ -457,6 +819,7 @@ test_expect_success 'verify one file change per commit' '\n             done\n             test_equal \"$x\" 1\n         )\n+    )\n '\n \n test_done\n-- \n1.8.1\n"},{"id":"206639","messageId":"1358041958-1998-7-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358041958-1998-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC 6/7] contrib/subtree: Use %B for the split commit message","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-13T01:52:37Z","receivedAt":"2013-01-13T01:52:37Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"Use %B rather than %s%n%n%b to handle the special case of a commit that\nonly has a subject line.  We don't want to introduce a newline after the\nsubject, causing generation of a new hash.\n\nAfter this commit, the newly split branch might differ from the previous\none. If this is the case, --fallback option could help.\n\nSigned-off-by: Techlive Zheng <techlivezheng@gmail.com>\nSigned-off-by: David A. Greene <greened@obbligato.org>\n---\n contrib/subtree/git-subtree.sh     | 13 ++++++++++-\n contrib/subtree/git-subtree.txt    | 13 +++++++++++\n contrib/subtree/t/t7900-subtree.sh | 47 ++++++++++++++++++++++++++++++++++++++\n 3 files changed, 72 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex 91e6e87..018ee32 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -25,6 +25,7 @@ b,branch=     create a new branch from the split subtree\n ignore-joins  ignore prior --rejoin commits\n onto=         try connecting new tree to an existing one\n rejoin        merge the new branch back into HEAD\n+fallback      fallback to the obsolete commit generating mechanism\n  options for 'add', 'merge', 'pull' and 'push'\n squash        merge subtree changes as a single commit\n \"\n@@ -45,6 +46,7 @@ ignore_joins=\n annotate=\n squash=\n message=\n+fallback=\n \n debug()\n {\n@@ -92,6 +94,8 @@ while [ $# -gt 0 ]; do\n \t\t--no-ignore-joins) ignore_joins= ;;\n \t\t--squash) squash=1 ;;\n \t\t--no-squash) squash= ;;\n+\t\t--fallback) fallback=1 ;;\n+\t\t--no-fallback) fallback= ;;\n \t\t--) break ;;\n \t\t*) die \"Unexpected option: $opt\" ;;\n \tesac\n@@ -296,7 +300,14 @@ copy_commit()\n \t# We're going to set some environment vars here, so\n \t# do it in a subshell to get rid of them safely later\n \tdebug copy_commit \"{$1}\" \"{$2}\" \"{$3}\"\n-\tgit log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%s%n%n%b' \"$1\" |\n+\n+\tif [ -z \"$fallback\" ]; then\n+\t\tlog_format='%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%B'\n+\telse\n+\t\tlog_format='%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%s%n%n%b'\n+\tfi\n+\n+\tgit log -1 --pretty=format:\"$log_format\" \"$1\" |\n \t(\n \t\tread GIT_AUTHOR_NAME\n \t\tread GIT_AUTHOR_EMAIL\ndiff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt\nindex c5bce41..ca9f199 100644\n--- a/contrib/subtree/git-subtree.txt\n+++ b/contrib/subtree/git-subtree.txt\n@@ -254,6 +254,19 @@ OPTIONS FOR split\n \t'--rejoin' when you split, because you don't want the\n \tsubproject's history to be part of your project anyway.\n \n+--fallback::\n+\tPreviously, git subtree would introduce an extra new line for\n+\tthe commits whose commit message contains only one line.\n+\tThis behavior has been correct. Unfortunately, for those whose\n+\tcurrent split branch contains these kind of commits, git subtree\n+\twill generate a new split branch which differs from the existing\n+\tsplit branch in these commits. It is better to use this new\n+\tsplit branch, because its commits stay intact within the mainline.\n+\t\n+\tOtherwise, the previous fault behavior could still be used with\n+\tthis option. This option is only for a compatible purpose, newly\n+\tsplit branch should never use this option.\n+\n \n EXAMPLE 1. Add command\n ----------------------\ndiff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh\nindex ece2064..1492303 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -399,6 +399,53 @@ test_expect_success 'split subdir/ with --branch for an incompatible branch' '\n     )\n '\n \n+test_expect_success 'make sure commits with one line message stay intact after split' '\n+    test_create_repo $test_count &&\n+    test_create_repo $test_count/subproj &&\n+    test_create_commit $test_count main1 &&\n+    test_create_commit $test_count/subproj sub1 &&\n+    (\n+        cd $test_count &&\n+        git fetch ./subproj master &&\n+        ori_hash=$(git rev-parse FETCH_HEAD) &&\n+        git branch subori FETCH_HEAD &&\n+        git filter-branch --index-filter '\\''git ls-files -s | sed \"s-\\t-&subdir/-\" | GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && mv \"$GIT_INDEX_FILE.new\" \"$GIT_INDEX_FILE\"'\\'' subori\n+        git merge -m \"Merge B project as our subdirectory\" subori &&\n+        git subtree split --prefix subdir --branch splitbr1 &&\n+        new_hash_1=$(git rev-parse splitbr1) &&\n+        test_equal \"$ori_hash\" \"$new_hash_1\" &&\n+        git subtree split --prefix subdir --branch splitbr2 --fallback &&\n+        new_hash_2=$(git rev-parse splitbr2) &&\n+        test_must_fail test_equal \"$ori_hash\" \"$new_hash_2\"\n+    )\n+'\n+\n+test_expect_success 'make sure --fallback option works correctly for the existing split branch' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count\"/subproj &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count\"/subproj sub1 &&\n+    (\n+        cd $test_count &&\n+        git fetch ./subproj master &&\n+        ori_hash=$(git rev-parse FETCH_HEAD) &&\n+        git subtree add --prefix=subdir FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub1 &&\n+    (\n+        cd $test_count &&\n+        git subtree split --prefix subdir --branch splitbr1 &&\n+        git subtree split --prefix subdir --branch splitbr2 --fallback &&\n+        test_must_fail test_equal \"$(git rev-parse splitbr1)\" \"$(git rev-parse splitbr2)\"\n+    ) &&\n+    test_create_commit \"$test_count\" subdir/main-sub2 &&\n+    (\n+        cd $test_count &&\n+        test_must_fail git subtree split --prefix subdir --branch splitbr2 &&\n+        git subtree split --prefix subdir --branch splitbr2 --fallback\n+    )\n+'\n+\n #\n # Validity checking\n #\n-- \n1.8.1\n"},{"id":"206640","messageId":"1358041958-1998-8-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358041958-1998-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC 7/7] contrib/subtree: Handle '--prefix' argument with a slash appended","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-13T01:52:38Z","receivedAt":"2013-01-13T01:52:38Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"'git subtree merge' will fail if the argument of '--prefix' has a slash\nappended.\n\nSigned-off-by: Techlive Zheng <techlivezheng@gmail.com>\n---\n contrib/subtree/git-subtree.sh     |  2 +-\n contrib/subtree/t/t7900-subtree.sh | 19 +++++++++++++++++++\n 2 files changed, 20 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex 018ee32..574ff04 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -83,7 +83,7 @@ while [ $# -gt 0 ]; do\n \t\t--annotate) annotate=\"$1\"; shift ;;\n \t\t--no-annotate) annotate= ;;\n \t\t-b) branch=\"$1\"; shift ;;\n-\t\t-P) prefix=\"$1\"; shift ;;\n+\t\t-P) prefix=\"${1%/}\"; shift ;;\n \t\t-m) message=\"$1\"; shift ;;\n \t\t--no-prefix) prefix= ;;\n \t\t--onto) onto=\"$1\"; shift ;;\ndiff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh\nindex 1492303..8e09606 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -238,6 +238,25 @@ test_expect_success 'merge new subproj history into subdir/ with --squash and --\n     )\n '\n \n+test_expect_success 'merge new subproj history into subdir/ with a slash appended to the argument of --prefix' '\n+    test_create_repo \"$test_count\" &&\n+    test_create_repo \"$test_count/subproj\" &&\n+    test_create_commit \"$test_count\" main1 &&\n+    test_create_commit \"$test_count/subproj\" sub1 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree add --prefix=subdir/ FETCH_HEAD\n+    ) &&\n+    test_create_commit \"$test_count/subproj\" sub2 &&\n+    (\n+        cd \"$test_count\" &&\n+        git fetch ./subproj master &&\n+        git subtree merge --prefix=subdir/ FETCH_HEAD &&\n+        test_equal \"$(last_commit_message)\" \"Merge commit '\\''$(git rev-parse FETCH_HEAD)'\\''\"\n+    )\n+'\n+\n #\n # Tests for 'git subtree split'\n #\n-- \n1.8.1\n"},{"id":"206732","messageId":"CAPYzjrTWJL_FeJVAzSm8fYn7Xw7XW35jLwQCNN+cGzGPO7kM9w@mail.gmail.com","threadId":"32611","inReplyTo":"1358041958-1998-5-git-send-email-techlivezheng@gmail.com","subject":"Re: [PATCH/RFC 4/7] contrib/subtree: Code cleaning and refactoring","fromName":"郑文辉 (Techlive Zheng)","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-14T03:30:02Z","receivedAt":"2013-01-14T03:30:02Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"2013/1/13 Techlive Zheng <techlivezheng@gmail.com>:\n> Mostly prepare for the later tests refactoring.\n>\n> Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>\n\nI am personally a SP-indenting guy, I did not aware of Git's indenting\npolicy until now, so it is bad that I replaced all the lines initially\nindent using HT with SP in the test file of this commit. I will submit\nanother set of patches with the right indenting.\n"},{"id":"206733","messageId":"1358135541-10349-1-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358041958-1998-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC v2 0/8] contrib/subtree: Reroll to follow Git's whitespace policy","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-14T03:52:13Z","receivedAt":"2013-01-14T03:52:13Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"David A. Greene (1):\n  contrib/subtree: Remove test number comments\n\nTechlive Zheng (7):\n  contrib/subtree: Fix whitespaces\n  contrib/subtree: Add vim modeline\n  contrib/subtree: Ignore testing directory\n  contrib/subtree: Code cleaning and refactoring\n  contrib/subtree: Make each test self-contained\n  contrib/subtree: Use %B for the split commit message\n  contrib/subtree: Handle '--prefix' argument with a slash appended\n\n contrib/subtree/.gitignore         |    5 +-\n contrib/subtree/git-subtree.sh     |   85 +--\n contrib/subtree/git-subtree.txt    |   55 +-\n contrib/subtree/t/t7900-subtree.sh | 1255 +++++++++++++++++++++++-------------\n 4 files changed, 905 insertions(+), 495 deletions(-)\n\n-- \n1.8.1\n"},{"id":"206734","messageId":"1358135541-10349-2-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358135541-10349-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC v2 1/8] contrib/subtree: Fix whitespaces","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-14T03:52:14Z","receivedAt":"2013-01-14T03:52:14Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"Previous code does not fulfill Git's whitespace policy.\n\nSigned-off-by: Techlive Zheng <techlivezheng@gmail.com>\n---\n contrib/subtree/git-subtree.sh     |  68 ++++----\n contrib/subtree/git-subtree.txt    |  42 ++---\n contrib/subtree/t/t7900-subtree.sh | 314 ++++++++++++++++++-------------------\n 3 files changed, 212 insertions(+), 212 deletions(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex 920c664..70f86ea 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -5,7 +5,7 @@\n # Copyright (C) 2009 Avery Pennarun <apenwarr@gmail.com>\n #\n if [ $# -eq 0 ]; then\n-    set -- -h\n+\tset -- -h\n fi\n OPTS_SPEC=\"\\\n git subtree add   --prefix=<prefix> <commit>\n@@ -110,9 +110,9 @@ if [ -z \"$prefix\" ]; then\n fi\n \n case \"$command\" in\n-\tadd) [ -e \"$prefix\" ] && \n+\tadd) [ -e \"$prefix\" ] &&\n \t\tdie \"prefix '$prefix' already exists.\" ;;\n-\t*)   [ -e \"$prefix\" ] || \n+\t*)   [ -e \"$prefix\" ] ||\n \t\tdie \"'$prefix' does not exist; use 'git subtree add'\" ;;\n esac\n \n@@ -181,8 +181,8 @@ cache_set()\n \toldrev=\"$1\"\n \tnewrev=\"$2\"\n \tif [ \"$oldrev\" != \"latest_old\" \\\n-\t     -a \"$oldrev\" != \"latest_new\" \\\n-\t     -a -e \"$cachedir/$oldrev\" ]; then\n+\t\t-a \"$oldrev\" != \"latest_new\" \\\n+\t\t-a -e \"$cachedir/$oldrev\" ]; then\n \t\tdie \"cache for $oldrev already exists!\"\n \tfi\n \techo \"$newrev\" >\"$cachedir/$oldrev\"\n@@ -304,7 +304,7 @@ copy_commit()\n \t\tread GIT_COMMITTER_NAME\n \t\tread GIT_COMMITTER_EMAIL\n \t\tread GIT_COMMITTER_DATE\n-\t\texport  GIT_AUTHOR_NAME \\\n+\t\texport GIT_AUTHOR_NAME \\\n \t\t\tGIT_AUTHOR_EMAIL \\\n \t\t\tGIT_AUTHOR_DATE \\\n \t\t\tGIT_COMMITTER_NAME \\\n@@ -327,7 +327,7 @@ add_msg()\n \tfi\n \tcat <<-EOF\n \t\t$commit_message\n-\t\t\n+\n \t\tgit-subtree-dir: $dir\n \t\tgit-subtree-mainline: $latest_old\n \t\tgit-subtree-split: $latest_new\n@@ -355,7 +355,7 @@ rejoin_msg()\n \tfi\n \tcat <<-EOF\n \t\t$commit_message\n-\t\t\n+\n \t\tgit-subtree-dir: $dir\n \t\tgit-subtree-mainline: $latest_old\n \t\tgit-subtree-split: $latest_new\n@@ -368,7 +368,7 @@ squash_msg()\n \toldsub=\"$2\"\n \tnewsub=\"$3\"\n \tnewsub_short=$(git rev-parse --short \"$newsub\")\n-\t\n+\n \tif [ -n \"$oldsub\" ]; then\n \t\toldsub_short=$(git rev-parse --short \"$oldsub\")\n \t\techo \"Squashed '$dir/' changes from $oldsub_short..$newsub_short\"\n@@ -378,7 +378,7 @@ squash_msg()\n \telse\n \t\techo \"Squashed '$dir/' content from commit $newsub_short\"\n \tfi\n-\t\n+\n \techo\n \techo \"git-subtree-dir: $dir\"\n \techo \"git-subtree-split: $newsub\"\n@@ -427,7 +427,7 @@ new_squash_commit()\n \tnewsub=\"$3\"\n \ttree=$(toptree_for_commit $newsub) || exit $?\n \tif [ -n \"$old\" ]; then\n-\t\tsquash_msg \"$dir\" \"$oldsub\" \"$newsub\" | \n+\t\tsquash_msg \"$dir\" \"$oldsub\" \"$newsub\" |\n \t\t\tgit commit-tree \"$tree\" -p \"$old\" || exit $?\n \telse\n \t\tsquash_msg \"$dir\" \"\" \"$newsub\" |\n@@ -455,7 +455,7 @@ copy_or_skip()\n \t\telse\n \t\t\tnonidentical=\"$parent\"\n \t\tfi\n-\t\t\n+\n \t\t# sometimes both old parents map to the same newparent;\n \t\t# eliminate duplicates\n \t\tis_new=1\n@@ -470,7 +470,7 @@ copy_or_skip()\n \t\t\tp=\"$p -p $parent\"\n \t\tfi\n \tdone\n-\t\n+\n \tif [ -n \"$identical\" ]; then\n \t\techo $identical\n \telse\n@@ -495,14 +495,14 @@ cmd_add()\n \tfi\n \n \tensure_clean\n-\t\n+\n \tif [ $# -eq 1 ]; then\n \t\t\"cmd_add_commit\" \"$@\"\n \telif [ $# -eq 2 ]; then\n \t\t\"cmd_add_repository\" \"$@\"\n \telse\n-\t    say \"error: parameters were '$@'\"\n-\t    die \"Provide either a refspec or a repository and refspec.\"\n+\t\tsay \"error: parameters were '$@'\"\n+\t\tdie \"Provide either a refspec or a repository and refspec.\"\n \tfi\n }\n \n@@ -522,19 +522,19 @@ cmd_add_commit()\n \trevs=$(git rev-parse $default --revs-only \"$@\") || exit $?\n \tset -- $revs\n \trev=\"$1\"\n-\t\n+\n \tdebug \"Adding $dir as '$rev'...\"\n \tgit read-tree --prefix=\"$dir\" $rev || exit $?\n \tgit checkout -- \"$dir\" || exit $?\n \ttree=$(git write-tree) || exit $?\n-\t\n+\n \theadrev=$(git rev-parse HEAD) || exit $?\n \tif [ -n \"$headrev\" -a \"$headrev\" != \"$rev\" ]; then\n \t\theadp=\"-p $headrev\"\n \telse\n \t\theadp=\n \tfi\n-\t\n+\n \tif [ -n \"$squash\" ]; then\n \t\trev=$(new_squash_commit \"\" \"\" \"$rev\") || exit $?\n \t\tcommit=$(add_squashed_msg \"$rev\" \"$dir\" |\n@@ -544,7 +544,7 @@ cmd_add_commit()\n \t\t\t git commit-tree $tree $headp -p \"$rev\") || exit $?\n \tfi\n \tgit reset \"$commit\" || exit $?\n-\t\n+\n \tsay \"Added dir '$dir'\"\n }\n \n@@ -552,7 +552,7 @@ cmd_split()\n {\n \tdebug \"Splitting $dir...\"\n \tcache_setup || exit $?\n-\t\n+\n \tif [ -n \"$onto\" ]; then\n \t\tdebug \"Reading history for --onto=$onto...\"\n \t\tgit rev-list $onto |\n@@ -563,13 +563,13 @@ cmd_split()\n \t\t\tcache_set $rev $rev\n \t\tdone\n \tfi\n-\t\n+\n \tif [ -n \"$ignore_joins\" ]; then\n \t\tunrevs=\n \telse\n \t\tunrevs=\"$(find_existing_splits \"$dir\" \"$revs\")\"\n \tfi\n-\t\n+\n \t# We can't restrict rev-list to only $dir here, because some of our\n \t# parents have the $dir contents the root, and those won't match.\n \t# (and rev-list --follow doesn't seem to solve this)\n@@ -591,12 +591,12 @@ cmd_split()\n \t\tdebug \"  parents: $parents\"\n \t\tnewparents=$(cache_get $parents)\n \t\tdebug \"  newparents: $newparents\"\n-\t\t\n+\n \t\ttree=$(subtree_for_commit $rev \"$dir\")\n \t\tdebug \"  tree is: $tree\"\n \n \t\tcheck_parents $parents\n-\t\t\n+\n \t\t# ugly.  is there no better way to tell if this is a subtree\n \t\t# vs. a mainline commit?  Does it matter?\n \t\tif [ -z $tree ]; then\n@@ -617,7 +617,7 @@ cmd_split()\n \tif [ -z \"$latest_new\" ]; then\n \t\tdie \"No new revisions were found\"\n \tfi\n-\t\n+\n \tif [ -n \"$rejoin\" ]; then\n \t\tdebug \"Merging split branch into HEAD...\"\n \t\tlatest_old=$(cache_get latest_old)\n@@ -645,13 +645,13 @@ cmd_merge()\n {\n \trevs=$(git rev-parse $default --revs-only \"$@\") || exit $?\n \tensure_clean\n-\t\n+\n \tset -- $revs\n \tif [ $# -ne 1 ]; then\n \t\tdie \"You must provide exactly one revision.  Got: '$revs'\"\n \tfi\n \trev=\"$1\"\n-\t\n+\n \tif [ -n \"$squash\" ]; then\n \t\tfirst_split=\"$(find_latest_squash \"$dir\")\"\n \t\tif [ -z \"$first_split\" ]; then\n@@ -697,15 +697,15 @@ cmd_pull()\n cmd_push()\n {\n \tif [ $# -ne 2 ]; then\n-\t    die \"You must provide <repository> <refspec>\"\n+\t\tdie \"You must provide <repository> <refspec>\"\n \tfi\n \tif [ -e \"$dir\" ]; then\n-\t    repository=$1\n-\t    refspec=$2\n-\t    echo \"git push using: \" $repository $refspec\n-\t    git push $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec\n+\t\trepository=$1\n+\t\trefspec=$2\n+\t\techo \"git push using: \" $repository $refspec\n+\t\tgit push $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec\n \telse\n-\t    die \"'$dir' must already exist. Try 'git subtree add'.\"\n+\t\tdie \"'$dir' must already exist. Try 'git subtree add'.\"\n \tfi\n }\n \ndiff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt\nindex c5bce41..72be8e4 100644\n--- a/contrib/subtree/git-subtree.txt\n+++ b/contrib/subtree/git-subtree.txt\n@@ -86,15 +86,15 @@ merge::\n \tgo back in time from v2.5 to v2.4, for example.  If your\n \tmerge introduces a conflict, you can resolve it in the\n \tusual ways.\n-\t\n+\n pull::\n \tExactly like 'merge', but parallels 'git pull' in that\n \tit fetches the given commit from the specified remote\n \trepository.\n-\t\n+\n push::\n \tDoes a 'split' (see below) using the <prefix> supplied\n-\tand then does a 'git push' to push the result to the \n+\tand then does a 'git push' to push the result to the\n \trepository and refspec. This can be used to push your\n \tsubtree to different branches of the remote repository.\n \n@@ -106,19 +106,19 @@ split::\n \tcontents of <prefix> at the root of the project instead\n \tof in a subdirectory.  Thus, the newly created history\n \tis suitable for export as a separate git repository.\n-\t\n+\n \tAfter splitting successfully, a single commit id is\n \tprinted to stdout.  This corresponds to the HEAD of the\n \tnewly created tree, which you can manipulate however you\n \twant.\n-\t\n+\n \tRepeated splits of exactly the same history are\n \tguaranteed to be identical (ie. to produce the same\n \tcommit ids).  Because of this, if you add new commits\n \tand then re-split, the new commits will be attached as\n \tcommits on top of the history you generated last time,\n \tso 'git merge' and friends will work as expected.\n-\t\n+\n \tNote that if you use '--squash' when you merge, you\n \tshould usually not just '--rejoin' when you split.\n \n@@ -155,26 +155,26 @@ OPTIONS FOR add, merge, push, pull\n \tproject, produce only a single commit that contains all\n \tthe differences you want to merge, and then merge that\n \tnew commit into your project.\n-\t\n+\n \tUsing this option helps to reduce log clutter. People\n \trarely want to see every change that happened between\n \tv1.0 and v1.1 of the library they're using, since none of the\n \tinterim versions were ever included in their application.\n-\t\n+\n \tUsing '--squash' also helps avoid problems when the same\n \tsubproject is included multiple times in the same\n \tproject, or is removed and then re-added.  In such a\n \tcase, it doesn't make sense to combine the histories\n \tanyway, since it's unclear which part of the history\n \tbelongs to which subtree.\n-\t\n+\n \tFurthermore, with '--squash', you can switch back and\n \tforth between different versions of a subtree, rather\n \tthan strictly forward.  'git subtree merge --squash'\n \talways adjusts the subtree to match the exactly\n \tspecified commit, even if getting to that commit would\n \trequire undoing some changes that were added earlier.\n-\t\n+\n \tWhether or not you use '--squash', changes made in your\n \tlocal repository remain intact and can be later split\n \tand send upstream to the subproject.\n@@ -190,11 +190,11 @@ OPTIONS FOR split\n \tcommits with the same commit message, but possibly\n \tdifferent content, from the original commits, this can help\n \tto differentiate them and avoid confusion.\n-\t\n+\n \tWhenever you split, you need to use the same\n \t<annotation>, or else you don't have a guarantee that\n \tthe new re-created history will be identical to the old\n-\tone.  That will prevent merging from working correctly. \n+\tone.  That will prevent merging from working correctly.\n \tgit subtree tries to make it work anyway, particularly\n \tif you use --rejoin, but it may not always be effective.\n \n@@ -203,8 +203,8 @@ OPTIONS FOR split\n \tThis option is only valid for the split command.\n \n \tAfter generating the synthetic history, create a new\n-\tbranch called <branch> that contains the new history. \n-\tThis is suitable for immediate pushing upstream. \n+\tbranch called <branch> that contains the new history.\n+\tThis is suitable for immediate pushing upstream.\n \t<branch> must not already exist.\n \n --ignore-joins::\n@@ -227,7 +227,7 @@ OPTIONS FOR split\n \trevision of the subproject's history that was imported\n \tinto your project, and git subtree will attempt to build\n \tits history from there.\n-\t\n+\n \tIf you used 'git subtree add', you should never need\n \tthis option.\n \n@@ -238,18 +238,18 @@ OPTIONS FOR split\n \thistory back into your main project.  That way, future\n \tsplits can search only the part of history that has\n \tbeen added since the most recent --rejoin.\n-\t\n+\n \tIf your split commits end up merged into the upstream\n \tsubproject, and then you want to get the latest upstream\n \tversion, this will allow git's merge algorithm to more\n \tintelligently avoid conflicts (since it knows these\n \tsynthetic commits are already part of the upstream\n \trepository).\n-\t\n+\n \tUnfortunately, using this option results in 'git log'\n \tshowing an extra copy of every new commit that was\n \tcreated (the original, and the synthetic one).\n-\t\n+\n \tIf you do all your merges with '--squash', don't use\n \t'--rejoin' when you split, because you don't want the\n \tsubproject's history to be part of your project anyway.\n@@ -284,7 +284,7 @@ First, get your own copy of the git.git repository:\n \t$ cd test-git\n \n gitweb (commit 1130ef3) was merged into git as of commit\n-0a8f4f0, after which it was no longer maintained separately. \n+0a8f4f0, after which it was no longer maintained separately.\n But imagine it had been maintained separately, and we wanted to\n extract git's changes to gitweb since that time, to share with\n the upstream.  You could do this:\n@@ -294,7 +294,7 @@ the upstream.  You could do this:\n         \t--branch gitweb-latest\n         $ gitk gitweb-latest\n         $ git push git@github.com:whatever/gitweb.git gitweb-latest:master\n-        \n+\n (We use '0a8f4f0^..' because that means \"all the changes from\n 0a8f4f0 to the current version, including 0a8f4f0 itself.\")\n \n@@ -328,7 +328,7 @@ And fast forward again:\n \t$ git subtree merge --prefix=gitweb --squash gitweb-latest\n \n And notice that your change is still intact:\n-\t\n+\n \t$ ls -l gitweb/myfile\n \n And you can split it out and look at your changes versus\ndiff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh\nindex bc2eeb0..b98f7d0 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -23,7 +23,7 @@ check_equal()\n {\n \ttest_debug 'echo'\n \ttest_debug \"echo \\\"check a:\\\" \\\"{$1}\\\"\"\n-\ttest_debug \"echo \\\"      b:\\\" \\\"{$2}\\\"\"\n+\ttest_debug \"echo \\\"\t\t b:\\\" \\\"{$2}\\\"\"\n \tif [ \"$1\" = \"$2\" ]; then\n \t\treturn 0\n \telse\n@@ -62,7 +62,7 @@ last_commit_message()\n \n # 1\n test_expect_success 'init subproj' '\n-        test_create_repo subproj\n+\t\ttest_create_repo subproj\n '\n \n # To the subproject!\n@@ -70,24 +70,24 @@ cd subproj\n \n # 2\n test_expect_success 'add sub1' '\n-        create sub1 &&\n-        git commit -m \"sub1\" &&\n-        git branch sub1 &&\n-        git branch -m master subproj\n+\t\tcreate sub1 &&\n+\t\tgit commit -m \"sub1\" &&\n+\t\tgit branch sub1 &&\n+\t\tgit branch -m master subproj\n '\n \n # 3\n test_expect_success 'add sub2' '\n-        create sub2 &&\n-        git commit -m \"sub2\" &&\n-        git branch sub2\n+\t\tcreate sub2 &&\n+\t\tgit commit -m \"sub2\" &&\n+\t\tgit branch sub2\n '\n \n # 4\n test_expect_success 'add sub3' '\n-        create sub3 &&\n-        git commit -m \"sub3\" &&\n-        git branch sub3\n+\t\tcreate sub3 &&\n+\t\tgit commit -m \"sub3\" &&\n+\t\tgit branch sub3\n '\n \n # Back to mainline\n@@ -95,173 +95,173 @@ cd ..\n \n # 5\n test_expect_success 'add main4' '\n-        create main4 &&\n-        git commit -m \"main4\" &&\n-        git branch -m master mainline &&\n-        git branch subdir\n+\t\tcreate main4 &&\n+\t\tgit commit -m \"main4\" &&\n+\t\tgit branch -m master mainline &&\n+\t\tgit branch subdir\n '\n \n # 6\n test_expect_success 'fetch subproj history' '\n-        git fetch ./subproj sub1 &&\n-        git branch sub1 FETCH_HEAD\n+\t\tgit fetch ./subproj sub1 &&\n+\t\tgit branch sub1 FETCH_HEAD\n '\n \n # 7\n test_expect_success 'no subtree exists in main tree' '\n-        test_must_fail git subtree merge --prefix=subdir sub1\n+\t\ttest_must_fail git subtree merge --prefix=subdir sub1\n '\n \n # 8\n test_expect_success 'no pull from non-existant subtree' '\n-        test_must_fail git subtree pull --prefix=subdir ./subproj sub1\n+\t\ttest_must_fail git subtree pull --prefix=subdir ./subproj sub1\n '\n \n # 9\n test_expect_success 'check if --message works for add' '\n-        git subtree add --prefix=subdir --message=\"Added subproject\" sub1 &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Added subproject\" &&\n-        undo\n+\t\tgit subtree add --prefix=subdir --message=\"Added subproject\" sub1 &&\n+\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Added subproject\" &&\n+\t\tundo\n '\n \n # 10\n test_expect_success 'check if --message works as -m and --prefix as -P' '\n-        git subtree add -P subdir -m \"Added subproject using git subtree\" sub1 &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Added subproject using git subtree\" &&\n-        undo\n+\t\tgit subtree add -P subdir -m \"Added subproject using git subtree\" sub1 &&\n+\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Added subproject using git subtree\" &&\n+\t\tundo\n '\n \n # 11\n test_expect_success 'check if --message works with squash too' '\n-        git subtree add -P subdir -m \"Added subproject with squash\" --squash sub1 &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Added subproject with squash\" &&\n-        undo\n+\t\tgit subtree add -P subdir -m \"Added subproject with squash\" --squash sub1 &&\n+\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Added subproject with squash\" &&\n+\t\tundo\n '\n \n # 12\n test_expect_success 'add subproj to mainline' '\n-        git subtree add --prefix=subdir/ FETCH_HEAD &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Add '\"'subdir/'\"' from commit '\"'\"'''\"$(git rev-parse sub1)\"'''\"'\"'\"\n+\t\tgit subtree add --prefix=subdir/ FETCH_HEAD &&\n+\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Add '\"'subdir/'\"' from commit '\"'\"'''\"$(git rev-parse sub1)\"'''\"'\"'\"\n '\n \n # 13\n # this shouldn't actually do anything, since FETCH_HEAD is already a parent\n test_expect_success 'merge fetched subproj' '\n-        git merge -m \"merge -s -ours\" -s ours FETCH_HEAD\n+\t\tgit merge -m \"merge -s -ours\" -s ours FETCH_HEAD\n '\n \n # 14\n test_expect_success 'add main-sub5' '\n-        create subdir/main-sub5 &&\n-        git commit -m \"main-sub5\"\n+\t\tcreate subdir/main-sub5 &&\n+\t\tgit commit -m \"main-sub5\"\n '\n \n # 15\n test_expect_success 'add main6' '\n-        create main6 &&\n-        git commit -m \"main6 boring\"\n+\t\tcreate main6 &&\n+\t\tgit commit -m \"main6 boring\"\n '\n \n # 16\n test_expect_success 'add main-sub7' '\n-        create subdir/main-sub7 &&\n-        git commit -m \"main-sub7\"\n+\t\tcreate subdir/main-sub7 &&\n+\t\tgit commit -m \"main-sub7\"\n '\n \n # 17\n test_expect_success 'fetch new subproj history' '\n-        git fetch ./subproj sub2 &&\n-        git branch sub2 FETCH_HEAD\n+\t\tgit fetch ./subproj sub2 &&\n+\t\tgit branch sub2 FETCH_HEAD\n '\n \n # 18\n test_expect_success 'check if --message works for merge' '\n-        git subtree merge --prefix=subdir -m \"Merged changes from subproject\" sub2 &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Merged changes from subproject\" &&\n-        undo\n+\t\tgit subtree merge --prefix=subdir -m \"Merged changes from subproject\" sub2 &&\n+\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Merged changes from subproject\" &&\n+\t\tundo\n '\n \n # 19\n test_expect_success 'check if --message for merge works with squash too' '\n-        git subtree merge --prefix subdir -m \"Merged changes from subproject using squash\" --squash sub2 &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Merged changes from subproject using squash\" &&\n-        undo\n+\t\tgit subtree merge --prefix subdir -m \"Merged changes from subproject using squash\" --squash sub2 &&\n+\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Merged changes from subproject using squash\" &&\n+\t\tundo\n '\n \n # 20\n test_expect_success 'merge new subproj history into subdir' '\n-        git subtree merge --prefix=subdir FETCH_HEAD &&\n-        git branch pre-split &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Merge commit '\"'\"'\"$(git rev-parse sub2)\"'\"'\"' into mainline\"\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n+\t\tgit branch pre-split &&\n+\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Merge commit '\"'\"'\"$(git rev-parse sub2)\"'\"'\"' into mainline\"\n '\n \n # 21\n test_expect_success 'Check that prefix argument is required for split' '\n-        echo \"You must provide the --prefix option.\" > expected &&\n-        test_must_fail git subtree split > actual 2>&1 &&\n-        test_debug \"echo -n expected: \" &&\n-        test_debug \"cat expected\" &&\n-        test_debug \"echo -n actual: \" &&\n-        test_debug \"cat actual\" &&\n-        test_cmp expected actual &&\n-        rm -f expected actual\n+\t\techo \"You must provide the --prefix option.\" > expected &&\n+\t\ttest_must_fail git subtree split > actual 2>&1 &&\n+\t\ttest_debug \"echo -n expected: \" &&\n+\t\ttest_debug \"cat expected\" &&\n+\t\ttest_debug \"echo -n actual: \" &&\n+\t\ttest_debug \"cat actual\" &&\n+\t\ttest_cmp expected actual &&\n+\t\trm -f expected actual\n '\n \n # 22\n test_expect_success 'Check that the <prefix> exists for a split' '\n-        echo \"'\"'\"'non-existent-directory'\"'\"'\" does not exist\\; use \"'\"'\"'git subtree add'\"'\"'\" > expected &&\n-        test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&\n-        test_debug \"echo -n expected: \" &&\n-        test_debug \"cat expected\" &&\n-        test_debug \"echo -n actual: \" &&\n-        test_debug \"cat actual\" &&\n-        test_cmp expected actual\n-#        rm -f expected actual\n+\t\techo \"'\"'\"'non-existent-directory'\"'\"'\" does not exist\\; use \"'\"'\"'git subtree add'\"'\"'\" > expected &&\n+\t\ttest_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&\n+\t\ttest_debug \"echo -n expected: \" &&\n+\t\ttest_debug \"cat expected\" &&\n+\t\ttest_debug \"echo -n actual: \" &&\n+\t\ttest_debug \"cat actual\" &&\n+\t\ttest_cmp expected actual\n+#\t\t rm -f expected actual\n '\n \n # 23\n test_expect_success 'check if --message works for split+rejoin' '\n-        spl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n-        git branch spl1 \"$spl1\" &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Split & rejoin\" &&\n-        undo\n+\t\tspl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n+\t\tgit branch spl1 \"$spl1\" &&\n+\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Split & rejoin\" &&\n+\t\tundo\n '\n \n # 24\n test_expect_success 'check split with --branch' '\n-        spl1=$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin) &&\n-        undo &&\n-        git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --branch splitbr1 &&\n-        check_equal ''\"$(git rev-parse splitbr1)\"'' \"$spl1\"\n+\t\tspl1=$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin) &&\n+\t\tundo &&\n+\t\tgit subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --branch splitbr1 &&\n+\t\tcheck_equal ''\"$(git rev-parse splitbr1)\"'' \"$spl1\"\n '\n \n # 25\n test_expect_success 'check split with --branch for an existing branch' '\n-        spl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n-        undo &&\n-        git branch splitbr2 sub1 &&\n-        git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --branch splitbr2 &&\n-        check_equal ''\"$(git rev-parse splitbr2)\"'' \"$spl1\"\n+\t\tspl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n+\t\tundo &&\n+\t\tgit branch splitbr2 sub1 &&\n+\t\tgit subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --branch splitbr2 &&\n+\t\tcheck_equal ''\"$(git rev-parse splitbr2)\"'' \"$spl1\"\n '\n \n # 26\n test_expect_success 'check split with --branch for an incompatible branch' '\n-        test_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir\n+\t\ttest_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir\n '\n \n \n # 27\n test_expect_success 'check split+rejoin' '\n-        spl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n-        undo &&\n-        git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --rejoin &&\n-        check_equal ''\"$(last_commit_message)\"'' \"Split '\"'\"'subdir/'\"'\"' into commit '\"'\"'\"$spl1\"'\"'\"'\"\n+\t\tspl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n+\t\tundo &&\n+\t\tgit subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --rejoin &&\n+\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Split '\"'\"'subdir/'\"'\"' into commit '\"'\"'\"$spl1\"'\"'\"'\"\n '\n \n # 28\n test_expect_success 'add main-sub8' '\n-        create subdir/main-sub8 &&\n-        git commit -m \"main-sub8\"\n+\t\tcreate subdir/main-sub8 &&\n+\t\tgit commit -m \"main-sub8\"\n '\n \n # To the subproject!\n@@ -269,15 +269,15 @@ cd ./subproj\n \n # 29\n test_expect_success 'merge split into subproj' '\n-        git fetch .. spl1 &&\n-        git branch spl1 FETCH_HEAD &&\n-        git merge FETCH_HEAD\n+\t\tgit fetch .. spl1 &&\n+\t\tgit branch spl1 FETCH_HEAD &&\n+\t\tgit merge FETCH_HEAD\n '\n \n # 30\n test_expect_success 'add sub9' '\n-        create sub9 &&\n-        git commit -m \"sub9\"\n+\t\tcreate sub9 &&\n+\t\tgit commit -m \"sub9\"\n '\n \n # Back to mainline\n@@ -285,20 +285,20 @@ cd ..\n \n # 31\n test_expect_success 'split for sub8' '\n-        split2=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir/ --rejoin)\"''\n-        git branch split2 \"$split2\"\n+\t\tsplit2=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir/ --rejoin)\"''\n+\t\tgit branch split2 \"$split2\"\n '\n \n # 32\n test_expect_success 'add main-sub10' '\n-        create subdir/main-sub10 &&\n-        git commit -m \"main-sub10\"\n+\t\tcreate subdir/main-sub10 &&\n+\t\tgit commit -m \"main-sub10\"\n '\n \n # 33\n test_expect_success 'split for sub10' '\n-        spl3=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --rejoin)\"'' &&\n-        git branch spl3 \"$spl3\"\n+\t\tspl3=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --rejoin)\"'' &&\n+\t\tgit branch spl3 \"$spl3\"\n '\n \n # To the subproject!\n@@ -306,10 +306,10 @@ cd ./subproj\n \n # 34\n test_expect_success 'merge split into subproj' '\n-        git fetch .. spl3 &&\n-        git branch spl3 FETCH_HEAD &&\n-        git merge FETCH_HEAD &&\n-        git branch subproj-merge-spl3\n+\t\tgit fetch .. spl3 &&\n+\t\tgit branch spl3 FETCH_HEAD &&\n+\t\tgit merge FETCH_HEAD &&\n+\t\tgit branch subproj-merge-spl3\n '\n \n chkm=\"main4 main6\"\n@@ -320,14 +320,14 @@ chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)\n \n # 35\n test_expect_success 'make sure exactly the right set of files ends up in the subproj' '\n-        subfiles=''\"$(git ls-files | fixnl)\"'' &&\n-        check_equal \"$subfiles\" \"$chkms $chks\"\n+\t\tsubfiles=''\"$(git ls-files | fixnl)\"'' &&\n+\t\tcheck_equal \"$subfiles\" \"$chkms $chks\"\n '\n \n # 36\n test_expect_success 'make sure the subproj history *only* contains commits that affect the subdir' '\n-        allchanges=''\"$(git log --name-only --pretty=format:'\"''\"' | sort | fixnl)\"'' &&\n-        check_equal \"$allchanges\" \"$chkms $chks\"\n+\t\tallchanges=''\"$(git log --name-only --pretty=format:'\"''\"' | sort | fixnl)\"'' &&\n+\t\tcheck_equal \"$allchanges\" \"$chkms $chks\"\n '\n \n # Back to mainline\n@@ -335,35 +335,35 @@ cd ..\n \n # 37\n test_expect_success 'pull from subproj' '\n-        git fetch ./subproj subproj-merge-spl3 &&\n-        git branch subproj-merge-spl3 FETCH_HEAD &&\n-        git subtree pull --prefix=subdir ./subproj subproj-merge-spl3\n+\t\tgit fetch ./subproj subproj-merge-spl3 &&\n+\t\tgit branch subproj-merge-spl3 FETCH_HEAD &&\n+\t\tgit subtree pull --prefix=subdir ./subproj subproj-merge-spl3\n '\n \n # 38\n test_expect_success 'make sure exactly the right set of files ends up in the mainline' '\n-        mainfiles=''\"$(git ls-files | fixnl)\"'' &&\n-        check_equal \"$mainfiles\" \"$chkm $chkms_sub $chks_sub\"\n+\t\tmainfiles=''\"$(git ls-files | fixnl)\"'' &&\n+\t\tcheck_equal \"$mainfiles\" \"$chkm $chkms_sub $chks_sub\"\n '\n \n # 39\n test_expect_success 'make sure each filename changed exactly once in the entire history' '\n-        # main-sub?? and /subdir/main-sub?? both change, because those are the\n-        # changes that were split into their own history.  And subdir/sub?? never\n-        # change, since they were *only* changed in the subtree branch.\n-        allchanges=''\"$(git log --name-only --pretty=format:'\"''\"' | sort | fixnl)\"'' &&\n-        check_equal \"$allchanges\" ''\"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)\"''\n+\t\t# main-sub?? and /subdir/main-sub?? both change, because those are the\n+\t\t# changes that were split into their own history.  And subdir/sub?? never\n+\t\t# change, since they were *only* changed in the subtree branch.\n+\t\tallchanges=''\"$(git log --name-only --pretty=format:'\"''\"' | sort | fixnl)\"'' &&\n+\t\tcheck_equal \"$allchanges\" ''\"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)\"''\n '\n \n # 40\n test_expect_success 'make sure the --rejoin commits never make it into subproj' '\n-        check_equal ''\"$(git log --pretty=format:'\"'%s'\"' HEAD^2 | grep -i split)\"'' \"\"\n+\t\tcheck_equal ''\"$(git log --pretty=format:'\"'%s'\"' HEAD^2 | grep -i split)\"'' \"\"\n '\n \n # 41\n test_expect_success 'make sure no \"git subtree\" tagged commits make it into subproj' '\n-        # They are meaningless to subproj since one side of the merge refers to the mainline\n-        check_equal ''\"$(git log --pretty=format:'\"'%s%n%b'\"' HEAD^2 | grep \"git-subtree.*:\")\"'' \"\"\n+\t\t# They are meaningless to subproj since one side of the merge refers to the mainline\n+\t\tcheck_equal ''\"$(git log --pretty=format:'\"'%s%n%b'\"' HEAD^2 | grep \"git-subtree.*:\")\"'' \"\"\n '\n \n # prepare second pair of repositories\n@@ -372,30 +372,30 @@ cd test2\n \n # 42\n test_expect_success 'init main' '\n-        test_create_repo main\n+\t\ttest_create_repo main\n '\n \n cd main\n \n # 43\n test_expect_success 'add main1' '\n-        create main1 &&\n-        git commit -m \"main1\"\n+\t\tcreate main1 &&\n+\t\tgit commit -m \"main1\"\n '\n \n cd ..\n \n # 44\n test_expect_success 'init sub' '\n-        test_create_repo sub\n+\t\ttest_create_repo sub\n '\n \n cd sub\n \n # 45\n test_expect_success 'add sub2' '\n-        create sub2 &&\n-        git commit -m \"sub2\"\n+\t\tcreate sub2 &&\n+\t\tgit commit -m \"sub2\"\n '\n \n cd ../main\n@@ -404,37 +404,37 @@ cd ../main\n \n # 46\n test_expect_success 'add sub as subdir in main' '\n-        git fetch ../sub master &&\n-        git branch sub2 FETCH_HEAD &&\n-        git subtree add --prefix subdir sub2\n+\t\tgit fetch ../sub master &&\n+\t\tgit branch sub2 FETCH_HEAD &&\n+\t\tgit subtree add --prefix subdir sub2\n '\n \n cd ../sub\n \n # 47\n test_expect_success 'add sub3' '\n-        create sub3 &&\n-        git commit -m \"sub3\"\n+\t\tcreate sub3 &&\n+\t\tgit commit -m \"sub3\"\n '\n \n cd ../main\n \n # 48\n test_expect_success 'merge from sub' '\n-        git fetch ../sub master &&\n-        git branch sub3 FETCH_HEAD &&\n-        git subtree merge --prefix subdir sub3\n+\t\tgit fetch ../sub master &&\n+\t\tgit branch sub3 FETCH_HEAD &&\n+\t\tgit subtree merge --prefix subdir sub3\n '\n \n # 49\n test_expect_success 'add main-sub4' '\n-        create subdir/main-sub4 &&\n-        git commit -m \"main-sub4\"\n+\t\tcreate subdir/main-sub4 &&\n+\t\tgit commit -m \"main-sub4\"\n '\n \n # 50\n test_expect_success 'split for main-sub4 without --onto' '\n-        git subtree split --prefix subdir --branch mainsub4\n+\t\tgit subtree split --prefix subdir --branch mainsub4\n '\n \n # at this point, the new commit parent should be sub3 if it is not,\n@@ -444,23 +444,23 @@ test_expect_success 'split for main-sub4 without --onto' '\n \n # 51\n test_expect_success 'check that the commit parent is sub3' '\n-        check_equal ''\"$(git log --pretty=format:%P -1 mainsub4)\"'' ''\"$(git rev-parse sub3)\"''\n+\t\tcheck_equal ''\"$(git log --pretty=format:%P -1 mainsub4)\"'' ''\"$(git rev-parse sub3)\"''\n '\n \n # 52\n test_expect_success 'add main-sub5' '\n-        mkdir subdir2 &&\n-        create subdir2/main-sub5 &&\n-        git commit -m \"main-sub5\"\n+\t\tmkdir subdir2 &&\n+\t\tcreate subdir2/main-sub5 &&\n+\t\tgit commit -m \"main-sub5\"\n '\n \n # 53\n test_expect_success 'split for main-sub5 without --onto' '\n-        # also test that we still can split out an entirely new subtree\n-        # if the parent of the first commit in the tree is not empty,\n-        # then the new subtree has accidently been attached to something\n-        git subtree split --prefix subdir2 --branch mainsub5 &&\n-        check_equal ''\"$(git log --pretty=format:%P -1 mainsub5)\"'' \"\"\n+\t\t# also test that we still can split out an entirely new subtree\n+\t\t# if the parent of the first commit in the tree is not empty,\n+\t\t# then the new subtree has accidently been attached to something\n+\t\tgit subtree split --prefix subdir2 --branch mainsub5 &&\n+\t\tcheck_equal ''\"$(git log --pretty=format:%P -1 mainsub5)\"'' \"\"\n '\n \n # make sure no patch changes more than one file.  The original set of commits\n@@ -489,20 +489,20 @@ joincommits()\n \n # 54\n test_expect_success 'verify one file change per commit' '\n-        x= &&\n-        list=''\"$(git log --pretty=format:'\"'commit: %H'\"' | joincommits)\"'' &&\n-#        test_debug \"echo HERE\" &&\n-#        test_debug \"echo ''\"$list\"''\" &&\n-        (git log --pretty=format:'\"'commit: %H'\"' | joincommits |\n-        (       while read commit a b; do\n-\t\t        test_debug \"echo Verifying commit \"''\"$commit\"''\n-\t\t        test_debug \"echo a: \"''\"$a\"''\n-\t\t        test_debug \"echo b: \"''\"$b\"''\n-\t\t        check_equal \"$b\" \"\"\n-\t\t        x=1\n-\t        done\n-\t        check_equal \"$x\" 1\n-        ))\n+\t\tx= &&\n+\t\tlist=''\"$(git log --pretty=format:'\"'commit: %H'\"' | joincommits)\"'' &&\n+#\t\t test_debug \"echo HERE\" &&\n+#\t\t test_debug \"echo ''\"$list\"''\" &&\n+\t\t(git log --pretty=format:'\"'commit: %H'\"' | joincommits |\n+\t\t(\t\twhile read commit a b; do\n+\t\t\t\ttest_debug \"echo Verifying commit \"''\"$commit\"''\n+\t\t\t\ttest_debug \"echo a: \"''\"$a\"''\n+\t\t\t\ttest_debug \"echo b: \"''\"$b\"''\n+\t\t\t\tcheck_equal \"$b\" \"\"\n+\t\t\t\tx=1\n+\t\t\tdone\n+\t\t\tcheck_equal \"$x\" 1\n+\t\t))\n '\n \n test_done\n-- \n1.8.1\n"},{"id":"206736","messageId":"1358135541-10349-3-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358135541-10349-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC v2 2/8] contrib/subtree: Add vim modeline","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-14T03:52:15Z","receivedAt":"2013-01-14T03:52:15Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>\n---\n contrib/subtree/git-subtree.sh     | 2 ++\n contrib/subtree/t/t7900-subtree.sh | 2 ++\n 2 files changed, 4 insertions(+)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex 70f86ea..88903c0 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -710,3 +710,5 @@ cmd_push()\n }\n \n \"cmd_$command\" \"$@\"\n+\n+# vim: set ts=4 sw=4 noet\ndiff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh\nindex b98f7d0..e32d31a 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -506,3 +506,5 @@ test_expect_success 'verify one file change per commit' '\n '\n \n test_done\n+\n+# vim: set ts=4 sw=4 noet\n-- \n1.8.1\n"},{"id":"206735","messageId":"1358135541-10349-4-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358135541-10349-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC v2 3/8] contrib/subtree: Ignore testing directory","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-14T03:52:16Z","receivedAt":"2013-01-14T03:52:16Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>\n---\n contrib/subtree/.gitignore | 5 ++---\n 1 file changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/subtree/.gitignore b/contrib/subtree/.gitignore\nindex 91360a3..59aeeb4 100644\n--- a/contrib/subtree/.gitignore\n+++ b/contrib/subtree/.gitignore\n@@ -1,6 +1,5 @@\n *~\n git-subtree\n-git-subtree.xml\n git-subtree.1\n-mainline\n-subproj\n+git-subtree.xml\n+t/trash\\ directory.*\n-- \n1.8.1\n"},{"id":"206737","messageId":"1358135541-10349-5-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358135541-10349-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC v2 4/8] contrib/subtree: Remove test number comments","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-14T03:52:17Z","receivedAt":"2013-01-14T03:52:17Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"From: \"David A. Greene\" <greened@obbligato.org>\n\nDelete the comments indicating test numbers as it causes maintenance\nheadaches.  t*.sh -i will help us find any broken tests.\n\nSigned-off-by: David A. Greene <greened@obbligato.org>\nSigned-off-by: Techlive Zheng <techlivezheng@gmail.com>\n---\n contrib/subtree/t/t7900-subtree.sh | 55 --------------------------------------\n 1 file changed, 55 deletions(-)\n\ndiff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh\nindex e32d31a..851d00c 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -60,7 +60,6 @@ last_commit_message()\n \tgit log --pretty=format:%s -1\n }\n \n-# 1\n test_expect_success 'init subproj' '\n \t\ttest_create_repo subproj\n '\n@@ -68,7 +67,6 @@ test_expect_success 'init subproj' '\n # To the subproject!\n cd subproj\n \n-# 2\n test_expect_success 'add sub1' '\n \t\tcreate sub1 &&\n \t\tgit commit -m \"sub1\" &&\n@@ -76,14 +74,12 @@ test_expect_success 'add sub1' '\n \t\tgit branch -m master subproj\n '\n \n-# 3\n test_expect_success 'add sub2' '\n \t\tcreate sub2 &&\n \t\tgit commit -m \"sub2\" &&\n \t\tgit branch sub2\n '\n \n-# 4\n test_expect_success 'add sub3' '\n \t\tcreate sub3 &&\n \t\tgit commit -m \"sub3\" &&\n@@ -93,7 +89,6 @@ test_expect_success 'add sub3' '\n # Back to mainline\n cd ..\n \n-# 5\n test_expect_success 'add main4' '\n \t\tcreate main4 &&\n \t\tgit commit -m \"main4\" &&\n@@ -101,101 +96,85 @@ test_expect_success 'add main4' '\n \t\tgit branch subdir\n '\n \n-# 6\n test_expect_success 'fetch subproj history' '\n \t\tgit fetch ./subproj sub1 &&\n \t\tgit branch sub1 FETCH_HEAD\n '\n \n-# 7\n test_expect_success 'no subtree exists in main tree' '\n \t\ttest_must_fail git subtree merge --prefix=subdir sub1\n '\n \n-# 8\n test_expect_success 'no pull from non-existant subtree' '\n \t\ttest_must_fail git subtree pull --prefix=subdir ./subproj sub1\n '\n \n-# 9\n test_expect_success 'check if --message works for add' '\n \t\tgit subtree add --prefix=subdir --message=\"Added subproject\" sub1 &&\n \t\tcheck_equal ''\"$(last_commit_message)\"'' \"Added subproject\" &&\n \t\tundo\n '\n \n-# 10\n test_expect_success 'check if --message works as -m and --prefix as -P' '\n \t\tgit subtree add -P subdir -m \"Added subproject using git subtree\" sub1 &&\n \t\tcheck_equal ''\"$(last_commit_message)\"'' \"Added subproject using git subtree\" &&\n \t\tundo\n '\n \n-# 11\n test_expect_success 'check if --message works with squash too' '\n \t\tgit subtree add -P subdir -m \"Added subproject with squash\" --squash sub1 &&\n \t\tcheck_equal ''\"$(last_commit_message)\"'' \"Added subproject with squash\" &&\n \t\tundo\n '\n \n-# 12\n test_expect_success 'add subproj to mainline' '\n \t\tgit subtree add --prefix=subdir/ FETCH_HEAD &&\n \t\tcheck_equal ''\"$(last_commit_message)\"'' \"Add '\"'subdir/'\"' from commit '\"'\"'''\"$(git rev-parse sub1)\"'''\"'\"'\"\n '\n \n-# 13\n # this shouldn't actually do anything, since FETCH_HEAD is already a parent\n test_expect_success 'merge fetched subproj' '\n \t\tgit merge -m \"merge -s -ours\" -s ours FETCH_HEAD\n '\n \n-# 14\n test_expect_success 'add main-sub5' '\n \t\tcreate subdir/main-sub5 &&\n \t\tgit commit -m \"main-sub5\"\n '\n \n-# 15\n test_expect_success 'add main6' '\n \t\tcreate main6 &&\n \t\tgit commit -m \"main6 boring\"\n '\n \n-# 16\n test_expect_success 'add main-sub7' '\n \t\tcreate subdir/main-sub7 &&\n \t\tgit commit -m \"main-sub7\"\n '\n \n-# 17\n test_expect_success 'fetch new subproj history' '\n \t\tgit fetch ./subproj sub2 &&\n \t\tgit branch sub2 FETCH_HEAD\n '\n \n-# 18\n test_expect_success 'check if --message works for merge' '\n \t\tgit subtree merge --prefix=subdir -m \"Merged changes from subproject\" sub2 &&\n \t\tcheck_equal ''\"$(last_commit_message)\"'' \"Merged changes from subproject\" &&\n \t\tundo\n '\n \n-# 19\n test_expect_success 'check if --message for merge works with squash too' '\n \t\tgit subtree merge --prefix subdir -m \"Merged changes from subproject using squash\" --squash sub2 &&\n \t\tcheck_equal ''\"$(last_commit_message)\"'' \"Merged changes from subproject using squash\" &&\n \t\tundo\n '\n \n-# 20\n test_expect_success 'merge new subproj history into subdir' '\n \t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n \t\tgit branch pre-split &&\n \t\tcheck_equal ''\"$(last_commit_message)\"'' \"Merge commit '\"'\"'\"$(git rev-parse sub2)\"'\"'\"' into mainline\"\n '\n \n-# 21\n test_expect_success 'Check that prefix argument is required for split' '\n \t\techo \"You must provide the --prefix option.\" > expected &&\n \t\ttest_must_fail git subtree split > actual 2>&1 &&\n@@ -207,7 +186,6 @@ test_expect_success 'Check that prefix argument is required for split' '\n \t\trm -f expected actual\n '\n \n-# 22\n test_expect_success 'Check that the <prefix> exists for a split' '\n \t\techo \"'\"'\"'non-existent-directory'\"'\"'\" does not exist\\; use \"'\"'\"'git subtree add'\"'\"'\" > expected &&\n \t\ttest_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&\n@@ -219,7 +197,6 @@ test_expect_success 'Check that the <prefix> exists for a split' '\n #\t\t rm -f expected actual\n '\n \n-# 23\n test_expect_success 'check if --message works for split+rejoin' '\n \t\tspl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n \t\tgit branch spl1 \"$spl1\" &&\n@@ -227,7 +204,6 @@ test_expect_success 'check if --message works for split+rejoin' '\n \t\tundo\n '\n \n-# 24\n test_expect_success 'check split with --branch' '\n \t\tspl1=$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin) &&\n \t\tundo &&\n@@ -235,7 +211,6 @@ test_expect_success 'check split with --branch' '\n \t\tcheck_equal ''\"$(git rev-parse splitbr1)\"'' \"$spl1\"\n '\n \n-# 25\n test_expect_success 'check split with --branch for an existing branch' '\n \t\tspl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n \t\tundo &&\n@@ -244,13 +219,10 @@ test_expect_success 'check split with --branch for an existing branch' '\n \t\tcheck_equal ''\"$(git rev-parse splitbr2)\"'' \"$spl1\"\n '\n \n-# 26\n test_expect_success 'check split with --branch for an incompatible branch' '\n \t\ttest_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir\n '\n \n-\n-# 27\n test_expect_success 'check split+rejoin' '\n \t\tspl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n \t\tundo &&\n@@ -258,7 +230,6 @@ test_expect_success 'check split+rejoin' '\n \t\tcheck_equal ''\"$(last_commit_message)\"'' \"Split '\"'\"'subdir/'\"'\"' into commit '\"'\"'\"$spl1\"'\"'\"'\"\n '\n \n-# 28\n test_expect_success 'add main-sub8' '\n \t\tcreate subdir/main-sub8 &&\n \t\tgit commit -m \"main-sub8\"\n@@ -267,14 +238,12 @@ test_expect_success 'add main-sub8' '\n # To the subproject!\n cd ./subproj\n \n-# 29\n test_expect_success 'merge split into subproj' '\n \t\tgit fetch .. spl1 &&\n \t\tgit branch spl1 FETCH_HEAD &&\n \t\tgit merge FETCH_HEAD\n '\n \n-# 30\n test_expect_success 'add sub9' '\n \t\tcreate sub9 &&\n \t\tgit commit -m \"sub9\"\n@@ -283,19 +252,16 @@ test_expect_success 'add sub9' '\n # Back to mainline\n cd ..\n \n-# 31\n test_expect_success 'split for sub8' '\n \t\tsplit2=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir/ --rejoin)\"''\n \t\tgit branch split2 \"$split2\"\n '\n \n-# 32\n test_expect_success 'add main-sub10' '\n \t\tcreate subdir/main-sub10 &&\n \t\tgit commit -m \"main-sub10\"\n '\n \n-# 33\n test_expect_success 'split for sub10' '\n \t\tspl3=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --rejoin)\"'' &&\n \t\tgit branch spl3 \"$spl3\"\n@@ -304,7 +270,6 @@ test_expect_success 'split for sub10' '\n # To the subproject!\n cd ./subproj\n \n-# 34\n test_expect_success 'merge split into subproj' '\n \t\tgit fetch .. spl3 &&\n \t\tgit branch spl3 FETCH_HEAD &&\n@@ -318,13 +283,11 @@ chkms_sub=$(echo $chkms | multiline | sed 's,^,subdir/,' | fixnl)\n chks=\"sub1 sub2 sub3 sub9\"\n chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)\n \n-# 35\n test_expect_success 'make sure exactly the right set of files ends up in the subproj' '\n \t\tsubfiles=''\"$(git ls-files | fixnl)\"'' &&\n \t\tcheck_equal \"$subfiles\" \"$chkms $chks\"\n '\n \n-# 36\n test_expect_success 'make sure the subproj history *only* contains commits that affect the subdir' '\n \t\tallchanges=''\"$(git log --name-only --pretty=format:'\"''\"' | sort | fixnl)\"'' &&\n \t\tcheck_equal \"$allchanges\" \"$chkms $chks\"\n@@ -333,20 +296,17 @@ test_expect_success 'make sure the subproj history *only* contains commits that\n # Back to mainline\n cd ..\n \n-# 37\n test_expect_success 'pull from subproj' '\n \t\tgit fetch ./subproj subproj-merge-spl3 &&\n \t\tgit branch subproj-merge-spl3 FETCH_HEAD &&\n \t\tgit subtree pull --prefix=subdir ./subproj subproj-merge-spl3\n '\n \n-# 38\n test_expect_success 'make sure exactly the right set of files ends up in the mainline' '\n \t\tmainfiles=''\"$(git ls-files | fixnl)\"'' &&\n \t\tcheck_equal \"$mainfiles\" \"$chkm $chkms_sub $chks_sub\"\n '\n \n-# 39\n test_expect_success 'make sure each filename changed exactly once in the entire history' '\n \t\t# main-sub?? and /subdir/main-sub?? both change, because those are the\n \t\t# changes that were split into their own history.  And subdir/sub?? never\n@@ -355,12 +315,10 @@ test_expect_success 'make sure each filename changed exactly once in the entire\n \t\tcheck_equal \"$allchanges\" ''\"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)\"''\n '\n \n-# 40\n test_expect_success 'make sure the --rejoin commits never make it into subproj' '\n \t\tcheck_equal ''\"$(git log --pretty=format:'\"'%s'\"' HEAD^2 | grep -i split)\"'' \"\"\n '\n \n-# 41\n test_expect_success 'make sure no \"git subtree\" tagged commits make it into subproj' '\n \t\t# They are meaningless to subproj since one side of the merge refers to the mainline\n \t\tcheck_equal ''\"$(git log --pretty=format:'\"'%s%n%b'\"' HEAD^2 | grep \"git-subtree.*:\")\"'' \"\"\n@@ -370,14 +328,12 @@ test_expect_success 'make sure no \"git subtree\" tagged commits make it into subp\n mkdir test2\n cd test2\n \n-# 42\n test_expect_success 'init main' '\n \t\ttest_create_repo main\n '\n \n cd main\n \n-# 43\n test_expect_success 'add main1' '\n \t\tcreate main1 &&\n \t\tgit commit -m \"main1\"\n@@ -385,14 +341,12 @@ test_expect_success 'add main1' '\n \n cd ..\n \n-# 44\n test_expect_success 'init sub' '\n \t\ttest_create_repo sub\n '\n \n cd sub\n \n-# 45\n test_expect_success 'add sub2' '\n \t\tcreate sub2 &&\n \t\tgit commit -m \"sub2\"\n@@ -402,7 +356,6 @@ cd ../main\n \n # check if split can find proper base without --onto\n \n-# 46\n test_expect_success 'add sub as subdir in main' '\n \t\tgit fetch ../sub master &&\n \t\tgit branch sub2 FETCH_HEAD &&\n@@ -411,7 +364,6 @@ test_expect_success 'add sub as subdir in main' '\n \n cd ../sub\n \n-# 47\n test_expect_success 'add sub3' '\n \t\tcreate sub3 &&\n \t\tgit commit -m \"sub3\"\n@@ -419,20 +371,17 @@ test_expect_success 'add sub3' '\n \n cd ../main\n \n-# 48\n test_expect_success 'merge from sub' '\n \t\tgit fetch ../sub master &&\n \t\tgit branch sub3 FETCH_HEAD &&\n \t\tgit subtree merge --prefix subdir sub3\n '\n \n-# 49\n test_expect_success 'add main-sub4' '\n \t\tcreate subdir/main-sub4 &&\n \t\tgit commit -m \"main-sub4\"\n '\n \n-# 50\n test_expect_success 'split for main-sub4 without --onto' '\n \t\tgit subtree split --prefix subdir --branch mainsub4\n '\n@@ -442,19 +391,16 @@ test_expect_success 'split for main-sub4 without --onto' '\n # have been sub3, but it was not, because its cache was not set to\n # itself)\n \n-# 51\n test_expect_success 'check that the commit parent is sub3' '\n \t\tcheck_equal ''\"$(git log --pretty=format:%P -1 mainsub4)\"'' ''\"$(git rev-parse sub3)\"''\n '\n \n-# 52\n test_expect_success 'add main-sub5' '\n \t\tmkdir subdir2 &&\n \t\tcreate subdir2/main-sub5 &&\n \t\tgit commit -m \"main-sub5\"\n '\n \n-# 53\n test_expect_success 'split for main-sub5 without --onto' '\n \t\t# also test that we still can split out an entirely new subtree\n \t\t# if the parent of the first commit in the tree is not empty,\n@@ -487,7 +433,6 @@ joincommits()\n \techo \"$commit $all\"\n }\n \n-# 54\n test_expect_success 'verify one file change per commit' '\n \t\tx= &&\n \t\tlist=''\"$(git log --pretty=format:'\"'commit: %H'\"' | joincommits)\"'' &&\n-- \n1.8.1\n"},{"id":"206739","messageId":"1358135541-10349-6-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358135541-10349-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC v2 5/8] contrib/subtree: Code cleaning and refactoring","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-14T03:52:18Z","receivedAt":"2013-01-14T03:52:18Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"Mostly prepare for the later tests refactoring.\n\nSigned-off-by: Techlive Zheng <techlivezheng@gmail.com>\n---\n contrib/subtree/t/t7900-subtree.sh | 251 +++++++++++++++++++------------------\n 1 file changed, 130 insertions(+), 121 deletions(-)\n\ndiff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh\nindex 851d00c..69bd41c 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -4,7 +4,7 @@\n #\n test_description='Basic porcelain support for subtrees\n \n-This test verifies the basic operation of the merge, pull, add\n+This test verifies the basic operation of the add, pull, merge\n and split subcommands of git subtree.\n '\n \n@@ -18,19 +18,6 @@ create()\n \tgit add \"$1\"\n }\n \n-\n-check_equal()\n-{\n-\ttest_debug 'echo'\n-\ttest_debug \"echo \\\"check a:\\\" \\\"{$1}\\\"\"\n-\ttest_debug \"echo \\\"\t\t b:\\\" \\\"{$2}\\\"\"\n-\tif [ \"$1\" = \"$2\" ]; then\n-\t\treturn 0\n-\telse\n-\t\treturn 1\n-\tfi\n-}\n-\n fixnl()\n {\n \tt=\"\"\n@@ -55,6 +42,42 @@ undo()\n \tgit reset --hard HEAD~\n }\n \n+test_equal()\n+{\n+\ttest_debug 'echo'\n+\ttest_debug \"echo \\\"check a:\\\" \\\"{$1}\\\"\"\n+\ttest_debug \"echo \\\"\t\t b:\\\" \\\"{$2}\\\"\"\n+\tif [ \"$1\" = \"$2\" ]; then\n+\t\treturn 0\n+\telse\n+\t\treturn 1\n+\tfi\n+}\n+\n+# Make sure no patch changes more than one file.\n+# The original set of commits changed only one file each.\n+# A multi-file change would imply that we pruned commits\n+# too aggressively.\n+join_commits()\n+{\n+\tcommit=\n+\tall=\n+\twhile read x y; do\n+\t\tif [ -z \"$x\" ]; then\n+\t\t\tcontinue\n+\t\telif [ \"$x\" = \"commit:\" ]; then\n+\t\t\tif [ -n \"$commit\" ]; then\n+\t\t\t\techo \"$commit $all\"\n+\t\t\t\tall=\n+\t\t\tfi\n+\t\t\tcommit=\"$y\"\n+\t\telse\n+\t\t\tall=\"$all $y\"\n+\t\tfi\n+\tdone\n+\techo \"$commit $all\"\n+}\n+\n last_commit_message()\n {\n \tgit log --pretty=format:%s -1\n@@ -93,7 +116,7 @@ test_expect_success 'add main4' '\n \t\tcreate main4 &&\n \t\tgit commit -m \"main4\" &&\n \t\tgit branch -m master mainline &&\n-\t\tgit branch subdir\n+\t\tgit branch init\n '\n \n test_expect_success 'fetch subproj history' '\n@@ -101,40 +124,43 @@ test_expect_success 'fetch subproj history' '\n \t\tgit branch sub1 FETCH_HEAD\n '\n \n-test_expect_success 'no subtree exists in main tree' '\n-\t\ttest_must_fail git subtree merge --prefix=subdir sub1\n-'\n-\n test_expect_success 'no pull from non-existant subtree' '\n \t\ttest_must_fail git subtree pull --prefix=subdir ./subproj sub1\n '\n \n-test_expect_success 'check if --message works for add' '\n-\t\tgit subtree add --prefix=subdir --message=\"Added subproject\" sub1 &&\n-\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Added subproject\" &&\n+test_expect_success 'no merge from non-existant subtree' '\n+\t\ttest_must_fail git subtree merge --prefix=subdir FETCH_HEAD\n+'\n+\n+test_expect_success 'add subproj as subtree into subdir/ with --prefix' '\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD &&\n+\t\ttest_equal \"$(last_commit_message)\" \"Add '\\''subdir/'\\'' from commit '\\''$(git rev-parse FETCH_HEAD)'\\''\" &&\n \t\tundo\n '\n \n-test_expect_success 'check if --message works as -m and --prefix as -P' '\n-\t\tgit subtree add -P subdir -m \"Added subproject using git subtree\" sub1 &&\n-\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Added subproject using git subtree\" &&\n+test_expect_success 'add subproj as subtree into subdir/ with --prefix and --message' '\n+\t\tgit subtree add --prefix=subdir --message=\"Added subproject\" FETCH_HEAD &&\n+\t\ttest_equal \"$(last_commit_message)\" \"Added subproject\" &&\n \t\tundo\n '\n \n-test_expect_success 'check if --message works with squash too' '\n-\t\tgit subtree add -P subdir -m \"Added subproject with squash\" --squash sub1 &&\n-\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Added subproject with squash\" &&\n+test_expect_success 'add subproj as subtree into subdir/ with --prefix as -P and --message as -m' '\n+\t\tgit subtree add -P subdir -m \"Added subproject\" FETCH_HEAD &&\n+\t\ttest_equal \"$(last_commit_message)\" \"Added subproject\" &&\n \t\tundo\n '\n \n-test_expect_success 'add subproj to mainline' '\n-\t\tgit subtree add --prefix=subdir/ FETCH_HEAD &&\n-\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Add '\"'subdir/'\"' from commit '\"'\"'''\"$(git rev-parse sub1)\"'''\"'\"'\"\n+test_expect_success 'add subproj as subtree into subdir/ with --squash and --prefix and --message' '\n+\t\tgit subtree add --prefix=subdir --message=\"Added subproject with squash\" --squash FETCH_HEAD &&\n+\t\ttest_equal \"$(last_commit_message)\" \"Added subproject with squash\" &&\n+\t\tundo\n '\n \n-# this shouldn't actually do anything, since FETCH_HEAD is already a parent\n-test_expect_success 'merge fetched subproj' '\n-\t\tgit merge -m \"merge -s -ours\" -s ours FETCH_HEAD\n+test_expect_success 'merge the added subproj again, should do nothing' '\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD &&\n+\t\t# this shouldn not actually do anything, since FETCH_HEAD\n+\t\t# is already a parent\n+\t\tgit merge -s ours -m \"merge -s -ours\" FETCH_HEAD\n '\n \n test_expect_success 'add main-sub5' '\n@@ -157,25 +183,30 @@ test_expect_success 'fetch new subproj history' '\n \t\tgit branch sub2 FETCH_HEAD\n '\n \n-test_expect_success 'check if --message works for merge' '\n-\t\tgit subtree merge --prefix=subdir -m \"Merged changes from subproject\" sub2 &&\n-\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Merged changes from subproject\" &&\n+test_expect_success 'merge new subproj history into subdir/ with --prefix' '\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n+\t\ttest_equal \"$(last_commit_message)\" \"Merge commit '\\''$(git rev-parse FETCH_HEAD)'\\'' into mainline\" &&\n \t\tundo\n '\n \n-test_expect_success 'check if --message for merge works with squash too' '\n-\t\tgit subtree merge --prefix subdir -m \"Merged changes from subproject using squash\" --squash sub2 &&\n-\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Merged changes from subproject using squash\" &&\n+test_expect_success 'merge new subproj history into subdir/ with --prefix and --message' '\n+\t\tgit subtree merge --prefix=subdir --message=\"Merged changes from subproject\" FETCH_HEAD &&\n+\t\ttest_equal \"$(last_commit_message)\" \"Merged changes from subproject\" &&\n \t\tundo\n '\n \n-test_expect_success 'merge new subproj history into subdir' '\n+test_expect_success 'merge new subproj history into subdir/ with --squash and --prefix and --message' '\n+\t\tgit subtree merge --prefix=subdir --message=\"Merged changes from subproject using squash\" --squash FETCH_HEAD &&\n+\t\ttest_equal \"$(last_commit_message)\" \"Merged changes from subproject using squash\" &&\n+\t\tundo\n+'\n+\n+test_expect_success 'merge new subproj history into subdir/' '\n \t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n-\t\tgit branch pre-split &&\n-\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Merge commit '\"'\"'\"$(git rev-parse sub2)\"'\"'\"' into mainline\"\n+\t\tgit branch pre-split\n '\n \n-test_expect_success 'Check that prefix argument is required for split' '\n+test_expect_success 'split requires option --prefix' '\n \t\techo \"You must provide the --prefix option.\" > expected &&\n \t\ttest_must_fail git subtree split > actual 2>&1 &&\n \t\ttest_debug \"echo -n expected: \" &&\n@@ -186,48 +217,52 @@ test_expect_success 'Check that prefix argument is required for split' '\n \t\trm -f expected actual\n '\n \n-test_expect_success 'Check that the <prefix> exists for a split' '\n-\t\techo \"'\"'\"'non-existent-directory'\"'\"'\" does not exist\\; use \"'\"'\"'git subtree add'\"'\"'\" > expected &&\n+test_expect_success 'split requires path given by option --prefix must exist' '\n+\t\techo \"'\\''non-existent-directory'\\'' does not exist; use '\\''git subtree add'\\''\" > expected &&\n \t\ttest_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&\n \t\ttest_debug \"echo -n expected: \" &&\n \t\ttest_debug \"cat expected\" &&\n \t\ttest_debug \"echo -n actual: \" &&\n \t\ttest_debug \"cat actual\" &&\n-\t\ttest_cmp expected actual\n-#\t\t rm -f expected actual\n+\t\ttest_cmp expected actual &&\n+\t\trm -f expected actual\n '\n \n-test_expect_success 'check if --message works for split+rejoin' '\n-\t\tspl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n+test_expect_success 'split subdir/ with --rejoin' '\n+\t\tspl1=$(git subtree split --prefix=subdir --annotate=\"*\") &&\n \t\tgit branch spl1 \"$spl1\" &&\n-\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Split & rejoin\" &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --rejoin &&\n+\t\ttest_equal \"$(last_commit_message)\" \"Split '\\''subdir/'\\'' into commit '\\''$spl1'\\''\" &&\n \t\tundo\n '\n \n-test_expect_success 'check split with --branch' '\n-\t\tspl1=$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin) &&\n+test_expect_success 'split subdir/ with --rejoin and --message' '\n+\t\tgit subtree split --prefix=subdir --message=\"Split & rejoin\" --annotate=\"*\" --rejoin &&\n+\t\ttest_equal \"$(last_commit_message)\" \"Split & rejoin\" &&\n+\t\tundo\n+'\n+\n+test_expect_success 'split subdir/ with --branch' '\n+\t\tspl1=$(git subtree split --prefix=subdir --message=\"Split & rejoin\" --annotate=\"*\" --rejoin) &&\n \t\tundo &&\n-\t\tgit subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --branch splitbr1 &&\n-\t\tcheck_equal ''\"$(git rev-parse splitbr1)\"'' \"$spl1\"\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch splitbr1 &&\n+\t\ttest_equal \"$(git rev-parse splitbr1)\" \"$spl1\"\n '\n \n-test_expect_success 'check split with --branch for an existing branch' '\n-\t\tspl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n+test_expect_success 'split subdir/ with --branch for an existing branch' '\n+\t\tspl1=$(git subtree split --prefix=subdir --annotate=\"*\" --message=\"Split & rejoin\" --rejoin) &&\n \t\tundo &&\n \t\tgit branch splitbr2 sub1 &&\n-\t\tgit subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --branch splitbr2 &&\n-\t\tcheck_equal ''\"$(git rev-parse splitbr2)\"'' \"$spl1\"\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch splitbr2 &&\n+\t\ttest_equal \"$(git rev-parse splitbr2)\" \"$spl1\"\n '\n \n-test_expect_success 'check split with --branch for an incompatible branch' '\n-\t\ttest_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir\n+test_expect_success 'split subdir/ with --branch for an incompatible branch' '\n+\t\ttest_must_fail git subtree split --prefix=subdir --branch init\n '\n \n-test_expect_success 'check split+rejoin' '\n-\t\tspl1=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --message \"Split & rejoin\" --rejoin)\"'' &&\n-\t\tundo &&\n-\t\tgit subtree split --annotate='\"'*'\"' --prefix subdir --onto FETCH_HEAD --rejoin &&\n-\t\tcheck_equal ''\"$(last_commit_message)\"'' \"Split '\"'\"'subdir/'\"'\"' into commit '\"'\"'\"$spl1\"'\"'\"'\"\n+test_expect_success 'split and rejoin' '\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --rejoin\n '\n \n test_expect_success 'add main-sub8' '\n@@ -253,8 +288,8 @@ test_expect_success 'add sub9' '\n cd ..\n \n test_expect_success 'split for sub8' '\n-\t\tsplit2=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir/ --rejoin)\"''\n-\t\tgit branch split2 \"$split2\"\n+\t\tspl2=$(git subtree split --prefix=subdir/ --annotate=\"*\" --rejoin) &&\n+\t\tgit branch spl2 \"$spl2\"\n '\n \n test_expect_success 'add main-sub10' '\n@@ -263,7 +298,7 @@ test_expect_success 'add main-sub10' '\n '\n \n test_expect_success 'split for sub10' '\n-\t\tspl3=''\"$(git subtree split --annotate='\"'*'\"' --prefix subdir --rejoin)\"'' &&\n+\t\tspl3=$(git subtree split --prefix=subdir --annotate=\"*\" --rejoin) &&\n \t\tgit branch spl3 \"$spl3\"\n '\n \n@@ -284,13 +319,13 @@ chks=\"sub1 sub2 sub3 sub9\"\n chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)\n \n test_expect_success 'make sure exactly the right set of files ends up in the subproj' '\n-\t\tsubfiles=''\"$(git ls-files | fixnl)\"'' &&\n-\t\tcheck_equal \"$subfiles\" \"$chkms $chks\"\n+\t\tsubfiles=$(git ls-files | fixnl) &&\n+\t\ttest_equal \"$subfiles\" \"$chkms $chks\"\n '\n \n-test_expect_success 'make sure the subproj history *only* contains commits that affect the subdir' '\n-\t\tallchanges=''\"$(git log --name-only --pretty=format:'\"''\"' | sort | fixnl)\"'' &&\n-\t\tcheck_equal \"$allchanges\" \"$chkms $chks\"\n+test_expect_success 'make sure the subproj *only* contains commits that affect the subdir' '\n+\t\tallchanges=$(git log --name-only --pretty=format:\"\" | sort | fixnl) &&\n+\t\ttest_equal \"$allchanges\" \"$chkms $chks\"\n '\n \n # Back to mainline\n@@ -303,25 +338,25 @@ test_expect_success 'pull from subproj' '\n '\n \n test_expect_success 'make sure exactly the right set of files ends up in the mainline' '\n-\t\tmainfiles=''\"$(git ls-files | fixnl)\"'' &&\n-\t\tcheck_equal \"$mainfiles\" \"$chkm $chkms_sub $chks_sub\"\n+\t\tmainfiles=$(git ls-files | fixnl) &&\n+\t\ttest_equal \"$mainfiles\" \"$chkm $chkms_sub $chks_sub\"\n '\n \n test_expect_success 'make sure each filename changed exactly once in the entire history' '\n \t\t# main-sub?? and /subdir/main-sub?? both change, because those are the\n \t\t# changes that were split into their own history.  And subdir/sub?? never\n \t\t# change, since they were *only* changed in the subtree branch.\n-\t\tallchanges=''\"$(git log --name-only --pretty=format:'\"''\"' | sort | fixnl)\"'' &&\n-\t\tcheck_equal \"$allchanges\" ''\"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)\"''\n+\t\tallchanges=$(git log --name-only --pretty=format:\"\" | sort | fixnl) &&\n+\t\ttest_equal \"$allchanges\" \"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)\"\n '\n \n test_expect_success 'make sure the --rejoin commits never make it into subproj' '\n-\t\tcheck_equal ''\"$(git log --pretty=format:'\"'%s'\"' HEAD^2 | grep -i split)\"'' \"\"\n+\t\ttest_equal \"$(git log --pretty=format:\"%s\" HEAD^2 | grep -i split)\" \"\"\n '\n \n test_expect_success 'make sure no \"git subtree\" tagged commits make it into subproj' '\n \t\t# They are meaningless to subproj since one side of the merge refers to the mainline\n-\t\tcheck_equal ''\"$(git log --pretty=format:'\"'%s%n%b'\"' HEAD^2 | grep \"git-subtree.*:\")\"'' \"\"\n+\t\ttest_equal \"$(git log --pretty=format:\"%s%n%b\" HEAD^2 | grep \"git-subtree.*:\")\" \"\"\n '\n \n # prepare second pair of repositories\n@@ -359,7 +394,7 @@ cd ../main\n test_expect_success 'add sub as subdir in main' '\n \t\tgit fetch ../sub master &&\n \t\tgit branch sub2 FETCH_HEAD &&\n-\t\tgit subtree add --prefix subdir sub2\n+\t\tgit subtree add --prefix=subdir sub2\n '\n \n cd ../sub\n@@ -374,7 +409,7 @@ cd ../main\n test_expect_success 'merge from sub' '\n \t\tgit fetch ../sub master &&\n \t\tgit branch sub3 FETCH_HEAD &&\n-\t\tgit subtree merge --prefix subdir sub3\n+\t\tgit subtree merge --prefix=subdir sub3\n '\n \n test_expect_success 'add main-sub4' '\n@@ -383,7 +418,7 @@ test_expect_success 'add main-sub4' '\n '\n \n test_expect_success 'split for main-sub4 without --onto' '\n-\t\tgit subtree split --prefix subdir --branch mainsub4\n+\t\tgit subtree split --prefix=subdir --branch mainsub4\n '\n \n # at this point, the new commit parent should be sub3 if it is not,\n@@ -392,7 +427,7 @@ test_expect_success 'split for main-sub4 without --onto' '\n # itself)\n \n test_expect_success 'check that the commit parent is sub3' '\n-\t\tcheck_equal ''\"$(git log --pretty=format:%P -1 mainsub4)\"'' ''\"$(git rev-parse sub3)\"''\n+\t\ttest_equal \"$(git log --pretty=format:%P -1 mainsub4)\" \"$(git rev-parse sub3)\"\n '\n \n test_expect_success 'add main-sub5' '\n@@ -405,49 +440,23 @@ test_expect_success 'split for main-sub5 without --onto' '\n \t\t# also test that we still can split out an entirely new subtree\n \t\t# if the parent of the first commit in the tree is not empty,\n \t\t# then the new subtree has accidently been attached to something\n-\t\tgit subtree split --prefix subdir2 --branch mainsub5 &&\n-\t\tcheck_equal ''\"$(git log --pretty=format:%P -1 mainsub5)\"'' \"\"\n+\t\tgit subtree split --prefix=subdir2 --branch mainsub5 &&\n+\t\ttest_equal \"$(git log --pretty=format:%P -1 mainsub5)\" \"\"\n '\n \n-# make sure no patch changes more than one file.  The original set of commits\n-# changed only one file each.  A multi-file change would imply that we pruned\n-# commits too aggressively.\n-joincommits()\n-{\n-\tcommit=\n-\tall=\n-\twhile read x y; do\n-\t\t#echo \"{$x}\" >&2\n-\t\tif [ -z \"$x\" ]; then\n-\t\t\tcontinue\n-\t\telif [ \"$x\" = \"commit:\" ]; then\n-\t\t\tif [ -n \"$commit\" ]; then\n-\t\t\t\techo \"$commit $all\"\n-\t\t\t\tall=\n-\t\t\tfi\n-\t\t\tcommit=\"$y\"\n-\t\telse\n-\t\t\tall=\"$all $y\"\n-\t\tfi\n-\tdone\n-\techo \"$commit $all\"\n-}\n-\n test_expect_success 'verify one file change per commit' '\n \t\tx= &&\n-\t\tlist=''\"$(git log --pretty=format:'\"'commit: %H'\"' | joincommits)\"'' &&\n-#\t\t test_debug \"echo HERE\" &&\n-#\t\t test_debug \"echo ''\"$list\"''\" &&\n-\t\t(git log --pretty=format:'\"'commit: %H'\"' | joincommits |\n-\t\t(\t\twhile read commit a b; do\n-\t\t\t\ttest_debug \"echo Verifying commit \"''\"$commit\"''\n-\t\t\t\ttest_debug \"echo a: \"''\"$a\"''\n-\t\t\t\ttest_debug \"echo b: \"''\"$b\"''\n-\t\t\t\tcheck_equal \"$b\" \"\"\n+\t\tgit log --pretty=format:\"commit: %H\" | join_commits |\n+\t\t(\n+\t\t\twhile read commit a b; do\n+\t\t\t\ttest_debug \"echo Verifying commit $commit\"\n+\t\t\t\ttest_debug \"echo a: $a\"\n+\t\t\t\ttest_debug \"echo b: $b\"\n+\t\t\t\ttest_equal \"$b\" \"\"\n \t\t\t\tx=1\n \t\t\tdone\n-\t\t\tcheck_equal \"$x\" 1\n-\t\t))\n+\t\t\ttest_equal \"$x\" 1\n+\t\t)\n '\n \n test_done\n-- \n1.8.1\n"},{"id":"206741","messageId":"1358135541-10349-7-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358135541-10349-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC v2 6/8] contrib/subtree: Make each test self-contained","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-14T03:52:19Z","receivedAt":"2013-01-14T03:52:19Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>\n---\n contrib/subtree/t/t7900-subtree.sh | 865 ++++++++++++++++++++++++++-----------\n 1 file changed, 614 insertions(+), 251 deletions(-)\n\ndiff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh\nindex 69bd41c..ef83f31 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -12,12 +12,6 @@ export TEST_DIRECTORY=$(pwd)/../../../t\n \n . ../../../t/test-lib.sh\n \n-create()\n-{\n-\techo \"$1\" >\"$1\"\n-\tgit add \"$1\"\n-}\n-\n fixnl()\n {\n \tt=\"\"\n@@ -37,11 +31,6 @@ multiline()\n \tdone\n }\n \n-undo()\n-{\n-\tgit reset --hard HEAD~\n-}\n-\n test_equal()\n {\n \ttest_debug 'echo'\n@@ -78,373 +67,746 @@ join_commits()\n \techo \"$commit $all\"\n }\n \n+test_create_commit() (\n+\trepo=$1\n+\tcommit=$2\n+\tcd \"$repo\"\n+\tmkdir -p \"$(dirname \"$commit\")\"\n+\techo \"$commit\" > \"$commit\"\n+\tgit add \"$commit\"\n+\tgit commit -m \"$commit\"\n+)\n+\n last_commit_message()\n {\n \tgit log --pretty=format:%s -1\n }\n \n-test_expect_success 'init subproj' '\n-\t\ttest_create_repo subproj\n-'\n-\n-# To the subproject!\n-cd subproj\n-\n-test_expect_success 'add sub1' '\n-\t\tcreate sub1 &&\n-\t\tgit commit -m \"sub1\" &&\n-\t\tgit branch sub1 &&\n-\t\tgit branch -m master subproj\n-'\n-\n-test_expect_success 'add sub2' '\n-\t\tcreate sub2 &&\n-\t\tgit commit -m \"sub2\" &&\n-\t\tgit branch sub2\n-'\n-\n-test_expect_success 'add sub3' '\n-\t\tcreate sub3 &&\n-\t\tgit commit -m \"sub3\" &&\n-\t\tgit branch sub3\n-'\n-\n-# Back to mainline\n-cd ..\n-\n-test_expect_success 'add main4' '\n-\t\tcreate main4 &&\n-\t\tgit commit -m \"main4\" &&\n-\t\tgit branch -m master mainline &&\n-\t\tgit branch init\n-'\n-\n-test_expect_success 'fetch subproj history' '\n-\t\tgit fetch ./subproj sub1 &&\n-\t\tgit branch sub1 FETCH_HEAD\n-'\n+#\n+# Tests for 'git subtree add'\n+#\n \n test_expect_success 'no pull from non-existant subtree' '\n-\t\ttest_must_fail git subtree pull --prefix=subdir ./subproj sub1\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\ttest_must_fail git subtree pull --prefix=subdir ./subproj master\n+\t)\n '\n \n test_expect_success 'no merge from non-existant subtree' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n \t\ttest_must_fail git subtree merge --prefix=subdir FETCH_HEAD\n+\t)\n '\n \n test_expect_success 'add subproj as subtree into subdir/ with --prefix' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n \t\tgit subtree add --prefix=subdir FETCH_HEAD &&\n-\t\ttest_equal \"$(last_commit_message)\" \"Add '\\''subdir/'\\'' from commit '\\''$(git rev-parse FETCH_HEAD)'\\''\" &&\n-\t\tundo\n+\t\ttest_equal \"$(last_commit_message)\" \"Add '\\''subdir/'\\'' from commit '\\''$(git rev-parse FETCH_HEAD)'\\''\"\n+\t)\n '\n \n test_expect_success 'add subproj as subtree into subdir/ with --prefix and --message' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n \t\tgit subtree add --prefix=subdir --message=\"Added subproject\" FETCH_HEAD &&\n-\t\ttest_equal \"$(last_commit_message)\" \"Added subproject\" &&\n-\t\tundo\n+\t\ttest_equal \"$(last_commit_message)\" \"Added subproject\"\n+\t)\n '\n \n test_expect_success 'add subproj as subtree into subdir/ with --prefix as -P and --message as -m' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n \t\tgit subtree add -P subdir -m \"Added subproject\" FETCH_HEAD &&\n-\t\ttest_equal \"$(last_commit_message)\" \"Added subproject\" &&\n-\t\tundo\n+\t\ttest_equal \"$(last_commit_message)\" \"Added subproject\"\n+\t)\n '\n \n test_expect_success 'add subproj as subtree into subdir/ with --squash and --prefix and --message' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n \t\tgit subtree add --prefix=subdir --message=\"Added subproject with squash\" --squash FETCH_HEAD &&\n-\t\ttest_equal \"$(last_commit_message)\" \"Added subproject with squash\" &&\n-\t\tundo\n+\t\ttest_equal \"$(last_commit_message)\" \"Added subproject with squash\"\n+\t)\n '\n \n test_expect_success 'merge the added subproj again, should do nothing' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n \t\tgit subtree add --prefix=subdir FETCH_HEAD &&\n \t\t# this shouldn not actually do anything, since FETCH_HEAD\n \t\t# is already a parent\n \t\tgit merge -s ours -m \"merge -s -ours\" FETCH_HEAD\n+\t)\n '\n \n-test_expect_success 'add main-sub5' '\n-\t\tcreate subdir/main-sub5 &&\n-\t\tgit commit -m \"main-sub5\"\n-'\n-\n-test_expect_success 'add main6' '\n-\t\tcreate main6 &&\n-\t\tgit commit -m \"main6 boring\"\n-'\n-\n-test_expect_success 'add main-sub7' '\n-\t\tcreate subdir/main-sub7 &&\n-\t\tgit commit -m \"main-sub7\"\n-'\n-\n-test_expect_success 'fetch new subproj history' '\n-\t\tgit fetch ./subproj sub2 &&\n-\t\tgit branch sub2 FETCH_HEAD\n-'\n+#\n+# Tests for 'git subtree merge'\n+#\n \n test_expect_success 'merge new subproj history into subdir/ with --prefix' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n \t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n-\t\ttest_equal \"$(last_commit_message)\" \"Merge commit '\\''$(git rev-parse FETCH_HEAD)'\\'' into mainline\" &&\n-\t\tundo\n+\t\ttest_equal \"$(last_commit_message)\" \"Merge commit '\\''$(git rev-parse FETCH_HEAD)'\\''\"\n+\t)\n '\n \n test_expect_success 'merge new subproj history into subdir/ with --prefix and --message' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n \t\tgit subtree merge --prefix=subdir --message=\"Merged changes from subproject\" FETCH_HEAD &&\n-\t\ttest_equal \"$(last_commit_message)\" \"Merged changes from subproject\" &&\n-\t\tundo\n+\t\ttest_equal \"$(last_commit_message)\" \"Merged changes from subproject\"\n+\t)\n '\n \n test_expect_success 'merge new subproj history into subdir/ with --squash and --prefix and --message' '\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n \t\tgit subtree merge --prefix=subdir --message=\"Merged changes from subproject using squash\" --squash FETCH_HEAD &&\n-\t\ttest_equal \"$(last_commit_message)\" \"Merged changes from subproject using squash\" &&\n-\t\tundo\n+\t\ttest_equal \"$(last_commit_message)\" \"Merged changes from subproject using squash\"\n+\t)\n '\n \n-test_expect_success 'merge new subproj history into subdir/' '\n-\t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n-\t\tgit branch pre-split\n-'\n+#\n+# Tests for 'git subtree split'\n+#\n \n test_expect_success 'split requires option --prefix' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD &&\n \t\techo \"You must provide the --prefix option.\" > expected &&\n \t\ttest_must_fail git subtree split > actual 2>&1 &&\n \t\ttest_debug \"echo -n expected: \" &&\n \t\ttest_debug \"cat expected\" &&\n \t\ttest_debug \"echo -n actual: \" &&\n \t\ttest_debug \"cat actual\" &&\n-\t\ttest_cmp expected actual &&\n-\t\trm -f expected actual\n+\t\ttest_cmp expected actual\n+\t)\n '\n \n test_expect_success 'split requires path given by option --prefix must exist' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD &&\n \t\techo \"'\\''non-existent-directory'\\'' does not exist; use '\\''git subtree add'\\''\" > expected &&\n \t\ttest_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&\n \t\ttest_debug \"echo -n expected: \" &&\n \t\ttest_debug \"cat expected\" &&\n \t\ttest_debug \"echo -n actual: \" &&\n \t\ttest_debug \"cat actual\" &&\n-\t\ttest_cmp expected actual &&\n-\t\trm -f expected actual\n+\t\ttest_cmp expected actual\n+\t)\n '\n \n test_expect_success 'split subdir/ with --rejoin' '\n-\t\tspl1=$(git subtree split --prefix=subdir --annotate=\"*\") &&\n-\t\tgit branch spl1 \"$spl1\" &&\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub1 &&\n+\ttest_create_commit \"$test_count\" main2 &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n+\t\tsplit_hash=$(git subtree split --prefix=subdir --annotate=\"*\") &&\n \t\tgit subtree split --prefix=subdir --annotate=\"*\" --rejoin &&\n-\t\ttest_equal \"$(last_commit_message)\" \"Split '\\''subdir/'\\'' into commit '\\''$spl1'\\''\" &&\n-\t\tundo\n+\t\ttest_equal \"$(last_commit_message)\" \"Split '\\''subdir/'\\'' into commit '\\''$split_hash'\\''\"\n+\t)\n '\n \n test_expect_success 'split subdir/ with --rejoin and --message' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub1 &&\n+\ttest_create_commit \"$test_count\" main2 &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n \t\tgit subtree split --prefix=subdir --message=\"Split & rejoin\" --annotate=\"*\" --rejoin &&\n-\t\ttest_equal \"$(last_commit_message)\" \"Split & rejoin\" &&\n-\t\tundo\n+\t\ttest_equal \"$(last_commit_message)\" \"Split & rejoin\"\n+\t)\n '\n \n test_expect_success 'split subdir/ with --branch' '\n-\t\tspl1=$(git subtree split --prefix=subdir --message=\"Split & rejoin\" --annotate=\"*\" --rejoin) &&\n-\t\tundo &&\n-\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch splitbr1 &&\n-\t\ttest_equal \"$(git rev-parse splitbr1)\" \"$spl1\"\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub1 &&\n+\ttest_create_commit \"$test_count\" main2 &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n+\t\tsplit_hash=$(git subtree split --prefix=subdir --annotate=\"*\") &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br &&\n+\t\ttest_equal \"$(git rev-parse subproj-br)\" \"$split_hash\"\n+\t)\n '\n \n test_expect_success 'split subdir/ with --branch for an existing branch' '\n-\t\tspl1=$(git subtree split --prefix=subdir --annotate=\"*\" --message=\"Split & rejoin\" --rejoin) &&\n-\t\tundo &&\n-\t\tgit branch splitbr2 sub1 &&\n-\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch splitbr2 &&\n-\t\ttest_equal \"$(git rev-parse splitbr2)\" \"$spl1\"\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit branch subproj-br FETCH_HEAD &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub1 &&\n+\ttest_create_commit \"$test_count\" main2 &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n+\t\tsplit_hash=$(git subtree split --prefix=subdir --annotate=\"*\") &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br &&\n+\t\ttest_equal \"$(git rev-parse subproj-br)\" \"$split_hash\"\n+\t)\n '\n \n test_expect_success 'split subdir/ with --branch for an incompatible branch' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit branch init HEAD &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub1 &&\n+\ttest_create_commit \"$test_count\" main2 &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n \t\ttest_must_fail git subtree split --prefix=subdir --branch init\n+\t)\n '\n \n-test_expect_success 'split and rejoin' '\n-\t\tgit subtree split --prefix=subdir --annotate=\"*\" --rejoin\n-'\n-\n-test_expect_success 'add main-sub8' '\n-\t\tcreate subdir/main-sub8 &&\n-\t\tgit commit -m \"main-sub8\"\n-'\n-\n-# To the subproject!\n-cd ./subproj\n-\n-test_expect_success 'merge split into subproj' '\n-\t\tgit fetch .. spl1 &&\n-\t\tgit branch spl1 FETCH_HEAD &&\n-\t\tgit merge FETCH_HEAD\n-'\n-\n-test_expect_success 'add sub9' '\n-\t\tcreate sub9 &&\n-\t\tgit commit -m \"sub9\"\n-'\n-\n-# Back to mainline\n-cd ..\n-\n-test_expect_success 'split for sub8' '\n-\t\tspl2=$(git subtree split --prefix=subdir/ --annotate=\"*\" --rejoin) &&\n-\t\tgit branch spl2 \"$spl2\"\n-'\n-\n-test_expect_success 'add main-sub10' '\n-\t\tcreate subdir/main-sub10 &&\n-\t\tgit commit -m \"main-sub10\"\n-'\n-\n-test_expect_success 'split for sub10' '\n-\t\tspl3=$(git subtree split --prefix=subdir --annotate=\"*\" --rejoin) &&\n-\t\tgit branch spl3 \"$spl3\"\n-'\n-\n-# To the subproject!\n-cd ./subproj\n-\n-test_expect_success 'merge split into subproj' '\n-\t\tgit fetch .. spl3 &&\n-\t\tgit branch spl3 FETCH_HEAD &&\n-\t\tgit merge FETCH_HEAD &&\n-\t\tgit branch subproj-merge-spl3\n-'\n-\n-chkm=\"main4 main6\"\n-chkms=\"main-sub10 main-sub5 main-sub7 main-sub8\"\n-chkms_sub=$(echo $chkms | multiline | sed 's,^,subdir/,' | fixnl)\n-chks=\"sub1 sub2 sub3 sub9\"\n-chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)\n+#\n+# Validity checking\n+#\n \n test_expect_success 'make sure exactly the right set of files ends up in the subproj' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub1 &&\n+\ttest_create_commit \"$test_count\" main2 &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub3 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub3 &&\n+\t(\n+\t\tcd \"$test_count/subproj\" &&\n+\t\tgit fetch .. subproj-br && git merge FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub4 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub4 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\t(\n+\t\tcd \"$test_count/subproj\" &&\n+\t\tgit fetch .. subproj-br && git merge FETCH_HEAD &&\n+\n+\t\tchks=\"sub1 sub2 sub3 sub4\" &&\n+\t\tchks_sub=$(echo $chks | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+\t\tchkms=\"main-sub1 main-sub2 main-sub3 main-sub4\" &&\n+\t\tchkms_sub=$(echo $chkms | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+\n \t\tsubfiles=$(git ls-files | fixnl) &&\n \t\ttest_equal \"$subfiles\" \"$chkms $chks\"\n+\t)\n '\n \n test_expect_success 'make sure the subproj *only* contains commits that affect the subdir' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub1 &&\n+\ttest_create_commit \"$test_count\" main2 &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub3 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub3 &&\n+\t(\n+\t\tcd \"$test_count/subproj\" &&\n+\t\tgit fetch .. subproj-br && git merge FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub4 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub4 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\t(\n+\t\tcd \"$test_count/subproj\" &&\n+\t\tgit fetch .. subproj-br && git merge FETCH_HEAD &&\n+\n+\t\tchks=\"sub1 sub2 sub3 sub4\" &&\n+\t\tchks_sub=$(echo $chks | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+\t\tchkms=\"main-sub1 main-sub2 main-sub3 main-sub4\" &&\n+\t\tchkms_sub=$(echo $chkms | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+\n \t\tallchanges=$(git log --name-only --pretty=format:\"\" | sort | fixnl) &&\n \t\ttest_equal \"$allchanges\" \"$chkms $chks\"\n-'\n-\n-# Back to mainline\n-cd ..\n-\n-test_expect_success 'pull from subproj' '\n-\t\tgit fetch ./subproj subproj-merge-spl3 &&\n-\t\tgit branch subproj-merge-spl3 FETCH_HEAD &&\n-\t\tgit subtree pull --prefix=subdir ./subproj subproj-merge-spl3\n+\t)\n '\n \n test_expect_success 'make sure exactly the right set of files ends up in the mainline' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub1 &&\n+\ttest_create_commit \"$test_count\" main2 &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub3 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub3 &&\n+\t(\n+\t\tcd \"$test_count/subproj\" &&\n+\t\tgit fetch .. subproj-br && git merge FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub4 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub4 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\t(\n+\t\tcd \"$test_count/subproj\" &&\n+\t\tgit fetch .. subproj-br && git merge FETCH_HEAD\n+\t) &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree pull --prefix=subdir ./subproj master &&\n+\n+\t\tchkm=\"main1 main2\" &&\n+\t\tchks=\"sub1 sub2 sub3 sub4\" &&\n+\t\tchks_sub=$(echo $chks | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+\t\tchkms=\"main-sub1 main-sub2 main-sub3 main-sub4\" &&\n+\t\tchkms_sub=$(echo $chkms | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+\n \t\tmainfiles=$(git ls-files | fixnl) &&\n \t\ttest_equal \"$mainfiles\" \"$chkm $chkms_sub $chks_sub\"\n+\t)\n '\n \n test_expect_success 'make sure each filename changed exactly once in the entire history' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub1 &&\n+\ttest_create_commit \"$test_count\" main2 &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub3 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub3 &&\n+\t(\n+\t\tcd \"$test_count/subproj\" &&\n+\t\tgit fetch .. subproj-br && git merge FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub4 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub4 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\t(\n+\t\tcd \"$test_count/subproj\" &&\n+\t\tgit fetch .. subproj-br && git merge FETCH_HEAD\n+\t) &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree pull --prefix=subdir ./subproj master &&\n+\n+\t\tchkm=\"main1 main2\" &&\n+\t\tchks=\"sub1 sub2 sub3 sub4\" &&\n+\t\tchks_sub=$(echo $chks | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+\t\tchkms=\"main-sub1 main-sub2 main-sub3 main-sub4\" &&\n+\t\tchkms_sub=$(echo $chkms | multiline | sed '\\''s,^,subdir/,'\\'' | fixnl) &&\n+\n \t\t# main-sub?? and /subdir/main-sub?? both change, because those are the\n \t\t# changes that were split into their own history.  And subdir/sub?? never\n \t\t# change, since they were *only* changed in the subtree branch.\n \t\tallchanges=$(git log --name-only --pretty=format:\"\" | sort | fixnl) &&\n \t\ttest_equal \"$allchanges\" \"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)\"\n+\t)\n '\n \n test_expect_success 'make sure the --rejoin commits never make it into subproj' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub1 &&\n+\ttest_create_commit \"$test_count\" main2 &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub3 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub3 &&\n+\t(\n+\t\tcd \"$test_count/subproj\" &&\n+\t\tgit fetch .. subproj-br && git merge FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub4 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub4 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\t(\n+\t\tcd \"$test_count/subproj\" &&\n+\t\tgit fetch .. subproj-br && git merge FETCH_HEAD\n+\t) &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree pull --prefix=subdir ./subproj master &&\n+\n \t\ttest_equal \"$(git log --pretty=format:\"%s\" HEAD^2 | grep -i split)\" \"\"\n+\t)\n '\n \n test_expect_success 'make sure no \"git subtree\" tagged commits make it into subproj' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub1 &&\n+\ttest_create_commit \"$test_count\" main2 &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub3 &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub3 &&\n+\t(\n+\t\tcd \"$test_count/subproj\" &&\n+\t\tgit fetch .. subproj-br && git merge FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub4 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub4 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir --annotate=\"*\" --branch subproj-br --rejoin\n+\t) &&\n+\t(\n+\t\tcd \"$test_count/subproj\" &&\n+\t\tgit fetch .. subproj-br && git merge FETCH_HEAD\n+\t) &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree pull --prefix=subdir ./subproj master &&\n+\n \t\t# They are meaningless to subproj since one side of the merge refers to the mainline\n \t\ttest_equal \"$(git log --pretty=format:\"%s%n%b\" HEAD^2 | grep \"git-subtree.*:\")\" \"\"\n+\t)\n '\n \n-# prepare second pair of repositories\n-mkdir test2\n-cd test2\n-\n-test_expect_success 'init main' '\n-\t\ttest_create_repo main\n-'\n-\n-cd main\n-\n-test_expect_success 'add main1' '\n-\t\tcreate main1 &&\n-\t\tgit commit -m \"main1\"\n-'\n-\n-cd ..\n-\n-test_expect_success 'init sub' '\n-\t\ttest_create_repo sub\n-'\n-\n-cd sub\n-\n-test_expect_success 'add sub2' '\n-\t\tcreate sub2 &&\n-\t\tgit commit -m \"sub2\"\n-'\n-\n-cd ../main\n-\n-# check if split can find proper base without --onto\n-\n-test_expect_success 'add sub as subdir in main' '\n-\t\tgit fetch ../sub master &&\n-\t\tgit branch sub2 FETCH_HEAD &&\n-\t\tgit subtree add --prefix=subdir sub2\n-'\n-\n-cd ../sub\n-\n-test_expect_success 'add sub3' '\n-\t\tcreate sub3 &&\n-\t\tgit commit -m \"sub3\"\n-'\n-\n-cd ../main\n-\n-test_expect_success 'merge from sub' '\n-\t\tgit fetch ../sub master &&\n-\t\tgit branch sub3 FETCH_HEAD &&\n-\t\tgit subtree merge --prefix=subdir sub3\n-'\n-\n-test_expect_success 'add main-sub4' '\n-\t\tcreate subdir/main-sub4 &&\n-\t\tgit commit -m \"main-sub4\"\n-'\n-\n-test_expect_success 'split for main-sub4 without --onto' '\n-\t\tgit subtree split --prefix=subdir --branch mainsub4\n-'\n-\n-# at this point, the new commit parent should be sub3 if it is not,\n-# something went wrong (the \"newparent\" of \"master~\" commit should\n-# have been sub3, but it was not, because its cache was not set to\n-# itself)\n-\n-test_expect_success 'check that the commit parent is sub3' '\n-\t\ttest_equal \"$(git log --pretty=format:%P -1 mainsub4)\" \"$(git rev-parse sub3)\"\n-'\n+#\n+# A new set of tests\n+#\n \n-test_expect_success 'add main-sub5' '\n-\t\tmkdir subdir2 &&\n-\t\tcreate subdir2/main-sub5 &&\n-\t\tgit commit -m \"main-sub5\"\n-'\n+test_expect_success 'make sure \"git subtree split\" find the correct parent' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit branch subproj-ref FETCH_HEAD &&\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir --branch subproj-br &&\n+\n+\t\t# at this point, the new commit parent should be subproj-ref, if it is\n+\t\t# not, something went wrong (the \"newparent\" of \"master~\" commit should\n+\t\t# have been sub2, but it was not, because its cache was not set to\n+\t\t# itself)\n+\t\ttest_equal \"$(git log --pretty=format:%P -1 subproj-br)\" \"$(git rev-parse subproj-ref)\"\n+\t)\n+'\n+\n+test_expect_success 'split a new subtree without --onto option' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir --branch subproj-br\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir2/main-sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n \n-test_expect_success 'split for main-sub5 without --onto' '\n \t\t# also test that we still can split out an entirely new subtree\n \t\t# if the parent of the first commit in the tree is not empty,\n \t\t# then the new subtree has accidently been attached to something\n-\t\tgit subtree split --prefix=subdir2 --branch mainsub5 &&\n-\t\ttest_equal \"$(git log --pretty=format:%P -1 mainsub5)\" \"\"\n+\t\tgit subtree split --prefix=subdir2 --branch subproj2-br &&\n+\t\ttest_equal \"$(git log --pretty=format:%P -1 subproj2-br)\" \"\"\n+\t)\n '\n \n test_expect_success 'verify one file change per commit' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit branch sub1 FETCH_HEAD &&\n+\t\tgit subtree add --prefix=subdir sub1\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree merge --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir --branch subproj-br\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir2/main-sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit subtree split --prefix=subdir2 --branch subproj2-br &&\n+\n \t\tx= &&\n \t\tgit log --pretty=format:\"commit: %H\" | join_commits |\n \t\t(\n@@ -457,6 +819,7 @@ test_expect_success 'verify one file change per commit' '\n \t\t\tdone\n \t\t\ttest_equal \"$x\" 1\n \t\t)\n+\t)\n '\n \n test_done\n-- \n1.8.1\n"},{"id":"206740","messageId":"1358135541-10349-8-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358135541-10349-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC v2 7/8] contrib/subtree: Use %B for the split commit message","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-14T03:52:20Z","receivedAt":"2013-01-14T03:52:20Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"Use %B rather than %s%n%n%b to handle the special case of a commit that\nonly has a subject line.  We don't want to introduce a newline after the\nsubject, causing generation of a new hash.\n\nAfter this commit, the newly split branch might differ from the previous\none. If this is the case, --fallback option could help.\n\nSigned-off-by: Techlive Zheng <techlivezheng@gmail.com>\nSigned-off-by: David A. Greene <greened@obbligato.org>\n---\n contrib/subtree/git-subtree.sh     | 13 ++++++++++-\n contrib/subtree/git-subtree.txt    | 13 +++++++++++\n contrib/subtree/t/t7900-subtree.sh | 47 ++++++++++++++++++++++++++++++++++++++\n 3 files changed, 72 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex 88903c0..d529a76 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -25,6 +25,7 @@ b,branch=     create a new branch from the split subtree\n ignore-joins  ignore prior --rejoin commits\n onto=         try connecting new tree to an existing one\n rejoin        merge the new branch back into HEAD\n+fallback      fallback to the obsolete commit generating mechanism\n  options for 'add', 'merge', 'pull' and 'push'\n squash        merge subtree changes as a single commit\n \"\n@@ -45,6 +46,7 @@ ignore_joins=\n annotate=\n squash=\n message=\n+fallback=\n \n debug()\n {\n@@ -92,6 +94,8 @@ while [ $# -gt 0 ]; do\n \t\t--no-ignore-joins) ignore_joins= ;;\n \t\t--squash) squash=1 ;;\n \t\t--no-squash) squash= ;;\n+\t\t--fallback) fallback=1 ;;\n+\t\t--no-fallback) fallback= ;;\n \t\t--) break ;;\n \t\t*) die \"Unexpected option: $opt\" ;;\n \tesac\n@@ -296,7 +300,14 @@ copy_commit()\n \t# We're going to set some environment vars here, so\n \t# do it in a subshell to get rid of them safely later\n \tdebug copy_commit \"{$1}\" \"{$2}\" \"{$3}\"\n-\tgit log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%s%n%n%b' \"$1\" |\n+\n+\tif [ -z \"$fallback\" ]; then\n+\t\tlog_format='%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%B'\n+\telse\n+\t\tlog_format='%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%s%n%n%b'\n+\tfi\n+\n+\tgit log -1 --pretty=format:\"$log_format\" \"$1\" |\n \t(\n \t\tread GIT_AUTHOR_NAME\n \t\tread GIT_AUTHOR_EMAIL\ndiff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt\nindex 72be8e4..55d0575 100644\n--- a/contrib/subtree/git-subtree.txt\n+++ b/contrib/subtree/git-subtree.txt\n@@ -254,6 +254,19 @@ OPTIONS FOR split\n \t'--rejoin' when you split, because you don't want the\n \tsubproject's history to be part of your project anyway.\n \n+--fallback::\n+\tPreviously, git subtree would introduce an extra new line for\n+\tthe commits whose commit message contains only one line.\n+\tThis behavior has been correct. Unfortunately, for those whose\n+\tcurrent split branch contains these kind of commits, git subtree\n+\twill generate a new split branch which differs from the existing\n+\tsplit branch in these commits. It is better to use this new\n+\tsplit branch, because its commits stay intact within the mainline.\n+\n+\tOtherwise, the previous fault behavior could still be used with\n+\tthis option. This option is only for a compatible purpose, newly\n+\tsplit branch should never use this option.\n+\n \n EXAMPLE 1. Add command\n ----------------------\ndiff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh\nindex ef83f31..232ed89 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -399,6 +399,53 @@ test_expect_success 'split subdir/ with --branch for an incompatible branch' '\n \t)\n '\n \n+test_expect_success 'make sure commits with one line message stay intact after split' '\n+\ttest_create_repo $test_count &&\n+\ttest_create_repo $test_count/subproj &&\n+\ttest_create_commit $test_count main1 &&\n+\ttest_create_commit $test_count/subproj sub1 &&\n+\t(\n+\t\tcd $test_count &&\n+\t\tgit fetch ./subproj master &&\n+\t\tori_hash=$(git rev-parse FETCH_HEAD) &&\n+\t\tgit branch subori FETCH_HEAD &&\n+\t\tgit filter-branch --index-filter '\\''git ls-files -s | sed \"s-\\t-&subdir/-\" | GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && mv \"$GIT_INDEX_FILE.new\" \"$GIT_INDEX_FILE\"'\\'' subori\n+\t\tgit merge -m \"Merge B project as our subdirectory\" subori &&\n+\t\tgit subtree split --prefix subdir --branch splitbr1 &&\n+\t\tnew_hash_1=$(git rev-parse splitbr1) &&\n+\t\ttest_equal \"$ori_hash\" \"$new_hash_1\" &&\n+\t\tgit subtree split --prefix subdir --branch splitbr2 --fallback &&\n+\t\tnew_hash_2=$(git rev-parse splitbr2) &&\n+\t\ttest_must_fail test_equal \"$ori_hash\" \"$new_hash_2\"\n+\t)\n+'\n+\n+test_expect_success 'make sure --fallback option works correctly for the existing split branch' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count\"/subproj &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count\"/subproj sub1 &&\n+\t(\n+\t\tcd $test_count &&\n+\t\tgit fetch ./subproj master &&\n+\t\tori_hash=$(git rev-parse FETCH_HEAD) &&\n+\t\tgit subtree add --prefix=subdir FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub1 &&\n+\t(\n+\t\tcd $test_count &&\n+\t\tgit subtree split --prefix subdir --branch splitbr1 &&\n+\t\tgit subtree split --prefix subdir --branch splitbr2 --fallback &&\n+\t\ttest_must_fail test_equal \"$(git rev-parse splitbr1)\" \"$(git rev-parse splitbr2)\"\n+\t) &&\n+\ttest_create_commit \"$test_count\" subdir/main-sub2 &&\n+\t(\n+\t\tcd $test_count &&\n+\t\ttest_must_fail git subtree split --prefix subdir --branch splitbr2 &&\n+\t\tgit subtree split --prefix subdir --branch splitbr2 --fallback\n+\t)\n+'\n+\n #\n # Validity checking\n #\n-- \n1.8.1\n"},{"id":"206738","messageId":"1358135541-10349-9-git-send-email-techlivezheng@gmail.com","threadId":"32611","inReplyTo":"1358135541-10349-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH/RFC v2 8/8] contrib/subtree: Handle '--prefix' argument with a slash appended","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2013-01-14T03:52:21Z","receivedAt":"2013-01-14T03:52:21Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"'git subtree merge' will fail if the argument of '--prefix' has a slash\nappended.\n\nSigned-off-by: Techlive Zheng <techlivezheng@gmail.com>\n---\n contrib/subtree/git-subtree.sh     |  2 +-\n contrib/subtree/t/t7900-subtree.sh | 19 +++++++++++++++++++\n 2 files changed, 20 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex d529a76..40100e5 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -83,7 +83,7 @@ while [ $# -gt 0 ]; do\n \t\t--annotate) annotate=\"$1\"; shift ;;\n \t\t--no-annotate) annotate= ;;\n \t\t-b) branch=\"$1\"; shift ;;\n-\t\t-P) prefix=\"$1\"; shift ;;\n+\t\t-P) prefix=\"${1%/}\"; shift ;;\n \t\t-m) message=\"$1\"; shift ;;\n \t\t--no-prefix) prefix= ;;\n \t\t--onto) onto=\"$1\"; shift ;;\ndiff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh\nindex 232ed89..297dac4 100755\n--- a/contrib/subtree/t/t7900-subtree.sh\n+++ b/contrib/subtree/t/t7900-subtree.sh\n@@ -238,6 +238,25 @@ test_expect_success 'merge new subproj history into subdir/ with --squash and --\n \t)\n '\n \n+test_expect_success 'merge new subproj history into subdir/ with a slash appended to the argument of --prefix' '\n+\ttest_create_repo \"$test_count\" &&\n+\ttest_create_repo \"$test_count/subproj\" &&\n+\ttest_create_commit \"$test_count\" main1 &&\n+\ttest_create_commit \"$test_count/subproj\" sub1 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree add --prefix=subdir/ FETCH_HEAD\n+\t) &&\n+\ttest_create_commit \"$test_count/subproj\" sub2 &&\n+\t(\n+\t\tcd \"$test_count\" &&\n+\t\tgit fetch ./subproj master &&\n+\t\tgit subtree merge --prefix=subdir/ FETCH_HEAD &&\n+\t\ttest_equal \"$(last_commit_message)\" \"Merge commit '\\''$(git rev-parse FETCH_HEAD)'\\''\"\n+\t)\n+'\n+\n #\n # Tests for 'git subtree split'\n #\n-- \n1.8.1\n"}]}