{"thread":{"id":"59542","subject":"git log causing hang while browsing upstream linux","startedAt":"2023-04-04T20:13:26Z","lastAt":"2023-04-16T15:25:19Z","messageCount":9,"participants":["Rohit Ner","Kristoffer Haugsbakk","Taylor Blau","SZEDER Gábor","Ævar Arnfjörð Bjarmason"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"474804","messageId":"CAKazavxTXwcZFtL2XyU3MpaUR=snWY8w8Lwpco+mkbqm2nWE=w@mail.gmail.com","threadId":"59542","inReplyTo":null,"subject":"git log causing hang while browsing upstream linux","fromName":"Rohit Ner","fromEmail":"rohitner1@gmail.com","sentAt":"2023-04-04T20:13:09Z","receivedAt":"2023-04-04T20:13:26Z","isPatch":false,"sender":{"key":"rohitner1@gmail.com","avatar":null},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n1. git clone https://github.com/torvalds/linux.git\n2. git checkout master\n3. git log --oneline --graph\n\nWhat did you expect to happen? (Expected behavior)\nSee a graph of onelined commit histories\n\nWhat happened instead? (Actual behavior)\nHang after entering the command\n\nWhat's different between what you expected and what actually happened?\nThe output is empty and the cursor is stuck. Cursor is unresponsive to any key\npress other than ^C which leads to an output like below\n### OUTPUT START ###\n...\n~\n~\n~\n~\n(END)\n### OUTPUT END ###\nPressing q key helps get the prompt back.\n\nAnything else you want to add:\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\ncompiler info: gnuc: 12.2\nlibc info: glibc: 2.36\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\ncommit-msg\npre-commit\nprepare-commit-msg\n"},{"id":"474809","messageId":"5b99135f-c1d4-434b-b508-35f5d66dd2bb@app.fastmail.com","threadId":"59542","inReplyTo":"CAKazavxTXwcZFtL2XyU3MpaUR=snWY8w8Lwpco+mkbqm2nWE=w@mail.gmail.com","subject":"Re: git log causing hang while browsing upstream linux","fromName":"Kristoffer Haugsbakk","fromEmail":"code@khaugsbakk.name","sentAt":"2023-04-04T20:27:26Z","receivedAt":"2023-04-04T20:27:52Z","isPatch":false,"sender":{"key":"code@khaugsbakk.name","avatar":"https://avatars.githubusercontent.com/u/2229597?v=4"},"body":"On Tue, Apr 4, 2023, at 22:13, Rohit Ner wrote:\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n>\n> What did you do before the bug happened? (Steps to reproduce your issue)\n> 1. git clone https://github.com/torvalds/linux.git\n> 2. git checkout master\n> 3. git log --oneline --graph\n\nSeems like `--graph` is expensive.\n\nFWIW: on my machine:\n\n    $ time git log --oneline --graph | head -1 \n    *   76f598ba7d8e Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm\n\n    real\t0m10.616s\n    user\t0m9.594s\n    sys\t0m0.654s\n\nSecond attempt is only marginally faster.\n\n-- \nKristoffer Haugsbakk\n"},{"id":"474811","messageId":"b5316855-971d-4b7b-89cd-e81ececc5124@app.fastmail.com","threadId":"59542","inReplyTo":"5b99135f-c1d4-434b-b508-35f5d66dd2bb@app.fastmail.com","subject":"Re: git log causing hang while browsing upstream linux","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2023-04-04T20:50:52Z","receivedAt":"2023-04-04T20:51:26Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Tue, Apr 4, 2023, at 22:27, Kristoffer Haugsbakk wrote:\n> FWIW: on my machine:\n\nSo my point is: have you given the command a half a minute or so to\noutput the initial lines? Certain `log` invocations can take a long time\non repositories with rich histories.\n\n-- \nKristoffer Haugsbakk\n"},{"id":"475073","messageId":"CAKazavzS112w3wsxnA-2ibWH3xGrE_w7Av+VZg-DfgfH0aK72A@mail.gmail.com","threadId":"59542","inReplyTo":"b5316855-971d-4b7b-89cd-e81ececc5124@app.fastmail.com","subject":"Re: git log causing hang while browsing upstream linux","fromName":"Rohit Ner","fromEmail":"rohitner1@gmail.com","sentAt":"2023-04-10T17:07:15Z","receivedAt":"2023-04-10T17:07:43Z","isPatch":false,"sender":{"key":"rohitner1@gmail.com","avatar":null},"body":"I have not given the command more than 10 seconds, shouldn't the\nintended behaviour be to render the visible subgraph first?\n\nOn Wed, Apr 5, 2023 at 2:21 AM Kristoffer Haugsbakk\n<kristofferhaugsbakk@fastmail.com> wrote:\n>\n> On Tue, Apr 4, 2023, at 22:27, Kristoffer Haugsbakk wrote:\n> > FWIW: on my machine:\n>\n> So my point is: have you given the command a half a minute or so to\n> output the initial lines? Certain `log` invocations can take a long time\n> on repositories with rich histories.\n>\n> --\n> Kristoffer Haugsbakk\n"},{"id":"475106","messageId":"ZDSjBQhyDBGi9wBN@nand.local","threadId":"59542","inReplyTo":"CAKazavzS112w3wsxnA-2ibWH3xGrE_w7Av+VZg-DfgfH0aK72A@mail.gmail.com","subject":"Re: git log causing hang while browsing upstream linux","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2023-04-11T00:00:05Z","receivedAt":"2023-04-11T00:00:11Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Mon, Apr 10, 2023 at 10:37:15PM +0530, Rohit Ner wrote:\n> I have not given the command more than 10 seconds, shouldn't the\n> intended behaviour be to render the visible subgraph first?\n\nThis is possible with Git's \"commit-graph\" feature, which you can read\nabout starting here:\n\n\t\thttps://devblogs.microsoft.com/devops/supercharging-the-git-commit-graph/\n\nTL;DR: if you run \"git commit-graph write\" once before running \"git log\n--oneline --graph\", you'll get near-instantaneous results.\n\nThanks,\nTaylor\n"},{"id":"475136","messageId":"a356d9d4-e7e5-460d-bf90-b9d51649a20b@app.fastmail.com","threadId":"59542","inReplyTo":"ZDSjBQhyDBGi9wBN@nand.local","subject":"Re: git log causing hang while browsing upstream linux","fromName":"Kristoffer Haugsbakk","fromEmail":"code@khaugsbakk.name","sentAt":"2023-04-11T09:45:47Z","receivedAt":"2023-04-11T09:46:34Z","isPatch":false,"sender":{"key":"code@khaugsbakk.name","avatar":"https://avatars.githubusercontent.com/u/2229597?v=4"},"body":"On Tue, Apr 11, 2023, at 02:00, Taylor Blau wrote:\n> TL;DR: if you run \"git commit-graph write\" once before running \"git log\n> --oneline --graph\", you'll get near-instantaneous results.\n\nCool! Testing on Linux repo:\n\nWithout it:\n\n    $ time git log --oneline --graph | head -1\n    *   0d3eb744aed4 Merge tag 'urgent-rcu.2023.04.07a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu\n\n    real\t0m11.379s\n    user\t0m10.655s\n    sys\t0m0.726s\n\nWith it:\n\n    $ time git log --oneline --graph | head -1\n    *   0d3eb744aed4 Merge tag 'urgent-rcu.2023.04.07a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu\n\n    real\t0m0.032s\n    user\t0m0.014s\n    sys\t0m0.023s\n\nMaybe I’m gonna enable `git maintenance` for my repos. :)\n\n-- \nKristoffer Haugsbakk\n"},{"id":"475481","messageId":"20230416070906.GA3271@szeder.dev","threadId":"59542","inReplyTo":"ZDSjBQhyDBGi9wBN@nand.local","subject":"Re: git log causing hang while browsing upstream linux","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2023-04-16T07:09:06Z","receivedAt":"2023-04-16T07:09:14Z","isPatch":false,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Mon, Apr 10, 2023 at 08:00:05PM -0400, Taylor Blau wrote:\n> On Mon, Apr 10, 2023 at 10:37:15PM +0530, Rohit Ner wrote:\n> > I have not given the command more than 10 seconds, shouldn't the\n> > intended behaviour be to render the visible subgraph first?\n> \n> This is possible with Git's \"commit-graph\" feature, which you can read\n> about starting here:\n> \n> \t\thttps://devblogs.microsoft.com/devops/supercharging-the-git-commit-graph/\n> \n> TL;DR: if you run \"git commit-graph write\"\n\nPlease never recommend 'git commit-graph write' without '--reachable';\nscanning all packed objects to find commits to include in the\ncommit-graph is just too inefficient for that.\n\n> once before running \"git log\n> --oneline --graph\", you'll get near-instantaneous results.\n\nThe commit-graph has been enabled by default in v2.24.0, released over\nthree years ago.  I wonder why Rohit's and/or Kristoffer's repos\ndidn't have it already?!\n\n"},{"id":"475488","messageId":"743b64a0-8731-46b8-a456-aaa51e310b9b@app.fastmail.com","threadId":"59542","inReplyTo":"20230416070906.GA3271@szeder.dev","subject":"How to write to the commit graph on clone?","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2023-04-16T12:46:49Z","receivedAt":"2023-04-16T12:47:36Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"> The commit-graph has been enabled by default in v2.24.0, released over\n> three years ago.  I wonder why Rohit's and/or Kristoffer's repos\n> didn't have it already?!\n\nI might have done a fresh clone of Linux right before I replied to this\nemail thread, or else it might have just been lying around. (I don’t\nwork on Linux. ;)\n\nI found out that I need to add this to my Git config in order for the\ncommit graph to be updated on `git fetch`, so I added it:\n\n    [fetch]\n            writeCommitGraph = true\n\nI was wondering if this would help with cloning, so I did a fresh one:\n\n    $ git clone https://github.com/torvalds/linux/ linux-github-2\n    $ cd linux-github-2/\n    $ time git log --oneline --graph | head -1\n    *   3e7bb4f24617 Merge tag '6.3-rc6-smb311-client-negcontext-fix' of git://git.samba.org/sfrench/cifs-2.6\n\n    real\t0m10.364s\n    user\t0m9.700s\n    sys\t0m0.666s\n\nSo no.\n\nBut doing a `git fetch origin` fixed it:\n\n    $ git fetch origin\n    Expanding reachable commits in commit graph: 1171056, done.\n    Writing out commit graph in 5 passes: 100% (5855280/5855280), done.\n    $ time git log --oneline --graph | head -1\n    *   3e7bb4f24617 Merge tag '6.3-rc6-smb311-client-negcontext-fix' of git://git.samba.org/sfrench/cifs-2.6\n\n    real\t0m0.017s\n    user\t0m0.007s\n    sys\t0m0.013s\n\nIs there any config for writing to the commit graph on clone?\n\n-- \nKristoffer Haugsbakk\n"},{"id":"475491","messageId":"230416.86edojsvc6.gmgdl@evledraar.gmail.com","threadId":"59542","inReplyTo":"743b64a0-8731-46b8-a456-aaa51e310b9b@app.fastmail.com","subject":"Re: How to write to the commit graph on clone?","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2023-04-16T15:24:33Z","receivedAt":"2023-04-16T15:25:19Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Sun, Apr 16 2023, Kristoffer Haugsbakk wrote:\n\n>> The commit-graph has been enabled by default in v2.24.0, released over\n>> three years ago.  I wonder why Rohit's and/or Kristoffer's repos\n>> didn't have it already?!\n>\n> I might have done a fresh clone of Linux right before I replied to this\n> email thread, or else it might have just been lying around. (I don’t\n> work on Linux. ;)\n>\n> I found out that I need to add this to my Git config in order for the\n> commit graph to be updated on `git fetch`, so I added it:\n>\n>     [fetch]\n>             writeCommitGraph = true\n>\n> I was wondering if this would help with cloning, so I did a fresh one:\n>\n>     $ git clone https://github.com/torvalds/linux/ linux-github-2\n>     $ cd linux-github-2/\n>     $ time git log --oneline --graph | head -1\n>     *   3e7bb4f24617 Merge tag '6.3-rc6-smb311-client-negcontext-fix' of git://git.samba.org/sfrench/cifs-2.6\n>\n>     real\t0m10.364s\n>     user\t0m9.700s\n>     sys\t0m0.666s\n>\n> So no.\n>\n> But doing a `git fetch origin` fixed it:\n>\n>     $ git fetch origin\n>     Expanding reachable commits in commit graph: 1171056, done.\n>     Writing out commit graph in 5 passes: 100% (5855280/5855280), done.\n>     $ time git log --oneline --graph | head -1\n>     *   3e7bb4f24617 Merge tag '6.3-rc6-smb311-client-negcontext-fix' of git://git.samba.org/sfrench/cifs-2.6\n>\n>     real\t0m0.017s\n>     user\t0m0.007s\n>     sys\t0m0.013s\n>\n> Is there any config for writing to the commit graph on clone?\n\nI don't think there is, but here's a lengthy discussion I started a\nwhile ago about having some \"on glone gc\", which would cover this:\nhttps://lore.kernel.org/git/87tvm3go42.fsf@evledraar.gmail.com/\n\nI haven't re-read it just now, but if you're interested that should be a\ngood place to start.\n"}]}