git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Avery Pennarun <apenwarr@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	Thomas Rast <trast@student.ethz.ch>,
	git@vger.kernel.org, Jakub Narebski <jnareb@gmail.com>,
	Miklos Vajna <vmiklos@frugalware.org>
Subject: Re: [PATCH] Documentation: warn against merging in a dirty tree
Date: Thu, 18 Sep 2008 08:15:13 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.1.10.0809180804100.3337@nehalem.linux-foundation.org> (raw)
In-Reply-To: <32541b130809151653w27d7876fp35e0967d597ae2a9@mail.gmail.com>



On Mon, 15 Sep 2008, Avery Pennarun wrote:
> 
> But how do you abort a *failed* merge in a situation like Linus's
> example?  "git reset --hard HEAD" would destroy the unstaged Makefile
> change.

As mentioned by others, sometimes you are simply willing to take the risk. 
If I have dirty data, I still want to merge, because (a) my dirty data is 
a _convenience_ and (b) the risk of me having to do a "git reset" is 
pretty low anyway.

That said, it's actually kind of sad that we don't expose a real 
capability that the git plumbing does have. Namely

	git read-tree -u -m HEAD ORIG_HEAD

should do the right thing if you want to undo a merge (except it doesn't 
actually write ORIG_HEAD to be the new head: you could use "git reset" 
with --soft to do that, or just git update-ref).

So it _may_ be that something like

	[alias]
		undo = !git read-tree -u -m HEAD ORIG_HEAD && git reset --soft ORIG_HEAD

would actually give you "git undo". 

So we have the technology, and we just don't _expose_ that capability as a 
"git reset" thing. And we probably should. In fact, that is often the 
thing people really want, and it would have made sense to have it as the 
default action, but the initial design for "git reset" was literally as a 
way to get you out of a sticky corner when you had unmerged entries and 
you just wanted to throw away crud.

NOTE NOTE NOTE! I did _not_ test that the git read-tree thing actually 
works, or that the above alias does the right thing. Caveat testor! You're 
on your own. But I agree that we should have something like that.

		Linus

  parent reply	other threads:[~2008-09-18 15:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-15 22:48 [IRC/patches] Failed octopus merge does not clean up Thomas Rast
2008-09-15 22:49 ` [PATCH] Add test that checks octopus merge cleanup Thomas Rast
2008-09-15 22:49   ` [PATCH] Documentation: warn against merging in a dirty tree Thomas Rast
2008-09-15 23:42     ` Junio C Hamano
2008-09-15 23:53       ` Avery Pennarun
2008-09-16  0:06         ` Junio C Hamano
2008-09-18 15:15         ` Linus Torvalds [this message]
2008-09-18 18:18           ` Avery Pennarun
2008-09-19 20:28           ` Junio C Hamano
2008-09-15 23:36 ` [IRC/patches] Failed octopus merge does not clean up Junio C Hamano
2008-09-15 23:47   ` Thomas Rast
2008-09-16  0:20   ` Junio C Hamano
2008-09-16 22:53     ` Jakub Narebski
2008-09-17  6:45       ` Andreas Ericsson
2008-09-17  8:11         ` Jakub Narebski
2008-09-17 15:59           ` Miklos Vajna
2008-09-17 16:40             ` Andreas Ericsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.1.10.0809180804100.3337@nehalem.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=apenwarr@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jnareb@gmail.com \
    --cc=trast@student.ethz.ch \
    --cc=vmiklos@frugalware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).