Skip to content

Commit 9e4a90b

Browse files
committed
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
2 parents 57f6ec0 + 3d79216 commit 9e4a90b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

git-add--interactive.perl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,10 @@ sub coalesce_overlapping_hunks {
841841
my ($last_o_ctx, $last_was_dirty);
842842

843843
for (grep { $_->{USE} } @in) {
844+
if ($_->{TYPE} ne 'hunk') {
845+
push @out, $_;
846+
next;
847+
}
844848
my $text = $_->{TEXT};
845849
my ($o_ofs) = parse_hunk_header($text->[0]);
846850
if (defined $last_o_ctx &&

t/t3701-add-interactive.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,17 @@ test_expect_success FILEMODE 'stage mode but not hunk' '
163163
git diff file | grep "+content"
164164
'
165165

166+
167+
test_expect_success FILEMODE 'stage mode and hunk' '
168+
git reset --hard &&
169+
echo content >>file &&
170+
chmod +x file &&
171+
printf "y\\ny\\n" | git add -p &&
172+
git diff --cached file | grep "new mode" &&
173+
git diff --cached file | grep "+content" &&
174+
test -z "$(git diff file)"
175+
'
176+
166177
# end of tests disabled when filemode is not usable
167178

168179
test_expect_success 'setup again' '

0 commit comments

Comments
 (0)