Git development
 help / color / mirror / Atom feed
* [PATCH] archive-zip: refactor 'path too long' error message to use Q_()
@ 2026-10-19  8:44 kerylefondji7
  2026-10-19 13:58 ` Phillip Wood
  0 siblings, 1 reply; 5+ messages in thread
From: kerylefondji7 @ 2026-10-19  8:44 UTC (permalink / raw)
  To: git
  Cc: gitster, phillip.wood123, christiancouder, siddharthasthana31,
	Keryle Fondji

From: Keryle Fondji <kerylefondji7@gmail.com>

The error message used "chars" even when pathlen was 1.

Replace _() with Q_() to handle both singular and plural forms
correctly depending on the value of pathlen.

Signed-off-by: Keryle Fondji <kerylefondji7@gmail.com>
---
 archive-zip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/archive-zip.c b/archive-zip.c
index 6f73ca6d58..e4f8ef5a36 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -328,7 +328,7 @@ static int write_zip_entry(struct archiver_args *args,
 	}
 
 	if (pathlen > 0xffff) {
-		return error(_("path too long (%d chars, SHA1: %s): %s"),
+		return error(Q_("path too long (%d char, SHA1: %s): %s", "path too long (%d chars, SHA1: %s): %s", pathlen),
 				(int)pathlen, oid_to_hex(oid), path);
 	}
 
-- 
2.53.0


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

* Re: [PATCH] archive-zip: refactor 'path too long' error message to use Q_()
  2026-10-19  8:44 [PATCH] archive-zip: refactor 'path too long' error message to use Q_() kerylefondji7
@ 2026-10-19 13:58 ` Phillip Wood
  2026-10-19 21:12   ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Phillip Wood @ 2026-10-19 13:58 UTC (permalink / raw)
  To: kerylefondji7, git; +Cc: gitster, christiancouder, siddharthasthana31

Hi Keryle

On 19/10/2026 09:44, kerylefondji7@gmail.com wrote:
> From: Keryle Fondji <kerylefondji7@gmail.com>
> 
> The error message used "chars" even when pathlen was 1.

Looking at the code below, pathlen has to be longer than 0xffff to 
trigger this message. However there can be more than one form of the 
plural string though. The gettext manual has the following example of 
the Polish translation of "file" for different numbers of files [1]

	1 plik
	2,3,4 pliki
	5-21 plików
	22-24 pliki
	25-31 plików

so using Q_() is correct, but we should explain that it is to 
accommodate different plural forms, rather than because pathlen can be 1.

Thanks

Phillip

[1] 
https://www.gnu.org/software/gettext/manual/gettext.html#Additional-functions-for-plural-forms

> 
> Replace _() with Q_() to handle both singular and plural forms
> correctly depending on the value of pathlen.
> 
> Signed-off-by: Keryle Fondji <kerylefondji7@gmail.com>
> ---
>   archive-zip.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/archive-zip.c b/archive-zip.c
> index 6f73ca6d58..e4f8ef5a36 100644
> --- a/archive-zip.c
> +++ b/archive-zip.c
> @@ -328,7 +328,7 @@ static int write_zip_entry(struct archiver_args *args,
>   	}
>   
>   	if (pathlen > 0xffff) {
> -		return error(_("path too long (%d chars, SHA1: %s): %s"),
> +		return error(Q_("path too long (%d char, SHA1: %s): %s", "path too long (%d chars, SHA1: %s): %s", pathlen),
>   				(int)pathlen, oid_to_hex(oid), path);
>   	}
>   


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

* Re: [PATCH] archive-zip: refactor 'path too long' error message to use Q_()
  2026-10-19 13:58 ` Phillip Wood
@ 2026-10-19 21:12   ` Junio C Hamano
  2026-10-20 10:22     ` [PATCH v3 0/1] archive-zip: refactor 'path too long' error message kerylefondji7
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2026-10-19 21:12 UTC (permalink / raw)
  To: Phillip Wood; +Cc: kerylefondji7, git, christiancouder, siddharthasthana31

Phillip Wood <phillip.wood123@gmail.com> writes:

> Hi Keryle
>
> On 19/10/2026 09:44, kerylefondji7@gmail.com wrote:
>> From: Keryle Fondji <kerylefondji7@gmail.com>
>> 
>> The error message used "chars" even when pathlen was 1.
>
> Looking at the code below, pathlen has to be longer than 0xffff to 
> trigger this message. However there can be more than one form of the 
> plural string though. The gettext manual has the following example of 
> the Polish translation of "file" for different numbers of files [1]
>
> 	1 plik
> 	2,3,4 pliki
> 	5-21 plików
> 	22-24 pliki
> 	25-31 plików
>
> so using Q_() is correct, but we should explain that it is to 
> accommodate different plural forms, rather than because pathlen can be 1.

Good.

>> Replace _() with Q_() to handle both singular and plural forms
>> correctly depending on the value of pathlen.

This is written better.

>> Signed-off-by: Keryle Fondji <kerylefondji7@gmail.com>
>> ---
>>   archive-zip.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/archive-zip.c b/archive-zip.c
>> index 6f73ca6d58..e4f8ef5a36 100644
>> --- a/archive-zip.c
>> +++ b/archive-zip.c
>> @@ -328,7 +328,7 @@ static int write_zip_entry(struct archiver_args *args,
>>   	}
>>   
>>   	if (pathlen > 0xffff) {
>> -		return error(_("path too long (%d chars, SHA1: %s): %s"),
>> +		return error(Q_("path too long (%d char, SHA1: %s): %s", "path too long (%d chars, SHA1: %s): %s", pathlen),
>>   				(int)pathlen, oid_to_hex(oid), path);

This is overly long and must be line-wrapped.


>>   	}
>>   

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

* [PATCH v3 0/1] archive-zip: refactor 'path too long' error message
  2026-10-19 21:12   ` Junio C Hamano
@ 2026-10-20 10:22     ` kerylefondji7
  2026-10-20 10:22       ` [PATCH v3 1/1] archive-zip: refactor 'path too long' error message to use Q_() kerylefondji7
  0 siblings, 1 reply; 5+ messages in thread
From: kerylefondji7 @ 2026-10-20 10:22 UTC (permalink / raw)
  To: git; +Cc: phillip.wood123, gitster, Keryle Fondji

From: Keryle Fondji <kerylefondji7@gmail.com>

This v3 addresses the review feedback by wrapping the overly long line
in archive-zip.c, while keeping the proper use of Q_() for plural forms.

Keryle Fondji (1):
  archive-zip: refactor 'path too long' error message to use Q_()

 archive-zip.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

-- 
2.53.0


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

* [PATCH v3 1/1] archive-zip: refactor 'path too long' error message to use Q_()
  2026-10-20 10:22     ` [PATCH v3 0/1] archive-zip: refactor 'path too long' error message kerylefondji7
@ 2026-10-20 10:22       ` kerylefondji7
  0 siblings, 0 replies; 5+ messages in thread
From: kerylefondji7 @ 2026-10-20 10:22 UTC (permalink / raw)
  To: git; +Cc: phillip.wood123, gitster, Keryle Fondji

From: Keryle Fondji <kerylefondji7@gmail.com>

Replace _() with Q_() in the 'path too long' error message. Although
pathlen is always greater than 0xffff when this error is hit, Q_() is
required to support correct translation for languages that require
different plural forms depending on the count.

Signed-off-by: Keryle Fondji <kerylefondji7@gmail.com>
---
 archive-zip.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/archive-zip.c b/archive-zip.c
index 6f73ca6d58..9df49ae160 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -328,8 +328,10 @@ static int write_zip_entry(struct archiver_args *args,
 	}
 
 	if (pathlen > 0xffff) {
-		return error(_("path too long (%d chars, SHA1: %s): %s"),
-				(int)pathlen, oid_to_hex(oid), path);
+	 return error(Q_("path too long (%d char, SHA1: %s): %s",
+	   "path too long (%d chars, SHA1: %s): %s",
+           pathlen),
+	       (int)pathlen, oid_to_hex(oid), path);
 	}
 
 	if (S_ISDIR(mode) || S_ISGITLINK(mode)) {
-- 
2.53.0


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

end of thread, other threads:[~2026-10-20 10:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19  8:44 [PATCH] archive-zip: refactor 'path too long' error message to use Q_() kerylefondji7
2026-10-19 13:58 ` Phillip Wood
2026-10-19 21:12   ` Junio C Hamano
2026-10-20 10:22     ` [PATCH v3 0/1] archive-zip: refactor 'path too long' error message kerylefondji7
2026-10-20 10:22       ` [PATCH v3 1/1] archive-zip: refactor 'path too long' error message to use Q_() kerylefondji7

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox