git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: standalone library/tool to query commit-graph?

From
Derrick Stolee <stolee@gmail.com>
Date
May 23, 2019, 23:48 UTC
Message-ID
<f05405d7-c78d-a0e4-75a1-d623f977400a@gmail.com>
In-Reply-To
<20190523222031.GC951@szeder.dev>
On 5/23/2019 6:20 PM, SZEDER Gábor wrote:
Show 32 quoted lines
> On Thu, May 23, 2019 at 11:54:22PM +0200, Ævar Arnfjörð Bjarmason wrote:
>>
>> On Thu, May 23 2019, Jakub Narebski wrote:
>>
>>> Derrick Stolee <stolee@gmail.com> writes:
>>>> On 5/22/2019 2:49 PM, Karl Ostmo wrote:
>>>
>>>>> After producing the file ".git/objects/info/commit-graph" with the
>>>>> command "git commit-graph write", is there a way to answer queries
>>>>> like "git merge-base --is-ancestor" without having a .git directory?
>>>>> E.g. is there a library that will operate on the "commit-graph" file
>>>>> all by itself?
>>>>
>>>> You could certainly build such a tool, assuming your merge-base parameters are
>>>> full-length commit ids. If you try to start at ref names, you'll need the .git
>>>> directory.
>>>>
>>>> I would not expect such a tool to ever exist in the Git codebase. Instead, you
>>>> would need a new project, say "graph-analyzer --graph=<path> --is-ancestor <id1> <id2>"
>>>
>>> It would be nice if such tool could convert commit-graph into other
>>> commonly used augmented graph storage formats, like GEXF (Graph Exchange
>>> XML Format), GraphML, GML (Graph Modelling Language), Pajek format or
>>> Graphviz .dot format.
>>
>> Wouldn't that make more sense as a hypothetical output format for "log
>> --graph" rather than something you'd want to emit from the commit-graph?
>> Presumably you'd want to export in such a format to see the shape of the
>> repo, and since the commit graph doesn't include any commits outside of
>> packs you'd miss any loose commits.
> 
> No, the commit-graph includes loose commits as well.
Depends on how you build the commit-graph.
	git commit-graph write
	git commit-graph write --stdin-packs
These options build based on commits in packs (and closes under reachability).
	git commit-graph write --reachable
	git commit-graph write --stdin-commits

These options build based on a set of starting commits. Either the refs (--reachable) or the input commit ids (--stdin-commits).

But I do like the flexibility of `git log --graph` as you could export the graph after reparenting (with options like `--simplify-merges -- <path>`). You also would not include commits from random topic branches you have sitting around.

-Stolee
Previous: SZEDER GáborNext: SZEDER Gábor
Message 6 of 12 in “standalone library/tool to query commit-graph?”
  1. Karl OstmoMay 22, 2019
  2. Derrick StoleeMay 22, 2019
  3. Jakub NarebskiMay 23, 2019
  4. Ævar Arnfjörð BjarmasonMay 23, 2019
  5. SZEDER GáborMay 23, 2019
  6. Derrick StoleeMay 23, 2019
  7. SZEDER GáborMay 24, 2019
  8. Ævar Arnfjörð BjarmasonMay 24, 2019
  9. SZEDER GáborMay 24, 2019
  10. Ævar Arnfjörð BjarmasonMay 24, 2019
  11. SZEDER GáborMay 24, 2019
  12. Jakub NarebskiJun 25, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.