Subject: Re: [WIP/PATCH] Teach fast-import to print the id of each imported commit

From: Sam Vilain <[email-masked]>
Date: Sun, 04 Jul 2010 15:44:04 +1200

On Sat, 2010-07-03 at 19:35 -0500, Jonathan Nieder wrote:
> Sam Vilain wrote:
> 
> > It should be very simple to implement --batch-verify as well, which is
> > essentially the same thing, just only printing the header and not the
> > contents.
> > 
> > How hard do you think it would be to implement a 'rev-parse' command?
> > Perhaps you can see where this is going... :-)
> 
> Well, I think I understand what you are saying, but it’s not quite
> like that.  fast-import is already doing a lot of work to keep track
> of this collection of objects in a pack that is not yet accessible to
> git because its index has not been written yet.
  [...]
> Or one can teach fast-import to supply exactly what we need from it,
> which is the raw content of some blobs (and perhaps trees) it has
> written to pack and not indexed yet.

Let me explain further.  If in fast-import.c:new_object, if it were to
make a struct object (see object.h), and make sure it was put in
obj_hash (see object.c, particularly create_object()), then you might
find a whole load of plumbing would magically start working and be able
to work with the new objects that you are trying to load.  Of course
there may be a couple of other functions which might need to change.
Primarily object.c:read_object, which needs to be able to check the
packfile being spooled by git fast-import.

If you did this, then to implement this feature you could in principle
just call read_sha1_file()

Sam