From 3d792161b1c86632d5331bb30d6b7c6b17261f38 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Sat, 15 Aug 2009 15:56:39 +0200 Subject: add -p: do not attempt to coalesce mode changes 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 Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- git-add--interactive.perl | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'git-add--interactive.perl') diff --git a/git-add--interactive.perl b/git-add--interactive.perl index a06172c69..e6f93c7c9 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -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 && -- cgit v1.2.1