Merge branch 'tr/maint-1.6.3-add-p-modeonly-fix'
authorJunio C Hamano <gitster@pobox.com>
Wed, 19 Aug 2009 06:32:58 +0000 (23:32 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 19 Aug 2009 06:32:58 +0000 (23:32 -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

1  2 
git-add--interactive.perl
t/t3701-add-interactive.sh
index df9f231635d2bc53073375971c1383966e2a140b,e6f93c7c95019473bc9585fc97b20c356bb4b111..06f70602cc619e9e13bdc609a43780ce8bc6570d
@@@ -841,6 -841,10 +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 &&
@@@ -1317,6 -1321,7 +1321,6 @@@ sub patch_update_file 
                open $fh, '| git apply --cached --recount';
                for (@{$head->{TEXT}}, @result) {
                        print $fh $_;
 -                      print STDERR $_;
                }
                if (!close $fh) {
                        for (@{$head->{TEXT}}, @result) {
index fd2a55a5c23247c010a02513af73a93641cfb067,63940b18934d8fe71110a5a9edc60a7ee09c5f91..62fd65e18d434711176ddb1c22ef057b879e992a
@@@ -163,14 -163,19 +163,25 @@@ test_expect_success FILEMODE 'stage mod
        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' '
 +      git reset --hard &&
 +      test_chmod +x file &&
 +      echo content >>file
 +'
 +
  # Write the patch file with a new line at the top and bottom
  cat >patch <<EOF
  index 180b47c..b6f2c08 100644