diff options
-rwxr-xr-x | git-add--interactive.perl | 2 | ||||
-rwxr-xr-x | t/t3701-add-interactive.sh | 43 |
2 files changed, 44 insertions, 1 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl index ab022ec073..8361ef45e7 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -1047,7 +1047,7 @@ sub recount_edited_hunk { $o_cnt++; } elsif ($mode eq '+') { $n_cnt++; - } elsif ($mode eq ' ') { + } elsif ($mode eq ' ' or $mode eq "\n") { $o_cnt++; $n_cnt++; } diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index e5c66f7500..f1bb879ea4 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -175,6 +175,49 @@ test_expect_success 'real edit works' ' diff_cmp expected output ' +test_expect_success 'setup file' ' + test_write_lines a "" b "" c >file && + git add file && + test_write_lines a "" d "" c >file +' + +test_expect_success 'setup patch' ' + SP=" " && + NULL="" && + cat >patch <<-EOF + @@ -1,4 +1,4 @@ + a + $NULL + -b + +f + $SP + c + EOF +' + +test_expect_success 'setup expected' ' + cat >expected <<-EOF + diff --git a/file b/file + index b5dd6c9..f910ae9 100644 + --- a/file + +++ b/file + @@ -1,5 +1,5 @@ + a + $SP + -f + +d + $SP + c + EOF +' + +test_expect_success 'edit can strip spaces from empty context lines' ' + test_write_lines e n q | git add -p 2>error && + test_must_be_empty error && + git diff >output && + diff_cmp expected output +' + test_expect_success 'skip files similarly as commit -a' ' git reset && echo file >.gitignore && |