threads / patch / 66583

patcharchive-zip: refactor 'path too long' error message to use Q_()

Subject: [PATCH] archive-zip: refactor 'path too long' error message to use Q_()

## tl;dr

18 messages between Oct 19, 2026 and Oct 26, 2026. Diffs are folded; open one to read it.

replies: 17people: 3as markdown or json

kerylefondji7@gmail.com· Oct 19, 2026, 08:44 UTC · lore
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(-)
Show changes to archive-zip.c +1 −1
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
Phillip Wood· Oct 19, 2026, 13:58 UTC · re: kerylefondji7@gmail.com · lore

Re: [PATCH] archive-zip: refactor 'path too long' error message to use Q_()

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
Show 18 quoted lines
> > 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);
>   	}
>   
Junio C Hamano· Oct 19, 2026, 21:12 UTC · re: Phillip Wood · lore

Re: [PATCH] archive-zip: refactor 'path too long' error message to use Q_()

Phillip Wood <phillip.wood123@gmail.com> writes:
Show 20 quoted lines
> 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.
Show 16 quoted lines
>> 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.
>>   	}
>>   
kerylefondji7@gmail.com· Oct 20, 2026, 10:22 UTC · re: Junio C Hamano · lore

[PATCH v3 0/1] archive-zip: refactor 'path too long' error message

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
kerylefondji7@gmail.com· Oct 20, 2026, 10:22 UTC · re: kerylefondji7@gmail.com · lore

[PATCH v3 1/1] archive-zip: refactor 'path too long' error message to use Q_()

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(-)
Show changes to archive-zip.c +4 −2
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
Phillip Wood· Oct 20, 2026, 15:05 UTC · re: kerylefondji7@gmail.com · lore

Re: [PATCH v3 1/1] archive-zip: refactor 'path too long' error message to use Q_()

Hi Keryle
On 20/10/2026 11:22, kerylefondji7@gmail.com wrote:
Show 10 quoted lines
> From: Keryle Fondji <kerylefondji7@gmail.com>
> > @@ -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);
The indentation seems to have got messed up here, the level is wrong and it seems to contain spaces as well - if I apply the patch I see
Applying: archive-zip: refactor 'path too long' error message to use Q_()
.git/rebase-apply/patch:17: indent with spaces.
           pathlen),
warning: 1 line applied after fixing whitespace errors.
The code should be wrapped so that lines are not much longer than 80 characters and should be indented with tabs (possibly followed by a few spaces so that the arguments are aligned).
Thanks
Phillip
>   	}
>   >   	if (S_ISDIR(mode) || S_ISGITLINK(mode)) {
kerylefondji7@gmail.com· Oct 20, 2026, 18:39 UTC · re: Junio C Hamano · lore

[PATCH v4 0/1] archive-zip: refactor 'path too long' error message to use Q_()

From: Keryle Fondji <kerylefondji7@gmail.com>
In v4:
- Fix code indentation by using tabs instead of spaces.
- Align Q_() arguments with spaces under the open parenthesis.
- Ensure line lengths remain strictly under 80 characters.
Thanks to reviewers for the feedback!
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
kerylefondji7@gmail.com· Oct 20, 2026, 18:39 UTC · re: kerylefondji7@gmail.com · lore

[PATCH v4 1/1] archive-zip: refactor 'path too long' error message to use Q_()

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(-)
Show changes to archive-zip.c +4 −2
diff --git a/archive-zip.c b/archive-zip.c
index 6f73ca6d58..5ab3ba786f 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
Phillip Wood· Oct 22, 2026, 14:29 UTC · re: kerylefondji7@gmail.com · lore

Re: [PATCH v4 1/1] archive-zip: refactor 'path too long' error message to use Q_()

Hi Keryle
On 20/10/2026 19:39, kerylefondji7@gmail.com wrote:
Show 13 quoted lines
> > diff --git a/archive-zip.c b/archive-zip.c
> index 6f73ca6d58..5ab3ba786f 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);

The indentation is still messed up. If you look at the deleted lines you can see that we've lost a level of indentation inside the "if" block and the function arguments no longer line up. It should look like

	if (pathlen > 0xffff) {
		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);
	}
Thanks
Phillip
Junio C Hamano· Oct 22, 2026, 17:41 UTC · re: Phillip Wood · lore

Re: [PATCH v4 1/1] archive-zip: refactor 'path too long' error message to use Q_()

Phillip Wood <phillip.wood123@gmail.com> writes:
Show 31 quoted lines
> Hi Keryle
>
> On 20/10/2026 19:39, kerylefondji7@gmail.com wrote:
>> 
>> diff --git a/archive-zip.c b/archive-zip.c
>> index 6f73ca6d58..5ab3ba786f 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);
>
> The indentation is still messed up. If you look at the deleted lines you can see that
> we've lost a level of indentation inside the "if" block and the function arguments no
> longer line up. It should look like
>
> 	if (pathlen > 0xffff) {
> 		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);
> 	}
>
> Thanks

Thanks. Just in case Keryle is reading the message in a terminal or webmail app with variable width fonts, the easiest way to see what is wrong in the posted patch is to visit

  https://lore.kernel.org/git/57e076d3-cfea-475d-b68d-a9f36746db35@gmail.com/

which should show the patch in fixed-width font and even uses real tab chars properly (so you can click-hold on the left end of a line and move your mouse right to highlight the indentation to tell the difference between a run of spaces and a tab).

kerylefondji7@gmail.com· Oct 23, 2026, 12:03 UTC · re: Junio C Hamano · lore

[PATCH v5 0/1] archive-zip: refactor 'path too long' error message to use Q_()

From: Keryle Fondji <kerylefondji7@gmail.com>

This v5 corrects the line alignment and indentation issues reported by Phillip Wood and Junio C Hamano:

- Pure tabs are used for structural indentation on all primary lines.
- Tabs combined with spaces are used for alignment on the continuation
  line ((int)pathlen...) to align arguments under the opening parenthesis.

In previous attempts, mixing tabs and spaces incorrectly caused formatting errors, but this structure now matches the expected Git style.

Keryle Fondji (1):
  archive-zip: refactor 'path too long' error message to use Q_()
 archive-zip.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
-- 
2.53.0
kerylefondji7@gmail.com· Oct 23, 2026, 12:03 UTC · re: kerylefondji7@gmail.com · lore

[PATCH v5 1/1] archive-zip: refactor 'path too long' error message to use Q_()

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 | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Show changes to archive-zip.c +4 −4
diff --git a/archive-zip.c b/archive-zip.c
index 5ab3ba786f..160efd878f 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -328,10 +328,10 @@ static int write_zip_entry(struct archiver_args *args,
 	}
 
 	if (pathlen > 0xffff) {
-	 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);
+		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
Phillip Wood· Oct 23, 2026, 15:09 UTC · re: kerylefondji7@gmail.com · lore

Re: [PATCH v5 1/1] archive-zip: refactor 'path too long' error message to use Q_()

Hi Keryle
On 23/10/2026 13:03, kerylefondji7@gmail.com wrote:
Show 15 quoted lines
> > diff --git a/archive-zip.c b/archive-zip.c
> index 5ab3ba786f..160efd878f 100644
> --- a/archive-zip.c
> +++ b/archive-zip.c
> @@ -328,10 +328,10 @@ static int write_zip_entry(struct archiver_args *args,
>   	}
>   >   	if (pathlen > 0xffff) {
> -	 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);
> +		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);
The indentation looks good, but this does not apply to master. When you get feedback about a patch, you should send an amended patch that applies to master, not a fix that applies on top of the patch you previously sent. If a patch series contains more than one patch, you can use "git rebase -i" to prepare the new version. If there is a single patch like this series you can use "git commit --amend".
Thanks
Phillip
kerylefondji7@gmail.com· Oct 23, 2026, 21:38 UTC · re: Junio C Hamano · lore

[PATCH v6 0/1] archive-zip: refactor 'path too long' error message to use Q_()

From: Keryle Fondji <kerylefondji7@gmail.com>

This v6 addresses the feedback from Phillip Wood regarding commit structure and patch applicability.

In previous attempts (like v5), the diff showed 4 deletions and 4 insertions because it was compared against prior iteration attempts. Since this v6 is flattened into a single clean commit applied directly on top of master, the diff naturally shows 2 deletions (-) (removing the original master lines) and 4 insertions (+) (adding the complete Q_() structure with correct tab/space alignments).

Summary of changes in v6:
- Rebased as a single commit directly on top of master.
- Maintained the exact indentation approved in v5.
- Cleaned up unrelated modifications from the working directory.
Thanks again to Phillip Wood and Junio C Hamano for their guidance
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
kerylefondji7@gmail.com· Oct 23, 2026, 21:38 UTC · re: kerylefondji7@gmail.com · lore

[PATCH v6 1/1] archive-zip: refactor 'path too long' error message to use Q_()

From: Keryle Fondji <kerylefondji7@gmail.com>
---
 archive-zip.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Show changes to archive-zip.c +4 −2
diff --git a/archive-zip.c b/archive-zip.c
index 6f73ca6d58..160efd878f 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
kerylefondji7@gmail.com· Oct 26, 2026, 17:24 UTC · re: Junio C Hamano · lore

Re: [PATCH v6 1/1] archive-zip: refactor 'path too long' error message to use Q_()

Hi everyone,
Just a gentle follow-up on this v6 patch. I have rebased the commit directly on top of master as suggested by Phillip, ensuring a clean single-commit structure and proper indentation.
Please let me know if this version looks good to you or if any further adjustments are needed.
Thank you for your time and guidance!

Best regards, Keryle

Junio C Hamano· Oct 26, 2026, 17:33 UTC · re: kerylefondji7@gmail.com · lore

Re: [PATCH v6 1/1] archive-zip: refactor 'path too long' error message to use Q_()

kerylefondji7@gmail.com writes:
Show 10 quoted lines
> Hi everyone,
>
> Just a gentle follow-up on this v6 patch. I have rebased the commit directly on top of master as suggested by Phillip, ensuring a clean single-commit structure and proper indentation.
>
> Please let me know if this version looks good to you or if any further adjustments are needed.
>
> Thank you for your time and guidance!
>
> Best regards,
> Keryle

It is not so friendly to send a reply to v4's review when the one you want people to take a look at is v6, though.

According to Documentation/SubmittingPatches
  https://lore.kernel.org/git/20261023213813.3318-2-kerylefondji7@gmail.com/

is not ready. No commit log message to explain and justify the changes, and it is not signed-off. The shape of the submission looked nicer in v5 iteration in this regard.

kerylefondji7@gmail.com· Oct 22, 2026, 10:28 UTC · re: Junio C Hamano · lore

Re: [PATCH v4] archive-zip: refactor 'path too long' error

Hi everyone,

Just following up on this v4 patch to check if any further changes are needed.

If the patch looks good as is, please let me know if it would be okay for me to start working on another microproject in the meantime.

Thanks,
Keryle

← back to recent threads