git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Sandro Santilli <strk@keybit.net>
Cc: git@vger.kernel.org
Subject: Re: preventing evil merges
Date: Mon, 03 Jun 2013 10:20:06 -0700	[thread overview]
Message-ID: <7vvc5vglh5.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20130530163459.GI31679@gnash> (Sandro Santilli's message of "Thu, 30 May 2013 18:34:59 +0200")

Sandro Santilli <strk@keybit.net> writes:

>  git merge anotherbranch
>  git add something
>  git commit --amend
>
> After the steps above the addition of "something" can't be found in
> the history anymore, but the file is there.

This is a very common and sensible thing to do when dealing with
semantic conflict.  Imagine that you changed the name of a global
variable in the code on your current branch since the anotherbranch
you are pulling from forked from you.  Then imagine further that the 
anotherbranch added one location that refers to that variable.

Since they are not aware of the name change, they added the new
reference with the old variable name.  The part they added is a new
code, so it is very likely that there is no textual conflict when
you did "git merge anotherbranch".  But now the result is broken.

And you fix that semantic conflict by editing the file they added
the new reference to the variable under the old name and make it use
the variable with the new name.  You "git add something" and amend
the merge.

"git show" of the result will show you what happened, I think.

  reply	other threads:[~2013-06-03 17:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-30 16:34 preventing evil merges Sandro Santilli
2013-06-03 17:20 ` Junio C Hamano [this message]
2013-06-03 17:37   ` Antoine Pelisse

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=7vvc5vglh5.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=strk@keybit.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).