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

Re: [PATCH] git-daemon server

From
Junio C Hamano <junkio@cox.net>
Date
Jun 3, 2005, 17:24 UTC
Message-ID
<7vk6lbmk01.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20050603152212.GA4598@jmcmullan.timesys>
Looks very nice.  Some comments.
    diff -u b/daemon.c b/daemon.c
    --- b/daemon.c
    +++ b/daemon.c
------------
    +
    +/* Protocol is symmetric, both client and server
    + * use the same commands.
    + *
    + * version\n -> error -- 0 <Version string>\n
    + *
    + * head <head-id>\n -> sha1 <head-id> <sha1>\n
    + *
    + * head <head-id> <old-sha1> <new-sha1>\n -> sha1 <head-id> <new-sha1>\n
    + *
    + * request <sha1>\n -> send <sha1> <hex-bytes>\n<bytes...>
    + *
    + * send <sha1> <hex-bytes>\n<bytes...> -> sha1 -- <sha1>\n
    + *
    + * exists <sha1>\n -> sha1 -- <sha1>\n
    + *
    + * sha1 <any> <sha1>\n -> no-op
    + *
    + * error <key> <hex-code> <error string>\n -> no-op
    + *
    + */

This is good for the first cut, but I have a latency concern about "single request - single send" style of communication. This being a dedicated GIT specific sync mechanism, you may want to give more smarts to the server, so that the client can say "I have these commits as HEADs in my forest, here are their SHA1s, now sync me up to the head you said you have whose SHA1 is this", implying he has all their HEADs dependents. Of course this can come later.

------------
    +static int verify_file(int fd, unsigned long mapsize, const unsigned char *sha1, char *type)
    +{
    +	void *map, *buffer;
   ~~~ 
    +		if (buffer && !strcmp(type, "delta")) {
    +			void *ref = NULL, *delta = buffer;
    +			unsigned long ref_size, delta_size = size;
    +			buffer = NULL;
   ~~~
    +			buffer = patch_delta(ref, ref_size,
    +					  delta+20, delta_size-20, 
    +					  &size);
    +			free(delta);
    +			free(ref);
    +		}

A possibility is to chuck the above special case for "delta", and instead introduce "delta" subclass in struct object family and make the base object of "delta" simply one object on the obj->refs list on such a "delta" object. I would imagine that this would let you reuse the sha1_retrieve() loop that you already do for "commit", "tree", and "tag".

    +		if (!strcmp(type, "blob")) {
    +			struct blob *blob = lookup_blob(sha1);
    +			parse_blob_buffer(blob, buffer, size);
   ~~~
    +			obj = &tag->object;
    +		} else {
    +			obj = NULL;
    +		}
    +
    +		free(buffer);
    +
    +		if (obj) {
    +			struct object_list *refs;
    +
    +			for (refs = obj->refs; refs ; refs = refs->next) {
    +				err = sha1_retrieve(refs->item->sha1);
    +				if (err < 0)
    +					return err;
    +			}
    +		
    +			return 0;
    +		}
    +
    +	}
    +	return -1;
    +}
------------
    +static int send_send(const unsigned char *sha1, int size, void *data)
    +{
   ~~~
    +}
   ~~~
    +static int cmd_request(int argc, char **argv)
    +{
    +	int err;
    +
    +	if (argc == 2) {
    +		char sha1[40];
    +		void *data;
    +		unsigned long size;
   ~~~
    +		err = send_send(sha1, size, data);
    +		if (err < 0)
    +			return err;

By definition, size of SHA1 blob is "unsigned long" so send_send() should take such not "int".

Previous: Linus TorvaldsNext: Junio C Hamano
Message 15 of 32 in “git-daemon server”
  1. git-daemon serverJason McMullan, Jun 3, 2005
  2. Linus TorvaldsJun 3, 2005
  3. McMullan, JasonJun 3, 2005
  4. Linus TorvaldsJun 3, 2005
  5. McMullan, JasonJun 3, 2005
  6. Linus TorvaldsJun 3, 2005
  7. McMullan, JasonJun 3, 2005
  8. Linus TorvaldsJun 3, 2005
  9. McMullan, JasonJun 3, 2005
  10. Linus TorvaldsJun 3, 2005
  11. Daniel SerpellJun 3, 2005
  12. Jason McMullanJun 5, 2005
  13. Junio C HamanoJun 3, 2005
  14. Linus TorvaldsJun 3, 2005
  15. Junio C HamanoJun 3, 2005
  16. Junio C HamanoJun 3, 2005
  17. Daniel BarkalowJun 3, 2005
  18. Linus TorvaldsJun 3, 2005
  19. Petr BaudisJun 3, 2005
  20. Daniel BarkalowJun 4, 2005
  21. Junio C HamanoJun 5, 2005
  22. Daniel BarkalowJun 5, 2005
  23. Junio C HamanoJun 5, 2005
  24. Daniel BarkalowJun 5, 2005
  25. Linus TorvaldsJun 5, 2005
  26. rename git-rpush and git-rpull to git-ssh-push and git-ssh-pullJunio C Hamano, Jun 5, 2005
  27. Daniel BarkalowJun 5, 2005
  28. Linus TorvaldsJun 5, 2005
  29. rename git-rpush and git-rpull to git-ssh-push and git-ssh-pullJunio C Hamano, Jun 5, 2005
  30. Linus TorvaldsJun 5, 2005
  31. Jason McMullanJun 5, 2005
  32. Linus TorvaldsJun 5, 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.