# git log causing hang while browsing upstream linux

9 messages from 2023-04-04 to 2023-04-16. Participants: Rohit Ner, Kristoffer Haugsbakk, Taylor Blau, SZEDER Gábor, Ævar Arnfjörð Bjarmason.
Thread: https://gitlist.dev/t/59542

## Rohit Ner, 2023-04-04 20:13

Subject: git log causing hang while browsing upstream linux
Message-ID: <CAKazavxTXwcZFtL2XyU3MpaUR=snWY8w8Lwpco+mkbqm2nWE=w@mail.gmail.com>
URL: https://gitlist.dev/e/CAKazavxTXwcZFtL2XyU3MpaUR%3DsnWY8w8Lwpco%2Bmkbqm2nWE%3Dw%40mail.gmail.com

```
Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)
1. git clone https://github.com/torvalds/linux.git
2. git checkout master
3. git log --oneline --graph

What did you expect to happen? (Expected behavior)
See a graph of onelined commit histories

What happened instead? (Actual behavior)
Hang after entering the command

What's different between what you expected and what actually happened?
The output is empty and the cursor is stuck. Cursor is unresponsive to any key
press other than ^C which leads to an output like below
### OUTPUT START ###
...
~
~
~
~
(END)
### OUTPUT END ###
Pressing q key helps get the prompt back.

Anything else you want to add:

Please review the rest of the bug report below.
You can delete any lines you don't wish to share.


[System Info]
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
compiler info: gnuc: 12.2
libc info: glibc: 2.36
$SHELL (typically, interactive shell): /bin/bash


[Enabled Hooks]
commit-msg
pre-commit
prepare-commit-msg

```

## Kristoffer Haugsbakk, 2023-04-04 20:27

Subject: Re: git log causing hang while browsing upstream linux
Message-ID: <5b99135f-c1d4-434b-b508-35f5d66dd2bb@app.fastmail.com>
URL: https://gitlist.dev/e/5b99135f-c1d4-434b-b508-35f5d66dd2bb%40app.fastmail.com
In-Reply-To: <CAKazavxTXwcZFtL2XyU3MpaUR=snWY8w8Lwpco+mkbqm2nWE=w@mail.gmail.com>

```
On Tue, Apr 4, 2023, at 22:13, Rohit Ner wrote:
> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.
>
> What did you do before the bug happened? (Steps to reproduce your issue)
> 1. git clone https://github.com/torvalds/linux.git
> 2. git checkout master
> 3. git log --oneline --graph

Seems like `--graph` is expensive.

FWIW: on my machine:

    $ time git log --oneline --graph | head -1 
    *   76f598ba7d8e Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm

    real	0m10.616s
    user	0m9.594s
    sys	0m0.654s

Second attempt is only marginally faster.

-- 
Kristoffer Haugsbakk

```

## Kristoffer Haugsbakk, 2023-04-04 20:50

Subject: Re: git log causing hang while browsing upstream linux
Message-ID: <b5316855-971d-4b7b-89cd-e81ececc5124@app.fastmail.com>
URL: https://gitlist.dev/e/b5316855-971d-4b7b-89cd-e81ececc5124%40app.fastmail.com
In-Reply-To: <5b99135f-c1d4-434b-b508-35f5d66dd2bb@app.fastmail.com>

```
On Tue, Apr 4, 2023, at 22:27, Kristoffer Haugsbakk wrote:
> FWIW: on my machine:

So my point is: have you given the command a half a minute or so to
output the initial lines? Certain `log` invocations can take a long time
on repositories with rich histories.

-- 
Kristoffer Haugsbakk

```

## Rohit Ner, 2023-04-10 17:07

Subject: Re: git log causing hang while browsing upstream linux
Message-ID: <CAKazavzS112w3wsxnA-2ibWH3xGrE_w7Av+VZg-DfgfH0aK72A@mail.gmail.com>
URL: https://gitlist.dev/e/CAKazavzS112w3wsxnA-2ibWH3xGrE_w7Av%2BVZg-DfgfH0aK72A%40mail.gmail.com
In-Reply-To: <b5316855-971d-4b7b-89cd-e81ececc5124@app.fastmail.com>

```
I have not given the command more than 10 seconds, shouldn't the
intended behaviour be to render the visible subgraph first?

On Wed, Apr 5, 2023 at 2:21 AM Kristoffer Haugsbakk
<kristofferhaugsbakk@fastmail.com> wrote:
>
> On Tue, Apr 4, 2023, at 22:27, Kristoffer Haugsbakk wrote:
> > FWIW: on my machine:
>
> So my point is: have you given the command a half a minute or so to
> output the initial lines? Certain `log` invocations can take a long time
> on repositories with rich histories.
>
> --
> Kristoffer Haugsbakk

```

## Taylor Blau, 2023-04-11 00:00

Subject: Re: git log causing hang while browsing upstream linux
Message-ID: <ZDSjBQhyDBGi9wBN@nand.local>
URL: https://gitlist.dev/e/ZDSjBQhyDBGi9wBN%40nand.local
In-Reply-To: <CAKazavzS112w3wsxnA-2ibWH3xGrE_w7Av+VZg-DfgfH0aK72A@mail.gmail.com>

```
On Mon, Apr 10, 2023 at 10:37:15PM +0530, Rohit Ner wrote:
> I have not given the command more than 10 seconds, shouldn't the
> intended behaviour be to render the visible subgraph first?

This is possible with Git's "commit-graph" feature, which you can read
about starting here:

		https://devblogs.microsoft.com/devops/supercharging-the-git-commit-graph/

TL;DR: if you run "git commit-graph write" once before running "git log
--oneline --graph", you'll get near-instantaneous results.

Thanks,
Taylor

```

## Kristoffer Haugsbakk, 2023-04-11 09:45

Subject: Re: git log causing hang while browsing upstream linux
Message-ID: <a356d9d4-e7e5-460d-bf90-b9d51649a20b@app.fastmail.com>
URL: https://gitlist.dev/e/a356d9d4-e7e5-460d-bf90-b9d51649a20b%40app.fastmail.com
In-Reply-To: <ZDSjBQhyDBGi9wBN@nand.local>

```
On Tue, Apr 11, 2023, at 02:00, Taylor Blau wrote:
> TL;DR: if you run "git commit-graph write" once before running "git log
> --oneline --graph", you'll get near-instantaneous results.

Cool! Testing on Linux repo:

Without it:

    $ time git log --oneline --graph | head -1
    *   0d3eb744aed4 Merge tag 'urgent-rcu.2023.04.07a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu

    real	0m11.379s
    user	0m10.655s
    sys	0m0.726s

With it:

    $ time git log --oneline --graph | head -1
    *   0d3eb744aed4 Merge tag 'urgent-rcu.2023.04.07a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu

    real	0m0.032s
    user	0m0.014s
    sys	0m0.023s

Maybe I’m gonna enable `git maintenance` for my repos. :)

-- 
Kristoffer Haugsbakk

```

## SZEDER Gábor, 2023-04-16 07:09

Subject: Re: git log causing hang while browsing upstream linux
Message-ID: <20230416070906.GA3271@szeder.dev>
URL: https://gitlist.dev/e/20230416070906.GA3271%40szeder.dev
In-Reply-To: <ZDSjBQhyDBGi9wBN@nand.local>

```
On Mon, Apr 10, 2023 at 08:00:05PM -0400, Taylor Blau wrote:
> On Mon, Apr 10, 2023 at 10:37:15PM +0530, Rohit Ner wrote:
> > I have not given the command more than 10 seconds, shouldn't the
> > intended behaviour be to render the visible subgraph first?
> 
> This is possible with Git's "commit-graph" feature, which you can read
> about starting here:
> 
> 		https://devblogs.microsoft.com/devops/supercharging-the-git-commit-graph/
> 
> TL;DR: if you run "git commit-graph write"

Please never recommend 'git commit-graph write' without '--reachable';
scanning all packed objects to find commits to include in the
commit-graph is just too inefficient for that.

> once before running "git log
> --oneline --graph", you'll get near-instantaneous results.

The commit-graph has been enabled by default in v2.24.0, released over
three years ago.  I wonder why Rohit's and/or Kristoffer's repos
didn't have it already?!


```

## Kristoffer Haugsbakk, 2023-04-16 12:46

Subject: How to write to the commit graph on clone?
Message-ID: <743b64a0-8731-46b8-a456-aaa51e310b9b@app.fastmail.com>
URL: https://gitlist.dev/e/743b64a0-8731-46b8-a456-aaa51e310b9b%40app.fastmail.com
In-Reply-To: <20230416070906.GA3271@szeder.dev>

```
> The commit-graph has been enabled by default in v2.24.0, released over
> three years ago.  I wonder why Rohit's and/or Kristoffer's repos
> didn't have it already?!

I might have done a fresh clone of Linux right before I replied to this
email thread, or else it might have just been lying around. (I don’t
work on Linux. ;)

I found out that I need to add this to my Git config in order for the
commit graph to be updated on `git fetch`, so I added it:

    [fetch]
            writeCommitGraph = true

I was wondering if this would help with cloning, so I did a fresh one:

    $ git clone https://github.com/torvalds/linux/ linux-github-2
    $ cd linux-github-2/
    $ time git log --oneline --graph | head -1
    *   3e7bb4f24617 Merge tag '6.3-rc6-smb311-client-negcontext-fix' of git://git.samba.org/sfrench/cifs-2.6

    real	0m10.364s
    user	0m9.700s
    sys	0m0.666s

So no.

But doing a `git fetch origin` fixed it:

    $ git fetch origin
    Expanding reachable commits in commit graph: 1171056, done.
    Writing out commit graph in 5 passes: 100% (5855280/5855280), done.
    $ time git log --oneline --graph | head -1
    *   3e7bb4f24617 Merge tag '6.3-rc6-smb311-client-negcontext-fix' of git://git.samba.org/sfrench/cifs-2.6

    real	0m0.017s
    user	0m0.007s
    sys	0m0.013s

Is there any config for writing to the commit graph on clone?

-- 
Kristoffer Haugsbakk

```

## Ævar Arnfjörð Bjarmason, 2023-04-16 15:24

Subject: Re: How to write to the commit graph on clone?
Message-ID: <230416.86edojsvc6.gmgdl@evledraar.gmail.com>
URL: https://gitlist.dev/e/230416.86edojsvc6.gmgdl%40evledraar.gmail.com
In-Reply-To: <743b64a0-8731-46b8-a456-aaa51e310b9b@app.fastmail.com>

```

On Sun, Apr 16 2023, Kristoffer Haugsbakk wrote:

>> The commit-graph has been enabled by default in v2.24.0, released over
>> three years ago.  I wonder why Rohit's and/or Kristoffer's repos
>> didn't have it already?!
>
> I might have done a fresh clone of Linux right before I replied to this
> email thread, or else it might have just been lying around. (I don’t
> work on Linux. ;)
>
> I found out that I need to add this to my Git config in order for the
> commit graph to be updated on `git fetch`, so I added it:
>
>     [fetch]
>             writeCommitGraph = true
>
> I was wondering if this would help with cloning, so I did a fresh one:
>
>     $ git clone https://github.com/torvalds/linux/ linux-github-2
>     $ cd linux-github-2/
>     $ time git log --oneline --graph | head -1
>     *   3e7bb4f24617 Merge tag '6.3-rc6-smb311-client-negcontext-fix' of git://git.samba.org/sfrench/cifs-2.6
>
>     real	0m10.364s
>     user	0m9.700s
>     sys	0m0.666s
>
> So no.
>
> But doing a `git fetch origin` fixed it:
>
>     $ git fetch origin
>     Expanding reachable commits in commit graph: 1171056, done.
>     Writing out commit graph in 5 passes: 100% (5855280/5855280), done.
>     $ time git log --oneline --graph | head -1
>     *   3e7bb4f24617 Merge tag '6.3-rc6-smb311-client-negcontext-fix' of git://git.samba.org/sfrench/cifs-2.6
>
>     real	0m0.017s
>     user	0m0.007s
>     sys	0m0.013s
>
> Is there any config for writing to the commit graph on clone?

I don't think there is, but here's a lengthy discussion I started a
while ago about having some "on glone gc", which would cover this:
https://lore.kernel.org/git/87tvm3go42.fsf@evledraar.gmail.com/

I haven't re-read it just now, but if you're interested that should be a
good place to start.

```
