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

Re: [PATCH 1/2] Add git-archive

From
Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Sep 6, 2006, 20:14 UTC
Message-ID
<44FF2C37.2010400@lsrfire.ath.cx>
In-Reply-To
<44FED12E.7010409@innova-card.com>
Franck Bui-Huu schrieb:
Show 37 quoted lines
> Junio C Hamano wrote:
>> "Franck Bui-Huu" <vagabon.xyz@gmail.com> writes:
>>
>>> git-archive is a command to make TAR and ZIP archives of a git tree.
>>> It helps prevent a proliferation of git-{format}-tree commands.
>> Thanks.  I like the overall structure, at least mostly.
>> Also dropping -tree suffix from the command name is nice, short
>> and sweet.
>>
> 
> great !
> 
>> Obviously I cannot apply this patch because it is totally
>> whitespace damaged, but here are some comments.
> 
> (sigh), sorry for that.
> 
>>> diff --git a/archive.h b/archive.h
>>> new file mode 100644
>>> index 0000000..6c69953
>>> --- /dev/null
>>> +++ b/archive.h
>>> @@ -0,0 +1,43 @@
>>> +#ifndef ARCHIVE_H
>>> +#define ARCHIVE_H
>>> +
>>> +typedef int (*write_archive_fn_t)(struct tree *tree,
>>> +				  const unsigned char *commit_sha1,
>>> +				  const char *prefix,
>>> +				  time_t time,
>>> +				  const char **pathspec);
>> The type of the first argument might have to be different,
>> depending on performance analysis by Rene on struct tree vs
>> struct tree_desc.
>>
> 
> OK. We'll wait for Rene.

The performance difference I noticed was caused by a memleak; the speed advantage of a struct tree_desc based traverser is significant if you look only at the traversers' performance, but it is lost in the noise of the "real" work that the payload function is doing (see my other mail).

Show 18 quoted lines
>>> +static int run_remote_archiver(struct archiver_struct *ar, int argc,
>>> +			       const char **argv)
>>> +{
>>> +	char *url, buf[1024];
>>> +	pid_t pid;
>>> +	int fd[2];
>>> +	int len, rv;
>>> +
>>> +	sprintf(buf, "git-upload-%s", ar->name);
>> Are you calling git-upload-{tar,zip,rar,...} here?
>>
> 
> yes. Actually git-upload-{tar,zip,...} commands are going to be
> removed, but git-daemon know them as a daemon service. It will
> map these services to the generic "git-upload-archive" command.
> One benefit is that we could still disable TAR format and enable
> TGZ one. Please take a look to the second patch that adds
> git-upload-archive command.

I don't think git-daemon should need to care about specific archivers. Policy decisions, like disallowing certain archive types or compression levels, should be made in git-upload-archive. This way all code regarding archive uploading is found in one place: git-upload-archive. We can keep git-upload-tar as a legacy interface, but please use only git-upload-archive for the new stuff (and not git-upload-zip etc.).

Show 27 quoted lines
>>> +int parse_treeish_arg(const char **argv, struct tree **tree,
>>> +		      const unsigned char **commit_sha1,
>>> +		      time_t *archive_time, const char *prefix,
>>> +		      const char **reason)
>>> +{
>>> ...
>>> +	if (prefix) {
>>> +		unsigned char tree_sha1[20];
>>> +		unsigned int mode;
>>> +		int err;
>>> +
>>> +		err = get_tree_entry((*tree)->object.sha1, prefix,
>>> +				     tree_sha1, &mode);
>>> +		if (err || !S_ISDIR(mode)) {
>>> +			*reason = "current working directory is untracked";
>>> +			goto out;
>>> +		}
>>> +		free(*tree);
>>> +		*tree = parse_tree_indirect(tree_sha1);
>>> +	}
>> I like the simplicity of just optionally sending one subtree (or
>> the whole thing), but I think this part would be made more
>> efficient if we go with "struct tree_desc" based interface.
>>
>> Also I wonder how this interacts with the pathspec you take from
>> the command line.  Personally I think this single subtree
>> support is good enough and limiting with pathspec is not needed.

[Note: There's potential for confusion here because we have two types of prefixes. One is the present working directory inside the git archive, the other is the one specified with --prefix=. Here we have the working directory kind of prefix.]

IMHO should work like in the following example, and the code above cuts off the Documentation part:

   $ cd Documentation
   $ git-archive --format=tar --prefix=v1.0/ HEAD howto | tar tf -
   v1.0/howto/
   v1.0/howto/isolate-bugs-with-bisect.txt
   ...

I agree that simple subtree matching would be enough, at least for now.

René
Previous: Franck Bui-HuuNext: Jakub Narebski
Message 4 of 40 in “Add git-archive”
  1. 1/2 Add git-archiveFranck Bui-Huu, Sep 5, 2006
  2. Junio C HamanoSep 5, 2006
  3. Franck Bui-HuuSep 6, 2006
  4. Rene ScharfeSep 6, 2006
  5. Jakub NarebskiSep 6, 2006
  6. Rene ScharfeSep 8, 2006
  7. Junio C HamanoSep 6, 2006
  8. Franck Bui-HuuSep 7, 2006
  9. Junio C HamanoSep 7, 2006
  10. Franck Bui-HuuSep 7, 2006
  11. Junio C HamanoSep 7, 2006
  12. Add git-archive [take #2]Franck Bui-Huu, Sep 7, 2006
  13. 1/4 Add git-archiveFranck Bui-Huu, Sep 7, 2006
  14. Junio C HamanoSep 8, 2006
  15. Franck Bui-HuuSep 8, 2006
  16. Rene ScharfeSep 8, 2006
  17. Franck Bui-HuuSep 9, 2006
  18. Rene ScharfeSep 9, 2006
  19. Franck Bui-HuuSep 9, 2006
  20. 2/4 git-archive: wire up TAR format.Franck Bui-Huu, Sep 7, 2006
  21. Rene ScharfeSep 8, 2006
  22. Junio C HamanoSep 8, 2006
  23. Junio C HamanoSep 9, 2006
  24. Rene ScharfeSep 9, 2006
  25. Franck Bui-HuuSep 9, 2006
  26. Junio C HamanoSep 9, 2006
  27. Use xstrdup instead of strdup in builtin-{tar,zip}-tree.cRene Scharfe, Sep 10, 2006
  28. Franck Bui-HuuSep 9, 2006
  29. 3/4 git-archive: wire up ZIP format.Franck Bui-Huu, Sep 7, 2006
  30. 4/4 Add git-upload-archiveFranck Bui-Huu, Sep 7, 2006
  31. Franck Bui-HuuSep 7, 2006
  32. Junio C HamanoSep 8, 2006
  33. Franck Bui-HuuSep 8, 2006
  34. Jakub NarebskiSep 8, 2006
  35. Junio C HamanoSep 8, 2006
  36. Franck Bui-HuuSep 8, 2006
  37. Junio C HamanoSep 8, 2006
  38. Rene ScharfeSep 8, 2006
  39. Junio C HamanoSep 8, 2006
  40. Rene ScharfeSep 6, 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.