git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Altmanninger <aclopte@gmail.com>
To: "Ryan Hodges (rhodges)" <rhodges@cisco.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>,
	Ryan Hodges <rphodges@gmail.com>
Subject: Re: git apply --intent-to-add deletes other files from the index
Date: Sat, 30 Oct 2021 22:39:16 +0200	[thread overview]
Message-ID: <20211030203916.zopggbajumvb4z3f@gmail.com> (raw)
In-Reply-To: <0DB10E05-094D-4382-AD1F-657878B06A80@cisco.com>

On Tue, Oct 26, 2021 at 03:11:36PM +0000, Ryan Hodges (rhodges) wrote:
> Hi all,
>  
> I’ve got a quick question about ‘git apply –intent-to-add’.  If I’ve got a patch that just adds one file to the tree:
>  
> [sjc-ads-2565:t.git]$ git diff
> diff --git a/c.c b/c.c
> new file mode 100644
> index 0000000..9daeafb
> --- /dev/null
> +++ b/c.c
> @@ -0,0 +1 @@
> +test
>  
> and I apply that patch with –intent-to-add:
>  
> [sjc-ads-2565:t.git]$ git apply --intent-to-add c.diff
>  
> The newly added file is tracked but other files in the tree get marked as deleted:
>  
> [sjc-ads-2565:t.git]$ git status
> On branch master
> Changes to be committed:
>   (use “git restore –staged <file>…” to unstage)
>                 deleted:    a.c

Yep, looks like a bug to me.
git apply should never change the status of files that are not mentioned in
the input patch.

>                 deleted:    b.c
>  
> Changes not staged for commit:
>   (use “git add <file>…” to update what will be committed)
>   (use “git restore <file>…” to discard changes in working directory)
>                 new file:   c.c
>  
> It looks like Git created a new index with only the newly added file in the patch.

Seems so.

> However, I’d like Git to just add one entry to the index corresponding
> to the newly added file in the patch.  Is this a bug or am I completely
> misinterpreting the goal of ‘intent-to-add’.

Yeah, I think your "git apply --intent-to-add c.diff" should behave exactly like

	echo test > c.c && git add --intent-to-add c.c

  reply	other threads:[~2021-10-30 20:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-26 15:11 git apply --indent-to-add deletes other files from the index Ryan Hodges (rhodges)
2021-10-30 20:39 ` Johannes Altmanninger [this message]
2021-10-30 21:42   ` git apply --intent-to-add " Ryan Hodges
2021-10-31  6:43     ` Johannes Altmanninger
2021-10-30 20:41 ` [PATCH] apply: make --intent-to-add not stomp index Johannes Altmanninger
2021-10-30 20:51   ` [PATCH v2] " Johannes Altmanninger
2021-11-01  6:40     ` Junio C Hamano
2021-11-01  7:07       ` Re* " Junio C Hamano
2021-11-06 11:24         ` Johannes Altmanninger
2021-11-06 11:42           ` [PATCH v3] apply: --intent-to-add should imply --index Johannes Altmanninger
2021-11-06 11:47             ` Johannes Altmanninger
2021-11-06 11:24       ` [PATCH v2] apply: make --intent-to-add not stomp index Johannes Altmanninger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211030203916.zopggbajumvb4z3f@gmail.com \
    --to=aclopte@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=rhodges@cisco.com \
    --cc=rphodges@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).