# [PATCH 1/3] Robustify rebase test: check patches are reapplied.

5 messages from 2007-06-06 to 2007-06-10. Participants: Yann Dirson, Karl Hasselström.
Thread: https://gitlist.dev/t/8474

## Yann Dirson, 2007-06-06 22:01

Subject: [SGIT PATCH 0/3] Assorted fixes
Message-ID: <20070606215922.18635.38379.stgit@gandelf.nowhere.earth>
URL: https://gitlist.dev/e/20070606215922.18635.38379.stgit%40gandelf.nowhere.earth

```
This fixes the issue reported by Andrey Borzenkov, and robustifies
another testcase to catch any similar issue.

Also updates stg-whatchanged, which for some reason had been left
broken.

-- 
Yann Dirson    <ydirson@altern.org> |
Debian-related: <dirson@debian.org> |   Support Debian GNU/Linux:
                                    |  Freedom, Power, Stability, Gratis
     http://ydirson.free.fr/        | Check <http://www.debian.org/>

```

## Yann Dirson, 2007-06-06 22:01

Subject: [PATCH 1/3] Robustify rebase test: check patches are reapplied.
Message-ID: <20070606220142.18635.3961.stgit@gandelf.nowhere.earth>
URL: https://gitlist.dev/e/20070606220142.18635.3961.stgit%40gandelf.nowhere.earth
In-Reply-To: <20070606215922.18635.38379.stgit@gandelf.nowhere.earth>

```

Signed-off-by: Yann Dirson <ydirson@altern.org>

---

 t/t2200-rebase.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/t/t2200-rebase.sh b/t/t2200-rebase.sh
index 52462dd..882572c 100755
--- a/t/t2200-rebase.sh
+++ b/t/t2200-rebase.sh
@@ -27,7 +27,8 @@ test_expect_success \
 	'Rebase to previous commit' \
 	'
 	stg rebase master~1 &&
-	test `stg id base@stack` = `git rev-parse master~1`
+	test `stg id base@stack` = `git rev-parse master~1` &&
+	test `stg applied | wc -l` = 1
 	'
 
 test_done

```

## Yann Dirson, 2007-06-06 22:01

Subject: [PATCH 2/3] Catch early trying rebasing to unknown ref, and add testcase.
Message-ID: <20070606220147.18635.81773.stgit@gandelf.nowhere.earth>
URL: https://gitlist.dev/e/20070606220147.18635.81773.stgit%40gandelf.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

```

## Yann Dirson, 2007-06-06 22:01

Subject: [PATCH 3/3] Fixed typo in contrib/stg-whatchanged.
Message-ID: <20070606220152.18635.43506.stgit@gandelf.nowhere.earth>
URL: https://gitlist.dev/e/20070606220152.18635.43506.stgit%40gandelf.nowhere.earth
In-Reply-To: <20070606215922.18635.38379.stgit@gandelf.nowhere.earth>

```

Signed-off-by: Yann Dirson <ydirson@altern.org>

---

 contrib/stg-whatchanged |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/contrib/stg-whatchanged b/contrib/stg-whatchanged
index f80d0a1..d5b6965 100755
--- a/contrib/stg-whatchanged
+++ b/contrib/stg-whatchanged
@@ -23,7 +23,7 @@ fi
 
 # Merges via "push" leave top=bottom so we must look at old patch
 # in this case (unlike, eg., "pick --fold")
-patchdir="$(git-rev-parse --git-dir)/patches/$(stg branch)/$(stg top)"
+patchdir="$(git-rev-parse --git-dir)/patches/$(stg branch)/patches/$(stg top)"
 if [ $(cat "$patchdir/bottom") = $(cat "$patchdir/top") ];
 then
     current_cmd="stg show //top.old"

```

## Karl Hasselström, 2007-06-10 08:40

Subject: Re: [PATCH 1/3] Robustify rebase test: check patches are reapplied.
Message-ID: <20070610084045.GA31274@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20070610084045.GA31274%40diana.vm.bytemark.co.uk
In-Reply-To: <20070606220142.18635.3961.stgit@gandelf.nowhere.earth>

```
On 2007-06-07 00:01:42 +0200, Yann Dirson wrote:

> +	test `stg applied | wc -l` = 1

Unimportant note: I believe "stg applied" has a -c (count) flag for
precisely this purpose.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```
