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

Re: [PATCH v2 1/4] t7401: modernize style

From
Shourya Shukla <shouryashukla.oo@gmail.com>
Date
Aug 14, 2020, 14:41 UTC
Message-ID
<20200814144126.GA137865@konoha>
In-Reply-To
<xmqqd03u4hpl.fsf@gitster.c.googlers.com>
On 13/08 09:46, Junio C Hamano wrote:
Show 52 quoted lines
> Kaartic Sivaraam <kaartic.sivaraam@gmail.com> writes:
> 
> >> @@ -16,12 +16,13 @@ add_file () {
> >>  	owd=$(pwd)
> >>  	cd "$sm"
> >>  	for name; do
> >> -		echo "$name" > "$name" &&
> >> +		echo "$name" >"$name" &&
> >>  		git add "$name" &&
> >>  		test_tick &&
> >>  		git commit -m "Add $name"
> >>  	done >/dev/null
> >> -	git rev-parse --verify HEAD | cut -c1-7
> >> +	git rev-parse --verify HEAD >out &&
> >> +	cut -c1-7 out
> >
> > In any case, I believe we can avoid the 'cut' altogether in both places
> > by doing something like this instead:
> >
> >    git rev-parse --short=7 HEAD
> 
> Ah, I missed the fact that this was a helper function and most of
> the error status is discarded anyway.  For example, we still run the
> rev-parse even after the for loop fails.
> 
> If the focus of this test script were to ensure that rev-parse works
> correctly, being careful to catch its exit status might have had a
> good value, but for that, all the other operations that happen in
> this helper function (including the "what happens when the loop body
> fails for $name that is not at the end of the argument list?") must
> also be checked for their exit status in the first place.
> 
> Since that is not done, and since testing rev-parse should not have
> to be part of the job for submodule test, the net effect of the
> above change has quite dubious value---it clobbered a file 'out'
> that may be used by the caller.
> 
> Doing "cd" without introducing a subshell is a bit harder to fix, as
> test_tick relies on the global counter in the topmost process.  It
> can be done, but I do not think it is worth doing here.  Most of the
> users of this helper function call it in var=$(add_file ...)
> subshell anyway (so test_tick is incrementing the timestamp
> independently for each caller and discarding the resulting
> timestamp).  As a NEEDSWORK comment added in the series says, this
> script may need a bit more work.
> 
> I agree with you that the split of "rev-parse | cut -c1-7" into two
> statements and clobbering 'out' is a bad change---that part should
> be reverted.  The style change on 'echo "$name" >"$name"' line is
> OK, though.
> 
> Thanks.

Understood. I will revert the change. Though, what Kaartic suggested, to do a '--short=7', that will be okay to keep right? Something like:

    git rev-parse --short=7 HEAD

This way we will not need a 'cut'. This change goes as a separate commit obviously.

Previous: Junio C HamanoNext: Junio C Hamano
Message 26 of 33 in “t7401: modernize, cleanup and warn”
  1. Shourya ShuklaAug 5, 2020
  2. 3/4 t7401: ensure uniformity in the '--for-status' testShourya Shukla, Aug 5, 2020
  3. Taylor BlauAug 5, 2020
  4. Junio C HamanoAug 5, 2020
  5. Taylor BlauAug 5, 2020
  6. Junio C HamanoAug 5, 2020
  7. Shourya ShuklaAug 6, 2020
  8. Junio C HamanoAug 6, 2020
  9. 4/4 t7401: add a WARNING and a NEEDSWORKShourya Shukla, Aug 5, 2020
  10. Taylor BlauAug 5, 2020
  11. Junio C HamanoAug 5, 2020
  12. Shourya ShuklaAug 6, 2020
  13. Junio C HamanoAug 6, 2020
  14. Christian CouderAug 7, 2020
  15. 2/4 t7401: change test_i18ncmp syntax for clarityShourya Shukla, Aug 5, 2020
  16. Taylor BlauAug 5, 2020
  17. Junio C HamanoAug 5, 2020
  18. 1/4 t7401: modernize styleShourya Shukla, Aug 5, 2020
  19. Denton LiuAug 5, 2020
  20. Taylor BlauAug 5, 2020
  21. Shourya ShuklaAug 6, 2020
  22. [GSoC][PATCH v2 0/4] t7401: modernize, cleanup and moreShourya Shukla, Aug 12, 2020
  23. 1/4 t7401: modernize styleShourya Shukla, Aug 12, 2020
  24. Kaartic SivaraamAug 13, 2020
  25. Junio C HamanoAug 13, 2020
  26. Shourya ShuklaAug 14, 2020
  27. Junio C HamanoAug 14, 2020
  28. 2/4 t7401: change test_i18ncmp syntax for clarityShourya Shukla, Aug 12, 2020
  29. Junio C HamanoAug 12, 2020
  30. Junio C HamanoAug 12, 2020
  31. Shourya ShuklaAug 14, 2020
  32. 3/4 t7401: change indentation for enhanced readabilityShourya Shukla, Aug 12, 2020
  33. 4/4 t7401: add a NEEDSWORKShourya Shukla, Aug 12, 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.