diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-08-18 23:32:58 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-08-18 23:32:58 -0700 |
commit | 09ba7b2d9fc9142a2195082dd0e74c8161b6b744 (patch) | |
tree | b1a787a2fe289c10c7cf70e27239fc02999a159f | |
parent | 91e50b2c0a3bfa818454590fcc6a1ef70c3c58d0 (diff) | |
parent | 3d792161b1c86632d5331bb30d6b7c6b17261f38 (diff) | |
download | git-09ba7b2d9fc9142a2195082dd0e74c8161b6b744.tar.gz |
Merge branch 'tr/maint-1.6.3-add-p-modeonly-fix'
* tr/maint-1.6.3-add-p-modeonly-fix:
add -p: do not attempt to coalesce mode changes
git add -p: demonstrate failure when staging both mode and hunk
-rwxr-xr-x | git-add--interactive.perl | 4 | ||||
-rwxr-xr-x | t/t3701-add-interactive.sh | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl index df9f231635..06f70602cc 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -841,6 +841,10 @@ sub coalesce_overlapping_hunks { my ($last_o_ctx, $last_was_dirty); for (grep { $_->{USE} } @in) { + if ($_->{TYPE} ne 'hunk') { + push @out, $_; + next; + } my $text = $_->{TEXT}; my ($o_ofs) = parse_hunk_header($text->[0]); if (defined $last_o_ctx && diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index fd2a55a5c2..62fd65e18d 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -163,6 +163,17 @@ test_expect_success FILEMODE 'stage mode but not hunk' ' git diff file | grep "+content" ' + +test_expect_success FILEMODE 'stage mode and hunk' ' + git reset --hard && + echo content >>file && + chmod +x file && + printf "y\\ny\\n" | git add -p && + git diff --cached file | grep "new mode" && + git diff --cached file | grep "+content" && + test -z "$(git diff file)" +' + # end of tests disabled when filemode is not usable test_expect_success 'setup again' ' |