Merge branch 'tr/maint-1.6.3-add-p-modeonly-fix' into maint-1.6.3
authorJunio C Hamano <gitster@pobox.com>
Wed, 26 Aug 2009 18:22:00 +0000 (11:22 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 26 Aug 2009 18:22:00 +0000 (11:22 -0700)
* 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

git-add--interactive.perl
t/t3701-add-interactive.sh
index df9f231635d2bc53073375971c1383966e2a140b..06f70602cc619e9e13bdc609a43780ce8bc6570d 100755 (executable)
@@ -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 &&
index fd2a55a5c23247c010a02513af73a93641cfb067..62fd65e18d434711176ddb1c22ef057b879e992a 100755 (executable)
@@ -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' '