{"thread":{"id":"66950","subject":"[PATCH] archive: pass export-subst attribute value as parameter","startedAt":"2026-11-28T18:47:49Z","lastAt":"2026-11-30T15:55:19Z","messageCount":3,"participants":["René Scharfe","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"559610","messageId":"6c09fc91-b461-451d-90d6-512a4f785d8a@web.de","threadId":"66950","inReplyTo":null,"subject":"[PATCH] archive: pass export-subst attribute value as parameter","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2026-11-28T18:47:49Z","receivedAt":"2026-11-28T18:47:49Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"The member \"convert\" of struct archiver_args is used to pass the value\nof blob attribute export-subst to object_file_to_archive().  That's an\nunusual place and a misleading name.  Add and use an appropriately named\nparameter to that function instead.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n archive.c | 12 +++++++-----\n archive.h |  1 -\n 2 files changed, 7 insertions(+), 6 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 59790be986..0aa610b5c5 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -86,11 +86,12 @@ static void *object_file_to_archive(const struct archiver_args *args,\n \t\t\t\t    const char *path,\n \t\t\t\t    const struct object_id *oid,\n \t\t\t\t    unsigned int mode,\n+\t\t\t\t    bool export_subst,\n \t\t\t\t    enum object_type *type,\n \t\t\t\t    size_t *sizep)\n {\n \tvoid *buffer;\n-\tconst struct commit *commit = args->convert ? args->commit : NULL;\n+\tconst struct commit *commit = export_subst ? args->commit : NULL;\n \tstruct checkout_metadata meta;\n \n \tinit_checkout_metadata(&meta, args->refname,\n@@ -161,8 +162,8 @@ static int write_archive_entry(const struct object_id *oid, const char *base,\n \tsize_t size;\n \tvoid *buffer;\n \tenum object_type type;\n+\tbool export_subst = 0;\n \n-\targs->convert = 0;\n \tstrbuf_reset(&path);\n \tstrbuf_grow(&path, PATH_MAX);\n \tstrbuf_add(&path, args->base, args->baselen);\n@@ -177,7 +178,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base,\n \t\tcheck = get_archive_attrs(args->repo->index, path_without_prefix);\n \t\tif (check_attr_export_ignore(check))\n \t\t\treturn 0;\n-\t\targs->convert = check_attr_export_subst(check);\n+\t\texport_subst = check_attr_export_subst(check);\n \t}\n \n \tif (args->prefix) {\n@@ -214,12 +215,13 @@ static int write_archive_entry(const struct object_id *oid, const char *base,\n \t}\n \n \t/* Stream it? */\n-\tif (S_ISREG(mode) && !args->convert &&\n+\tif (S_ISREG(mode) && !export_subst &&\n \t    odb_read_object_info(args->repo->objects, oid, &size) == OBJ_BLOB &&\n \t    size > repo_settings_get_big_file_threshold(the_repository))\n \t\treturn write_entry(args, oid, path.buf, path.len, mode, NULL, size);\n \n-\tbuffer = object_file_to_archive(args, path.buf, oid, mode, &type, &size);\n+\tbuffer = object_file_to_archive(args, path.buf, oid, mode, export_subst,\n+\t\t\t\t\t&type, &size);\n \tif (!buffer)\n \t\treturn error(_(\"cannot read '%s'\"), oid_to_hex(oid));\n \terr = write_entry(args, oid, path.buf, path.len, mode, buffer, size);\ndiff --git a/archive.h b/archive.h\nindex bbe65ba0f9..e5ed3283c5 100644\n--- a/archive.h\n+++ b/archive.h\n@@ -21,7 +21,6 @@ struct archiver_args {\n \tstruct pathspec pathspec;\n \tunsigned int verbose : 1;\n \tunsigned int worktree_attributes : 1;\n-\tunsigned int convert : 1;\n \tint compression_level;\n \tstruct string_list extra_files;\n \tstruct pretty_print_context *pretty_ctx;\n-- \n2.56.1\n\n"},{"id":"559620","messageId":"xmqqv75gtwdq.fsf@gitster.g","threadId":"66950","inReplyTo":"6c09fc91-b461-451d-90d6-512a4f785d8a@web.de","subject":"Re: [PATCH] archive: pass export-subst attribute value as parameter","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-28T22:38:09Z","receivedAt":"2026-11-28T22:38:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <l.s.r@web.de> writes:\n\n> The member \"convert\" of struct archiver_args is used to pass the value\n> of blob attribute export-subst to object_file_to_archive().  That's an\n> unusual place and a misleading name.  Add and use an appropriately named\n> parameter to that function instead.\n>\n> Signed-off-by: René Scharfe <l.s.r@web.de>\n> ---\n>  archive.c | 12 +++++++-----\n>  archive.h |  1 -\n>  2 files changed, 7 insertions(+), 6 deletions(-)\n\nThe name is misleading indeed.  Why it is \"an unusual place\" needs a bit\nof explanation to convince others, I am afraid, so let me try to spell\nout the reason why, as I understand it, and see if that matches yours\n(and if so, \"an unusual place\" above may want to be strengthened by the\nreason why).\n\nThere are two ways this function and write_entry() (and possibly others)\nreceive settings from their caller, write_archive_entry().\n\nThe archiver_args structure is meant to hold the settings common across\ndifferent entries to be written.  In addition, per-call parameters give\ninformation specific to each entry being written by a particular call,\nlike the path of the entry and its file mode.\n\nThe 'export_subst' setting is per path and specified via attributes, so\nit definitely is not common across entries.  It does not belong there,\nand making it a parameter passed to object_file_to_archive() moves it to\nthe right place.  And with a more correct name, which is very nice ;-)\n\nNow, are there members other than '.convert' in the archiver_args that\nshould be moved out of there for the same reason?  The '.convert' member\nneeds to be reset in write_archive_entry() for each and every path\nbecause of this misplacement.  If there is no longer any member that is\nnot common across entries, perhaps many of the consumers of\n'struct archiver_args *' can take a const pointer, most notably the\nwrite_archive_entry() function?  It needs to propagate the constness\ndown to write_entry(), and is better left outside this patch, perhaps.\n\nThe patch of looks good to me.  Thanks.\n\n"},{"id":"559708","messageId":"a0ef12f1-bd57-4caa-89d0-749753041917@web.de","threadId":"66950","inReplyTo":"xmqqv75gtwdq.fsf@gitster.g","subject":"Re: [PATCH] archive: pass export-subst attribute value as parameter","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2026-11-30T15:55:19Z","receivedAt":"2026-11-30T15:55:19Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"On 11/28/26 11:38 PM, Junio C Hamano wrote:\n> René Scharfe <l.s.r@web.de> writes:\n> \n>> The member \"convert\" of struct archiver_args is used to pass the value\n>> of blob attribute export-subst to object_file_to_archive().  That's an\n>> unusual place and a misleading name.  Add and use an appropriately named\n>> parameter to that function instead.\n>>\n>> Signed-off-by: René Scharfe <l.s.r@web.de>\n>> ---\n>>  archive.c | 12 +++++++-----\n>>  archive.h |  1 -\n>>  2 files changed, 7 insertions(+), 6 deletions(-)\n> \n> The name is misleading indeed.  Why it is \"an unusual place\" needs a bit\n> of explanation to convince others, I am afraid, so let me try to spell\n> out the reason why, as I understand it, and see if that matches yours\n> (and if so, \"an unusual place\" above may want to be strengthened by the\n> reason why).\n> \n> There are two ways this function and write_entry() (and possibly others)\n> receive settings from their caller, write_archive_entry().\n> \n> The archiver_args structure is meant to hold the settings common across\n> different entries to be written.  In addition, per-call parameters give\n> information specific to each entry being written by a particular call,\n> like the path of the entry and its file mode.\n> \n> The 'export_subst' setting is per path and specified via attributes, so\n> it definitely is not common across entries.  It does not belong there,\n> and making it a parameter passed to object_file_to_archive() moves it to\n> the right place.  And with a more correct name, which is very nice ;-)\n\nRight, that's what I mean: The value of the blob-specific attribute\nexport-subst is passed in a struct for archiver options.  They have\ndifferent scopes and topics.  There's only a single instance of struct\narchiver_args, so .convert has to be updated for each blob, of which\nthere are usually many.\n\n> Now, are there members other than '.convert' in the archiver_args that\n> should be moved out of there for the same reason?  The '.convert' member\n> needs to be reset in write_archive_entry() for each and every path\n> because of this misplacement.  If there is no longer any member that is\n> not common across entries, perhaps many of the consumers of\n> 'struct archiver_args *' can take a const pointer, most notably the\n> write_archive_entry() function?  It needs to propagate the constness\n> down to write_entry(), and is better left outside this patch, perhaps.\nGood idea.  21d3cf2276 (archive-zip: fix prefix stripping for extra and\nvirtual files, 2026-11-24) in next moves the members .base and .baselen\ninto that category, though.  We'd have to address that first, e.g. by\nadding a path_without_prefix parameter or a struct archive_entry that\nincludes something like it.\n\nRené\n\n\n"}]}