# Question about git log --merge option

3 messages from 2016-04-13 to 2016-04-14. Participants: Andrey Hsiao, Junio C Hamano.
Thread: https://gitlist.dev/t/42019

## Andrey Hsiao, 2016-04-13 16:53

Subject: Question about git log --merge option
Message-ID: <CAArk4YMOkd3dEn-09-LMO7zf=X3iJqXUjCS0YNN5v4h=PjrTLg@mail.gmail.com>
URL: https://gitlist.dev/e/CAArk4YMOkd3dEn-09-LMO7zf%3DX3iJqXUjCS0YNN5v4h%3DPjrTLg%40mail.gmail.com

```
Dear list:

Just encountered the --merge option for git log.

In the man page, it has the following explanation:
- After a failed merge, show refs that touch files having a conflict
and don't exist on all heads to merge.

I tried this option and get below results:

1. For a failed merge (with conflicts), if the conflicted file does
not exist on either side of the merge, the --merge option will return
the log from the other side.

2. If the conflicted file exists on both sides of the merge, the
--merge option will return the latest change on either side. (i.e: git
log -1 -- conflict_file / git log -1 --merge -- conflict_file may
return different results, whichever changed the latest)

I'm not sure whether above behavior is the unexpected result (cannot
find detailed explanation for --merge option online).

Thanks

```

## Junio C Hamano, 2016-04-13 20:37

Subject: Re: Question about git log --merge option
Message-ID: <xmqqvb3ljldq.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqvb3ljldq.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <CAArk4YMOkd3dEn-09-LMO7zf=X3iJqXUjCS0YNN5v4h=PjrTLg@mail.gmail.com>

```
Andrey Hsiao <andreyhsiao@gmail.com> writes:

> Dear list:
>
> Just encountered the --merge option for git log.
>
> In the man page, it has the following explanation:
> - After a failed merge, show refs that touch files having a conflict
> and don't exist on all heads to merge.

	git log --merge [options] -- $paths

is roughly the same as

	git log [options] HEAD...MERGE_HEAD -- $paths'

where $paths' is $paths limited to those with conflicts.  You can
further think of that as a rough equivalent of

	git log [options] ^X HEAD MERGE_HEAD -- $paths'

where X is the merge base between the tips of these two branches:

    X---o---o---o---H
     \
      o---o---o---M

And the commits among these ('o's, H and M in the picture), the ones
that change any of the $paths' are shown.  If you further limit the
output (e.g. with -n<n>, or --since=<time>), you may not see all of
them, of course.

```

## Andrey Hsiao, 2016-04-14 02:31

Subject: Re: Question about git log --merge option
Message-ID: <CAArk4YNKoM9p+FVv+q5Ty4YYoWDcXuF-HjEk96F4Pf-i8QWKDA@mail.gmail.com>
URL: https://gitlist.dev/e/CAArk4YNKoM9p%2BFVv%2Bq5Ty4YYoWDcXuF-HjEk96F4Pf-i8QWKDA%40mail.gmail.com
In-Reply-To: <xmqqvb3ljldq.fsf@gitster.mtv.corp.google.com>

```
Thanks Junio, I understand the option's meaning now :)

On Thu, Apr 14, 2016 at 4:37 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Andrey Hsiao <andreyhsiao@gmail.com> writes:
>
>> Dear list:
>>
>> Just encountered the --merge option for git log.
>>
>> In the man page, it has the following explanation:
>> - After a failed merge, show refs that touch files having a conflict
>> and don't exist on all heads to merge.
>
>         git log --merge [options] -- $paths
>
> is roughly the same as
>
>         git log [options] HEAD...MERGE_HEAD -- $paths'
>
> where $paths' is $paths limited to those with conflicts.  You can
> further think of that as a rough equivalent of
>
>         git log [options] ^X HEAD MERGE_HEAD -- $paths'
>
> where X is the merge base between the tips of these two branches:
>
>     X---o---o---o---H
>      \
>       o---o---o---M
>
> And the commits among these ('o's, H and M in the picture), the ones
> that change any of the $paths' are shown.  If you further limit the
> output (e.g. with -n<n>, or --since=<time>), you may not see all of
> them, of course.

```
