@matheusbsbs / matheus-bagliano / commits / b145b211ba
Fork 0

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 <pav@iki.fi> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Pauli Virtanen committed Oct 10, 2009 at 18:51 UTC b145b211baa4129a827cc1b1b1a7984523b8f903
2 files changed +15 -1
git-add--interactive.perl
+1 -1
@@ -186,7 +186,7 @@ sub list_modified {
186 @tracked = map {
187 chomp $_;
188 unquote_path($_);
189 - } run_cmd_pipe(qw(git ls-files --exclude-standard --), @ARGV);
189 + } run_cmd_pipe(qw(git ls-files --), @ARGV);
190 return if (!@tracked);
191 }
192
t/t3701-add-interactive.sh
+14
@@ -138,6 +138,20 @@ test_expect_success 'real edit works' '
138 test_cmp expected output
139 '
140
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 +
155 if test "$(git config --bool core.filemode)" = false
156 then
157 say 'skipping filemode tests (filesystem does not properly support modes)'