Skip to content

Commit 7b8c705

Browse files
letogitster
authored andcommitted
Correct help blurb in checkout -p and friends
When git checkout -p from the index or HEAD is run in edit mode, the help message about removing '-' and '+' lines was backwards. Because it is reverse applying the patch, the meanings of '-' and '+' are reversed. Signed-off-by: Jonathan "Duke" Leto <[email protected]> Acked-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8a90438 commit 7b8c705

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

git-add--interactive.perl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ sub colored {
8787
TARGET => '',
8888
PARTICIPLE => 'staging',
8989
FILTER => 'file-only',
90+
IS_REVERSE => 0,
9091
},
9192
'stash' => {
9293
DIFF => 'diff-index -p HEAD',
@@ -96,6 +97,7 @@ sub colored {
9697
TARGET => '',
9798
PARTICIPLE => 'stashing',
9899
FILTER => undef,
100+
IS_REVERSE => 0,
99101
},
100102
'reset_head' => {
101103
DIFF => 'diff-index -p --cached',
@@ -105,6 +107,7 @@ sub colored {
105107
TARGET => '',
106108
PARTICIPLE => 'unstaging',
107109
FILTER => 'index-only',
110+
IS_REVERSE => 1,
108111
},
109112
'reset_nothead' => {
110113
DIFF => 'diff-index -R -p --cached',
@@ -114,6 +117,7 @@ sub colored {
114117
TARGET => ' to index',
115118
PARTICIPLE => 'applying',
116119
FILTER => 'index-only',
120+
IS_REVERSE => 0,
117121
},
118122
'checkout_index' => {
119123
DIFF => 'diff-files -p',
@@ -123,6 +127,7 @@ sub colored {
123127
TARGET => ' from worktree',
124128
PARTICIPLE => 'discarding',
125129
FILTER => 'file-only',
130+
IS_REVERSE => 1,
126131
},
127132
'checkout_head' => {
128133
DIFF => 'diff-index -p',
@@ -132,6 +137,7 @@ sub colored {
132137
TARGET => ' from index and worktree',
133138
PARTICIPLE => 'discarding',
134139
FILTER => undef,
140+
IS_REVERSE => 1,
135141
},
136142
'checkout_nothead' => {
137143
DIFF => 'diff-index -R -p',
@@ -141,6 +147,7 @@ sub colored {
141147
TARGET => ' to index and worktree',
142148
PARTICIPLE => 'applying',
143149
FILTER => undef,
150+
IS_REVERSE => 0,
144151
},
145152
);
146153

@@ -999,10 +1006,12 @@ sub edit_hunk_manually {
9991006
print $fh "# Manual hunk edit mode -- see bottom for a quick guide\n";
10001007
print $fh @$oldtext;
10011008
my $participle = $patch_mode_flavour{PARTICIPLE};
1009+
my $is_reverse = $patch_mode_flavour{IS_REVERSE};
1010+
my ($remove_plus, $remove_minus) = $is_reverse ? ('-', '+') : ('+', '-');
10021011
print $fh <<EOF;
10031012
# ---
1004-
# To remove '-' lines, make them ' ' lines (context).
1005-
# To remove '+' lines, delete them.
1013+
# To remove '$remove_minus' lines, make them ' ' lines (context).
1014+
# To remove '$remove_plus' lines, delete them.
10061015
# Lines starting with # will be removed.
10071016
#
10081017
# If the patch applies cleanly, the edited hunk will immediately be

0 commit comments

Comments
 (0)