Commit afdaa41
committed
stash: allow "git stash -p <pathspec>" to assume push again
Historically "git stash [<options>]" was assumed to mean "git stash save
[<options>]". Since 1ada502 (stash: use stash_push for no verb form,
2017-02-28) it is assumed to mean "git stash push [<options>]". As the
push subcommand supports pathspecs 9e14090 (stash: allow pathspecs
in the no verb form, 2017-02-28) allowed "git stash -p <pathspec>" to
mean "git stash push -p <pathspec>". This was broken in
8c3713c (stash: eliminate crude option parsing, 2020-02-17) which
failed to account for "push" being added to the start of argv in
cmd_stash() before it calls push_stash() and kept looking in argv[0] for
"-p" after moving the code to push_stash().
The support for assuming "push" when "-p" is given introduced in
9e14090 is very narrow, neither "git stash -m <message> -p
<pathspec>" nor "git stash --patch <pathspec>" imply "push" and die
instead. Fix the regression introduced by 8c3713c and relax the
behavior introduced in 9e14090 by passing
PARSE_OPT_STOP_AT_NON_OPTION when push is being assumed and then setting
"force_assume" if "--patch" was present. This means "git stash
<pathspec> -p" still dies so do assume the user meant "push" if they
mistype a subcommand name but "git stash -m <message> -p <pathspec>"
will now succeed. Tests are added to prevent future regressions.
Signed-off-by: Phillip Wood <[email protected]>1 parent 1a8a497 commit afdaa41
2 files changed
+26
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1789 | 1789 | | |
1790 | 1790 | | |
1791 | 1791 | | |
1792 | | - | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
1793 | 1797 | | |
1794 | 1798 | | |
1795 | | - | |
1796 | | - | |
| 1799 | + | |
| 1800 | + | |
1797 | 1801 | | |
1798 | 1802 | | |
1799 | 1803 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1177 | 1177 | | |
1178 | 1178 | | |
1179 | 1179 | | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
1180 | 1199 | | |
1181 | 1200 | | |
1182 | 1201 | | |
| |||
0 commit comments