{"thread":{"id":"65196","subject":"[PATCH] merge-file: fix BUG when --object-id is used in a worktree","startedAt":"2026-03-10T11:46:46Z","lastAt":"2026-03-18T19:45:57Z","messageCount":13,"participants":["Mathias Rav","Karthik Nayak","Patrick Steinhardt","Kristoffer Haugsbakk","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"538391","messageId":"86e5c9f7-cd99-4c4f-a852-f3b1ada53722@app.fastmail.com","threadId":"65196","inReplyTo":null,"subject":"[PATCH] merge-file: fix BUG when --object-id is used in a worktree","fromName":"Mathias Rav","fromEmail":"m@git.strova.dk","sentAt":"2026-03-10T11:46:01Z","receivedAt":"2026-03-10T11:46:46Z","isPatch":true,"sender":{"key":"m@git.strova.dk","avatar":"https://avatars.githubusercontent.com/u/373639?v=4"},"body":"The `--object-id` option was added in commit e1068f0ad4\n(\"merge-file: add an option to process object IDs\", 2023-11-01)\ntogether with a call to setup_git_directory() to avoid crashing\nwhen run outside a repository.\n\nHowever, the call to setup_git_directory() is redundant when run inside\na repository, as merge-file runs with RUN_SETUP_GENTLY, so the\nrepository has already been set up. The redundant call is harmless when\nworktrees are not used, but when run inside a worktree, the\nrepo_set_gitdir() function ends up being called twice.\n\nCalling repo_set_gitdir() used to be silently accepted, but commit\n2816b748e5 (\"odb: handle changing a repository's commondir\", 2025-11-19)\nchanged this to a BUG in repository.c with the error message:\n\"cannot reinitialize an already-initialized object directory\".\n\nGuard the call to setup_git_directory() behind a repo pointer check,\nto ensure that we continue to give the correct \"not a git repo\" error\nwhilst avoiding the BUG when running inside a worktree.\n\nSigned-off-by: Mathias Rav <m@git.strova.dk>\n---\n builtin/merge-file.c  | 4 ++--\n t/t6403-merge-file.sh | 9 +++++++++\n 2 files changed, 11 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex 46775d0c79..a8768c6e0c 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -60,7 +60,7 @@ static int diff_algorithm_cb(const struct option *opt,\n int cmd_merge_file(int argc,\n \t\t   const char **argv,\n \t\t   const char *prefix,\n-\t\t   struct repository *repo UNUSED)\n+\t\t   struct repository *repo)\n {\n \tconst char *names[3] = { 0 };\n \tmmfile_t mmfs[3] = { 0 };\n@@ -110,7 +110,7 @@ int cmd_merge_file(int argc,\n \t\t\treturn error_errno(\"failed to redirect stderr to /dev/null\");\n \t}\n \n-\tif (object_id)\n+\tif (object_id && !repo)\n \t\tsetup_git_directory();\n \n \tfor (i = 0; i < 3; i++) {\ndiff --git a/t/t6403-merge-file.sh b/t/t6403-merge-file.sh\nindex 06ab4d7aed..60cc43775f 100755\n--- a/t/t6403-merge-file.sh\n+++ b/t/t6403-merge-file.sh\n@@ -506,6 +506,15 @@ test_expect_success '--object-id fails without repository' '\n \tgrep \"not a git repository\" err\n '\n \n+test_expect_success 'run inside worktree with --object-id' '\n+\tempty=\"$(test_oid empty_blob)\" &&\n+\tgit worktree add work &&\n+\t(cd work && git merge-file --object-id $empty $empty $empty) >actual &&\n+\tgit worktree remove work &&\n+\tgit merge-file --object-id $empty $empty $empty >expected &&\n+\ttest_cmp actual expected\n+'\n+\n test_expect_success 'merging C files with \"myers\" diff algorithm creates some spurious conflicts' '\n \tcat >expect.c <<-\\EOF &&\n \tint g(size_t u)\n-- \n2.53.0\n\n"},{"id":"538411","messageId":"CAOLa=ZTTjvSv04QPtHiUEvDfJMfKYks=5PscZxH15SLkBmoCDg@mail.gmail.com","threadId":"65196","inReplyTo":"86e5c9f7-cd99-4c4f-a852-f3b1ada53722@app.fastmail.com","subject":"Re: [PATCH] merge-file: fix BUG when --object-id is used in a worktree","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-03-10T12:35:02Z","receivedAt":"2026-03-10T12:35:04Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"\"Mathias Rav\" <m@git.strova.dk> writes:\n\n> The `--object-id` option was added in commit e1068f0ad4\n> (\"merge-file: add an option to process object IDs\", 2023-11-01)\n> together with a call to setup_git_directory() to avoid crashing\n> when run outside a repository.\n>\n> However, the call to setup_git_directory() is redundant when run inside\n> a repository, as merge-file runs with RUN_SETUP_GENTLY, so the\n> repository has already been set up. The redundant call is harmless when\n> worktrees are not used, but when run inside a worktree, the\n> repo_set_gitdir() function ends up being called twice.\n>\n> Calling repo_set_gitdir() used to be silently accepted, but commit\n> 2816b748e5 (\"odb: handle changing a repository's commondir\", 2025-11-19)\n> changed this to a BUG in repository.c with the error message:\n> \"cannot reinitialize an already-initialized object directory\".\n>\n> Guard the call to setup_git_directory() behind a repo pointer check,\n> to ensure that we continue to give the correct \"not a git repo\" error\n> whilst avoiding the BUG when running inside a worktree.\n>\n\nWell explained. Additionally you may want to clarify that you're talking\nabout a linked worktree. Since the dir initialized by 'git-init(1)' or\n'git-clone(1)' is also a worktree (AKA main worktree).\n\n> Signed-off-by: Mathias Rav <m@git.strova.dk>\n> ---\n>  builtin/merge-file.c  | 4 ++--\n>  t/t6403-merge-file.sh | 9 +++++++++\n>  2 files changed, 11 insertions(+), 2 deletions(-)\n>\n> diff --git a/builtin/merge-file.c b/builtin/merge-file.c\n> index 46775d0c79..a8768c6e0c 100644\n> --- a/builtin/merge-file.c\n> +++ b/builtin/merge-file.c\n> @@ -60,7 +60,7 @@ static int diff_algorithm_cb(const struct option *opt,\n>  int cmd_merge_file(int argc,\n>  \t\t   const char **argv,\n>  \t\t   const char *prefix,\n> -\t\t   struct repository *repo UNUSED)\n> +\t\t   struct repository *repo)\n>  {\n>  \tconst char *names[3] = { 0 };\n>  \tmmfile_t mmfs[3] = { 0 };\n> @@ -110,7 +110,7 @@ int cmd_merge_file(int argc,\n>  \t\t\treturn error_errno(\"failed to redirect stderr to /dev/null\");\n>  \t}\n>\n> -\tif (object_id)\n> +\tif (object_id && !repo)\n>  \t\tsetup_git_directory();\n>\n\nNit: but would be nice to also add a comment here.\n\n>  \tfor (i = 0; i < 3; i++) {\n> diff --git a/t/t6403-merge-file.sh b/t/t6403-merge-file.sh\n> index 06ab4d7aed..60cc43775f 100755\n> --- a/t/t6403-merge-file.sh\n> +++ b/t/t6403-merge-file.sh\n> @@ -506,6 +506,15 @@ test_expect_success '--object-id fails without repository' '\n>  \tgrep \"not a git repository\" err\n>  '\n>\n> +test_expect_success 'run inside worktree with --object-id' '\n> +\tempty=\"$(test_oid empty_blob)\" &&\n> +\tgit worktree add work &&\n> +\t(cd work && git merge-file --object-id $empty $empty $empty) >actual &&\n> +\tgit worktree remove work &&\n> +\tgit merge-file --object-id $empty $empty $empty >expected &&\n> +\ttest_cmp actual expected\n> +'\n> +\n>  test_expect_success 'merging C files with \"myers\" diff algorithm creates some spurious conflicts' '\n>  \tcat >expect.c <<-\\EOF &&\n>  \tint g(size_t u)\n> --\n> 2.53.0\n\nLooks good otherwise.\n\n- Karthik\n"},{"id":"538414","messageId":"abATPiRUczb8fe4t@pks.im","threadId":"65196","inReplyTo":"86e5c9f7-cd99-4c4f-a852-f3b1ada53722@app.fastmail.com","subject":"Re: [PATCH] merge-file: fix BUG when --object-id is used in a worktree","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-03-10T12:49:02Z","receivedAt":"2026-03-10T12:49:08Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Mar 10, 2026 at 11:46:01AM +0000, Mathias Rav wrote:\n\nWhich commit is this patch based on? It doesn't apply in its current\nform on top of \"master\" since at least 8600b4ec9e (merge-file: honor\nmerge.conflictStyle outside of a repository, 2026-02-07). Please rebase\nthe patch.\n\n> diff --git a/builtin/merge-file.c b/builtin/merge-file.c\n> index 46775d0c79..a8768c6e0c 100644\n> --- a/builtin/merge-file.c\n> +++ b/builtin/merge-file.c\n> @@ -110,7 +110,7 @@ int cmd_merge_file(int argc,\n>  \t\t\treturn error_errno(\"failed to redirect stderr to /dev/null\");\n>  \t}\n>  \n> -\tif (object_id)\n> +\tif (object_id && !repo)\n>  \t\tsetup_git_directory();\n>  \n>  \tfor (i = 0; i < 3; i++) {\n\nOkay, makes sense. Makes me wonder whether we have other cases of the\nsame error class.\n\n> diff --git a/t/t6403-merge-file.sh b/t/t6403-merge-file.sh\n> index 06ab4d7aed..60cc43775f 100755\n> --- a/t/t6403-merge-file.sh\n> +++ b/t/t6403-merge-file.sh\n> @@ -506,6 +506,15 @@ test_expect_success '--object-id fails without repository' '\n>  \tgrep \"not a git repository\" err\n>  '\n>  \n> +test_expect_success 'run inside worktree with --object-id' '\n> +\tempty=\"$(test_oid empty_blob)\" &&\n> +\tgit worktree add work &&\n> +\t(cd work && git merge-file --object-id $empty $empty $empty) >actual &&\n\nThis can be written without a subshell by saying `git -C work\nmerge-file`.\n\nThanks!\n\nPatrick\n"},{"id":"538435","messageId":"c4781432-57f1-4b2f-a52d-aa0d5cc2b406@app.fastmail.com","threadId":"65196","inReplyTo":"86e5c9f7-cd99-4c4f-a852-f3b1ada53722@app.fastmail.com","subject":"Re: [PATCH] merge-file: fix BUG when --object-id is used in a worktree","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-03-10T13:34:33Z","receivedAt":"2026-03-10T13:34:56Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Tue, Mar 10, 2026, at 12:46, Mathias Rav wrote:\n> The `--object-id` option was added in commit e1068f0ad4\n> (\"merge-file: add an option to process object IDs\", 2023-11-01)\n\nUsing `git show -s --pretty=reference <commit>` for mentioning commits\nis recommended (SubmittingPatches).\n\n> together with a call to setup_git_directory() to avoid crashing\n> when run outside a repository.\n>\n> However, the call to setup_git_directory() is redundant when run inside\n> a repository, as merge-file runs with RUN_SETUP_GENTLY, so the\n> repository has already been set up. The redundant call is harmless when\n> worktrees are not used, but when run inside a worktree, the\n> repo_set_gitdir() function ends up being called twice.\n>\n> Calling repo_set_gitdir() used to be silently accepted, but commit\n> 2816b748e5 (\"odb: handle changing a repository's commondir\", 2025-11-19)\n> changed this to a BUG in repository.c with the error message:\n> \"cannot reinitialize an already-initialized object directory\".\n>\n> Guard the call to setup_git_directory() behind a repo pointer check,\n> to ensure that we continue to give the correct \"not a git repo\" error\n> whilst avoiding the BUG when running inside a worktree.\n>\n> Signed-off-by: Mathias Rav <m@git.strova.dk>\n> ---\n>  builtin/merge-file.c  | 4 ++--\n>  t/t6403-merge-file.sh | 9 +++++++++\n>  2 files changed, 11 insertions(+), 2 deletions(-)\n>\n> diff --git a/builtin/merge-file.c b/builtin/merge-file.c\n> index 46775d0c79..a8768c6e0c 100644\n> --- a/builtin/merge-file.c\n> +++ b/builtin/merge-file.c\n> @@ -60,7 +60,7 @@ static int diff_algorithm_cb(const struct option *opt,\n>  int cmd_merge_file(int argc,\n>  \t\t   const char **argv,\n>  \t\t   const char *prefix,\n> -\t\t   struct repository *repo UNUSED)\n> +\t\t   struct repository *repo)\n>  {\n>  \tconst char *names[3] = { 0 };\n>  \tmmfile_t mmfs[3] = { 0 };\n> @@ -110,7 +110,7 @@ int cmd_merge_file(int argc,\n>  \t\t\treturn error_errno(\"failed to redirect stderr to /dev/null\");\n>  \t}\n>\n> -\tif (object_id)\n> +\tif (object_id && !repo)\n>  \t\tsetup_git_directory();\n>\n>  \tfor (i = 0; i < 3; i++) {\n> diff --git a/t/t6403-merge-file.sh b/t/t6403-merge-file.sh\n> index 06ab4d7aed..60cc43775f 100755\n> --- a/t/t6403-merge-file.sh\n> +++ b/t/t6403-merge-file.sh\n> @@ -506,6 +506,15 @@ test_expect_success '--object-id fails without\n> repository' '\n>  \tgrep \"not a git repository\" err\n>  '\n>\n> +test_expect_success 'run inside worktree with --object-id' '\n> +\tempty=\"$(test_oid empty_blob)\" &&\n> +\tgit worktree add work &&\n> +\t(cd work && git merge-file --object-id $empty $empty $empty) >actual\n> &&\n> +\tgit worktree remove work &&\n> +\tgit merge-file --object-id $empty $empty $empty >expected &&\n> +\ttest_cmp actual expected\n> +'\n> +\n>  test_expect_success 'merging C files with \"myers\" diff algorithm\n> creates some spurious conflicts' '\n>  \tcat >expect.c <<-\\EOF &&\n>  \tint g(size_t u)\n> --\n> 2.53.0\n"},{"id":"538513","messageId":"xmqqh5qntpvy.fsf@gitster.g","threadId":"65196","inReplyTo":"abATPiRUczb8fe4t@pks.im","subject":"Re: [PATCH] merge-file: fix BUG when --object-id is used in a worktree","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-10T20:01:53Z","receivedAt":"2026-03-10T20:01:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Tue, Mar 10, 2026 at 11:46:01AM +0000, Mathias Rav wrote:\n>\n> Which commit is this patch based on? It doesn't apply in its current\n> form on top of \"master\" since at least 8600b4ec9e (merge-file: honor\n> merge.conflictStyle outside of a repository, 2026-02-07). Please rebase\n> the patch.\n\nThis applies cleanly relative to v2.53.0.  Generally, it is a\nrecommended practice to fork from the latest stable release in many\nprojects, so I do not mind it too much.\n\n>> diff --git a/builtin/merge-file.c b/builtin/merge-file.c\n>> index 46775d0c79..a8768c6e0c 100644\n>> --- a/builtin/merge-file.c\n>> +++ b/builtin/merge-file.c\n>> @@ -110,7 +110,7 @@ int cmd_merge_file(int argc,\n>>  \t\t\treturn error_errno(\"failed to redirect stderr to /dev/null\");\n>>  \t}\n>>  \n>> -\tif (object_id)\n>> +\tif (object_id && !repo)\n>>  \t\tsetup_git_directory();\n\nGood.  I suspect we would want to check !repo first, though.  The\nidea here is\n\n (1) We know we need to support running \"git merge-file\" outside a\n     repository, so the git potty may have called us with !repo (aka\n     RUN_SETUP_GENTLY);\n\n (2) But we do need to make sure we have a repository in some case.\n     We happen to have only one case, i.e., when \"--object-id\"\n     option is in use, but that condition may grow in the future.\n\nSo in the longer run, we'd better prepared for the \"has the user\ngave us the object_id option?\" part to grow over time, which would\nmean\n\n\tif (!repo &&\n\t    (object_id || another_option || yet_another ...))\n\t\tsetup_git_directory();\n\nwould be easier to handle.\n\n>>  \tfor (i = 0; i < 3; i++) {\n>\n> Okay, makes sense. Makes me wonder whether we have other cases of the\n> same error class.\n\nWhile I agree that the second call to setup_git_directory() that\ntriggered this patch is pointless, I also wish that the function\nwere more robust.  I wonder if there is a clean way to make it\nidempotent.\n\n>> diff --git a/t/t6403-merge-file.sh b/t/t6403-merge-file.sh\n>> index 06ab4d7aed..60cc43775f 100755\n>> --- a/t/t6403-merge-file.sh\n>> +++ b/t/t6403-merge-file.sh\n>> @@ -506,6 +506,15 @@ test_expect_success '--object-id fails without repository' '\n>>  \tgrep \"not a git repository\" err\n>>  '\n>>  \n>> +test_expect_success 'run inside worktree with --object-id' '\n>> +\tempty=\"$(test_oid empty_blob)\" &&\n>> +\tgit worktree add work &&\n>> +\t(cd work && git merge-file --object-id $empty $empty $empty) >actual &&\n>\n> This can be written without a subshell by saying `git -C work\n> merge-file`.\n\nYup, that would make the test even better.\n"},{"id":"538558","messageId":"c076edd0-9057-443b-ba37-33aacde2eede@app.fastmail.com","threadId":"65196","inReplyTo":"xmqqh5qntpvy.fsf@gitster.g","subject":"[PATCH v2] merge-file: fix BUG when --object-id is used in a worktree","fromName":"Mathias Rav","fromEmail":"m@git.strova.dk","sentAt":"2026-03-11T06:44:06Z","receivedAt":"2026-03-11T06:44:32Z","isPatch":true,"sender":{"key":"m@git.strova.dk","avatar":"https://avatars.githubusercontent.com/u/373639?v=4"},"body":"The `--object-id` option was added in commit e1068f0ad4\n(merge-file: add an option to process object IDs, 2023-11-01)\ntogether with a call to setup_git_directory() to avoid crashing\nwhen run outside a repository.\n\nHowever, the call to setup_git_directory() is redundant when run inside\na repository, as merge-file runs with RUN_SETUP_GENTLY, so the\nrepository has already been set up. The redundant call is harmless\nwhen linked worktrees are not used, but in a linked worktree,\nthe repo_set_gitdir() function ends up being called twice.\n\nCalling repo_set_gitdir() used to be silently accepted, but commit\n2816b748e5 (odb: handle changing a repository's commondir, 2025-11-19)\nchanged this to a BUG in repository.c with the error message:\n\"cannot reinitialize an already-initialized object directory\".\n\nGuard the redundant call to setup_git_directory() behind a repo pointer\ncheck, to ensure that we continue to give the correct \"not a git repo\"\nerror whilst avoiding the BUG when running in a linked worktree.\n\nSigned-off-by: Mathias Rav <m@git.strova.dk>\n---\nThanks Karthik, Patrick, Kristoffer and Junio for your feedback.\nI've incorporated the sum of it all in this PATCH v2:\n\n- Check !repo before object_id and add a comment\n- Use term \"linked worktree\" instead of just \"worktree\" throughout\n- Use git -C instead of a subshell in test\n- Remove gitk's quotes from the commit references in the commit message\n\nAs for the quotes in the commit references, I use gitk's \"Copy commit\nreference\" daily and am personally used to the quotes. Since\nSubmittingPatches seems to give equal preference to --pretty=reference and\n\"Copy commit reference\" I didn't think that the quotes were a problem.\n(I wonder how controversial it would be to remove the quotes in gitk.)\n\n builtin/merge-file.c  | 5 +++--\n t/t6403-merge-file.sh | 9 +++++++++\n 2 files changed, 12 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex 46775d0c79..cc8fda3b5b 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -60,7 +60,7 @@ static int diff_algorithm_cb(const struct option *opt,\n int cmd_merge_file(int argc,\n \t\t   const char **argv,\n \t\t   const char *prefix,\n-\t\t   struct repository *repo UNUSED)\n+\t\t   struct repository *repo)\n {\n \tconst char *names[3] = { 0 };\n \tmmfile_t mmfs[3] = { 0 };\n@@ -110,7 +110,8 @@ int cmd_merge_file(int argc,\n \t\t\treturn error_errno(\"failed to redirect stderr to /dev/null\");\n \t}\n \n-\tif (object_id)\n+\tif (!repo && object_id)\n+\t\t/* emit the correct \"not a git repo\" error in this case */\n \t\tsetup_git_directory();\n \n \tfor (i = 0; i < 3; i++) {\ndiff --git a/t/t6403-merge-file.sh b/t/t6403-merge-file.sh\nindex 06ab4d7aed..ed7eec8f93 100755\n--- a/t/t6403-merge-file.sh\n+++ b/t/t6403-merge-file.sh\n@@ -506,6 +506,15 @@ test_expect_success '--object-id fails without repository' '\n \tgrep \"not a git repository\" err\n '\n \n+test_expect_success 'run in a linked worktree with --object-id' '\n+\tempty=\"$(test_oid empty_blob)\" &&\n+\tgit worktree add work &&\n+\tgit -C work merge-file --object-id $empty $empty $empty >actual &&\n+\tgit worktree remove work &&\n+\tgit merge-file --object-id $empty $empty $empty >expected &&\n+\ttest_cmp actual expected\n+'\n+\n test_expect_success 'merging C files with \"myers\" diff algorithm creates some spurious conflicts' '\n \tcat >expect.c <<-\\EOF &&\n \tint g(size_t u)\n-- \n2.53.0\n"},{"id":"538560","messageId":"4176455b-87a5-4b13-a3d0-fd35b51cad37@app.fastmail.com","threadId":"65196","inReplyTo":"c076edd0-9057-443b-ba37-33aacde2eede@app.fastmail.com","subject":"Re: [PATCH v2] merge-file: fix BUG when --object-id is used in a worktree","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-03-11T07:18:04Z","receivedAt":"2026-03-11T07:18:27Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Wed, Mar 11, 2026, at 07:44, Mathias Rav wrote:\n>[snip]\n> Signed-off-by: Mathias Rav <m@git.strova.dk>\n> ---\n> Thanks Karthik, Patrick, Kristoffer and Junio for your feedback.\n> I've incorporated the sum of it all in this PATCH v2:\n>\n> - Check !repo before object_id and add a comment\n> - Use term \"linked worktree\" instead of just \"worktree\" throughout\n> - Use git -C instead of a subshell in test\n> - Remove gitk's quotes from the commit references in the commit message\n>\n> As for the quotes in the commit references, I use gitk's \"Copy commit\n> reference\" daily and am personally used to the quotes. Since\n> SubmittingPatches seems to give equal preference to --pretty=reference and\n> \"Copy commit reference\" I didn't think that the quotes were a problem.\n> (I wonder how controversial it would be to remove the quotes in gitk.)\n\nThanks for this explanation. I was ignorant of this Gitk fact.\n\n>[snip]\n"},{"id":"538584","messageId":"bcbbdcb3-9c4b-4eb8-9e70-3eb0bd19b32c@app.fastmail.com","threadId":"65196","inReplyTo":"c076edd0-9057-443b-ba37-33aacde2eede@app.fastmail.com","subject":"Re: [PATCH v2] merge-file: fix BUG when --object-id is used in a worktree","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-03-11T11:14:11Z","receivedAt":"2026-03-11T11:14:34Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Wed, Mar 11, 2026, at 07:44, Mathias Rav wrote:\n>[snip]\n> As for the quotes in the commit references, I use gitk's \"Copy commit\n> reference\" daily and am personally used to the quotes. Since\n> SubmittingPatches seems to give equal preference to --pretty=reference and\n> \"Copy commit reference\" I didn't think that the quotes were a problem.\n\n> (I wonder how controversial it would be to remove the quotes in gitk.)\n\nTurns out that this has been attempted least once before:\n\nhttps://lore.kernel.org/git/1472230741-5161-1-git-send-email-dev+git@drbeat.li/\n"},{"id":"538627","messageId":"xmqq5x72qnu6.fsf@gitster.g","threadId":"65196","inReplyTo":"bcbbdcb3-9c4b-4eb8-9e70-3eb0bd19b32c@app.fastmail.com","subject":"Re: [PATCH v2] merge-file: fix BUG when --object-id is used in a worktree","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-11T17:26:41Z","receivedAt":"2026-03-11T17:26:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kristoffer Haugsbakk\" <kristofferhaugsbakk@fastmail.com> writes:\n\n> On Wed, Mar 11, 2026, at 07:44, Mathias Rav wrote:\n>>[snip]\n>> As for the quotes in the commit references, I use gitk's \"Copy commit\n>> reference\" daily and am personally used to the quotes. Since\n>> SubmittingPatches seems to give equal preference to --pretty=reference and\n>> \"Copy commit reference\" I didn't think that the quotes were a problem.\n>\n>> (I wonder how controversial it would be to remove the quotes in gitk.)\n>\n> Turns out that this has been attempted least once before:\n>\n> https://lore.kernel.org/git/1472230741-5161-1-git-send-email-dev+git@drbeat.li/\n\nTrue.\n\nPerhaps something like this patch makes it clear that what the gitk\ncommand gives and what --pretty=reference gives are not identical,\nto avoid confusion like this?  I dunno.\n\n\n Documentation/SubmittingPatches | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git c/Documentation/SubmittingPatches w/Documentation/SubmittingPatches\nindex e270ccbe85..fad0b41af0 100644\n--- c/Documentation/SubmittingPatches\n+++ w/Documentation/SubmittingPatches\n@@ -335,7 +335,7 @@ date)\", like this:\n ....\n \n The \"Copy commit reference\" command of gitk can be used to obtain this\n-format (with the subject enclosed in a pair of double-quotes), or this\n+format (but with the subject enclosed in an extra pair of double-quotes), or this\n invocation of `git show`:\n \n ....\n"},{"id":"538676","messageId":"4b2a192e-240a-45d2-92a5-7ab669f481a9@app.fastmail.com","threadId":"65196","inReplyTo":"xmqq5x72qnu6.fsf@gitster.g","subject":"Re: [PATCH v2] merge-file: fix BUG when --object-id is used in a worktree","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-03-11T20:16:13Z","receivedAt":"2026-03-11T20:16:36Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Wed, Mar 11, 2026, at 18:26, Junio C Hamano wrote:\n>>>[snip]\n>>\n>> Turns out that this has been attempted least once before:\n>>\n>> https://lore.kernel.org/git/1472230741-5161-1-git-send-email-dev+git@drbeat.li/\n>\n> True.\n>\n> Perhaps something like this patch makes it clear that what the gitk\n> command gives and what --pretty=reference gives are not identical,\n> to avoid confusion like this?  I dunno.\n>\n>\n>  Documentation/SubmittingPatches | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git c/Documentation/SubmittingPatches w/Documentation/SubmittingPatches\n> index e270ccbe85..fad0b41af0 100644\n> --- c/Documentation/SubmittingPatches\n> +++ w/Documentation/SubmittingPatches\n> @@ -335,7 +335,7 @@ date)\", like this:\n>  ....\n>\n>  The \"Copy commit reference\" command of gitk can be used to obtain this\n> -format (with the subject enclosed in a pair of double-quotes), or this\n\nAnd now I see for the first time that the doc points out the difference\nalready... I’m really paying attention it turns out.\n\n> +format (but with the subject enclosed in an extra pair of double-quotes), or this\n\nI think replacing “with” with “but” is good. But why “extra” pairs? It’s\njust a pair of double quotes.\n\n>  invocation of `git show`:\n>\n>  ....\n"},{"id":"539312","messageId":"94dd3222-42bc-42af-8d97-5bd471a86fcd@app.fastmail.com","threadId":"65196","inReplyTo":"c076edd0-9057-443b-ba37-33aacde2eede@app.fastmail.com","subject":"Re: [PATCH v2] merge-file: fix BUG when --object-id is used in a worktree","fromName":"Mathias Rav","fromEmail":"m@git.strova.dk","sentAt":"2026-03-18T19:16:06Z","receivedAt":"2026-03-18T19:16:29Z","isPatch":true,"sender":{"key":"m@git.strova.dk","avatar":"https://avatars.githubusercontent.com/u/373639?v=4"},"body":"On Wed, Mar 11, 2026, at 6:44 AM, Mathias Rav wrote:\n> Thanks Karthik, Patrick, Kristoffer and Junio for your feedback.\n> I've incorporated the sum of it all in this PATCH v2:\n> \n> - Check !repo before object_id and add a comment\n> - Use term \"linked worktree\" instead of just \"worktree\" throughout\n> - Use git -C instead of a subshell in test\n> - Remove gitk's quotes from the commit references in the commit message\n\nI'm unsure of the process from here for a small bugfix like this.\nI believe I followed the SubmittingPatches document\nby sending a PATCH v2 with To: Junio, Cc: list and others.\nDo I need to do anything else to see this patch eventually land in Junio's tree?\n\nCheers,\nMathias\n"},{"id":"539314","messageId":"xmqq341xq63d.fsf@gitster.g","threadId":"65196","inReplyTo":"4b2a192e-240a-45d2-92a5-7ab669f481a9@app.fastmail.com","subject":"Re: [PATCH v2] merge-file: fix BUG when --object-id is used in a worktree","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-18T19:40:22Z","receivedAt":"2026-03-18T19:40:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kristoffer Haugsbakk\" <kristofferhaugsbakk@fastmail.com> writes:\n\n>> diff --git c/Documentation/SubmittingPatches w/Documentation/SubmittingPatches\n>> index e270ccbe85..fad0b41af0 100644\n>> --- c/Documentation/SubmittingPatches\n>> +++ w/Documentation/SubmittingPatches\n>> @@ -335,7 +335,7 @@ date)\", like this:\n>>  ....\n>>\n>>  The \"Copy commit reference\" command of gitk can be used to obtain this\n>> -format (with the subject enclosed in a pair of double-quotes), or this\n>\n> And now I see for the first time that the doc points out the difference\n> already... I’m really paying attention it turns out.\n>\n>> +format (but with the subject enclosed in an extra pair of double-quotes), or this\n>\n> I think replacing “with” with “but” is good. But why “extra” pairs? It’s\n> just a pair of double quotes.\n\nBecause they can exist but they do not have to be there to be\nunderstandable?\n\n"},{"id":"539315","messageId":"xmqqy0joq5u5.fsf@gitster.g","threadId":"65196","inReplyTo":"94dd3222-42bc-42af-8d97-5bd471a86fcd@app.fastmail.com","subject":"Re: [PATCH v2] merge-file: fix BUG when --object-id is used in a worktree","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-18T19:45:54Z","receivedAt":"2026-03-18T19:45:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Mathias Rav\" <m@git.strova.dk> writes:\n\n> On Wed, Mar 11, 2026, at 6:44 AM, Mathias Rav wrote:\n>> Thanks Karthik, Patrick, Kristoffer and Junio for your feedback.\n>> I've incorporated the sum of it all in this PATCH v2:\n>> \n>> - Check !repo before object_id and add a comment\n>> - Use term \"linked worktree\" instead of just \"worktree\" throughout\n>> - Use git -C instead of a subshell in test\n>> - Remove gitk's quotes from the commit references in the commit message\n>\n> I'm unsure of the process from here for a small bugfix like this.\n> I believe I followed the SubmittingPatches document\n> by sending a PATCH v2 with To: Junio, Cc: list and others.\n> Do I need to do anything else to see this patch eventually land in Junio's tree?\n\nPinging like this was absolutely the right thing to do in this case,\nas the patch fell through the cracks.  Will apply (assuming that\neverybody involved in the review is now happy with this iteration).\n\nThanks.\n"}]}