summaryrefslogtreecommitdiff
path: root/t/t3701-add-interactive.sh
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-01-13 12:10:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-01-16 20:32:45 (GMT)
commit12434efc1d4a83d768e8b60bfdb711780677a308 (patch)
tree7cb2212005c775450426360fb691e313ddfe0cab /t/t3701-add-interactive.sh
parent6366dd9000a3f67e47a30d94375a88dabc18ec6f (diff)
downloadgit-12434efc1d4a83d768e8b60bfdb711780677a308.zip
git-12434efc1d4a83d768e8b60bfdb711780677a308.tar.gz
git-12434efc1d4a83d768e8b60bfdb711780677a308.tar.bz2
add--interactive: ignore submodule changes except HEAD
For 'add -i' and 'add -p', the only action we can take on a dirty submodule entry is update the index with a new value from its HEAD. The content changes inside (from its own index, untracked files...) do not matter, at least until 'git add -i' learns about launching a new interactive add session inside a submodule. Ignore all other submodules changes except HEAD. This reduces the number of entries the user has to check through in 'git add -i', and the number of 'no' they have to answer to 'git add -p' when dirty submodules are present. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3701-add-interactive.sh')
-rwxr-xr-xt/t3701-add-interactive.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index a49c12c..058698d 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