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

Re: Fast access git-rev-list output: some OS knowledge required

From
Shawn Pearce <spearce@spearce.org>
Date
Dec 6, 2006, 19:42 UTC
Message-ID
<20061206194258.GD20320@spearce.org>
In-Reply-To
<e5bfff550612061134r3725dcbu2ff2dd6284fcd651@mail.gmail.com>
Marco Costalba <mcostalba@gmail.com> wrote:
Show 15 quoted lines
> On 12/6/06, Shawn Pearce <spearce@spearce.org> wrote:
> >Marco Costalba <mcostalba@gmail.com> wrote:
> >> The time it takes to read, without processing, the whole Linux tree
> >> with this approach it's almost _double_ of the time it takes 'git
> >> rev-list' to write to a file:
> >>
> >> 3) Other suggestions?  ;-)
> >
> >The revision listing machinery is fairly well isolated behind some
> >pretty clean APIs in Git.  Why not link qgit against libgit.a and
> >just do the revision listing in process?
> >
> 
> Where can I found some documentation (yes I know RTFS, but...) or,
> better, an example of using the API to read git-rev-list output?
builtin-rev-list.c.  :-)
 
I think all you may need is:
	#include "revision.h"
	...
	struct rev_info revs;
	init_revisions(&revs, prefix);
	revs.abbrev = 0;
	revs.commit_format = CMIT_FMT_UNSPECIFIED;
	argc = setup_revisions(argc, argv, &revs, NULL);

where argv just a char** of the arguments you were going to hand to rev-list on the command line.

then get the data back:
	static void show_commit(struct commit *commit)
	{
		const char * hex = sha1_to_hex(commit->object.sha1);
		... copy from hex to your own structures ...
	}
	static void show_object(struct object_array_entry *p)
	{
		/* do nothing */
	}
	prepare_revision_walk(&revs);
	traverse_commit_list(&revs, show_commit, show_object);
Previous: Marco CostalbaNext: Shawn Pearce
Message 4 of 17 in “Fast access git-rev-list output: some OS knowledge required”
  1. Marco CostalbaDec 6, 2006
  2. Shawn PearceDec 6, 2006
  3. Marco CostalbaDec 6, 2006
  4. Shawn PearceDec 6, 2006
  5. Shawn PearceDec 6, 2006
  6. Marco CostalbaDec 6, 2006
  7. Shawn PearceDec 6, 2006
  8. Andreas EricssonDec 7, 2006
  9. Johannes SchindelinDec 7, 2006
  10. Andreas EricssonDec 7, 2006
  11. Johannes SchindelinDec 7, 2006
  12. Marco CostalbaDec 8, 2006
  13. Michael K. EdwardsDec 8, 2006
  14. Marco CostalbaDec 9, 2006
  15. Johannes SchindelinDec 6, 2006
  16. Linus TorvaldsDec 7, 2006
  17. Marco CostalbaDec 7, 2006

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.