Skip to content

Commit b145b21

Browse files
pvgitster
authored andcommitted
git-add--interactive: never skip files included in index
Make "git add -p" to not skip files that are in index even if they are excluded (by .gitignore etc.). This fixes the contradictory behavior that "git status" and "git commit -a" listed such files as modified, but "git add -p FILENAME" ignored them. Signed-off-by: Pauli Virtanen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ac78b00 commit b145b21

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

git-add--interactive.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ sub list_modified {
186186
@tracked = map {
187187
chomp $_;
188188
unquote_path($_);
189-
} run_cmd_pipe(qw(git ls-files --exclude-standard --), @ARGV);
189+
} run_cmd_pipe(qw(git ls-files --), @ARGV);
190190
return if (!@tracked);
191191
}
192192

t/t3701-add-interactive.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,20 @@ test_expect_success 'real edit works' '
138138
test_cmp expected output
139139
'
140140

141+
test_expect_success 'skip files similarly as commit -a' '
142+
git reset &&
143+
echo file >.gitignore &&
144+
echo changed >file &&
145+
echo y | git add -p file &&
146+
git diff >output &&
147+
git reset &&
148+
git commit -am commit &&
149+
git diff >expected &&
150+
test_cmp expected output &&
151+
git reset --hard HEAD^
152+
'
153+
rm -f .gitignore
154+
141155
if test "$(git config --bool core.filemode)" = false
142156
then
143157
say 'skipping filemode tests (filesystem does not properly support modes)'

0 commit comments

Comments
 (0)