{"thread":{"id":"63379","subject":"RE: [PATCH v3] apply: --intent-to-add should imply --index","startedAt":"2025-05-01T09:03:16Z","lastAt":"2025-05-13T17:53:12Z","messageCount":14,"participants":["Jason Cho","Kristoffer Haugsbakk","Junio C Hamano","Ryan Hodges","Raymond E. Pasco"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"517040","messageId":"93yuUC_Wn9lQIDzJuvAWbCQ35kz1YxeNhsLLX67x9VzoPtRugVLNaHC_p1sWBzMxWy_VVRRl8av3Dx5PHw4_Cch0gmWs40DDrZRaezLVkGk=@proton.me","threadId":"63379","inReplyTo":null,"subject":"RE: [PATCH v3] apply: --intent-to-add should imply --index","fromName":"Jason Cho","fromEmail":"jason11choca@proton.me","sentAt":"2025-05-01T09:03:07Z","receivedAt":"2025-05-01T09:03:16Z","isPatch":true,"sender":{"key":"jason11choca@proton.me","avatar":null},"body":"I'm following up on the bug reported by Ryan Hodges on October 26, 2021,\nregarding the `git apply --intent-to-add` command incorrectly marking all \nother tracked files as deleted from the index.\n\nJohannes Altmanninger submitted patch v3 titled \"apply: --intent-to-add \nshould imply --index\" to fix this issue. \n\nIs this fix merged? If so, which Git version includes this fix.\n\n\n"},{"id":"517041","messageId":"8a61dc13-0b7e-437d-b060-c17bff483c7a@app.fastmail.com","threadId":"63379","inReplyTo":"93yuUC_Wn9lQIDzJuvAWbCQ35kz1YxeNhsLLX67x9VzoPtRugVLNaHC_p1sWBzMxWy_VVRRl8av3Dx5PHw4_Cch0gmWs40DDrZRaezLVkGk=@proton.me","subject":"Re: [PATCH v3] apply: --intent-to-add should imply --index","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-05-01T12:48:11Z","receivedAt":"2025-05-01T12:48:32Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"\nOn Thu, May 1, 2025, at 11:03, Jason Cho wrote:\n> I'm following up on the bug reported by Ryan Hodges on October 26, 2021,\n> regarding the `git apply --intent-to-add` command incorrectly marking all\n> other tracked files as deleted from the index.\n>\n> Johannes Altmanninger submitted patch v3 titled \"apply: --intent-to-add\n> should imply --index\" to fix this issue.\n>\n> Is this fix merged? If so, which Git version includes this fix.\n\nI can’t find any commits by Johannes Altmanninger that addresses this.\nI also can’t find any commits that start with `apply: --intent-to-add`.\n"},{"id":"517051","messageId":"xmqqmsbwxpfn.fsf@gitster.g","threadId":"63379","inReplyTo":"8a61dc13-0b7e-437d-b060-c17bff483c7a@app.fastmail.com","subject":"Re: [PATCH v3] apply: --intent-to-add should imply --index","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-01T16:31:56Z","receivedAt":"2025-05-01T16:31:59Z","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>> Johannes Altmanninger submitted patch v3 titled \"apply: --intent-to-add\n>> should imply --index\" to fix this issue.\n>>\n>> Is this fix merged? If so, which Git version includes this fix.\n>\n> I can’t find any commits by Johannes Altmanninger that addresses this.\n> I also can’t find any commits that start with `apply: --intent-to-add`.\n\nThe documentation says this:\n\n    --intent-to-add::\n            When applying the patch only to the working tree, mark new\n            files to be added to the index later (see `--intent-to-add`\n            option in linkgit:git-add[1]). This option is ignored unless\n            running in a Git repository and `--index` is not specified.\n            Note that `--index` could be implied by other options such\n            as `--cached` or `--3way`.\n\nIt is clear that whoever wrote it understands that for this option\nto be effective, the patch needs to affect the index, and one way to\ndo so is for the user to pass `--index`.  But at the same time, that\nis not the only option that makes the command touch the index (e.g.,\n`--cached` does, too), and it would make it behave incorrectly if a\npatch automatically pretends that `--index` was given when this\noption was given.\n\nI can't find the patch either, but given the above documentation, is\nit even still relevant?\n\nThanks.\n\n"},{"id":"517082","messageId":"ED60E13F-F9D4-4261-8C85-29AC771B5D54@gmail.com","threadId":"63379","inReplyTo":"xmqqmsbwxpfn.fsf@gitster.g","subject":"Re: [PATCH v3] apply: --intent-to-add should imply --index","fromName":"Ryan Hodges","fromEmail":"rphodges@gmail.com","sentAt":"2025-05-02T04:11:05Z","receivedAt":"2025-05-02T04:11:17Z","isPatch":true,"sender":{"key":"rphodges@gmail.com","avatar":null},"body":"\n\n> On May 1, 2025, at 9:31 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> \n> \"Kristoffer Haugsbakk\" <kristofferhaugsbakk@fastmail.com> writes:\n> \n>>> Johannes Altmanninger submitted patch v3 titled \"apply: --intent-to-add\n>>> should imply --index\" to fix this issue.\n>>> \n>>> Is this fix merged? If so, which Git version includes this fix.\n>> \n>> I can’t find any commits by Johannes Altmanninger that addresses this.\n>> I also can’t find any commits that start with `apply: --intent-to-add`.\n> \n> The documentation says this:\n> \n>    --intent-to-add::\n>            When applying the patch only to the working tree, mark new\n>            files to be added to the index later (see `--intent-to-add`\n>            option in linkgit:git-add[1]). This option is ignored unless\n>            running in a Git repository and `--index` is not specified.\n>            Note that `--index` could be implied by other options such\n>            as `--cached` or `--3way`.\n> \n> It is clear that whoever wrote it understands that for this option\n> to be effective, the patch needs to affect the index, and one way to\n> do so is for the user to pass `--index`.  But at the same time, that\n> is not the only option that makes the command touch the index (e.g.,\n> `--cached` does, too), and it would make it behave incorrectly if a\n> patch automatically pretends that `--index` was given when this\n> option was given.\n\nThe person that wrote that understood that there’s a conflict between\n—index and —intent-to-add:\n\n—index means add new files to the index and stage them for commit\n—intent-to-add means add an entry for the file to the index but don’t stage it; ie it will be added later\n\nThe author of this commit decided that if —intent-to-add and —index are both specified, then —index takes precedence.\n\n\n> \n> I can't find the patch either, but given the above documentation, is\n\nThe reason you can’t find the patch is because you took issue with the fix provided by Johannes and asked for more analysis.  If you want I can dig up the details of that thread.\n\n> it even still relevant?\n> \n\nThis issue is still very relevant.  Firstly, let me point out the major issue with the current functionality:\n\nGiven a repo with one file, “b.c” and the following diff that adds file “a.c\":\n\n\tryan@Ryans-Macbook-Pro git-repo % cat diff\n\tdiff --git a/a.c b/a.c\n\tnew file mode 100644\n\tindex 0000000..e69de29\n\nHere’s what happens when you run git apply —intent-to-add:\n\n\tryan@Ryans-Macbook-Pro git-repo % git apply --intent-to-add diff\n\n\tryan@Ryans-Macbook-Pro git-repo % git status\n\tOn branch master\n\tChanges to be committed:\n   \t(use \"git restore --staged <file>...\" to unstage)\n        \t deleted:    b.c\n\nBam! b.c gets marked for deletion.  The whole index gets replaced with just the files that are marked by —intent-to-add. That’s very bad. \n\n\nLastly, I’d like to point out my use case for —intent-to-add.  In many VCSs if you run ‘apply’, ‘diff’, and ‘commit’ in sequence and in a clean workspace with no changes, the diff that gets fed to ‘apply’ should look the same as the diff that you get from running ‘diff’, which should be the same as the diff created by the commit command.  Because of the index, that doesn’t happen with Git. When applying a patch in git, new files get added to the worktree but they are not registered in the index.  Thus git diff never sees them. Additionally, those files will be missed by commit even if you use -a. The —intent-to-add switch fixes this workflow and allows files to remain out of the index until the user is ready for them.\n\nThanks\n\n\n\n> Thanks.\n\n\n"},{"id":"517163","messageId":"4e2szrowd43w6lrzawqtddamdxvp6ke65jkzmdoru4gjin7xhn@kaqe7skrktgt","threadId":"63379","inReplyTo":"ED60E13F-F9D4-4261-8C85-29AC771B5D54@gmail.com","subject":"Re: [PATCH v3] apply: --intent-to-add should imply --index","fromName":"Raymond E. Pasco","fromEmail":"ray@ameretat.dev","sentAt":"2025-05-03T03:51:01Z","receivedAt":"2025-05-03T03:51:14Z","isPatch":true,"sender":{"key":"ray@ameretat.dev","avatar":"https://avatars.githubusercontent.com/u/115765?v=4"},"body":"Intents to add are a tricky part of the system; I fixed them up\nsome time ago for `add -p` which uses apply.c machinery, but not for\n`apply -N`, which seems to have never worked since its introduction\nin Git 2.19.\n\nTo recap how this all works, apply has three modes: with no flag, it\napplies a diff to the physical files in the worktree; with --index it\napplies a diff to both the physical files in the worktree and to the\nindex, and with --cached it applies to the index but *not* the physical\nfiles in the worktree.\n\n--intent-to-add / -N is intended to apply only to the first of these\nmodes; this makes sense, because an intent to add is meant to behave\nlike a diff not added to the index. However, the intent to add lives in\nthe index; Git just behaves as though it were a worktree change not in\nthe index.\n\nThe behavior `apply -N` actually exhibits is that it clobbers the index\nwith a new index containing *only* the contents of the diff, nothing\nelse; my guess is that it was only tested against repositories with\nentirely empty trees. If the tree is not empty, then of course an index\nwith only the intent to add and nothing else shows up as every file in\nthe tree being deleted.\n\nThe patch discussed here (the headers for the thread seem broken,\nbut the message id is <20211106114202.3486969-1-aclopte@gmail.com>) does\nseem like a mostly complete fix for the issue. However, the message is\nentirely wrong and confused about how any of this works, which is likely\nwhy the patch fell through the cracks. (Of course --intent-to-add can't\nimply --index, they are mutually exclusive options.)\n\nHowever, the code appears entirely correct. The combination of --cached\nwith -N doesn't work, despite the message claiming it does, but it can't\npossibly work because it includes the file in the index, so it can't\ninclude it as an intent to add in the index. So this just merits a note\nthat --intent-to-add is mutually exclusive with both --index and\n--cached.\n\nIf the original author (Johannes Altmanninger) isn't around or doesn't\nwant to, I can clean this patch up for resubmission.\n"},{"id":"517168","messageId":"5xsywkqp5nctahl26yb6hrhv5sytbzwvhxqvs5y74e46xepmxq@j7o5kxivw24x","threadId":"63379","inReplyTo":"4e2szrowd43w6lrzawqtddamdxvp6ke65jkzmdoru4gjin7xhn@kaqe7skrktgt","subject":"Re: [PATCH v3] apply: --intent-to-add should imply --index","fromName":"Raymond E. Pasco","fromEmail":"ray@ameretat.dev","sentAt":"2025-05-03T08:22:42Z","receivedAt":"2025-05-03T08:22:59Z","isPatch":true,"sender":{"key":"ray@ameretat.dev","avatar":"https://avatars.githubusercontent.com/u/115765?v=4"},"body":"On 25/05/02 11:51PM, Raymond E. Pasco wrote:\n> However, the code appears entirely correct. The combination of --cached\n> with -N doesn't work, despite the message claiming it does, but it can't\n> possibly work because it includes the file in the index, so it can't\n> include it as an intent to add in the index. So this just merits a note\n> that --intent-to-add is mutually exclusive with both --index and\n> --cached.\n> \n> If the original author (Johannes Altmanninger) isn't around or doesn't\n> want to, I can clean this patch up for resubmission.\n\nIn fact, I've just discovered an additional issue that remains even\npost-patch (it tries to apply the whole diff, even parts that are\nnot new file additions, with ita_only on), so it needs slightly more\nwork than implied above to be complete.\n"},{"id":"517768","messageId":"20250511003955.242889-1-ray@ameretat.dev","threadId":"63379","inReplyTo":"4e2szrowd43w6lrzawqtddamdxvp6ke65jkzmdoru4gjin7xhn@kaqe7skrktgt","subject":"[PATCH 0/5] apply: fix apply --intent-to-add","fromName":"Raymond E. Pasco","fromEmail":"ray@ameretat.dev","sentAt":"2025-05-11T00:36:43Z","receivedAt":"2025-05-11T00:40:26Z","isPatch":true,"sender":{"key":"ray@ameretat.dev","avatar":"https://avatars.githubusercontent.com/u/115765?v=4"},"body":"This patch series fixes the -N/--intent-to-add flag for git apply, which\nhas not worked properly since its introduction in Git 2.19.\n\nIn particular, the index is properly initialized, and not touched except\nto add the requested intents to add.\n\nLoosely based on the patch from Johannes Altmanninger, message-id\n<20211106114202.3486969-1-aclopte@gmail.com>, but that patch turned out to\nbe incorrect.\n\nRaymond E. Pasco (5):\n  apply: error on --intent-to-add outside gitdir\n  apply: read in the index in --intent-to-add mode\n  apply: only write intents to add for new files\n  t4140: test apply --intent-to-add interactions\n  apply docs: clarify wording for --intent-to-add\n\n Documentation/git-apply.adoc |  8 ++++----\n apply.c                      | 12 ++++++++----\n t/t4140-apply-ita.sh         | 31 ++++++++++++++++++++++++++++++-\n 3 files changed, 42 insertions(+), 9 deletions(-)\n\n-- \n2.49.0.1106.gc0efa3ba58\n\n"},{"id":"517769","messageId":"20250511003955.242889-2-ray@ameretat.dev","threadId":"63379","inReplyTo":"20250511003955.242889-1-ray@ameretat.dev","subject":"[PATCH 1/5] apply: error on --intent-to-add outside gitdir","fromName":"Raymond E. Pasco","fromEmail":"ray@ameretat.dev","sentAt":"2025-05-11T00:36:44Z","receivedAt":"2025-05-11T00:40:42Z","isPatch":true,"sender":{"key":"ray@ameretat.dev","avatar":"https://avatars.githubusercontent.com/u/115765?v=4"},"body":"It makes no sense to register an intent to add outside a repository. We\nshould error out here.\n\nBased-on-patch-by: Johannes Altmanninger <aclopte@gmail.com>\nSigned-off-by: Raymond E. Pasco <ray@ameretat.dev>\n---\n apply.c | 8 ++++++--\n 1 file changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex f274a37948..5e39cadde4 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -174,8 +174,12 @@ int check_apply_state(struct apply_state *state, int force_apply)\n \t\t\treturn error(_(\"'%s' outside a repository\"), \"--cached\");\n \t\tstate->check_index = 1;\n \t}\n-\tif (state->ita_only && (state->check_index || is_not_gitdir))\n-\t\tstate->ita_only = 0;\n+\tif (state->ita_only) {\n+\t\tif (is_not_gitdir)\n+\t\t\treturn error(_(\"'%s' outside a repository\"), \"--intent-to-add\");\n+\t\tif (state->check_index)\n+\t\t\tstate->ita_only = 0;\n+\t}\n \tif (state->check_index)\n \t\tstate->unsafe_paths = 0;\n \n-- \n2.49.0.1106.gc0efa3ba58\n\n"},{"id":"517770","messageId":"20250511003955.242889-3-ray@ameretat.dev","threadId":"63379","inReplyTo":"20250511003955.242889-1-ray@ameretat.dev","subject":"[PATCH 2/5] apply: read in the index in --intent-to-add mode","fromName":"Raymond E. Pasco","fromEmail":"ray@ameretat.dev","sentAt":"2025-05-11T00:36:45Z","receivedAt":"2025-05-11T00:40:45Z","isPatch":true,"sender":{"key":"ray@ameretat.dev","avatar":"https://avatars.githubusercontent.com/u/115765?v=4"},"body":"There are three main modes of operation for apply: applying only to the\nworktree, applying to the worktree and index (--index), and applying\nonly to the index (--cached).\n\nThe --intent-to-add flag modifies the first of these modes, applying\nonly to the worktree, in a way which touches the index, because\nintents to add are special index entries. However, it has not ever\nworked correctly in any but the most trivial (empty repository)\ncases, because the index was never read in (in apply, this is done\nin read_apply_cache()) before writing to it.\n\nThe update_index flag is set in apply_patch() to mean that we\nare touching the index at all, as opposed to the check_index flag\nindicating --index mode.  Therefore, the reading of the index should\nbe gated by the update_index flag rather than the check_index flag,\nso that we are prepared to work with the index before we begin adding\nintents to add to it.\n\nReported-by: Ryan Hodges <rhodges@cisco.com>\nOriginal-patch-by: Johannes Altmanninger <aclopte@gmail.com>\nSigned-off-by: Raymond E. Pasco <ray@ameretat.dev>\n---\n apply.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/apply.c b/apply.c\nindex 5e39cadde4..3bde54a04a 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -4837,7 +4837,7 @@ static int apply_patch(struct apply_state *state,\n \t\t\t\t\t       LOCK_DIE_ON_ERROR);\n \t}\n \n-\tif (state->check_index && read_apply_cache(state) < 0) {\n+\tif (state->update_index && read_apply_cache(state) < 0) {\n \t\terror(_(\"unable to read index file\"));\n \t\tres = -128;\n \t\tgoto end;\n-- \n2.49.0.1106.gc0efa3ba58\n\n"},{"id":"517771","messageId":"20250511003955.242889-4-ray@ameretat.dev","threadId":"63379","inReplyTo":"20250511003955.242889-1-ray@ameretat.dev","subject":"[PATCH 3/5] apply: only write intents to add for new files","fromName":"Raymond E. Pasco","fromEmail":"ray@ameretat.dev","sentAt":"2025-05-11T00:36:46Z","receivedAt":"2025-05-11T00:40:47Z","isPatch":true,"sender":{"key":"ray@ameretat.dev","avatar":"https://avatars.githubusercontent.com/u/115765?v=4"},"body":"In the \"update only the worktree\" mode, the index should not be touched\nexcept to record intents to add when --intent-to-add is on. Because\nhaving --intent-to-add on sets update_index, to indicate that we are\ntouching the index, we can't rely only on that flag to decide whether to\nwrite an index entry. Instead, we must test whether we are in a mode\nwhich updates the index, or else are in worktree-only mode with\n--intent-to-add on and the current file being an addition.\n\nSigned-off-by: Raymond E. Pasco <ray@ameretat.dev>\n---\n apply.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/apply.c b/apply.c\nindex 3bde54a04a..a749f904c7 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -4569,7 +4569,7 @@ static int create_file(struct apply_state *state, struct patch *patch)\n \n \tif (patch->conflicted_threeway)\n \t\treturn add_conflicted_stages_file(state, patch);\n-\telse if (state->update_index)\n+\telse if (state->check_index || (state->ita_only && patch->is_new > 0))\n \t\treturn add_index_file(state, path, mode, buf, size);\n \treturn 0;\n }\n-- \n2.49.0.1106.gc0efa3ba58\n\n"},{"id":"517772","messageId":"20250511003955.242889-5-ray@ameretat.dev","threadId":"63379","inReplyTo":"20250511003955.242889-1-ray@ameretat.dev","subject":"[PATCH 4/5] t4140: test apply --intent-to-add interactions","fromName":"Raymond E. Pasco","fromEmail":"ray@ameretat.dev","sentAt":"2025-05-11T00:36:47Z","receivedAt":"2025-05-11T00:40:49Z","isPatch":true,"sender":{"key":"ray@ameretat.dev","avatar":"https://avatars.githubusercontent.com/u/115765?v=4"},"body":"Test that applying a new file creation patch to an existing index works,\nand that applying a patch with both modifications and new file creations\nworks.\n\nSigned-off-by: Raymond E. Pasco <ray@ameretat.dev>\n---\n t/t4140-apply-ita.sh | 31 ++++++++++++++++++++++++++++++-\n 1 file changed, 30 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t4140-apply-ita.sh b/t/t4140-apply-ita.sh\nindex c614eaf04c..c664209c41 100755\n--- a/t/t4140-apply-ita.sh\n+++ b/t/t4140-apply-ita.sh\n@@ -7,6 +7,10 @@ test_description='git apply of i-t-a file'\n test_expect_success setup '\n \ttest_write_lines 1 2 3 4 5 >blueprint &&\n \n+  cat blueprint >committed-file &&\n+  git add committed-file &&\n+  git commit -m \"commit\" &&\n+\n \tcat blueprint >test-file &&\n \tgit add -N test-file &&\n \tgit diff >creation-patch &&\n@@ -14,7 +18,14 @@ test_expect_success setup '\n \n \trm -f test-file &&\n \tgit diff >deletion-patch &&\n-\tgrep \"deleted file mode 100644\" deletion-patch\n+\tgrep \"deleted file mode 100644\" deletion-patch &&\n+\n+\tgit rm -f test-file &&\n+\ttest_write_lines 6 >>committed-file &&\n+\tcat blueprint >test-file &&\n+\tgit add -N test-file &&\n+\tgit diff >complex-patch &&\n+\tgit restore committed-file\n '\n \n test_expect_success 'apply creation patch to ita path (--cached)' '\n@@ -53,4 +64,22 @@ test_expect_success 'apply deletion patch to ita path (--index)' '\n \tgit ls-files --stage --error-unmatch test-file\n '\n \n+test_expect_success 'apply creation patch to existing index with -N' '\n+  git rm -f test-file &&\n+  cat blueprint >index-file &&\n+  git add index-file &&\n+  git apply -N creation-patch &&\n+\n+  git ls-files --stage --error-unmatch index-file &&\n+  git ls-files --stage --error-unmatch test-file\n+'\n+\n+test_expect_success 'apply complex patch with -N' '\n+  git rm -f test-file index-file &&\n+  git apply -N complex-patch &&\n+\n+  git ls-files --stage --error-unmatch test-file &&\n+  git diff | grep \"a/committed-file\"\n+'\n+\n test_done\n-- \n2.49.0.1106.gc0efa3ba58\n\n"},{"id":"517773","messageId":"20250511003955.242889-6-ray@ameretat.dev","threadId":"63379","inReplyTo":"20250511003955.242889-1-ray@ameretat.dev","subject":"[PATCH 5/5] apply docs: clarify wording for --intent-to-add","fromName":"Raymond E. Pasco","fromEmail":"ray@ameretat.dev","sentAt":"2025-05-11T00:36:48Z","receivedAt":"2025-05-11T00:40:52Z","isPatch":true,"sender":{"key":"ray@ameretat.dev","avatar":"https://avatars.githubusercontent.com/u/115765?v=4"},"body":"Avoid using a double negative, and keep in mind that --index and\n--cached are distinct modes of operation.\n\nSigned-off-by: Raymond E. Pasco <ray@ameretat.dev>\n---\n Documentation/git-apply.adoc | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-apply.adoc b/Documentation/git-apply.adoc\nindex 952518b8af..a41069c0ab 100644\n--- a/Documentation/git-apply.adoc\n+++ b/Documentation/git-apply.adoc\n@@ -75,13 +75,13 @@ OPTIONS\n \ttree. If `--check` is in effect, merely check that it would\n \tapply cleanly to the index entry.\n \n+-N::\n --intent-to-add::\n \tWhen applying the patch only to the working tree, mark new\n \tfiles to be added to the index later (see `--intent-to-add`\n-\toption in linkgit:git-add[1]). This option is ignored unless\n-\trunning in a Git repository and `--index` is not specified.\n-\tNote that `--index` could be implied by other options such\n-\tas `--cached` or `--3way`.\n+\toption in linkgit:git-add[1]). This option is ignored if\n+\t`--index` or `--cached` are used. Note that `--index` could\n+\tbe implied by other options such as `--3way`.\n \n -3::\n --3way::\n-- \n2.49.0.1106.gc0efa3ba58\n\n"},{"id":"517797","messageId":"gz4sl3e3nqmkamkfmoktlqaefxteamj6v3fcs7dbavgys7ubng@utz2i5ahl77f","threadId":"63379","inReplyTo":"20250511003955.242889-3-ray@ameretat.dev","subject":"Re: [PATCH 2/5] apply: read in the index in --intent-to-add mode","fromName":"Raymond E. Pasco","fromEmail":"ray@ameretat.dev","sentAt":"2025-05-12T02:13:44Z","receivedAt":"2025-05-12T02:13:58Z","isPatch":true,"sender":{"key":"ray@ameretat.dev","avatar":"https://avatars.githubusercontent.com/u/115765?v=4"},"body":"On 25/05/10 08:36PM, Raymond E. Pasco wrote:\n> diff --git a/apply.c b/apply.c\n> index 5e39cadde4..3bde54a04a 100644\n> --- a/apply.c\n> +++ b/apply.c\n> @@ -4837,7 +4837,7 @@ static int apply_patch(struct apply_state *state,\n>  \t\t\t\t\t       LOCK_DIE_ON_ERROR);\n>  \t}\n>  \n> -\tif (state->check_index && read_apply_cache(state) < 0) {\n> +\tif (state->update_index && read_apply_cache(state) < 0) {\n>  \t\terror(_(\"unable to read index file\"));\n>  \t\tres = -128;\n>  \t\tgoto end;\n> -- \n> 2.49.0.1106.gc0efa3ba58\n> \n> \n\nFor some reason, this causes checkout -p to break in a way which which I\ndon't understand. Directly using (state->check_index || state->ita_only)\ndoesn't break it, but because it doesn't seem logically possible to me\nfor this to change any behavior besides behavior when ita_only is on\n(the update_index flag is in fact set just a few lines above!), I want\nto investigate a bit further to find out what I'm confused about.\n\nEither way, reroll coming, though I'd still appreciate review on the\nseries in general.\n"},{"id":"517961","messageId":"pHu_JjAnK8kIuq7d3kCledkNo-FNQo-lHtHLQ6sbVvgp_Q2XGSpuyjcSm4XJy_iH4RABVwEzFjupGxvh059y1cYOo4hTpK5ZFNbAMwkJv-s=@proton.me","threadId":"63379","inReplyTo":"gz4sl3e3nqmkamkfmoktlqaefxteamj6v3fcs7dbavgys7ubng@utz2i5ahl77f","subject":"Re: [PATCH 2/5] apply: read in the index in --intent-to-add mode","fromName":"Jason Cho","fromEmail":"jason11choca@proton.me","sentAt":"2025-05-13T17:52:58Z","receivedAt":"2025-05-13T17:53:12Z","isPatch":true,"sender":{"key":"jason11choca@proton.me","avatar":null},"body":"Raymond, thank you for getting on top of my initial query. Although your current patch has bugs, I'm confident that you are able to fix it.\n\nI'm looking forward to see the option --intent-to-add works correctly.\n\nI appreciate the effort of you and code reviewers.\n"}]}