Re: unmerging feature branches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> writes:

> Now, that said, reverting the data is not that hard. There is not any 
> single-command "revert this arm of a merge", but on the other hand, git 
> can certainly help you.
>
> The way to do it is:
>
> 	# go back to just before the merge, create a "fixup" branch
> 	#
> 	git branch -b fixup M^
>
> 	# merge all of it again, *except* the branch you didn't want to 
> 	# merge (this example assumes that you had a four-way octopus 
> 	# merge, and you now want to turn it into a three-way with the
> 	# next-to-last parent skipped):
> ...

Desire to revert an octopus would, as you demonstrated, often be
to revert only one arm, but I think allowing to revert a twohead
merge should be trivial.  If we define "reverting a merge" to
always revert all arms, then this should suffice.

diff --git a/builtin-revert.c b/builtin-revert.c
index a655c8e..719e293 100644
--- a/builtin-revert.c
+++ b/builtin-revert.c
@@ -269,8 +269,8 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 
 	if (!commit->parents)
 		die ("Cannot %s a root commit", me);
-	if (commit->parents->next)
-		die ("Cannot %s a multi-parent commit.", me);
+	if (action != REVERT && commit->parents->next)
+		die ("Cannot %s a merge commit.", me);
 	if (!(message = commit->buffer))
 		die ("Cannot get commit message for %s",
 				sha1_to_hex(commit->object.sha1));

Note that allowing cherry-pick by removing the above two lines
allow replaying the data of a merge similar to a squash merge.
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux