git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Antoine Pelisse <apelisse@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Sandro Santilli <strk@keybit.net>, git <git@vger.kernel.org>
Subject: Re: preventing evil merges
Date: Mon, 3 Jun 2013 19:37:00 +0200	[thread overview]
Message-ID: <CALWbr2yLHN7VgPhH-HvyBx04pHasH=zr6fTXtjjsKJgqHA8kKQ@mail.gmail.com> (raw)
In-Reply-To: <7vvc5vglh5.fsf@alter.siamese.dyndns.org>

On Mon, Jun 3, 2013 at 7:20 PM, Junio C Hamano <gitster@pobox.com> wrote:
> 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.

Also, you need to use --cc option of log to see the change in history
(in addition to -p):

    git log --cc -p

      reply	other threads:[~2013-06-03 17:37 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
2013-06-03 17:37   ` Antoine Pelisse [this message]

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='CALWbr2yLHN7VgPhH-HvyBx04pHasH=zr6fTXtjjsKJgqHA8kKQ@mail.gmail.com' \
    --to=apelisse@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --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).