Skip to contentSkip to conversation

git rebase --skip

PATCH New Mike Hommey 9 participants 20 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

I use git-rebase quite regularly, and I haven't used git-rebase --skip after a failed merge without first resetting the working tree. I was wondering if it wouldn't make sense to automatically do the reset when running git-rebase --skip.

Mike

#1 lore raw

PATCH 1/1 Do git reset --hard HEAD when using git rebase --skip

When you have a merge conflict and want to bypass the commit causing it, you don't want to care about the dirty state of the working tree.

Also, don't git reset --hard HEAD in the rebase-skip test, so that the lack of support for this is detected.

---
 git-rebase.sh          |    1 +
 t/t3403-rebase-skip.sh |    2 --
 2 files changed, 1 insertions(+), 2 deletions(-)
git-rebase.sh +1 -0
index e3ad7de..8814be9 100755
@@ -158,6 +158,7 @@ do
 		exit
 		;;
 	--skip)
+		git reset --hard HEAD || exit $?
 		if test -d "$dotest"
 		then
 			git rerere clear
t/t3403-rebase-skip.sh +0 -2
index eab053c..becabfc 100755
@@ -36,7 +36,6 @@ test_expect_failure 'rebase with git am -3 (default)' '
 '
 
 test_expect_success 'rebase --skip with am -3' '
-	git reset --hard HEAD &&
 	git rebase --skip
 	'
 test_expect_success 'checkout skip-merge' 'git checkout -f skip-merge'
@@ -44,7 +43,6 @@ test_expect_success 'checkout skip-merge' 'git checkout -f skip-merge'
 test_expect_failure 'rebase with --merge' 'git rebase --merge master'
 
 test_expect_success 'rebase --skip with --merge' '
-	git reset --hard HEAD &&
 	git rebase --skip
 	'
 
Signature · 1 line
1.5.3.5
#2 lore raw
In reply to Mike Hommey
Quoted 4 lines · Mike Hommey

I use git-rebase quite regularly, and I haven't used git-rebase --skip after a failed merge without first resetting the working tree. I was wondering if it wouldn't make sense to automatically do the reset when running git-rebase --skip.

I have often been annoyed by this behavior, too, and I can't think of any situation where you _wouldn't_ want the reset to happen. But I would be more comfortable hearing confirmation from others that they can't think of such a situation.

-Peff

#3 lore raw
Quoted 11 lines · Jeff King
Quoted 4 lines · Mike Hommey

I use git-rebase quite regularly, and I haven't used git-rebase --skip after a failed merge without first resetting the working tree. I was wondering if it wouldn't make sense to automatically do the reset when running git-rebase --skip.

I have often been annoyed by this behavior, too, and I can't think of any situation where you _wouldn't_ want the reset to happen. But I would be more comfortable hearing confirmation from others that they can't think of such a situation.

Let's take this history:

      C---D---E topic
     /
    A---B master

You then do:
git rebase master topic

Now D causes conflicts, because B did a similar change, but not quite the same, maybe having a bug. So you want to keep parts of D, but it's no longer the same commit semantically and the original commit message would be bogus. So you resolve the conflicts and do:

git commit
git rebase --skip

Because you replaced D with a new different commit, instead of really just rebasing it. With plain --continue, you'd have to go back and fix the commit message once the rebase is complete. And --continue after the commit is a no-go, too, because rebase will complain that there's nothing left to produce the rebased D commit.

And now imagine that you forget to commit but instead just --skip. Ouch, all the work is lost, time to restart the rebase. With the current behaviour, rebase won't just throw away your stuff.

Björn

#4 lore raw
Quoted 35 lines · Björn Steinbrink
Quoted 10 lines · Jeff King
Quoted 4 lines · Mike Hommey

I use git-rebase quite regularly, and I haven't used git-rebase --skip after a failed merge without first resetting the working tree. I was wondering if it wouldn't make sense to automatically do the reset when running git-rebase --skip.

I have often been annoyed by this behavior, too, and I can't think of any situation where you _wouldn't_ want the reset to happen. But I would be more comfortable hearing confirmation from others that they can't think of such a situation.

Let's take this history:

      C---D---E topic
     /
    A---B master

You then do:
git rebase master topic

Now D causes conflicts, because B did a similar change, but not quite the same, maybe having a bug. So you want to keep parts of D, but it's no longer the same commit semantically and the original commit message would be bogus. So you resolve the conflicts and do:

git commit
git rebase --skip

Because you replaced D with a new different commit, instead of really just rebasing it. With plain --continue, you'd have to go back and fix the commit message once the rebase is complete. And --continue after the commit is a no-go, too, because rebase will complain that there's nothing left to produce the rebased D commit.

Quoted 4 lines

And now imagine that you forget to commit but instead just --skip. Ouch, all the work is lost, time to restart the rebase. With the current behaviour, rebase won't just throw away your stuff.

How about if the state to skip was stashed, the patch reapplied and the differences compared. If they were identical, go ahead and force the reset --hard, otherwise abort. That way, --skip will dwim only when it's safe, and all the lost work can be automagically created by just re-applying the patch again?

Signature · 3 lines
Andreas Ericsson                   [email protected]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
#5 lore raw
Quoted 41 lines · Andreas Ericsson
Quoted 35 lines · Björn Steinbrink
Quoted 10 lines · Jeff King
Quoted 4 lines · Mike Hommey

I use git-rebase quite regularly, and I haven't used git-rebase --skip after a failed merge without first resetting the working tree. I was wondering if it wouldn't make sense to automatically do the reset when running git-rebase --skip.

I have often been annoyed by this behavior, too, and I can't think of any situation where you _wouldn't_ want the reset to happen. But I would be more comfortable hearing confirmation from others that they can't think of such a situation.

Let's take this history:

      C---D---E topic
     /
    A---B master

You then do:
git rebase master topic

Now D causes conflicts, because B did a similar change, but not quite the same, maybe having a bug. So you want to keep parts of D, but it's no longer the same commit semantically and the original commit message would be bogus. So you resolve the conflicts and do:

git commit
git rebase --skip

Because you replaced D with a new different commit, instead of really just rebasing it. With plain --continue, you'd have to go back and fix the commit message once the rebase is complete. And --continue after the commit is a no-go, too, because rebase will complain that there's nothing left to produce the rebased D commit.

Quoted 4 lines

And now imagine that you forget to commit but instead just --skip. Ouch, all the work is lost, time to restart the rebase. With the current behaviour, rebase won't just throw away your stuff.

Quoted 5 lines

How about if the state to skip was stashed, the patch reapplied and the differences compared. If they were identical, go ahead and force the reset --hard, otherwise abort. That way, --skip will dwim only when it's safe, and all the lost work can be automagically created by just re-applying the patch again?

I'd prefer the --force option suggested in some other mail. Maybe I'm just not manly enough, but messing up a rebase can mean lots of duplicated work, so I'm rather happy with no dwim at all. Maybe for the real manly users out there, add a rebase.alwaysForce option so they can laugh at me for not using that ;-)

Björn

#6 lore raw
Quoted 11 lines · Björn Steinbrink
Quoted 5 lines

How about if the state to skip was stashed, the patch reapplied and the differences compared. If they were identical, go ahead and force the reset --hard, otherwise abort. That way, --skip will dwim only when it's safe, and all the lost work can be automagically created by just re-applying the patch again?

I'd prefer the --force option suggested in some other mail. Maybe I'm just not manly enough, but messing up a rebase can mean lots of duplicated work, so I'm rather happy with no dwim at all. Maybe for the real manly users out there, add a rebase.alwaysForce option so they can laugh at me for not using that ;-)

Personally, I don't see the point of a --force option; it turns your work flow from:

1. git-rebase --skip
2. Oops, I guess I have to reset.
3. git-reset --hard; git-rebase --skip

to:

1. same as above
2. same as above
3. git-rebase --force --skip

I guess it's a little bit easier to explain to new users, but it in no way eliminates the annoyance of "I expected this to work, and it didn't, so now I have to think about what happened and enter another command."

AIUI, Andreas's proposal is not so much DWIM as "do the obvious thing, but include a safety valve to prevent throwing away work." Is there actually a case where it would not have the desired effect?

-Peff

#7 lore raw
Quoted 7 lines · Jeff King

Personally, I don't see the point of a --force option; it turns your work flow from:

1. git-rebase --skip
2. Oops, I guess I have to reset.
3. git-reset --hard; git-rebase --skip

Quoted 5 lines

to:

1. same as above
2. same as above
3. git-rebase --force --skip

I do not see it as improvement, either, for the same reason you state.

Quoted 3 lines

AIUI, Andreas's proposal is not so much DWIM as "do the obvious thing, but include a safety valve to prevent throwing away work." Is there actually a case where it would not have the desired effect?

The user is explicitly saying --skip, so I do not think it is dangerous even if we unconditionally did "reset --hard" at that point.

Or we could introduce a new option "--drop" (that's "drop the current commit and continue") to do so, if people find that the word "skip" does not sound like a scary destructive operation.

But I do not think that is needed.

#8 lore raw
Quoted 18 lines · Junio C Hamano
Quoted 7 lines · Jeff King

Personally, I don't see the point of a --force option; it turns your work flow from:

1. git-rebase --skip
2. Oops, I guess I have to reset.
3. git-reset --hard; git-rebase --skip

Quoted 5 lines

to:

1. same as above
2. same as above
3. git-rebase --force --skip

I do not see it as improvement, either, for the same reason you state.

Quoted 7 lines
Quoted 3 lines

AIUI, Andreas's proposal is not so much DWIM as "do the obvious thing, but include a safety valve to prevent throwing away work." Is there actually a case where it would not have the desired effect?

The user is explicitly saying --skip, so I do not think it is dangerous even if we unconditionally did "reset --hard" at that point.

The user _must_ say --skip in the case I outlined. And I'm pretty sure that the first thing I'll (accidently) do once --skip implies "reset --hard" is to forget to commit. Murphy has never let me down.

How about adding that --amend option that someone mentioned? Or even just letting --continue act like --skip when there's nothing to commit. That way, you're no longer forced to use --skip.

Björn

#9 lore raw
In reply to Junio C Hamano
Quoted 3 lines · Junio C Hamano

The user is explicitly saying --skip, so I do not think it is dangerous even if we unconditionally did "reset --hard" at that point.

Sure, I think the complaint is not that "reset --hard" is the wrong behavior, but that people are prone to type --skip in error. Right now we handle that error in a data-preserving way (we complain, and the user has to think and issue a "throw away this data" command), but automatic reset is less safe (even though there are fewer times when somebody meant to commit instead of just reset, the consequences are harder to recover from).

I've never personally run into this, but I think it is a reasonable thing to think about, and if it is easy to add an additional safety valve (either stashing the index/wt state, or checking before automatic "reset --hard" whether any work has been done towards resolving), then we probably should.

So I am fine with the original patch (unconditional reset --hard), but it would be nice to see the people who care submit concrete proposals for such a safety valve.

Quoted 3 lines

Or we could introduce a new option "--drop" (that's "drop the current commit and continue") to do so, if people find that the word "skip" does not sound like a scary destructive operation.

I don't think the problem is "users don't realize how scary --skip can be", but rather "I use --skip to resolve this situation 99% of the time, so in the other 1%, I soetimes use it accidentally."

-Peff

#10 lore raw

Hi,

Quoted 3 lines · Jeff King

So I am fine with the original patch (unconditional reset --hard), but it would be nice to see the people who care submit concrete proposals for such a safety valve.

Isn't having to say "--skip" instead of "--continue" enough? Some people might complain that it's too easy to get your fingers wired to type --skip.

In that case, I might beg to differ for two reasons: --skip is definitely not the default operation, so the fingers do not get any chance to do that, and even if, they would get wired to --force --skip just as easily.

Besides, after my patch to rebase on a detached HEAD, it is very easy to go back to the original state and try again.

Ciao,
Dscho

#11 lore raw
Quoted 12 lines · Johannes Schindelin

Hi,

Quoted 3 lines · Jeff King

So I am fine with the original patch (unconditional reset --hard), but it would be nice to see the people who care submit concrete proposals for such a safety valve.

Isn't having to say "--skip" instead of "--continue" enough? Some people might complain that it's too easy to get your fingers wired to type --skip.

Quoted 6 lines

In that case, I might beg to differ for two reasons: --skip is definitely not the default operation, so the fingers do not get any chance to do that, and even if, they would get wired to --force --skip just as easily.

Besides, after my patch to rebase on a detached HEAD, it is very easy to go back to the original state and try again.

We can't make --skip do an automatic reset --hard. I expect --skip to tell me if I haven't finished resolving conflicts. If it doesn't do that, I'll lose work. I can't be the only user with that expectation.

(To be more specific: the work I lose is the work spent resolving how however many conflicts I've dealt with so far. It isn't always the case that I get to a certain point in a rebase and say "ah, yes, I know this is already applied, I can reset and skip it." More often I want to go through each conflict and decide individually. So I do that for a few, I run --continue or --skip when I think I'm done (but don't actually check first, 'cause I count on rebase to do that), then fix up anything remaining.)

--b.

#12 lore raw
Quoted 24 lines · J. Bruce Fields
Quoted 12 lines · Johannes Schindelin

Hi,

Quoted 3 lines · Jeff King

So I am fine with the original patch (unconditional reset --hard), but it would be nice to see the people who care submit concrete proposals for such a safety valve.

Isn't having to say "--skip" instead of "--continue" enough? Some people might complain that it's too easy to get your fingers wired to type --skip.

Quoted 6 lines

In that case, I might beg to differ for two reasons: --skip is definitely not the default operation, so the fingers do not get any chance to do that, and even if, they would get wired to --force --skip just as easily.

Besides, after my patch to rebase on a detached HEAD, it is very easy to go back to the original state and try again.

We can't make --skip do an automatic reset --hard. I expect --skip to tell me if I haven't finished resolving conflicts. If it doesn't do that, I'll lose work. I can't be the only user with that expectation.

Quoted 8 lines

(To be more specific: the work I lose is the work spent resolving how however many conflicts I've dealt with so far. It isn't always the case that I get to a certain point in a rebase and say "ah, yes, I know this is already applied, I can reset and skip it." More often I want to go through each conflict and decide individually. So I do that for a few, I run --continue or --skip when I think I'm done (but don't actually check first, 'cause I count on rebase to do that), then fix up anything remaining.)

(Eh, now that I think of it: what I actually usually do is run --continue, git says there's one more conflict, I fix that up and run --continue again, it tells me there's nothing to commit, I say huh? Then eventually I remember I need to run --skip instead, cursing it for not just figuring that out on its own.... So actually it may be that the only time I run --skip is after --continue has told me I need to. I can't *swear* that that's the case, so I'm still nervous about the idea of --skip automatically resetting. Oh well. Take that one user's experience for what it's worth.)

--b.

#13 lore raw
In reply to Johannes Schindelin
Quoted 3 lines · Johannes Schindelin

Isn't having to say "--skip" instead of "--continue" enough? Some people might complain that it's too easy to get your fingers wired to type --skip.

They already have.

Quoted 2 lines

Besides, after my patch to rebase on a detached HEAD, it is very easy to go back to the original state and try again.

But you are losing any work you did in resolving merges.

But I don't personally have this problem, so I will stop defending those who claim to, and let them speak for themselves (hopefully with patches!).

-Peff

#14 lore raw
In reply to Björn Steinbrink
Quoted 22 lines · Björn Steinbrink
Quoted 11 lines · Jeff King
Quoted 4 lines · Mike Hommey

I use git-rebase quite regularly, and I haven't used git-rebase --skip after a failed merge without first resetting the working tree. I was wondering if it wouldn't make sense to automatically do the reset when running git-rebase --skip.

I have often been annoyed by this behavior, too, and I can't think of any situation where you _wouldn't_ want the reset to happen. But I would be more comfortable hearing confirmation from others that they can't think of such a situation.

Let's take this history:

      C---D---E topic
     /
    A---B master

You then do:
git rebase master topic

Quoted 7 lines

Now D causes conflicts, because B did a similar change, but not quite the same, maybe having a bug. So you want to keep parts of D, but it's no longer the same commit semantically and the original commit message would be bogus. So you resolve the conflicts and do:

git commit
git rebase --skip

I guess that works, and nothing else presently does. But I don't think that's at all intuitive as the correct thing to do (plus it feels too easy to get into losing your commit message). Maybe we should have a "git rebase --amend", which does the obvious thing (acts like --continue, but lets you edit the message). It's not like you just did something totally different; the commit is still the replacement for D, it's just less the same.

-Daniel
*This .sig left intentionally blank*

#15 lore raw
Quoted 10 lines · Daniel Barkalow
Quoted 2 lines

git commit
git rebase --skip

I guess that works, and nothing else presently does. But I don't think that's at all intuitive as the correct thing to do (plus it feels too easy to get into losing your commit message). Maybe we should have a "git rebase --amend", which does the obvious thing (acts like --continue, but lets you edit the message). It's not like you just did something totally different; the commit is still the replacement for D, it's just less the same.

Maybe some commands such as commit should fail or at least emit warning when used during a rebase ?

Mike

#16 lore raw
Quoted 12 lines · Mike Hommey
Quoted 10 lines · Daniel Barkalow
Quoted 2 lines

git commit
git rebase --skip

I guess that works, and nothing else presently does. But I don't think that's at all intuitive as the correct thing to do (plus it feels too easy to get into losing your commit message). Maybe we should have a "git rebase --amend", which does the obvious thing (acts like --continue, but lets you edit the message). It's not like you just did something totally different; the commit is still the replacement for D, it's just less the same.

Quoted 2 lines

Maybe some commands such as commit should fail or at least emit warning when used during a rebase ?

Or, in the present case, doing the same as what "edit" would do in a git-rebase --interactive could be enough.

Mike

#17 lore raw
In reply to Mike Hommey

Hi,

Quoted 2 lines · Mike Hommey

Maybe some commands such as commit should fail or at least emit warning when used during a rebase ?

No, that would disrupt comming (and valid!) workflow too much. Even a warning.

Ciao,
Dscho

#18 lore raw
In reply to Jeff King
Quoted 11 lines · Jeff King
Quoted 4 lines · Mike Hommey

I use git-rebase quite regularly, and I haven't used git-rebase --skip after a failed merge without first resetting the working tree. I was wondering if it wouldn't make sense to automatically do the reset when running git-rebase --skip.

I have often been annoyed by this behavior, too, and I can't think of any situation where you _wouldn't_ want the reset to happen. But I would be more comfortable hearing confirmation from others that they can't think of such a situation.

Perhaps "git rebase --force-skip" or "git rebase --force --skip" would be the way to fo above...

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
#19 lore raw
In reply to Mike Hommey

Hi,

Quoted 4 lines · Mike Hommey

I use git-rebase quite regularly, and I haven't used git-rebase --skip after a failed merge without first resetting the working tree. I was wondering if it wouldn't make sense to automatically do the reset when running git-rebase --skip.

Makes sense to me. The user is already required to pass "--skip" to say "scrap this patch".

FWIW --interactive already has this behaviour since it was added to "official" git.

Ciao,
Dscho