Skip to content

Commit 3191d91

Browse files
committed
feat(pop): allow unescaped negative patch offsets
This allows, for example, `stg pop -1` to pop the patch preceding the topmost patch. Previously, a negative relative patch offset would have had to been escaped, e.g. `stg pop '\-1'`
1 parent b42de59 commit 3191d91

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/cmd/pop.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ fn make() -> clap::Command {
5050
.help("Patches to pop")
5151
.value_name("patch")
5252
.num_args(1..)
53+
.allow_negative_numbers(true)
5354
.value_parser(clap::value_parser!(PatchRange))
5455
.conflicts_with_all(["all", "number"]),
5556
)

t/t1208-push-and-pop.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ test_expect_success 'Check prev, next, and top with all applied' '
4242
'
4343

4444
test_expect_success 'Pop three patches' '
45-
stg pop -n 3 &&
45+
stg pop -n3 &&
4646
[ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 p3 p4 p5 p6" ] &&
4747
[ "$(echo $(stg series --unapplied --noprefix))" = "p7 p8 p9" ]
4848
'
@@ -126,6 +126,12 @@ test_expect_success 'Push two patches in reverse' '
126126
[ "$(git notes show)" = "note7" ]
127127
'
128128

129+
test_expect_success 'Pop relative patch offset' '
130+
stg pop -4 &&
131+
[ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 p3 p5 p6 p8 p7" ] &&
132+
[ "$(echo $(stg series --unapplied --noprefix))" = "p4 p9" ]
133+
'
134+
129135
test_expect_success 'Attempt to push already applied patches' '
130136
command_error stg push p0..p2 2>err &&
131137
grep -e "patch \`p0\` is already applied" err &&

0 commit comments

Comments
 (0)