git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] Catch early trying rebasing to unknown ref, and add testcase.

From
Yann Dirson <ydirson@altern.org>
Date
Jun 6, 2007, 22:01 UTC
Message-ID
<20070606220147.18635.81773.stgit@gandelf.nowhere.earth>
In-Reply-To
<20070606215922.18635.38379.stgit@gandelf.nowhere.earth>
Signed-off-by: Yann Dirson <ydirson@altern.org>
---
 stgit/commands/rebase.py |    4 ++++
 t/t2200-rebase.sh        |   12 ++++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/stgit/commands/rebase.py b/stgit/commands/rebase.py
index d132b60..2f0e660 100644
--- a/stgit/commands/rebase.py
+++ b/stgit/commands/rebase.py
@@ -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)
diff --git a/t/t2200-rebase.sh b/t/t2200-rebase.sh
index 882572c..c142e08 100755
--- a/t/t2200-rebase.sh
+++ b/t/t2200-rebase.sh
@@ -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
Previous: Karl HasselströmNext: Yann Dirson
Message 4 of 5 in “Assorted fixes”
  1. 0/3 Assorted fixesYann Dirson, Jun 6, 2007
  2. 1/3 Robustify rebase test: check patches are reapplied.Yann Dirson, Jun 6, 2007
  3. Karl HasselströmJun 10, 2007
  4. 2/3 Catch early trying rebasing to unknown ref, and add testcase.Yann Dirson, Jun 6, 2007
  5. 3/3 Fixed typo in contrib/stg-whatchanged.Yann Dirson, Jun 6, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.