Skip to content

Commit

Permalink
Merge branch 'tr/maint-1.6.3-add-p-modeonly-fix' into maint-1.6.3
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Junio C Hamano committed Aug 26, 2009
2 parents 57f6ec0 + 3d79216 commit 9e4a90b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions git-add--interactive.perl
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
11 changes: 11 additions & 0 deletions t/t3701-add-interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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' '
Expand Down

0 comments on commit 9e4a90b

Please sign in to comment.