All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Jason McMullan <jason.mcmullan@timesys.com>
Cc: git@vger.kernel.org, torvalds@osdl.org
Subject: Re: [PATCH] git-daemon server
Date: Fri, 03 Jun 2005 10:24:14 -0700	[thread overview]
Message-ID: <7vk6lbmk01.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <20050603152212.GA4598@jmcmullan.timesys> (Jason McMullan's message of "Fri, 3 Jun 2005 11:22:12 -0400")

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".


  parent reply	other threads:[~2005-06-03 17:21 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-03 15:22 [PATCH] git-daemon server Jason McMullan
2005-06-03 16:02 ` Linus Torvalds
2005-06-03 16:09   ` McMullan, Jason
2005-06-03 16:30     ` Linus Torvalds
2005-06-03 17:18       ` McMullan, Jason
2005-06-03 17:41         ` Linus Torvalds
2005-06-03 19:30           ` McMullan, Jason
2005-06-03 20:25             ` Linus Torvalds
2005-06-03 20:56               ` McMullan, Jason
2005-06-03 21:38                 ` Linus Torvalds
2005-06-03 22:01                   ` Daniel Serpell
2005-06-05 16:44                   ` Jason McMullan
2005-06-03 17:00   ` Junio C Hamano
2005-06-03 17:50     ` Linus Torvalds
2005-06-03 17:24 ` Junio C Hamano [this message]
2005-06-03 18:30   ` Junio C Hamano
2005-06-03 21:33 ` Daniel Barkalow
2005-06-03 21:59   ` Linus Torvalds
2005-06-03 22:39     ` Petr Baudis
2005-06-04  0:06     ` Daniel Barkalow
2005-06-05  4:47       ` Junio C Hamano
2005-06-05  5:38         ` Daniel Barkalow
2005-06-05  6:48           ` Junio C Hamano
2005-06-05 16:03             ` Daniel Barkalow
2005-06-05 16:17             ` Linus Torvalds
2005-06-05  6:57           ` [PATCH-CAREFUL/RENAME] rename git-rpush and git-rpull to git-ssh-push and git-ssh-pull Junio C Hamano
2005-06-05 16:06             ` Daniel Barkalow
2005-06-05 21:31             ` Linus Torvalds
2005-06-05 22:41               ` Junio C Hamano
2005-06-05 23:17                 ` Linus Torvalds
2005-06-05 16:49     ` [PATCH] git-daemon server Jason McMullan
2005-06-05 18:11       ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vk6lbmk01.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=jason.mcmullan@timesys.com \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.