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

[PATCH v3 2/5] t7401: use 'short' instead of 'verify' and cut in rev-parse calls

From
Shourya Shukla <shouryashukla.oo@gmail.com>
Date
Aug 21, 2020, 16:59 UTC
Message-ID
<20200821165952.14376-3-shouryashukla.oo@gmail.com>
In-Reply-To
<20200821165952.14376-1-shouryashukla.oo@gmail.com>

'git rev-parse' can limit the number of characters in the hash it outputs using the '--short' option, thereby, making the 'cut' invocation redundant. Since using '--short' implies '--verify' as well, we can safely replace the latter with the former. This change results in the helper functions getting the hash in the same way 'summary' gets the hash internally.

So, avoid the unnecessary invocation to 'cut' in the helper functions.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com>
---
 t/t7401-submodule-summary.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
index 07d4ba0b26..ccbac875fe 100755
--- a/t/t7401-submodule-summary.sh
+++ b/t/t7401-submodule-summary.sh
@@ -21,7 +21,7 @@ add_file () {
 		test_tick &&
 		git commit -m "Add $name"
 	done >/dev/null
-	git rev-parse --verify HEAD | cut -c1-7
+	git rev-parse --short HEAD
 	cd "$owd"
 }
 commit_file () {
@@ -125,7 +125,7 @@ commit_file sm1 &&
 head3=$(
 	cd sm1 &&
 	git reset --hard HEAD~2 >/dev/null &&
-	git rev-parse --verify HEAD | cut -c1-7
+	git rev-parse --short HEAD
 )
 
 test_expect_success 'modified submodule(backward)' "
-- 
2.28.0
Previous: Shourya Shukla
Message 6 of 6 in “t7401: modernize, cleanup and more”
  1. Shourya ShuklaAug 21, 2020
  2. 1/5 t7401: modernize styleShourya Shukla, Aug 21, 2020
  3. 3/5 t7401: change syntax of test_i18ncmp calls for clarityShourya Shukla, Aug 21, 2020
  4. 5/5 t7401: add a NEEDSWORKShourya Shukla, Aug 21, 2020
  5. 4/5 t7401: change indentation for enhanced readabilityShourya Shukla, Aug 21, 2020
  6. 2/5 t7401: use 'short' instead of 'verify' and cut in rev-parse callsShourya Shukla, Aug 21, 2020

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.