# [PATCH] Clean up .dotest if an error occurs before rebase work starts

2 messages from 2007-09-05 to 2007-09-05. Participants: Robin Rosenberg, Junio C Hamano.
Thread: https://gitlist.dev/t/9785

## Robin Rosenberg, 2007-09-05 19:27

Subject: [PATCH] Clean up .dotest if an error occurs before rebase work starts
Message-ID: <1189020436633-git-send-email-robin.rosenberg@dewire.com>
URL: https://gitlist.dev/e/1189020436633-git-send-email-robin.rosenberg%40dewire.com

```
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 git-rebase.sh |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/git-rebase.sh b/git-rebase.sh
index 3bd66b0..81c48d1 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -253,23 +253,33 @@ else
 fi
 
 # The tree must be really really clean.
-git update-index --refresh || exit
+git update-index --refresh || {
+	rm -rf .dotest
+	exit 1
+}
+
 diff=$(git diff-index --cached --name-status -r HEAD)
 case "$diff" in
 ?*)	echo "cannot rebase: your index is not up-to-date"
 	echo "$diff"
+	rm -rf .dotest
 	exit 1
 	;;
 esac
 
 # The upstream head must be given.  Make sure it is valid.
 upstream_name="$1"
-upstream=`git rev-parse --verify "${upstream_name}^0"` ||
-    die "invalid upstream $upstream_name"
+upstream=`git rev-parse --verify "${upstream_name}^0"` || {
+	rm -rf .dotest
+	die "invalid upstream $upstream_name"
+}
 
 # Make sure the branch to rebase onto is valid.
 onto_name=${newbase-"$upstream_name"}
-onto=$(git rev-parse --verify "${onto_name}^0") || exit
+onto=$(git rev-parse --verify "${onto_name}^0") || {
+	rm -rf .dotest
+	exit 1
+}
 
 # If a hook exists, give it a chance to interrupt
 if test -x "$GIT_DIR/hooks/pre-rebase"
-- 
1.5.3

```

## Junio C Hamano, 2007-09-05 20:07

Subject: Re: [PATCH] Clean up .dotest if an error occurs before rebase work starts
Message-ID: <7vmyw0j2q9.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vmyw0j2q9.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <1189020436633-git-send-email-robin.rosenberg@dewire.com>

```
It looks to me that we should instead delay the creation of
that .dotest directory until we determine that we _are_ going to
be able to run git-rebase, no?

```
