@matheusbsbs / matheus-bagliano / commits / 7b8c705188
Fork 0

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 <jonathan@leto.net> Acked-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan "Duke" Leto committed Oct 27, 2010 at 17:49 UTC 7b8c70518894db9c6376913be04c2c8bf9827e4d
1 file changed +11 -2
git-add--interactive.perl
+11 -2
@@ -87,6 +87,7 @@ my %patch_modes = (
87 TARGET => '',
88 PARTICIPLE => 'staging',
89 FILTER => 'file-only',
90 + IS_REVERSE => 0,
91 },
92 'stash' => {
93 DIFF => 'diff-index -p HEAD',
@@ -96,6 +97,7 @@ my %patch_modes = (
97 TARGET => '',
98 PARTICIPLE => 'stashing',
99 FILTER => undef,
100 + IS_REVERSE => 0,
101 },
102 'reset_head' => {
103 DIFF => 'diff-index -p --cached',
@@ -105,6 +107,7 @@ my %patch_modes = (
107 TARGET => '',
108 PARTICIPLE => 'unstaging',
109 FILTER => 'index-only',
110 + IS_REVERSE => 1,
111 },
112 'reset_nothead' => {
113 DIFF => 'diff-index -R -p --cached',
@@ -114,6 +117,7 @@ my %patch_modes = (
117 TARGET => ' to index',
118 PARTICIPLE => 'applying',
119 FILTER => 'index-only',
120 + IS_REVERSE => 0,
121 },
122 'checkout_index' => {
123 DIFF => 'diff-files -p',
@@ -123,6 +127,7 @@ my %patch_modes = (
127 TARGET => ' from worktree',
128 PARTICIPLE => 'discarding',
129 FILTER => 'file-only',
130 + IS_REVERSE => 1,
131 },
132 'checkout_head' => {
133 DIFF => 'diff-index -p',
@@ -132,6 +137,7 @@ my %patch_modes = (
137 TARGET => ' from index and worktree',
138 PARTICIPLE => 'discarding',
139 FILTER => undef,
140 + IS_REVERSE => 1,
141 },
142 'checkout_nothead' => {
143 DIFF => 'diff-index -R -p',
@@ -141,6 +147,7 @@ my %patch_modes = (
147 TARGET => ' to index and worktree',
148 PARTICIPLE => 'applying',
149 FILTER => undef,
150 + IS_REVERSE => 0,
151 },
152 );
153
@@ -999,10 +1006,12 @@ sub edit_hunk_manually {
1006 print $fh "# Manual hunk edit mode -- see bottom for a quick guide\n";
1007 print $fh @$oldtext;
1008 my $participle = $patch_mode_flavour{PARTICIPLE};
1009 + my $is_reverse = $patch_mode_flavour{IS_REVERSE};
1010 + my ($remove_plus, $remove_minus) = $is_reverse ? ('-', '+') : ('+', '-');
1011 print $fh <<EOF;
1012 # ---
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.
1015 # Lines starting with # will be removed.
1016 #
1017 # If the patch applies cleanly, the edited hunk will immediately be