git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] t9800: correct misuse of 'show -s --raw' in a test
@ 2023-05-06 21:29 Junio C Hamano
  2023-05-08 18:55 ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2023-05-06 21:29 UTC (permalink / raw)
  To: git

There is $(git show -s --raw --pretty=format:%at HEAD) in this test
that is meant to grab the author time of the commit.  We used to
have a bug in the command line option parser of the diff family of
commands, where "show -s --raw" was identical to "show -s".

With the "-s" bug fixed, "show -s --raw" would mean the same thing
as "show --raw", i.e. show the output from the diff machinery in the
"raw" format.  And this test will start failing, so fix it before
that happens.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

* It appears pretty obvious that the original wanted to just grab
  the %at timestamp of the HEAD, and with the fix to allow output
  format options to take effect after "-s" is given, the existing
  misuse of "--raw" after "-s" that ought to be a no-op breaks the
  test.

  https://github.com/git/git/actions/runs/4897931294/jobs/8755228452#step:4:1847

  is CI run with the "-s" fix merged into 'seen'.

 t/t9800-git-p4-basic.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh
index dc88d0e064..a4b3cb9492 100755
--- a/t/t9800-git-p4-basic.sh
+++ b/t/t9800-git-p4-basic.sh
@@ -330,7 +330,7 @@ test_expect_success 'initial import time from top change time' '
 	test_when_finished cleanup_git &&
 	(
 		cd "$git" &&
-		gittime=$(git show -s --raw --pretty=format:%at HEAD) &&
+		gittime=$(git show -s --pretty=format:%at HEAD) &&
 		echo $p4time $gittime &&
 		test $p4time = $gittime
 	)
-- 
2.40.1-476-g69c786637d


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] t9800: correct misuse of 'show -s --raw' in a test
  2023-05-06 21:29 [PATCH] t9800: correct misuse of 'show -s --raw' in a test Junio C Hamano
@ 2023-05-08 18:55 ` Jeff King
  2023-05-08 20:53   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2023-05-08 18:55 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Sat, May 06, 2023 at 02:29:55PM -0700, Junio C Hamano wrote:

> There is $(git show -s --raw --pretty=format:%at HEAD) in this test
> that is meant to grab the author time of the commit.  We used to
> have a bug in the command line option parser of the diff family of
> commands, where "show -s --raw" was identical to "show -s".
> 
> With the "-s" bug fixed, "show -s --raw" would mean the same thing
> as "show --raw", i.e. show the output from the diff machinery in the
> "raw" format.  And this test will start failing, so fix it before
> that happens.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> 
> * It appears pretty obvious that the original wanted to just grab
>   the %at timestamp of the HEAD, and with the fix to allow output
>   format options to take effect after "-s" is given, the existing
>   misuse of "--raw" after "-s" that ought to be a no-op breaks the
>   test.

Yes, I think this is matching what the original code was trying to do.
The patch looks good to me.

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] t9800: correct misuse of 'show -s --raw' in a test
  2023-05-08 18:55 ` Jeff King
@ 2023-05-08 20:53   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2023-05-08 20:53 UTC (permalink / raw)
  To: Jeff King; +Cc: git

Jeff King <peff@peff.net> writes:

>> * It appears pretty obvious that the original wanted to just grab
>>   the %at timestamp of the HEAD, and with the fix to allow output
>>   format options to take effect after "-s" is given, the existing
>>   misuse of "--raw" after "-s" that ought to be a no-op breaks the
>>   test.
>
> Yes, I think this is matching what the original code was trying to do.
> The patch looks good to me.

Thanks.

This still can be a cause for backward compatibility worry, though.
I do not think anybody would have lifted $(git show -s --raw --format=%ad)
as a way to get the author timestamp from this test script, but it
is entirely possible that this was written by the author who saw it
done (incorrectly) that way elsewhere, and who knows how many others
copied that (incorrect) way of using "-s --raw" from that original
source we have no control over.

Anyway.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-08 20:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-06 21:29 [PATCH] t9800: correct misuse of 'show -s --raw' in a test Junio C Hamano
2023-05-08 18:55 ` Jeff King
2023-05-08 20:53   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).