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

Re: Complete http-pull; where should it go?

From
Linus Torvalds <torvalds@osdl.org>
Date
May 1, 2005, 20:46 UTC
Message-ID
<Pine.LNX.4.58.0505011337070.2296@ppc970.osdl.org>
In-Reply-To
<Pine.LNX.4.21.0505011544120.30848-100000@iabervon.org>
On Sun, 1 May 2005, Daniel Barkalow wrote:
Show 5 quoted lines
> 
> Right; what I want to make programs able to do is take explicit
> references, instead of only taking the objects they reference. So you
> say heads/master or heads/linus instead of
> "198b0fb635ed8a007bac0c16eab112c5e2c7995c".
That's fine. 

This is really just an issue of havign a function that does "get_sha1()", and then making the things that take command line arguments use that one instead of "get_sha1_hex()".

Then you can have rules like:
 - if it's a hex number, take it
 - if it's a filename,  look it up
 - if ".git/refs + str is a filename, look it up.
Something like
	int get_sha1(char *str, unsigned char *result)
	{
		static char pathname[PATH_MAX];
		if (get_sha1_hex(str, result) == 0)
			return 0;
		if (get_sha1_file(str, result) == 0)
			return 0;
		snprintf(pathname, sizeof(pathname), ".git/refs/%s", str);
		if (get_sha1_file(pathname, result) == 0)
			return 0;
		...
	}
where you have
	int get_sha1_file(char *path, unsigned char *result)
	{
		char buffer[60];
		int fd = open(path, O_RDONLY);
		int len;
		if (fd < 0)
			return -1;
		len = read(fd, buffer, sizeof(buffer));
		close(fd);
		if (len < 40)
			return -1;
		return get_sha1_hex(buffer, result);
	}
			
or whatever.

The _only_ thing I want to be careful about is that all the _internal_ stuff still have to use the strict "get_sha1_hex()" function, ie we should never _ever_ accept a tree object where the "sha1" ends up being anything but the hex thing. So this "generalized get_sha1()" would have to be used only on real user input (ie argv[] array and the like).

		Linus
Previous: Daniel BarkalowNext: Daniel Barkalow
Message 4 of 14 in “Complete http-pull; where should it go?”
  1. Daniel BarkalowMay 1, 2005
  2. Linus TorvaldsMay 1, 2005
  3. Daniel BarkalowMay 1, 2005
  4. Linus TorvaldsMay 1, 2005
  5. Daniel BarkalowMay 1, 2005
  6. Linus TorvaldsMay 1, 2005
  7. Daniel BarkalowMay 1, 2005
  8. Linus TorvaldsMay 1, 2005
  9. Junio C HamanoMay 2, 2005
  10. Linus TorvaldsMay 2, 2005
  11. Junio C HamanoMay 2, 2005
  12. Linus TorvaldsMay 2, 2005
  13. Daniel BarkalowMay 2, 2005
  14. Junio C HamanoMay 1, 2005

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.