# rebase-merge/done: No such file or directory

5 messages from 2009-01-12 to 2009-01-13. Participants: jidanni@jidanni.org, Johannes Schindelin, Adeodato Simó, Junio C Hamano, Pierre Habouzit.
Thread: https://gitlist.dev/t/17123

## jidanni@jidanni.org, 2009-01-12 19:13

Subject: rebase-merge/done: No such file or directory
Message-ID: <87ocycjq29.fsf@jidanni.org>
URL: https://gitlist.dev/e/87ocycjq29.fsf%40jidanni.org

```
Bug at git-rebase--interactive.sh:107: count=$(grep -c '^[^#]' < "$DONE")

$DONE might not exist. Do test -f $DONE before you grep it.

This will happen if the user gave a wrong squash choice.

$ git rebase --interactive ...
Waiting for Emacs...
grep: .git/rebase-merge/done: No such file or directory
Cannot 'squash' without a previous commit

```

## Johannes Schindelin, 2009-01-12 22:47

Subject: Re: rebase-merge/done: No such file or directory
Message-ID: <alpine.DEB.1.00.0901122342420.3586@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0901122342420.3586%40pacific.mpi-cbg.de
In-Reply-To: <87ocycjq29.fsf@jidanni.org>

```
Hi,

On Tue, 13 Jan 2009, jidanni@jidanni.org wrote:

> Bug at git-rebase--interactive.sh:107: count=$(grep -c '^[^#]' < "$DONE")

Woohoo.  Buuuug.

> $DONE might not exist. Do test -f $DONE before you grep it.

I cannot reproduce here.  Since all the files in .git/rebase-merge/ are 
internal files to rebase--interactive, I think we do not have to guard 
against any possible user action rendering assumptions about internals 
invalid.

Wasting a minute, I seem to understand why I cannot reproduce.  Just 
looking all of _two_ lines above the line you mentioned:

	sed -e 1q < "$TODO" >> "$DONE"

Hrmpf.  You're right.  The user could have removed "$DONE"e between the 
two lines ;-)

Hth,
Dscho

```

## Adeodato Simó, 2009-01-12 23:02

Subject: Re: rebase-merge/done: No such file or directory
Message-ID: <20090112230228.GA28545@chistera.yi.org>
URL: https://gitlist.dev/e/20090112230228.GA28545%40chistera.yi.org
In-Reply-To: <alpine.DEB.1.00.0901122342420.3586@pacific.mpi-cbg.de>

```
* Johannes Schindelin [Mon, 12 Jan 2009 23:47:47 +0100]:

> > $DONE might not exist. Do test -f $DONE before you grep it.

> I cannot reproduce here.  Since all the files in .git/rebase-merge/ are 
> internal files to rebase--interactive, I think we do not have to guard 
> against any possible user action rendering assumptions about internals 
> invalid.

> Wasting a minute, I seem to understand why I cannot reproduce.  Just 
> looking all of _two_ lines above the line you mentioned:

> 	sed -e 1q < "$TODO" >> "$DONE"

> Hrmpf.  You're right.  The user could have removed "$DONE"e between the 
> two lines ;-)

No, not really. Start a rebase -i. Change the *first* "pick" to a
"squash". Save and exit the editor. You'll see the output jidanni
mentioned:

  grep: .git/rebase-merge/done: No such file or directory
  Cannot 'squash' without a previous commit

The second line tells the user what happened (what their error was), but
I guess we could do without the first one.

-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
Debugging is twice as hard as writing the code in the first place. Therefore,
if you write the code as cleverly as possible, you are, by definition, not
smart enough to debug it.
                -- Brian W. Kernighan

```

## Pierre Habouzit, 2009-01-12 23:09

Subject: [PATCH] Avoid spurious error messages on error mistakes.
Message-ID: <1231801776-20724-1-git-send-email-madcoder@debian.org>
URL: https://gitlist.dev/e/1231801776-20724-1-git-send-email-madcoder%40debian.org
In-Reply-To: <20090112230228.GA28545@chistera.yi.org>

```
Prior to that, if the user chose "squash" as a first action, the stderr
looked like:

    grep: /home/madcoder/dev/scm/git/.git/rebase-merge/done: No such file or directory
    Cannot 'squash' without a previous commit

Now the first line is gone.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
 git-rebase--interactive.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index c8b0861..8ed2244 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -349,7 +349,7 @@ do_next () {
 	squash|s)
 		comment_for_reflog squash
 
-		has_action "$DONE" ||
+		test -f "$DONE" && has_action "$DONE" ||
 			die "Cannot 'squash' without a previous commit"
 
 		mark_action_done
-- 
1.6.1.161.g5e07b.dirty


```

## Junio C Hamano, 2009-01-13 08:20

Subject: Re: [PATCH] Avoid spurious error messages on error mistakes.
Message-ID: <7vk58zd3c3.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vk58zd3c3.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <1231801776-20724-1-git-send-email-madcoder@debian.org>

```
Pierre Habouzit <madcoder@debian.org> writes:

> Prior to that, if the user chose "squash" as a first action, the stderr
> looked like:
>
>     grep: /home/madcoder/dev/scm/git/.git/rebase-merge/done: No such file or directory
>     Cannot 'squash' without a previous commit
>
> Now the first line is gone.
>
> Signed-off-by: Pierre Habouzit <madcoder@debian.org>
> ---
>  git-rebase--interactive.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index c8b0861..8ed2244 100755
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -349,7 +349,7 @@ do_next () {
>  	squash|s)
>  		comment_for_reflog squash
>  
> -		has_action "$DONE" ||
> +		test -f "$DONE" && has_action "$DONE" ||
>  			die "Cannot 'squash' without a previous commit"
>  
>  		mark_action_done
> -- 
> 1.6.1.161.g5e07b.dirty

Make sense.  Will apply to maint.

```
