From: Junio C Hamano Date: Wed, 26 Aug 2009 18:22:00 +0000 (-0700) Subject: Merge branch 'tr/maint-1.6.3-add-p-modeonly-fix' into maint-1.6.3 X-Git-Tag: v1.6.4.2~13^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/9e4a90ba19033d25dca1eea495b0a8c5f06efbc6?hp=-c Merge branch 'tr/maint-1.6.3-add-p-modeonly-fix' into maint-1.6.3 * 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 --- 9e4a90ba19033d25dca1eea495b0a8c5f06efbc6 diff --combined git-add--interactive.perl index df9f231635,e6f93c7c95..06f70602cc --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@@ -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) { diff --combined t/t3701-add-interactive.sh index fd2a55a5c2,63940b1893..62fd65e18d --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@@ -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 <