summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-01-23 13:16:41 -0800
committerJunio C Hamano <gitster@pobox.com>2018-01-23 13:16:41 -0800
commite7e80778e705ea3f9332c634781d6d0f8c6eab64 (patch)
treeaaada0f9cb2029976fb2a877e50462862cabf278
parent897de845e62ddccba5310057b64d568bc3d4e182 (diff)
parent12434efc1d4a83d768e8b60bfdb711780677a308 (diff)
downloadgit-e7e80778e705ea3f9332c634781d6d0f8c6eab64.tar.gz
Merge branch 'nd/add-i-ignore-submodules'
"git add -p" was taught to ignore local changes to submodules as they do not interfere with the partial addition of regular changes anyway. * nd/add-i-ignore-submodules: add--interactive: ignore submodule changes except HEAD
-rwxr-xr-xgit-add--interactive.perl2
-rwxr-xr-xt/t3701-add-interactive.sh48
2 files changed, 49 insertions, 1 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 28b325d754..964c3a7542 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -262,7 +262,7 @@ sub list_modified {
}
}
- for (run_cmd_pipe(qw(git diff-files --numstat --summary --raw --), @ARGV)) {
+ for (run_cmd_pipe(qw(git diff-files --ignore-submodules=dirty --numstat --summary --raw --), @ARGV)) {
if (($add, $del, $file) =
/^([-\d]+) ([-\d]+) (.*)/) {
$file = unquote_path($file);
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index a49c12c79b..058698df6a 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -493,4 +493,52 @@ test_expect_success 'add -p works even with color.ui=always' '
test_cmp expect actual
'
+test_expect_success 'setup different kinds of dirty submodules' '
+ test_create_repo for-submodules &&
+ (
+ cd for-submodules &&
+ test_commit initial &&
+ test_create_repo dirty-head &&
+ (
+ cd dirty-head &&
+ test_commit initial
+ ) &&
+ cp -R dirty-head dirty-otherwise &&
+ cp -R dirty-head dirty-both-ways &&
+ git add dirty-head &&
+ git add dirty-otherwise dirty-both-ways &&
+ git commit -m initial &&
+
+ cd dirty-head &&
+ test_commit updated &&
+ cd ../dirty-both-ways &&
+ test_commit updated &&
+ echo dirty >>initial &&
+ : >untracked &&
+ cd ../dirty-otherwise &&
+ echo dirty >>initial &&
+ : >untracked
+ ) &&
+ git -C for-submodules diff-files --name-only >actual &&
+ cat >expected <<-\EOF &&
+ dirty-both-ways
+ dirty-head
+ dirty-otherwise
+ EOF
+ test_cmp expected actual &&
+ git -C for-submodules diff-files --name-only --ignore-submodules=dirty >actual &&
+ cat >expected <<-\EOF &&
+ dirty-both-ways
+ dirty-head
+ EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'status ignores dirty submodules (except HEAD)' '
+ git -C for-submodules add -i </dev/null >output &&
+ grep dirty-head output &&
+ grep dirty-both-ways output &&
+ ! grep dirty-otherwise output
+'
+
test_done