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

Re: [PATCH] Improve tests for detached worktree in git-submodule

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 30, 2012, 17:51 UTC
Message-ID
<7vobmxqgqv.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vsjc9qh33.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 10 quoted lines
> Daniel Graña <dangra@gmail.com> writes:
> ...
>> is it still better than "git rev-parse --max-count=1 HEAD" seen in
>> t7406-submodule.update.sh?
>
> "git rev-parse --max-count=1 HEAD" will show "--max-count=1\n"
> followed by the value of HEAD, so if the expected result and the
> actual result were both prepared by that command, the comparison
> would succeed (as the irrelevant --max-count=1 line will appear in
> both output), but honestly, I do not think it makes any sense.
Thanks for noticing; I'll queue this.
-- >8 --
Subject: [PATCH] t7406: fix misleading "rev-parse --max-count=1 HEAD"

The test happened to use "rev-parse --max-count=1 HEAD" consistently to prepare the expected output and the actual output, so the comparison between them gave us a correct success/failure because both output had irrelevant "--max-count=1" in it.

But that is not an excuse to keep it broken. Replace it a more meaningful construct "rev-parse --verify HEAD".

Noticed by Daniel Graña while working on his submodule tests.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t7406-submodule-update.sh | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 807f761..f4e6602 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -305,7 +305,7 @@ test_expect_success 'submodule update continues after checkout error' '
 	 git submodule init &&
 	 git commit -am "new_submodule" &&
 	 (cd submodule2 &&
-	  git rev-parse --max-count=1 HEAD > ../expect
+	  git rev-parse --verify HEAD >../expect
 	 ) &&
 	 (cd submodule &&
 	  test_commit "update_submodule" file
@@ -322,7 +322,7 @@ test_expect_success 'submodule update continues after checkout error' '
 	 git checkout HEAD^ &&
 	 test_must_fail git submodule update &&
 	 (cd submodule2 &&
-	  git rev-parse --max-count=1 HEAD > ../actual
+	  git rev-parse --verify HEAD >../actual
 	 ) &&
 	 test_cmp expect actual
 	)
@@ -351,7 +351,7 @@ test_expect_success 'submodule update continues after recursive checkout error'
 	  test_commit "update_submodule_again_again" file
 	 ) &&
 	 (cd submodule2 &&
-	  git rev-parse --max-count=1 HEAD > ../expect &&
+	  git rev-parse --verify HEAD >../expect &&
 	  test_commit "update_submodule2_again" file
 	 ) &&
 	 git add submodule &&
@@ -366,7 +366,7 @@ test_expect_success 'submodule update continues after recursive checkout error'
 	 ) &&
 	 test_must_fail git submodule update --recursive &&
 	 (cd submodule2 &&
-	  git rev-parse --max-count=1 HEAD > ../actual
+	  git rev-parse --verify HEAD >../actual
 	 ) &&
 	 test_cmp expect actual
 	)
@@ -398,12 +398,12 @@ test_expect_success 'submodule update exit immediately in case of merge conflict
 	 ) &&
 	 git checkout HEAD^ &&
 	 (cd submodule2 &&
-	  git rev-parse --max-count=1 HEAD > ../expect
+	  git rev-parse --verify HEAD >../expect
 	 ) &&
 	 git config submodule.submodule.update merge &&
 	 test_must_fail git submodule update &&
 	 (cd submodule2 &&
-	  git rev-parse --max-count=1 HEAD > ../actual
+	  git rev-parse --verify HEAD >../actual
 	 ) &&
 	 test_cmp expect actual
 	)
@@ -432,12 +432,12 @@ test_expect_success 'submodule update exit immediately after recursive rebase er
 	 ) &&
 	 git checkout HEAD^ &&
 	 (cd submodule2 &&
-	  git rev-parse --max-count=1 HEAD > ../expect
+	  git rev-parse --verify HEAD >../expect
 	 ) &&
 	 git config submodule.submodule.update rebase &&
 	 test_must_fail git submodule update &&
 	 (cd submodule2 &&
-	  git rev-parse --max-count=1 HEAD > ../actual
+	  git rev-parse --verify HEAD >../actual
 	 ) &&
 	 test_cmp expect actual
 	)
-- 
1.7.12.rc0.80.gb93a609
Previous: Junio C HamanoNext: Daniel Graña
Message 6 of 12 in “Improve tests for detached worktree in git-submodule”
  1. Improve tests for detached worktree in git-submoduleDaniel Graña, Jul 30, 2012
  2. Jeff KingJul 30, 2012
  3. Junio C HamanoJul 30, 2012
  4. Daniel GrañaJul 30, 2012
  5. Junio C HamanoJul 30, 2012
  6. Junio C HamanoJul 30, 2012
  7. Improve tests for detached worktree in git-submoduleDaniel Graña, Jul 30, 2012
  8. Junio C HamanoJul 30, 2012
  9. Daniel GrañaJul 30, 2012
  10. Improve tests for detached worktree in git-submoduleDaniel Graña, Jul 30, 2012
  11. Daniel GrañaJul 30, 2012
  12. Fwd: [PATCH] Improve tests for detached worktree in git-submoduleDaniel Graña, Jul 30, 2012

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.