Skip to content

Commit e7e8077

Browse files
committed
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
2 parents 897de84 + 12434ef commit e7e8077

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

git-add--interactive.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ sub list_modified {
262262
}
263263
}
264264

265-
for (run_cmd_pipe(qw(git diff-files --numstat --summary --raw --), @ARGV)) {
265+
for (run_cmd_pipe(qw(git diff-files --ignore-submodules=dirty --numstat --summary --raw --), @ARGV)) {
266266
if (($add, $del, $file) =
267267
/^([-\d]+) ([-\d]+) (.*)/) {
268268
$file = unquote_path($file);

t/t3701-add-interactive.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,4 +493,52 @@ test_expect_success 'add -p works even with color.ui=always' '
493493
test_cmp expect actual
494494
'
495495

496+
test_expect_success 'setup different kinds of dirty submodules' '
497+
test_create_repo for-submodules &&
498+
(
499+
cd for-submodules &&
500+
test_commit initial &&
501+
test_create_repo dirty-head &&
502+
(
503+
cd dirty-head &&
504+
test_commit initial
505+
) &&
506+
cp -R dirty-head dirty-otherwise &&
507+
cp -R dirty-head dirty-both-ways &&
508+
git add dirty-head &&
509+
git add dirty-otherwise dirty-both-ways &&
510+
git commit -m initial &&
511+
512+
cd dirty-head &&
513+
test_commit updated &&
514+
cd ../dirty-both-ways &&
515+
test_commit updated &&
516+
echo dirty >>initial &&
517+
: >untracked &&
518+
cd ../dirty-otherwise &&
519+
echo dirty >>initial &&
520+
: >untracked
521+
) &&
522+
git -C for-submodules diff-files --name-only >actual &&
523+
cat >expected <<-\EOF &&
524+
dirty-both-ways
525+
dirty-head
526+
dirty-otherwise
527+
EOF
528+
test_cmp expected actual &&
529+
git -C for-submodules diff-files --name-only --ignore-submodules=dirty >actual &&
530+
cat >expected <<-\EOF &&
531+
dirty-both-ways
532+
dirty-head
533+
EOF
534+
test_cmp expected actual
535+
'
536+
537+
test_expect_success 'status ignores dirty submodules (except HEAD)' '
538+
git -C for-submodules add -i </dev/null >output &&
539+
grep dirty-head output &&
540+
grep dirty-both-ways output &&
541+
! grep dirty-otherwise output
542+
'
543+
496544
test_done

0 commit comments

Comments
 (0)