@@ -149,6 +149,20 @@ sub colored {
149
149
FILTER => undef ,
150
150
IS_REVERSE => 0,
151
151
},
152
+ ' worktree_head' => {
153
+ DIFF => ' diff-index -p' ,
154
+ APPLY => sub { apply_patch ' apply -R' , @_ },
155
+ APPLY_CHECK => ' apply -R' ,
156
+ FILTER => undef ,
157
+ IS_REVERSE => 1,
158
+ },
159
+ ' worktree_nothead' => {
160
+ DIFF => ' diff-index -R -p' ,
161
+ APPLY => sub { apply_patch ' apply' , @_ },
162
+ APPLY_CHECK => ' apply' ,
163
+ FILTER => undef ,
164
+ IS_REVERSE => 0,
165
+ },
152
166
);
153
167
154
168
$patch_mode = ' stage' ;
@@ -1049,6 +1063,12 @@ sub color_diff {
1049
1063
marked for discarding." ),
1050
1064
checkout_nothead => N__(
1051
1065
" If the patch applies cleanly, the edited hunk will immediately be
1066
+ marked for applying." ),
1067
+ worktree_head => N__(
1068
+ " If the patch applies cleanly, the edited hunk will immediately be
1069
+ marked for discarding." ),
1070
+ worktree_nothead => N__(
1071
+ " If the patch applies cleanly, the edited hunk will immediately be
1052
1072
marked for applying." ),
1053
1073
);
1054
1074
@@ -1259,6 +1279,18 @@ sub edit_hunk_loop {
1259
1279
n - do not apply this hunk to index and worktree
1260
1280
q - quit; do not apply this hunk or any of the remaining ones
1261
1281
a - apply this hunk and all later hunks in the file
1282
+ d - do not apply this hunk or any of the later hunks in the file" ),
1283
+ worktree_head => N__(
1284
+ " y - discard this hunk from worktree
1285
+ n - do not discard this hunk from worktree
1286
+ q - quit; do not discard this hunk or any of the remaining ones
1287
+ a - discard this hunk and all later hunks in the file
1288
+ d - do not discard this hunk or any of the later hunks in the file" ),
1289
+ worktree_nothead => N__(
1290
+ " y - apply this hunk to worktree
1291
+ n - do not apply this hunk to worktree
1292
+ q - quit; do not apply this hunk or any of the remaining ones
1293
+ a - apply this hunk and all later hunks in the file
1262
1294
d - do not apply this hunk or any of the later hunks in the file" ),
1263
1295
);
1264
1296
@@ -1421,6 +1453,16 @@ sub display_hunks {
1421
1453
deletion => N__(" Apply deletion to index and worktree [y,n,q,a,d%s ,?]? " ),
1422
1454
hunk => N__(" Apply this hunk to index and worktree [y,n,q,a,d%s ,?]? " ),
1423
1455
},
1456
+ worktree_head => {
1457
+ mode => N__(" Discard mode change from worktree [y,n,q,a,d%s ,?]? " ),
1458
+ deletion => N__(" Discard deletion from worktree [y,n,q,a,d%s ,?]? " ),
1459
+ hunk => N__(" Discard this hunk from worktree [y,n,q,a,d%s ,?]? " ),
1460
+ },
1461
+ worktree_nothead => {
1462
+ mode => N__(" Apply mode change to worktree [y,n,q,a,d%s ,?]? " ),
1463
+ deletion => N__(" Apply deletion to worktree [y,n,q,a,d%s ,?]? " ),
1464
+ hunk => N__(" Apply this hunk to worktree [y,n,q,a,d%s ,?]? " ),
1465
+ },
1424
1466
);
1425
1467
1426
1468
sub patch_update_file {
@@ -1756,6 +1798,16 @@ sub process_args {
1756
1798
' checkout_head' : ' checkout_nothead' );
1757
1799
$arg = shift @ARGV or die __(" missing --" );
1758
1800
}
1801
+ } elsif ($1 eq ' worktree' ) {
1802
+ $arg = shift @ARGV or die __(" missing --" );
1803
+ if ($arg eq ' --' ) {
1804
+ $patch_mode = ' checkout_index' ;
1805
+ } else {
1806
+ $patch_mode_revision = $arg ;
1807
+ $patch_mode = ($arg eq ' HEAD' ?
1808
+ ' worktree_head' : ' worktree_nothead' );
1809
+ $arg = shift @ARGV or die __(" missing --" );
1810
+ }
1759
1811
} elsif ($1 eq ' stage' or $1 eq ' stash' ) {
1760
1812
$patch_mode = $1 ;
1761
1813
$arg = shift @ARGV or die __(" missing --" );
0 commit comments