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

Re: [PATCH 3/3] sha1-name: mark get_oid() error messages for translation

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 29, 2020, 21:42 UTC
Message-ID
<xmqqimkudjmt.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<xmqqpnf2dk6m.fsf@gitster-ct.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 39 quoted lines
> Jeff King <peff@peff.net> writes:
>
>> +			die(_("path '%s' exists, but not '%s'\n"
>> +			    "hint: Did you mean '%.*s:%s' aka '%.*s:./%s'?"),
>> ...
>
> The above is meant to be localizable, but...
>
>> diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh
>> index f49fc770d6..c2b5125c12 100755
>> --- a/t/t1506-rev-parse-diagnosis.sh
>> +++ b/t/t1506-rev-parse-diagnosis.sh
>> @@ -9,8 +9,8 @@ exec </dev/null
>>  test_did_you_mean ()
>>  {
>>  	cat >expected <<-EOF &&
>> -	fatal: Path '$2$3' $4, but not ${5:-$SQ$3$SQ}.
>> -	Did you mean '$1:$2$3'${2:+ aka $SQ$1:./$3$SQ}?
>> +	fatal: path '$2$3' $4, but not ${5:-$SQ$3$SQ}
>> +	hint: Did you mean '$1:$2$3'${2:+ aka $SQ$1:./$3$SQ}?
>>  	EOF
>>  	test_cmp expected error
>
> ...this obviously would not allow GIT_TEST_GETTEXT_POISON test to
> pass.  And ...
>
>>  test_expect_success 'incorrect file in sha1:path' '
>>  	test_must_fail git rev-parse HEAD:nothing.txt 2>error &&
>> -	grep "fatal: Path '"'"'nothing.txt'"'"' does not exist in '"'"'HEAD'"'"'" error &&
>> +	test_i18ngrep "path .nothing.txt. does not exist in .HEAD." error &&
>>  	test_must_fail git rev-parse HEAD:index-only.txt 2>error &&
>> -	grep "fatal: Path '"'"'index-only.txt'"'"' exists on disk, but not in '"'"'HEAD'"'"'." error &&
>> +	test_i18ngrep "path .index-only.txt. exists on disk, but not in .HEAD." error &&
>>  	(cd subdir &&
>>  	 test_must_fail git rev-parse HEAD:file2.txt 2>error &&
>>  	 test_did_you_mean HEAD subdir/ file2.txt exists )
>>  '
>
> ... the last step executed in "subdir" does not seem to pass.

I'll queue this band-aid on top before making my last pushout for the day. Even with poisoned i18n/l10n, die(_(msg)) gives "fatal:" prefix at the beginning, so that is what test_did_you_mean would expect to see from a passing test under GIT_TEST_GETTEXT_POISON.

The other hunk is about a test that greps in "error".
 t/t1506-rev-parse-diagnosis.sh | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh
index 2d26d2267e..f28a35c84e 100755
--- a/t/t1506-rev-parse-diagnosis.sh
+++ b/t/t1506-rev-parse-diagnosis.sh
@@ -8,11 +8,16 @@ exec </dev/null
 
 test_did_you_mean ()
 {
-	cat >expected <<-EOF &&
-	fatal: path '$2$3' $4, but not ${5:-$SQ$3$SQ}
-	hint: Did you mean '$1:$2$3'${2:+ aka $SQ$1:./$3$SQ}?
-	EOF
-	test_cmp expected error
+	if ! test_have_prereq C_LOCALE_OUTPUT
+	then
+		grep "^fatal: " error
+	else
+		cat >expected <<-EOF &&
+		fatal: path '$2$3' $4, but not ${5:-$SQ$3$SQ}
+		hint: Did you mean '$1:$2$3'${2:+ aka $SQ$1:./$3$SQ}?
+		EOF
+		test_cmp expected error
+	fi
 }
 
 HASH_file=
@@ -149,7 +154,7 @@ test_expect_success 'relative path not found' '
 	(
 		cd subdir &&
 		test_must_fail git rev-parse HEAD:./nonexistent.txt 2>error &&
-		grep subdir/nonexistent.txt error
+		test_i18ngrep subdir/nonexistent.txt error
 	)
 '
 
Previous: Junio C HamanoNext: Jeff King
Message 12 of 15 in “Bug or unexpected behaviour in git show <rev>:a\b”
  1. David BurströmJan 24, 2020
  2. Jeff KingJan 24, 2020
  3. Junio C HamanoJan 24, 2020
  4. Jeff KingJan 25, 2020
  5. David BurströmJan 25, 2020
  6. Junio C HamanoJan 27, 2020
  7. Jeff KingJan 25, 2020
  8. 1/3 t1400: avoid "test" string comparisonsJeff King, Jan 25, 2020
  9. 2/3 t1506: drop space after redirection operatorJeff King, Jan 25, 2020
  10. 3/3 sha1-name: mark get_oid() error messages for translationJeff King, Jan 25, 2020
  11. Junio C HamanoJan 29, 2020
  12. Junio C HamanoJan 29, 2020
  13. Jeff KingJan 30, 2020
  14. Junio C HamanoJan 30, 2020
  15. Jeff KingJan 31, 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.