git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yann Dirson <ydirson@altern.org>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [PATCH 2/3] Catch early trying rebasing to unknown ref, and add testcase.
Date: Thu, 07 Jun 2007 00:01:47 +0200	[thread overview]
Message-ID: <20070606220147.18635.81773.stgit@gandelf.nowhere.earth> (raw)
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

  parent reply	other threads:[~2007-06-06 22:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-06 22:01 [SGIT PATCH 0/3] Assorted fixes Yann Dirson
2007-06-06 22:01 ` [PATCH 1/3] Robustify rebase test: check patches are reapplied Yann Dirson
2007-06-10  8:40   ` Karl Hasselström
2007-06-06 22:01 ` Yann Dirson [this message]
2007-06-06 22:01 ` [PATCH 3/3] Fixed typo in contrib/stg-whatchanged Yann Dirson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070606220147.18635.81773.stgit@gandelf.nowhere.earth \
    --to=ydirson@altern.org \
    --cc=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).