if len(args) > 0:
patches = parse_patches(args, all)
else:
- patches = [ crt_series.get_current() ]
+ current = crt_series.get_current()
+ if not current:
+ raise CmdException('No patch applied')
+ patches = [current]
- crt_series.pop_patch(options.to or oldapplied[0])
+ if oldapplied:
+ crt_series.pop_patch(options.to or oldapplied[0])
push_patches(crt_series, patches)
if not options.nopush:
--- /dev/null
+#!/bin/sh
+
+test_description='Test "stg sink"'
+
+. ./test-lib.sh
+
+test_expect_success 'Initialize StGit stack' '
+ echo 000 >> x &&
+ git add x &&
+ git commit -m initial &&
+ echo 000 >> y &&
+ git add y &&
+ git commit -m y &&
+ stg init &&
+ stg uncommit &&
+ stg pop
+'
+
+test_expect_success 'sink without applied patches' '
+ ! stg sink
+'
+
+test_expect_success 'sink a specific patch without applied patches' '
+ stg sink y &&
+ test $(echo $(stg applied)) = "y"
+'
+
+test_done