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

Re: parsecvs tool now creates git repositories

From
Junio C Hamano <junkio@cox.net>
Date
Apr 4, 2006, 06:09 UTC
Message-ID
<7vodzhc1oh.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<1144122709.2303.153.camel@neko.keithp.com>
Keith Packard <keithp@keithp.com> writes:
Show 5 quoted lines
> I've just changed parsecvs to generate blobs for every revision in
> each ,v file right after they're read in; putting the necessary code
> right into parsecvs should be reasonably straightforward; we don't need
> the multi-patch logic as we do want to compute each intermediate version
> of the file.

If you want to go really fast without extra fork, are writing it in C, and have the data for blob in core, you could link with libgit.a and call write_sha1_file() yourself:

	unsigned char sha1[20];
        void *buf;
        unsigned long len;
	write_sha1_file(buf, len, "blob", sha1);

instead of forking "hash-object -w". You feed your blob data in buf, with its length in len, and you will get the blob object name back in sha1[]. buf is owned by you and after write_sha1_file() returns it is safe for you to scribble over it or free() it. sha1[] stores binary object name (20 bytes, not 40-byte hexadecimal), and you can use the helper function sha1_to_hex() if you need a hex representation:

	char *sha1_to_hex(sha1)

which returns a pointer to a static buffer that is valid until next call to sha1_to_hex(), so you need to strdup it if you want to retain it.

Previous: Keith Packard
Message 22 of 22 in “parsecvs tool now creates git repositories”
  1. Keith PackardApr 2, 2006
  2. Jan-Benedict GlawApr 2, 2006
  3. Jan-Benedict GlawApr 2, 2006
  4. Keith PackardApr 3, 2006
  5. Linus TorvaldsApr 3, 2006
  6. Jan-Benedict GlawApr 3, 2006
  7. Erik MouwApr 3, 2006
  8. Keith PackardApr 3, 2006
  9. Keith PackardApr 3, 2006
  10. Erik MouwApr 3, 2006
  11. Jakub NarebskiApr 3, 2006
  12. Keith PackardApr 3, 2006
  13. Keith PackardApr 3, 2006
  14. Jeff KingApr 3, 2006
  15. Anand KumriaApr 4, 2006
  16. Martin LanghoffApr 3, 2006
  17. Keith PackardApr 4, 2006
  18. Martin LanghoffApr 4, 2006
  19. Keith PackardApr 4, 2006
  20. Martin LanghoffApr 4, 2006
  21. Keith PackardApr 4, 2006
  22. Junio C HamanoApr 4, 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.