Subject: Re: git-rebase --abort eats files

From: Pete Harlan <[email-masked]>
Date: Mon, 28 Jun 2010 23:47:26 -0700

On 06/28/2010 06:23 PM, Madhu wrote:
>   |Date: Mon, 28 Jun 2010 11:05:17 +0200
>   |From: Ramkumar Ramachandra <[email-masked]>
>   |Cc: Madhu <[email-masked]>, [email-masked]
>   |
>   |> No, it can't be that simple. If rebase stopped due to a conflict
>   |> on a commit that added new files, then your version of rebase
>   |> --abort will leave these new files behind as untracked.
>   |
>   |Right. The interactive rebase has to be able to differentiate
>   |between files that you added to resolve a conflict and files that
>   |you added to retain at the end of the rebase -- and the interactive
>   |rebase has no information about this. Hence, this problem can't be
>   |fixed without explicitly finding out the intent of the user.
> 
> Wrong.  Rebase has to be able to differentaiate between two cases
> 
> 1. when there is a conflict, and the user is prompted to fix it, and
>  then continue with a git-add, git-commit, and git-rebase --continue
> 
> and 
> 
> 2. when the user is given a commit, which he is asked to git-commit
>   --amend, and then git-rebase --continue
> 
> Rebase is already aware of when each situation occurs.

If I read your original question correctly, the problem is: if you
have an untracked file in your directory before you start a rebase,
and then you add that file during the rebase, and then abort the
rebase, Git will delete your file from the working directory instead
of just returning it to its untracked state.

So aborting a rebase doesn't simply roll back time: it can be
destructive in a way the user may not expect.

The followups to the original question seem to me to be clouding the
issue with the question of what to do with any new material added
during a rebase, not just files that were originally present but
untracked.

Maybe it's not easy to solve the original problem, or maybe it's not
worth doing; maybe it's worth documenting.  (And documenting how to
recover the files, since they're in the object database for a while.)
I'd guess that to solve it rebase would have to do a "git status" when
it started, to see which files it should leave behind in the working
directory.  I'm not a Git hacker so that's just speculation.

But I think it's worth discussing this behavior on its own, separately
from the question about other material added during a rebase.

[As to what to do with other material added during a rebase, I'd like
it nuked.  When I abort a rebase it's because I've gummed things up
and want to start over.]

--Pete

> 
>   |In my opinion, you should simply stash your changes before aborting
>   |the rebase instead of adding files and figuring out some complex
>   |way of expressing intent.
> 
> This does not make sense.
> 
> --
> Madhu