Skip to content

Commit

Permalink
git-add--interactive: never skip files included in index
Browse files Browse the repository at this point in the history
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 <pav@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Pauli Virtanen authored and Junio C Hamano committed Oct 10, 2009
1 parent ac78b00 commit b145b21
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion git-add--interactive.perl
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ sub list_modified {
@tracked = map {
chomp $_;
unquote_path($_);
} run_cmd_pipe(qw(git ls-files --exclude-standard --), @ARGV);
} run_cmd_pipe(qw(git ls-files --), @ARGV);
return if (!@tracked);
}

Expand Down
14 changes: 14 additions & 0 deletions t/t3701-add-interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,20 @@ test_expect_success 'real edit works' '
test_cmp expected output
'

test_expect_success 'skip files similarly as commit -a' '
git reset &&
echo file >.gitignore &&
echo changed >file &&
echo y | git add -p file &&
git diff >output &&
git reset &&
git commit -am commit &&
git diff >expected &&
test_cmp expected output &&
git reset --hard HEAD^
'
rm -f .gitignore

if test "$(git config --bool core.filemode)" = false
then
say 'skipping filemode tests (filesystem does not properly support modes)'
Expand Down

0 comments on commit b145b21

Please sign in to comment.