git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] contrib/subtree: Fix broken &&-chains and revealed test error

From
Charles Bailey <charles@hashpling.org>
Date
Jun 22, 2015, 13:53 UTC
Message-ID
<1434981210-13036-2-git-send-email-charles@hashpling.org>
In-Reply-To
<1434981210-13036-1-git-send-email-charles@hashpling.org>
From: Charles Bailey <cbailey32@bloomberg.net>

This fixes two instances where a &&-chain was broken in the subtree tests and fixes a test error that was revealed because of this.

Many tests in t7900-subtree.sh make a commit and then use 'undo' to reset the state for the next test. In the 'check hash of split' test, an 'undo' was being invoked after a 'subtree split' even though the particular invocation of 'subtree split' did not actually make a commit. The subsequent check_equal was failing, but this failure was masked by that broken &&-chain.

Removing this undo causes the failing check_equal to succeed but breaks the a check_equal later on in the same test.

It turns out that an earlier test ('check if --message for merge works with squash too') makes a commit but doesn't 'undo' to the state expected by the remaining tests. None of the intervening tests cared enough about the state of the test repo to fail and the spurious 'undo' in 'check hash of split' restored the expected state for any remaining test that might care.

Adding the missing 'undo' to 'check if --message for merge works with squash too' and removing the spurious one from 'check hash of split' fixes all tests once the &&-chains are completed.

Signed-off-by: Charles Bailey <cbailey32@bloomberg.net>
---
 contrib/subtree/t/t7900-subtree.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 2c5bfc1..001c604 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -177,7 +177,8 @@ test_expect_success 'check if --message for merge works with squash too' '
 test_expect_success 'merge new subproj history into subdir' '
 	git subtree merge --prefix=subdir FETCH_HEAD &&
 	git branch pre-split &&
-	check_equal ''"$(last_commit_message)"'' "Merge commit '"'"'"$(git rev-parse sub2)"'"'"' into mainline"
+	check_equal ''"$(last_commit_message)"'' "Merge commit '"'"'"$(git rev-parse sub2)"'"'"' into mainline" &&
+	undo
 '
 
 test_expect_success 'Check that prefix argument is required for split' '
@@ -218,9 +219,8 @@ test_expect_success 'check split with --branch' '
 
 test_expect_success 'check hash of split' '
 	spl1=$(git subtree split --prefix subdir) &&
-	undo &&
 	git subtree split --prefix subdir --branch splitbr1test &&
-	check_equal ''"$(git rev-parse splitbr1test)"'' "$spl1"
+	check_equal ''"$(git rev-parse splitbr1test)"'' "$spl1" &&
 	git checkout splitbr1test &&
 	new_hash=$(git rev-parse HEAD~2) &&
 	git checkout mainline &&
@@ -269,7 +269,7 @@ test_expect_success 'add sub9' '
 cd ..
 
 test_expect_success 'split for sub8' '
-	split2=''"$(git subtree split --annotate='"'*'"' --prefix subdir/ --rejoin)"''
+	split2=''"$(git subtree split --annotate='"'*'"' --prefix subdir/ --rejoin)"'' &&
 	git branch split2 "$split2"
 '
 
-- 
2.4.0.53.g8440f74
Previous: Charles BaileyNext: Charles Bailey
Message 2 of 4 in “contrib/subtree: Use tabs consitently for indentation in tests”
  1. 1/3 contrib/subtree: Use tabs consitently for indentation in testsCharles Bailey, Jun 22, 2015
  2. 2/3 contrib/subtree: Fix broken &&-chains and revealed test errorCharles Bailey, Jun 22, 2015
  3. 3/3 contrib/subtree: Small tidy-up to testCharles Bailey, Jun 22, 2015
  4. Eric SunshineJun 22, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.