Catch early trying rebasing to unknown ref, and add testcase.
authorYann Dirson <ydirson@altern.org>
Wed, 6 Jun 2007 22:01:47 +0000 (00:01 +0200)
committerCatalin Marinas <catalin.marinas@gmail.com>
Thu, 7 Jun 2007 21:52:23 +0000 (22:52 +0100)
Signed-off-by: Yann Dirson <ydirson@altern.org>
stgit/commands/rebase.py
t/t2200-rebase.sh

index d132b60..2f0e660 100644 (file)
@@ -52,6 +52,10 @@ def func(parser, options, args):
     check_conflicts()
     check_head_top_equal()
 
+    # ensure an exception is raised before popping on non-existent target
+    if git_id(args[0]) == None:
+        raise GitException, 'Unknown revision: %s' % git_id
+        
     applied = prepare_rebase(real_rebase=True, force=options.force)
     rebase(args[0])
     post_rebase(applied, options.nopush, options.merged)
index 882572c..c142e08 100755 (executable)
@@ -31,4 +31,16 @@ test_expect_success \
        test `stg applied | wc -l` = 1
        '
 
+test_expect_failure \
+       'Attempt rebase to non-existing commit' \
+       '
+       stg rebase not-a-ref
+       '
+
+test_expect_success \
+       'Check patches were re-applied' \
+       '
+       test $(stg applied | wc -l) = 1
+       '
+
 test_done