From: Junio C Hamano <junkio@cox.net>
To: Franck Bui-Huu <vagabon.xyz@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/4] Add git-archive
Date: Thu, 07 Sep 2006 19:35:12 -0700 [thread overview]
Message-ID: <7vodtrnl0f.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <11576347251776-git-send-email-vagabon.xyz@gmail.com> (Franck Bui-Huu's message of "Thu, 7 Sep 2006 15:12:02 +0200")
Franck Bui-Huu <vagabon.xyz@gmail.com> writes:
> The main reason for making this API is to avoid using
> git-{tar,zip}-tree commands, hence making them useless. Maybe it's
> time for them to die ?
The answer is "not yet" and the above paragraph, at least the
last sentence and half, do not belong to the commit log message.
> It also implements remote operations by defining a very simple
> protocol: it first sends the name of the specific uploader followed
> the repository name (git-upload-tar git://example.org/repo.git).
> Then it sends options. It's done by sending a sequence of one
> argument per packet, with prefix "argument ", followed by a flush.
I haven't looked the existing code closely recently, but my
impression was that if you want to make the protocol operable
with both git-daemon, ssh target, and local pipe, it is easier
to make the request message exactly like you would invoke the
remote command over the ssh connection in the target repository
(see connect.c). I am not sure how well the above
"git-upload-tar reponame" would work. I would have expected it
to be "git-upload-archive reponame" with the first on-protocol
parameter being "--fmt=tar".
Does your code work well when you run the remote archive
fetching locally, i.e. "git-archive --remote=../other.git",
I wonder?
... goes on and reads the patch, notices that the protocol
command is git-upload-archive with the archive location. Which
is GOOD. It is just the above description is a tad stale.
> diff --git a/archive.h b/archive.h
> new file mode 100644
> index 0000000..f33398e
> --- /dev/null
> +++ b/archive.h
> @@ -0,0 +1,41 @@
> +#ifndef ARCHIVE_H
> +#define ARCHIVE_H
> +
> +#define MAX_EXTRA_ARGS 32
> +#define MAX_ARGS (MAX_EXTRA_ARGS + 32)
> +
> +struct archiver_args {
> + const char *base;
> + struct tree *tree;
> + const unsigned char *commit_sha1;
> + time_t time;
> + const char **pathspec;
> + void *extra;
> +};
> +
> +typedef int (*write_archive_fn_t)(struct archiver_args *);
> +
> +typedef void *(*parse_extra_args_fn_t)(int argc, const char **argv);
> +
> +struct archiver {
> + const char *name;
> + const char *remote;
> + struct archiver_args args;
> + write_archive_fn_t write_archive;
> + parse_extra_args_fn_t parse_extra;
> +};
> +
> +extern struct archiver archivers[];
I thought the reason for archiver_args (and archiver_args.extra)
was because we wanted to avoid storing per invocation parameters
in static variables, which would hamper reentrancy. If one
process is creating two archives, both format=tar, it might be
reasonable for the code (future archiver enhancement, not your
current implementation of git-archive driver) to parse two sets
of parameters first (to get separate archiver instances) and
call their write_archive, but if archivers[] list has the
per-invocation parameter args then we are back to square one,
aren't we?
Reentrancy may not matter, but in any case the above archiver_args
is not helping enough to improve the situation, I think.
Actually you may be able to get away by returning a copy of
archivers[] element from get_archiver() when we need reentrancy
in the future. Of course the caller needs to free() it when it
is done with it, since it is a per-invocation handle.
> +void parse_treeish_arg(const char **argv, struct archiver_args *ar_args,
> + const char *prefix)
> +{
> +...
> + //free(tree);
> + ar_args->tree = tree;
> + ar_args->commit_sha1 = commit_sha1;
> + ar_args->time = archive_time;
> +}
Stray comment...
Overall looks good, except you already know your issue #4 ;-).
I haven't had a chance to look at connect.c code but I have a
mild suspicion that full reuse of upload-pack code by moving
everything into connect.c is not possible; at least the initial
handshake to determine if sideband is to be used is specific to
upload-pack protocol which needed to bolt-it-on to an existing
protocol to support older clients and servers, and I do not
think we would want to carry that baggage for this new protocol.
The pipe setup code in upload-pack.c::create_pack_file() is
quite specific to upload-pack. I am not sure how much of it can
be reused by refactoring, but it may be worth a try.
The part that reads from fd 1 and 2 and to multiplex into the
stream on the uploader side (the main while() loop in the same
create_pack_file() function, and send_client_data() function),
and the code to setup and demultiplex the bands on the
downloader side (setup_sideband() in fetch-clone.c) should be
reusable as-is, I think. They are defined as static so you
would need to move the code around to make them available from
elsewhere.
next prev parent reply other threads:[~2006-09-08 2:35 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-05 12:16 [PATCH 1/2] Add git-archive Franck Bui-Huu
2006-09-05 19:23 ` Junio C Hamano
2006-09-06 13:46 ` Franck Bui-Huu
2006-09-06 20:14 ` Rene Scharfe
2006-09-06 20:29 ` Jakub Narebski
2006-09-08 20:21 ` Rene Scharfe
2006-09-06 21:42 ` Junio C Hamano
2006-09-07 6:32 ` Franck Bui-Huu
2006-09-07 7:19 ` Junio C Hamano
2006-09-07 7:53 ` Franck Bui-Huu
2006-09-07 8:16 ` Junio C Hamano
2006-09-07 13:08 ` Add git-archive [take #2] Franck Bui-Huu
2006-09-07 13:12 ` [PATCH 1/4] Add git-archive Franck Bui-Huu
2006-09-08 2:35 ` Junio C Hamano [this message]
2006-09-08 9:00 ` Franck Bui-Huu
2006-09-08 20:21 ` Rene Scharfe
2006-09-09 14:31 ` Franck Bui-Huu
2006-09-09 15:02 ` Rene Scharfe
2006-09-09 15:25 ` Franck Bui-Huu
2006-09-07 13:12 ` [PATCH 2/4] git-archive: wire up TAR format Franck Bui-Huu
2006-09-08 20:21 ` Rene Scharfe
2006-09-08 21:42 ` Junio C Hamano
2006-09-09 1:53 ` Junio C Hamano
2006-09-09 15:02 ` Rene Scharfe
2006-09-09 15:10 ` Franck Bui-Huu
2006-09-09 19:42 ` Junio C Hamano
2006-09-10 16:10 ` [PATCH] Use xstrdup instead of strdup in builtin-{tar,zip}-tree.c Rene Scharfe
2006-09-09 14:38 ` [PATCH 2/4] git-archive: wire up TAR format Franck Bui-Huu
2006-09-07 13:12 ` [PATCH 3/4] git-archive: wire up ZIP format Franck Bui-Huu
2006-09-07 13:12 ` [PATCH 4/4] Add git-upload-archive Franck Bui-Huu
2006-09-07 17:26 ` Add git-archive [take #2] Franck Bui-Huu
2006-09-08 0:37 ` Junio C Hamano
2006-09-08 8:18 ` Franck Bui-Huu
2006-09-08 8:47 ` Jakub Narebski
2006-09-08 8:58 ` Junio C Hamano
2006-09-08 9:43 ` Franck Bui-Huu
2006-09-08 21:42 ` Junio C Hamano
2006-09-08 20:21 ` Rene Scharfe
2006-09-08 21:42 ` Junio C Hamano
2006-09-06 20:17 ` [PATCH 1/2] Add git-archive Rene Scharfe
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=7vodtrnl0f.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=vagabon.xyz@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).