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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Marco Costalba <mcostalba@xxxxxxxxx> wrote:
> On 12/6/06, Shawn Pearce <spearce@xxxxxxxxxxx> wrote:
> >Marco Costalba <mcostalba@xxxxxxxxx> 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);

-- 
Shawn.
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]