Skip to content

Commit

Permalink
add -p: do not attempt to coalesce mode changes
Browse files Browse the repository at this point in the history
In 0392513 (add-interactive: refactor mode hunk handling, 2009-04-16),
we merged the interaction loops for mode changes and hunk staging.
This was fine at the time, because 0beee4c (git-add--interactive:
remove hunk coalescing, 2008-07-02) removed hunk coalescing.

However, in 7a26e65 (Revert "git-add--interactive: remove hunk
coalescing", 2009-05-16), we resurrected it.  Since then, the code
would attempt in vain to merge mode changes with diff hunks,
corrupting both in the process.

We add a check to the coalescing loop to ensure it only looks at diff
hunks, thus skipping mode changes.

Noticed-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Thomas Rast authored and Junio C Hamano committed Aug 15, 2009
1 parent 87ca2ea commit 3d79216
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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
2 changes: 1 addition & 1 deletion t/t3701-add-interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ test_expect_success FILEMODE 'stage mode but not hunk' '
'


test_expect_failure FILEMODE 'stage mode and hunk' '
test_expect_success FILEMODE 'stage mode and hunk' '
git reset --hard &&
echo content >>file &&
chmod +x file &&
Expand Down

0 comments on commit 3d79216

Please sign in to comment.