# Confusing --graph --all output with detached branches

4 messages from 2016-05-19 to 2016-05-23. Participants: Bjørnar Snoksrud, Junio C Hamano.
Thread: https://gitlist.dev/t/42386

## Bjørnar Snoksrud, 2016-05-19 13:45

Subject: Confusing --graph --all output with detached branches
Message-ID: <CA+cck7FPzK-zccBVzphY_N41acOvqjwmDmgQH7ZE3SHG2k1rFw@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2Bcck7FPzK-zccBVzphY_N41acOvqjwmDmgQH7ZE3SHG2k1rFw%40mail.gmail.com

```
If you end up with a history containing commit A with parent B, where
a detached branch is merged into A while an unrelated branch branches
off of B, you will get the following output:

$ git log --graph --all
*   commit ff4265fcbfe94a2abe93c97d86e0d9f0e0a136cb
|\  Merge: 8b62de9 0bbc311
| | Author: XXX
| | Date:   Thu May 19 15:31:46 2016 +0200
| |
| |     Merge branch 'bar'
| |
| * commit 0bbc3115caa089d8578eb52ba6c12c1b43153dad
| | Author: XXX
| | Date:   Thu May 19 15:31:40 2016 +0200
| |
| |     5
| |
| * commit b1c9c491a05d9ffeca2e1d7b5cbd392cd90eef82
|   Author: XXX
|   Date:   Thu May 19 15:31:39 2016 +0200
|
|       4
|
| * commit ce053f92a9290f5472aac3319ddadbaf5bf62371
|/  Author: XXX
|   Date:   Thu May 19 15:31:31 2016 +0200
|
|       3
|
* commit 8b62de9f421c0be46300a3e68f85c6e7608c24f6
| Author: XXX
| Date:   Thu May 19 15:31:02 2016 +0200
|
|     2
|
* commit cb7e7e2662f1477f030a889cab135ed5a19ba43e
  Author: XXX
  Date:   Thu May 19 15:31:00 2016 +0200

      1

-

Which is pretty informative  - after '2' we branched out for commit 3,
and the branch containing 4 and 5 was merged into master.

However, if you use the pretty common `one line` git log alias, you get this:

*   ff4265f  (HEAD -> master) Merge branch 'bar'
|\
| * 0bbc311  (bar) 5
| * b1c9c49  4
| * ce053f9  (foo) 3
|/
* 8b62de9  2
* cb7e7e2  1

.. which indicates that `foo` is contained within `bar`. Maybe

*   ff4265f  (HEAD -> master) Merge branch 'bar'
|\
| * 0bbc311  (bar) 5
| * b1c9c49  4
|
| * ce053f9  (foo) 3
|/
* 8b62de9  2
* cb7e7e2  1

.. would be better?

Reproduction steps:

git init
git commit --allow-empty -m 1
git commit --allow-empty -m 2
git checkout --branch foo
git checkout -b foo
git commit --allow-empty -m 3
git checkout --orphan bar
git commit --allow-empty -m 4
git commit --allow-empty -m 5
git checkout master
git merge bar -m merge
git log --graph --all  --pretty=format:'%Cred%h %C(yellow)%-d%Creset %s '


-- 
bjornar@snoksrud.no

```

## Junio C Hamano, 2016-05-19 15:18

Subject: Re: Confusing --graph --all output with detached branches
Message-ID: <xmqqzirmoz38.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqzirmoz38.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <CA+cck7FPzK-zccBVzphY_N41acOvqjwmDmgQH7ZE3SHG2k1rFw@mail.gmail.com>

```

```

## Junio C Hamano, 2016-05-19 15:20

Subject: Re: Confusing --graph --all output with detached branches
Message-ID: <xmqqvb2aoz13.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqvb2aoz13.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <CA+cck7FPzK-zccBVzphY_N41acOvqjwmDmgQH7ZE3SHG2k1rFw@mail.gmail.com>

```
Bjørnar Snoksrud <snoksrud@gmail.com> writes:

> .. which indicates that `foo` is contained within `bar`. Maybe
>
> *   ff4265f  (HEAD -> master) Merge branch 'bar'
> |\
> | * 0bbc311  (bar) 5
> | * b1c9c49  4
> |
> | * ce053f9  (foo) 3
> |/
> * 8b62de9  2
> * cb7e7e2  1
>
> .. would be better?
>

Yes, it would be.

```

## Junio C Hamano, 2016-05-23 21:18

Subject: Re: Confusing --graph --all output with detached branches
Message-ID: <xmqqa8jg8od4.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqa8jg8od4.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <xmqqvb2aoz13.fsf@gitster.mtv.corp.google.com>

```
Junio C Hamano <gitster@pobox.com> writes:

> Bjørnar Snoksrud <snoksrud@gmail.com> writes:
>
>> .. which indicates that `foo` is contained within `bar`. Maybe
>>
>> *   ff4265f  (HEAD -> master) Merge branch 'bar'
>> |\
>> | * 0bbc311  (bar) 5
>> | * b1c9c49  4
>> |
>> | * ce053f9  (foo) 3
>> |/
>> * 8b62de9  2
>> * cb7e7e2  1
>>
>> .. would be better?
>
> Yes, it would be.

Another possibility would be to shift the columns between 4 and 3.

```
