git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-add--interactive: never skip files included in index

From
PVPauli Virtanen <pav@iki.fi>
Date
Oct 10, 2009, 15:51 UTC
Message-ID
<1255189906-16049-1-git-send-email-pav@iki.fi>

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>
---
 git-add--interactive.perl  |    2 +-
 t/t3701-add-interactive.sh |   18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 392efb9..69aeaf0 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -259,7 +259,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);
 	}
 
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 62fd65e..89bfdcb 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -138,6 +138,24 @@ test_expect_success 'real edit works' '
 	test_cmp expected output
 '
 
+cat >.gitignore <<EOF
+file
+EOF
+cat >file <<EOF
+changed
+EOF
+test_expect_success 'skip files similarly as commit -a' '
+	git reset
+	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)'
-- 
1.6.3.3
Next: Junio C Hamano
Message 1 of 8 in “git-add--interactive: never skip files included in index”
  1. git-add--interactive: never skip files included in indexPauli Virtanen, Oct 10, 2009
  2. Junio C HamanoOct 11, 2009
  3. Jeff KingOct 11, 2009
  4. Junio C HamanoOct 11, 2009
  5. Jeff KingOct 12, 2009
  6. Junio C HamanoOct 12, 2009
  7. Jeff KingOct 12, 2009
  8. Junio C HamanoOct 12, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.