]> git.ipfire.org Git - thirdparty/git.git/commit - add-interactive.c
built-in add -i: allow filtering the modified files list
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 29 Nov 2019 21:11:42 +0000 (21:11 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 1 Dec 2019 15:30:54 +0000 (07:30 -0800)
commitc08171d156f6f77bdab6500f0b433b650a31ccae
treed44096ccca43ec17dcfcb5cb1a7426906d07fd8b
parent0c3944a628e46f6abb1add20f19641c5bbef8a1a
built-in add -i: allow filtering the modified files list

In the `update` command of `git add -i`, we are primarily interested in the
list of modified files that have worktree (i.e. unstaged) changes.

At the same time, we need to determine _also_ the staged changes, to be
able to produce the full added/deleted information.

The Perl script version of `git add -i` has a parameter of the
`list_modified()` function for that matter. In C, we can be a lot more
precise, using an `enum`.

The C implementation of the filter also has an easier time to avoid
unnecessary work, simply by using an adaptive order of the `diff-index`
and `diff-files` phases, and then skipping files in the second phase
when they have not been seen in the first phase.

Seeing as we change the meaning of the `phase` field, we rename it to
`mode` to reflect that the order depends on the exact invocation of the
`git add -i` command.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
add-interactive.c