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

[PATCH 07/10] t2020: abstract away SHA-1 specific constants

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Mar 25, 2018, 19:20 UTC
Message-ID
<20180325192055.841459-8-sandals@crustytoothpaste.net>
In-Reply-To
<20180325192055.841459-1-sandals@crustytoothpaste.net>

Adjust the test so that it uses variables for the revisions we're checking out instead of hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t2020-checkout-detach.sh | 40 +++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 16 deletions(-)
diff --git a/t/t2020-checkout-detach.sh b/t/t2020-checkout-detach.sh
index bb4f2e0c63..1fa670625c 100755
--- a/t/t2020-checkout-detach.sh
+++ b/t/t2020-checkout-detach.sh
@@ -189,8 +189,12 @@ test_expect_success 'no advice given for explicit detached head state' '
 # Detached HEAD tests for GIT_PRINT_SHA1_ELLIPSIS (new format)
 test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not asked to' "
 
+	commit=$(git rev-parse --short=12 master^) &&
+	commit2=$(git rev-parse --short=12 master~2) &&
+	commit3=$(git rev-parse --short=12 master~3) &&
+
 	# The first detach operation is more chatty than the following ones.
-	cat >1st_detach <<-'EOF' &&
+	cat >1st_detach <<-EOF &&
 	Note: checking out 'HEAD^'.
 
 	You are in 'detached HEAD' state. You can look around, make experimental
@@ -202,18 +206,18 @@ test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not as
 
 	  git checkout -b <new-branch-name>
 
-	HEAD is now at 7c7cd714e262 three
+	HEAD is now at \$commit three
 	EOF
 
 	# The remaining ones just show info about previous and current HEADs.
-	cat >2nd_detach <<-'EOF' &&
-	Previous HEAD position was 7c7cd714e262 three
-	HEAD is now at 139b20d8e6c5 two
+	cat >2nd_detach <<-EOF &&
+	Previous HEAD position was \$commit three
+	HEAD is now at \$commit2 two
 	EOF
 
-	cat >3rd_detach <<-'EOF' &&
-	Previous HEAD position was 139b20d8e6c5 two
-	HEAD is now at d79ce1670bdc one
+	cat >3rd_detach <<-EOF &&
+	Previous HEAD position was \$commit2 two
+	HEAD is now at \$commit3 one
 	EOF
 
 	reset &&
@@ -261,8 +265,12 @@ test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not as
 # Detached HEAD tests for GIT_PRINT_SHA1_ELLIPSIS (old format)
 test_expect_success 'describe_detached_head does print SHA-1 ellipsis when asked to' "
 
+	commit=$(git rev-parse --short=12 master^) &&
+	commit2=$(git rev-parse --short=12 master~2) &&
+	commit3=$(git rev-parse --short=12 master~3) &&
+
 	# The first detach operation is more chatty than the following ones.
-	cat >1st_detach <<-'EOF' &&
+	cat >1st_detach <<-EOF &&
 	Note: checking out 'HEAD^'.
 
 	You are in 'detached HEAD' state. You can look around, make experimental
@@ -274,18 +282,18 @@ test_expect_success 'describe_detached_head does print SHA-1 ellipsis when asked
 
 	  git checkout -b <new-branch-name>
 
-	HEAD is now at 7c7cd714e262... three
+	HEAD is now at \$commit... three
 	EOF
 
 	# The remaining ones just show info about previous and current HEADs.
-	cat >2nd_detach <<-'EOF' &&
-	Previous HEAD position was 7c7cd714e262... three
-	HEAD is now at 139b20d8e6c5... two
+	cat >2nd_detach <<-EOF &&
+	Previous HEAD position was \$commit... three
+	HEAD is now at \$commit2... two
 	EOF
 
-	cat >3rd_detach <<-'EOF' &&
-	Previous HEAD position was 139b20d8e6c5... two
-	HEAD is now at d79ce1670bdc... one
+	cat >3rd_detach <<-EOF &&
+	Previous HEAD position was \$commit2... two
+	HEAD is now at \$commit3... one
 	EOF
 
 	reset &&
Previous: brian m. carlsonNext: brian m. carlson
Message 9 of 20 in “Hash-independent tests (part 1)”
  1. 00/10 Hash-independent tests (part 1)brian m. carlson, Mar 25, 2018
  2. 01/10 t1011: abstract away SHA-1-specific constantsbrian m. carlson, Mar 25, 2018
  3. 02/10 t1304: abstract away SHA-1-specific constantsbrian m. carlson, Mar 25, 2018
  4. 03/10 t1300: abstract away SHA-1-specific constantsbrian m. carlson, Mar 25, 2018
  5. 05/10 t1411: abstract away SHA-1-specific constantsbrian m. carlson, Mar 25, 2018
  6. 04/10 t1405: sort reflog entries in a hash-independent waybrian m. carlson, Mar 25, 2018
  7. Junio C HamanoMar 26, 2018
  8. brian m. carlsonMar 26, 2018
  9. 07/10 t2020: abstract away SHA-1 specific constantsbrian m. carlson, Mar 25, 2018
  10. 06/10 t1507: abstract away SHA-1-specific constantsbrian m. carlson, Mar 25, 2018
  11. 08/10 t2101: modernize test stylebrian m. carlson, Mar 25, 2018
  12. 09/10 t2101: abstract away SHA-1-specific constantsbrian m. carlson, Mar 25, 2018
  13. 10/10 t2107: abstract away SHA-1-specific constantsbrian m. carlson, Mar 25, 2018
  14. Eric SunshineMar 26, 2018
  15. Junio C HamanoMar 26, 2018
  16. Johannes SchindelinMar 27, 2018
  17. Junio C HamanoMar 28, 2018
  18. Johannes SchindelinMar 29, 2018
  19. brian m. carlsonMar 26, 2018
  20. Johannes SchindelinMar 27, 2018

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.