git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git-rebase --abort eats files
@ 2010-06-26 12:53 Madhu
  2010-06-26 18:09 ` Johannes Sixt
  2013-08-31 15:26 ` git-rebase --continue eats commits Madhu
  0 siblings, 2 replies; 6+ messages in thread
From: Madhu @ 2010-06-26 12:53 UTC (permalink / raw)
  To: git

Don't know if this has been resolved-by-debate here before, But adding
a file via git-add in the middle of an interactive rebase and aborting
the rebase deletes the hitherto untracked file.  It should not. 

rm -rfv /tmp/t1 ; mkdir -pv /tmp/t1
cd /tmp/t1 && git-init-db
cd /tmp/t1 && touch file1 file2 file3
cd /tmp/t1 && git-add file1
cd /tmp/t1 && git-commit -m "Explet1" file1
cd /tmp/t1 && git-add file2
cd /tmp/t1 && git-commit -m "Explet2" file2
cd /tmp/t1 && git-rebase --abort
cd /tmp/t1 && EDITOR="sed -i -e 's/^pick/edit/'" git rebase -i 'HEAD^'
cd /tmp/t1 && git-add file3
cd /tmp/t1 && git-status
cd /tmp/t1 && git-rebase --abort
test -e /tmp/t1/file3 || echo bwaaah

Maybe something like this to fix it?

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 436b7f5..2702536 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -749,6 +749,7 @@ first and then run 'git rebase --continue' again."
                        git symbolic-ref HEAD $HEADNAME
                        ;;
                esac &&
+               git-reset &&
                output git reset --hard $HEAD &&
                rm -rf "$DOTEST"
                exit

--
Madhu

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: git-rebase --abort eats files
  2010-06-26 12:53 git-rebase --abort eats files Madhu
@ 2010-06-26 18:09 ` Johannes Sixt
  2010-06-28  9:05   ` Ramkumar Ramachandra
  2013-08-31 15:26 ` git-rebase --continue eats commits Madhu
  1 sibling, 1 reply; 6+ messages in thread
From: Johannes Sixt @ 2010-06-26 18:09 UTC (permalink / raw)
  To: Madhu; +Cc: git

On Samstag, 26. Juni 2010, Madhu wrote:
> Don't know if this has been resolved-by-debate here before, But adding
> a file via git-add in the middle of an interactive rebase and aborting
> the rebase deletes the hitherto untracked file.  It should not.
>
> Maybe something like this to fix it?
>
> +++ b/git-rebase--interactive.sh
> @@ -749,6 +749,7 @@ first and then run 'git rebase --continue' again."
>                         git symbolic-ref HEAD $HEADNAME
>                         ;;
>                 esac &&
> +               git-reset &&
>                 output git reset --hard $HEAD &&
>                 rm -rf "$DOTEST"
>                 exit

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.

-- Hannes

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git-rebase --abort eats files
  2010-06-26 18:09 ` Johannes Sixt
@ 2010-06-28  9:05   ` Ramkumar Ramachandra
  2010-06-29  1:23     ` Madhu
  0 siblings, 1 reply; 6+ messages in thread
From: Ramkumar Ramachandra @ 2010-06-28  9:05 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Madhu, git

Hi Madhu,

Johannes Sixt wrote:
> On Samstag, 26. Juni 2010, Madhu wrote:
> > +++ b/git-rebase--interactive.sh
> > @@ -749,6 +749,7 @@ first and then run 'git rebase --continue' again."
> >                         git symbolic-ref HEAD $HEADNAME
> >                         ;;
> >                 esac &&
> > +               git-reset &&
> >                 output git reset --hard $HEAD &&
> >                 rm -rf "$DOTEST"
> >                 exit
> 
> 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. 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.

-- Ram

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git-rebase --abort eats files
  2010-06-28  9:05   ` Ramkumar Ramachandra
@ 2010-06-29  1:23     ` Madhu
  2010-06-29  6:47       ` Pete Harlan
  0 siblings, 1 reply; 6+ messages in thread
From: Madhu @ 2010-06-29  1:23 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: j6t, git

  |Date: Mon, 28 Jun 2010 11:05:17 +0200
  |From: Ramkumar Ramachandra <artagnon@gmail.com>
  |Cc: Madhu <enometh@meer.net>, git@vger.kernel.org
  |Content-Type: text/plain; charset=us-ascii
  |Content-Disposition: inline
  |
  |> 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.

  |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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git-rebase --abort eats files
  2010-06-29  1:23     ` Madhu
@ 2010-06-29  6:47       ` Pete Harlan
  0 siblings, 0 replies; 6+ messages in thread
From: Pete Harlan @ 2010-06-29  6:47 UTC (permalink / raw)
  To: Madhu; +Cc: Ramkumar Ramachandra, j6t, git

On 06/28/2010 06:23 PM, Madhu wrote:
>   |Date: Mon, 28 Jun 2010 11:05:17 +0200
>   |From: Ramkumar Ramachandra <artagnon@gmail.com>
>   |Cc: Madhu <enometh@meer.net>, git@vger.kernel.org
>   |
>   |> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* git-rebase --continue eats commits
  2010-06-26 12:53 git-rebase --abort eats files Madhu
  2010-06-26 18:09 ` Johannes Sixt
@ 2013-08-31 15:26 ` Madhu
  1 sibling, 0 replies; 6+ messages in thread
From: Madhu @ 2013-08-31 15:26 UTC (permalink / raw)
  To: git


Don't know if this has been resolved-by-debate here before, But if
`git-rebase' finds a hitherto untracked file in the worktree, which it
wants to create, it then aborts asking you to remove the file.  So if
you remove it and ask git to continue with `git-rebase --continue', it
then deletes the commit that was being applied from the branch. ---Madhu


(setenv "TDIR" "/dev/shm/foo/")

mkdir -pv $TDIR && cd $TDIR && git-init
(cd $TDIR && echo a > a && git add a && git commit -m "a")
(cd $TDIR && echo b > b && git add b && git commit -m "b")
(cd $TDIR && echo c > c && git add c && git commit -m "c")
(cd $TDIR && EDITOR="sed -i -e 's/^pick/edit/'" git rebase -i 'HEAD^^')
(cd $TDIR && echo fubar > c)
(cd $TDIR && git-rebase --continue)

    Rebasing (2/2)
error: The following untracked working tree files would be overwritten by merge:
	c
    Please move or remove them before you can merge.
    Aborting
    Could not apply ddd6f51...

(cd $TDIR && rm -fv c)
(cd $TDIR && git-rebase --continue)

    Rebasing (2/2)
Successfully rebased and updated refs/heads/master.

(cd $TDIR && git log)

;; commit `c' is gone

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-08-31 15:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-26 12:53 git-rebase --abort eats files Madhu
2010-06-26 18:09 ` Johannes Sixt
2010-06-28  9:05   ` Ramkumar Ramachandra
2010-06-29  1:23     ` Madhu
2010-06-29  6:47       ` Pete Harlan
2013-08-31 15:26 ` git-rebase --continue eats commits Madhu

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).