Skip to contentSkip to conversation

rebase: convert revert to squash on autosquash

PATCH In review Michael S. Tsirkin 3 participants 9 messages Jun 16, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rebase: convert revert to squash on autosquash

Reverts can typically be treated like squash. Eliminating both the original commit and the revert would be even nicer, but this seems a bit harder to implement.

---
 git-rebase--interactive.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
git-rebase--interactive.sh +7 -1
index 6a766ca..6fc1935 100644
@@ -777,7 +777,7 @@ rearrange_squash () {
 	do
 		test -z "${format}" || message=$(git log -n 1 --format="%s" ${sha1})
 		case "$message" in
-		"squash! "*|"fixup! "*|"ack! "*)
+		"squash! "*|"fixup! "*|"ack! "*|"Revert \""*)
 			action="${message%%!*}"
 			rest=$message
 			prefix=
@@ -789,6 +789,12 @@ rearrange_squash () {
 					prefix="$prefix${rest%%!*},"
 					rest="${rest#*! }"
 					;;
+				"Revert \""*\")
+					action="squash"
+					prefix="Revert,"
+					rest="${rest#Revert \"}"
+					rest="${rest%%\"}"
+					;;
 				*)
 					break
 					;;
Signature · 1 line
MST
#1 lore raw

Hi,

Quoted 3 lines · Michael S. Tsirkin

Reverts can typically be treated like squash. Eliminating both the original commit and the revert would be even nicer, but this seems a bit harder to implement.

Whoa. This rings a lot of alarm bells, very loudly. It seems you intend to introduce a *major* change in behavior, and all we get to convince us that this is a good change is this puny paragraph (which, by the way, does not do half a good job of explaining to me what you think this patch is supposed to do, let alone of convincing me that what you want is a good change).

So. What is it again that you want to achieve? Please use plain English, e.g. explaining how exactly reverts are typically to be treated like squashes. And please make it convincing, because so far, I am far from convinced.

Ciao,
Johannes

#2 lore raw
Quoted 9 lines · Johannes Schindelin

Hi,

Quoted 3 lines · Michael S. Tsirkin

Reverts can typically be treated like squash. Eliminating both the original commit and the revert would be even nicer, but this seems a bit harder to implement.

Whoa. This rings a lot of alarm bells, very loudly.

Whoa don't be alarmed. It's just a patch :). I've been using this patch for more than a year now, so I thought I'd post it in case it's useful for others.

Quoted 2 lines

It seems you intend to
introduce a *major* change in behavior,

Doing this automatically for all users might be a bit too drastic for the upstream git. So there could be an option, or something - if there's interest I can add that. I thought I'd test the waters before I spend time on that.

Quoted 6 lines

and all we get to convince us that
this is a good change is this puny paragraph (which, by the way, does not do half a good job of explaining to me what you think this patch is supposed to do, let alone of convincing me that what you want is a good change).

Quoted 7 lines

So. What is it again that you want to achieve? Please use plain English, e.g. explaining how exactly reverts are typically to be treated like squashes. And please make it convincing, because so far, I am far from convinced.

Ciao,
Johannes

It's rather simple.

If there's a commit later followed by a revert, history can be simplified by squashing them, and if the result is empty, removing both.

The removal part is not automatic with my patch. If someone wants to implement it, that would be nice and useful for me.

squashing/fixing is similar in that they are also useful to keep history clean.

Signature · 1 line
MST
#3 lore raw

Hi Michael,

Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Johannes Schindelin
Quoted 3 lines · Michael S. Tsirkin

Reverts can typically be treated like squash. Eliminating both the original commit and the revert would be even nicer, but this seems a bit harder to implement.

Whoa. This rings a lot of alarm bells, very loudly.

Whoa don't be alarmed. It's just a patch :).

It's just a patch. Like every major breakage would be. So: no, there is reason to be alarmed if it is likely to disrupt normal usage.

Quoted 4 lines
Quoted 1 line

It seems you intend to introduce a *major* change in behavior,

Doing this automatically for all users might be a bit too drastic for the upstream git.

That is a pretty safe thing to say, even without the subjunctive.

Quoted 2 lines

If there's a commit later followed by a revert, history can be simplified by squashing them, and if the result is empty, removing both.

True. But that is not what the user told Git to do. If the user's intention was to squash the reverting patch, she could have easily done this:

	git revert -n deadbeef
	git commit --squash deadbeef

where "deadbeef" is the placeholder for the actual commit to revert.

And indeed, I use exactly this song and dance quite frequently, *iff* my intention is to drop a patch.

A much better idea than co-opting the "Revert" commit message would be to introduce a sibling to --fixup and --squash that you could call --drop.

Ciao,
Johannes

#4 lore raw
Quoted 38 lines · Johannes Schindelin

Hi Michael,

Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Johannes Schindelin
Quoted 3 lines · Michael S. Tsirkin

Reverts can typically be treated like squash. Eliminating both the original commit and the revert would be even nicer, but this seems a bit harder to implement.

Whoa. This rings a lot of alarm bells, very loudly.

Whoa don't be alarmed. It's just a patch :).

It's just a patch. Like every major breakage would be. So: no, there is reason to be alarmed if it is likely to disrupt normal usage.

Quoted 4 lines
Quoted 1 line

It seems you intend to introduce a *major* change in behavior,

Doing this automatically for all users might be a bit too drastic for the upstream git.

That is a pretty safe thing to say, even without the subjunctive.

Quoted 2 lines

If there's a commit later followed by a revert, history can be simplified by squashing them, and if the result is empty, removing both.

True. But that is not what the user told Git to do. If the user's intention was to squash the reverting patch, she could have easily done this:

	git revert -n deadbeef
	git commit --squash deadbeef

where "deadbeef" is the placeholder for the actual commit to revert.

Quoted 8 lines

And indeed, I use exactly this song and dance quite frequently, *iff* my intention is to drop a patch.

A much better idea than co-opting the "Revert" commit message would be to introduce a sibling to --fixup and --squash that you could call --drop.

Ciao,
Johannes

Sounds rather cool. Or alternatively

git revert --squash deadbeef

#5 lore raw
In reply to Johannes Schindelin
Quoted 11 lines · Johannes Schindelin
	git revert -n deadbeef
	git commit --squash deadbeef

where "deadbeef" is the placeholder for the actual commit to revert.

And indeed, I use exactly this song and dance quite frequently, *iff* my intention is to drop a patch.

A much better idea than co-opting the "Revert" commit message would be to introduce a sibling to --fixup and --squash that you could call --drop.

One could also add --fixup and --squash to "git revert", so the above would become

    git revert --squash deadbeef

In most cases, I find it simpler to just start a rebase -i and drop the commit from rebase's todo-list.

Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/
#6 lore raw
Quoted 14 lines · Matthieu Moy
Quoted 11 lines · Johannes Schindelin
	git revert -n deadbeef
	git commit --squash deadbeef

where "deadbeef" is the placeholder for the actual commit to revert.

And indeed, I use exactly this song and dance quite frequently, *iff* my intention is to drop a patch.

A much better idea than co-opting the "Revert" commit message would be to introduce a sibling to --fixup and --squash that you could call --drop.

Quoted 7 lines

One could also add --fixup and --squash to "git revert", so the above would become

    git revert --squash deadbeef

In most cases, I find it simpler to just start a rebase -i and drop the commit from rebase's todo-list.

Absolutely, but moving rebase to near the commit to drop also makes it easier to spot where the commit is. Thoughts?

Quoted 3 lines
Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/
#7 lore raw
In reply to Johannes Schindelin
Quoted 33 lines · Johannes Schindelin

Hi Michael,

Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Johannes Schindelin
Quoted 3 lines · Michael S. Tsirkin

Reverts can typically be treated like squash. Eliminating both the original commit and the revert would be even nicer, but this seems a bit harder to implement.

Whoa. This rings a lot of alarm bells, very loudly.

Whoa don't be alarmed. It's just a patch :).

It's just a patch. Like every major breakage would be. So: no, there is reason to be alarmed if it is likely to disrupt normal usage.

Quoted 4 lines
Quoted 1 line

It seems you intend to introduce a *major* change in behavior,

Doing this automatically for all users might be a bit too drastic for the upstream git.

That is a pretty safe thing to say, even without the subjunctive.

Quoted 2 lines

If there's a commit later followed by a revert, history can be simplified by squashing them, and if the result is empty, removing both.

True. But that is not what the user told Git to do. If the user's intention was to squash the reverting patch, she could have easily done this:

Quoted 7 lines
	git revert -n deadbeef
	git commit --squash deadbeef

where "deadbeef" is the placeholder for the actual commit to revert.

And indeed, I use exactly this song and dance quite frequently, *iff* my intention is to drop a patch.

Well then you have to decide whether you want to drop it when you commit.
If *I* want do drop the patch when I commit, I just do git rebase.

Quoted 5 lines

A much better idea than co-opting the "Revert" commit message would be to introduce a sibling to --fixup and --squash that you could call --drop.

Ciao,
Johannes

Maybe but it's a different usecase.

What this addresses is a case where you first wanted to avoid rebases, so you reverted.
But then you rebased after all.
Now finding what was reverted automatically is helpful.

#8 lore raw
In reply to Michael S. Tsirkin
Quoted 4 lines · Michael S. Tsirkin

Doing this automatically for all users might be a bit too drastic for the upstream git. So there could be an option, or something - if there's interest I can add that. I thought I'd test the waters before I spend time on that.

If the goal is to test the waters, then adding an RFC tag to your subject helps starting more constructive discussion and avoid alarm bells ringing like Johannes' reaction. Having the content of this paragraph as a comment below the --- part of the patch also helps.

Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/