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

Re: [PATCH v2 4/4] archive: remove the_repository global variable

From
johncai86@gmail.com <johncai86@gmail.com>
Date
Oct 4, 2024, 20:05 UTC
Message-ID
<40DAFE71-EC0C-4FC4-B7C4-F054562E8B19@gmail.com>
In-Reply-To
<xmqq1q106hdd.fsf@gitster.g>
Hi Junio,
On 30 Sep 2024, at 16:01, Junio C Hamano wrote:
Show 46 quoted lines
> "John Cai via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
>> -#define USE_THE_REPOSITORY_VARIABLE
>>  #include "builtin.h"
>>  #include "archive.h"
>>  #include "gettext.h"
>> @@ -79,7 +78,7 @@ static int run_remote_archiver(int argc, const char **argv,
>>  int cmd_archive(int argc,
>>  		const char **argv,
>>  		const char *prefix,
>> -		struct repository *repo UNUSED)
>> +		struct repository *repo)
>>  {
>>  	const char *exec = "git-upload-archive";
>>  	char *output = NULL;
>> @@ -110,7 +109,7 @@ int cmd_archive(int argc,
>>
>>  	setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
>>
>> -	ret = write_archive(argc, argv, prefix, the_repository, output, 0);
>> +	ret = write_archive(argc, argv, prefix, repo, output, 0);
>
> This looks OK, but unlike the original, write_archive() now needs to
> be prepared to see NULL in the repo parameter.  Is that reasonable?
>
> Perdon me to think aloud for a bit.
>
> The context before this hunk handles "git archive --remote" which
> can be run outside a repository (and that is the whole reason why we
> ask SETUP_GENTLY), but this part has to happen in a repository,
> doesn't it?  Or is there some mode of operation of "git archive" I
> am forgetting that can be done without a repository?
>
>     ... goes and looks ...
>
> OK, write_archive() has its own setup_git_directory() call when
> startup_info->have_repository is false, so this happens to be OK,
> until the beginning part of archive.c:write_archive() will not
> changed to start dereferencing "repo" pointer.
>
> That sounds brittle, but probalby outside the scope of what this
> patch series wants to address.  It also makes git_config() calls
> even before it realizes there is no repository and dies, which
> smells fishy without actually doing any harm.
>
> So, after all, I think this step is probably OK.

Yeah I think these are issues we’ll need to address once removing the the_repository global from archive code.

Thanks John

>
> Thanks.
Previous: Junio C HamanoNext: John Cai via GitGitGadget
Message 24 of 44 in “Remove the_repository global for am, annotate, apply, archive builtins”
  1. 0/4 Remove the_repository global for am, annotate, apply, archive builtinsJohn Cai via GitGitGadget, Sep 24, 2024
  2. 1/4 git: pass in repo for RUN_SETUP_GENTLYJohn Cai via GitGitGadget, Sep 24, 2024
  3. shejialuoSep 24, 2024
  4. Junio C HamanoSep 24, 2024
  5. Junio C HamanoSep 24, 2024
  6. Patrick SteinhardtSep 26, 2024
  7. Junio C HamanoSep 26, 2024
  8. 2/4 annotate: remove usage of the_repository globalJohn Cai via GitGitGadget, Sep 24, 2024
  9. 3/4 apply: remove the_repository global variableJohn Cai via GitGitGadget, Sep 24, 2024
  10. Junio C HamanoSep 24, 2024
  11. Junio C HamanoSep 24, 2024
  12. John CaiSep 26, 2024
  13. Junio C HamanoSep 26, 2024
  14. 4/4 archive: remove the_repository global variableJohn Cai via GitGitGadget, Sep 24, 2024
  15. Junio C HamanoSep 24, 2024
  16. 0/4 Remove the_repository global for am, annotate, apply, archive builtinsJohn Cai via GitGitGadget, Sep 30, 2024
  17. 1/4 git: pass in repo for RUN_SETUP_GENTLYJohn Cai via GitGitGadget, Sep 30, 2024
  18. Junio C HamanoSep 30, 2024
  19. shejialuoOct 1, 2024
  20. 2/4 annotate: remove usage of the_repository globalJohn Cai via GitGitGadget, Sep 30, 2024
  21. Junio C HamanoSep 30, 2024
  22. 4/4 archive: remove the_repository global variableJohn Cai via GitGitGadget, Sep 30, 2024
  23. Junio C HamanoSep 30, 2024
  24. johncai86@gmail.comOct 4, 2024
  25. 3/4 apply: remove the_repository global variableJohn Cai via GitGitGadget, Sep 30, 2024
  26. Junio C HamanoSep 30, 2024
  27. shejialuoOct 1, 2024
  28. Patrick SteinhardtOct 1, 2024
  29. shejialuoOct 1, 2024
  30. Patrick SteinhardtOct 1, 2024
  31. Junio C HamanoOct 1, 2024
  32. johncai86@gmail.comOct 3, 2024
  33. 0/3 Remove the_repository global for am, annotate, apply, archive builtinsJohn Cai via GitGitGadget, Oct 5, 2024
  34. 1/3 git: pass in repo to builtin based on setup_git_directory_gentlyJohn Cai via GitGitGadget, Oct 5, 2024
  35. shejialuoOct 5, 2024
  36. 2/3 annotate: remove usage of the_repository globalJohn Cai via GitGitGadget, Oct 5, 2024
  37. 3/3 archive: remove the_repository global variableJohn Cai via GitGitGadget, Oct 5, 2024
  38. shejialuoOct 5, 2024
  39. johncai86@gmail.comOct 10, 2024
  40. 0/3 Remove the_repository global for am, annotate, apply, archive builtinsJohn Cai via GitGitGadget, Oct 10, 2024
  41. 1/3 git: pass in repo to builtin based on setup_git_directory_gentlyJohn Cai via GitGitGadget, Oct 10, 2024
  42. 2/3 annotate: remove usage of the_repository globalJohn Cai via GitGitGadget, Oct 10, 2024
  43. 3/3 archive: remove the_repository global variableJohn Cai via GitGitGadget, Oct 10, 2024
  44. Junio C HamanoOct 11, 2024

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.