git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* merge conflict diff
@ 2008-04-03 14:13 Jeremy Ramer
  2008-04-03 14:26 ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Jeremy Ramer @ 2008-04-03 14:13 UTC (permalink / raw)
  To: git

Hi,
I am trying to figure out how to quickly diff two source files that
led to a merge conflict.  When a conflict occurs the command
# git diff
performs a diff -cc, but I would like to compare the files before any
merging takes place so I can decide if I should just take all the
changes from one of the sources.
 i.e. take the changes from the merging branch:
# git checkout-index -f -u --stage=3 foo
# git add foo

So far I am thinking of
# git checkout-index --stage=2 --temp foo
# git checkout-index --stage=3 --temp foo
# git diff .merge_x1 .merge_x2

Are there any built-in ways to accomplish this? I'd like to be able to
build a script that can quickly start the diff based on the file name
I provide.

Thanks!
Jeremy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: merge conflict diff
  2008-04-03 14:13 merge conflict diff Jeremy Ramer
@ 2008-04-03 14:26 ` Jeff King
  2008-04-03 14:58   ` Jeremy Ramer
  2008-04-03 16:48   ` Matthieu Moy
  0 siblings, 2 replies; 4+ messages in thread
From: Jeff King @ 2008-04-03 14:26 UTC (permalink / raw)
  To: Jeremy Ramer; +Cc: git

On Thu, Apr 03, 2008 at 08:13:04AM -0600, Jeremy Ramer wrote:

> I am trying to figure out how to quickly diff two source files that
> led to a merge conflict.  When a conflict occurs the command
> [...]
> So far I am thinking of
> # git checkout-index --stage=2 --temp foo
> # git checkout-index --stage=3 --temp foo
> # git diff .merge_x1 .merge_x2

The special ref syntax :<n>:file refers to the blob in stage <n> of the
index. So you can see them with:

  git show :2:foo
  git show :3:foo

Or diff them with:

  git diff :2:foo :3:foo

You may also want to look at the git-mergetool script, which uses both
versions (along with the ancestor) as the arguments to many common merge
resolution programs.

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: merge conflict diff
  2008-04-03 14:26 ` Jeff King
@ 2008-04-03 14:58   ` Jeremy Ramer
  2008-04-03 16:48   ` Matthieu Moy
  1 sibling, 0 replies; 4+ messages in thread
From: Jeremy Ramer @ 2008-04-03 14:58 UTC (permalink / raw)
  To: Jeff King; +Cc: git

On Thu, Apr 3, 2008 at 8:26 AM, Jeff King <peff@peff.net> wrote:
> On Thu, Apr 03, 2008 at 08:13:04AM -0600, Jeremy Ramer wrote:
>
>  > I am trying to figure out how to quickly diff two source files that
>  > led to a merge conflict.  When a conflict occurs the command
>  > [...]
>
> > So far I am thinking of
>  > # git checkout-index --stage=2 --temp foo
>  > # git checkout-index --stage=3 --temp foo
>  > # git diff .merge_x1 .merge_x2
>
>  The special ref syntax :<n>:file refers to the blob in stage <n> of the
>  index. So you can see them with:
>
>   git show :2:foo
>   git show :3:foo
>
>  Or diff them with:
>
>   git diff :2:foo :3:foo

Perfect! I was not aware of that syntax. That solves the question I asked.

>  You may also want to look at the git-mergetool script, which uses both
>  versions (along with the ancestor) as the arguments to many common merge
>  resolution programs.

This suggestion solves the actual problem in a much better way than I
was thinking.  Thanks for the help!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: merge conflict diff
  2008-04-03 14:26 ` Jeff King
  2008-04-03 14:58   ` Jeremy Ramer
@ 2008-04-03 16:48   ` Matthieu Moy
  1 sibling, 0 replies; 4+ messages in thread
From: Matthieu Moy @ 2008-04-03 16:48 UTC (permalink / raw)
  To: Jeff King; +Cc: Jeremy Ramer, git

Jeff King <peff@peff.net> writes:

> On Thu, Apr 03, 2008 at 08:13:04AM -0600, Jeremy Ramer wrote:
>
>> I am trying to figure out how to quickly diff two source files that
>> led to a merge conflict.  When a conflict occurs the command
>> [...]
>> So far I am thinking of
>> # git checkout-index --stage=2 --temp foo
>> # git checkout-index --stage=3 --temp foo
>> # git diff .merge_x1 .merge_x2
>
> The special ref syntax :<n>:file refers to the blob in stage <n> of the
> index. So you can see them with:
>
>   git show :2:foo
>   git show :3:foo
>
> Or diff them with:
>
>   git diff :2:foo :3:foo

See also

git diff --ours
git diff --theirs
git diff --base

and man git-diff-files (BTW, it's a pity not to find this in man
git-diff).

-- 
Matthieu

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-04-03 16:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-03 14:13 merge conflict diff Jeremy Ramer
2008-04-03 14:26 ` Jeff King
2008-04-03 14:58   ` Jeremy Ramer
2008-04-03 16:48   ` Matthieu Moy

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).