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

Re: [PATCH] prune-packed: remove USE_THE_REPOSITORY_VARIABLE

From
SSShashank S <shashu8660@gmail.com>
Date
Oct 20, 2026, 16:27 UTC
Message-ID
<CANHmUQR2RG+4AGvxN2mPZoBeNn4HUpTivXm5bck0yVXyb+RuOg@mail.gmail.com>
In-Reply-To
<xmqqqzhl2yfq.fsf@gitster.g>
On Tue, 20 Oct 2026 at 02:35, Junio C Hamano <gitster@pobox.com> wrote:
Show 32 quoted lines
>
> Shashank S <shashu8660@gmail.com> writes:
>
> > I have checked git.c file in that file I went through this commands .
> > prune , prune-packed and repack which are .
> > { "prune", cmd_prune, RUN_SETUP },
> > { "prune-packed", cmd_prune_packed, RUN_SETUP },
> > { "repack", cmd_repack, RUN_SETUP },
> > All this commands are all registered with a special flags '
> > RUN_SETUP'. This flags search for .git folder . If it finds a .git
> > folder Git successfully initializes the repo struct and passes that to
> > valid pointer to your builtin . If it does not find a .git folder (if
> > they ran it outside the repository) Git immediately stops and shows
> > the error . It never run the code .
>
> The analysis is not entirely correct.  Assuming that your system
> administrator is not insane enough and did not make the entire
> filesystem as a working tree of a repository,
>
>     $ cd / && git repack -h
>
> does call cmd_repack() with "repo" set to NULL.
>
> The call to parse_options() will give the short help and exit.
> Becaues the references to "repo" you added all happen after the code
> already called parse_options(), your update will not make the code
> dereference NULL.  Some subcommands with tricky call sequence into
> parse_options() _may_ have to be a bit more careful than just
> checking "are we using RUN_SETUP?".  Of course RUN_SETUP_GENTLY is
> an explicit sign that you have to be prepared to see NULL in "repo".
>
> Thanks.
Thank you for the correction and the detailed explanation.

I had not considered the parse_options() and the behavior of the -h flags outside of a working tree. It is great to know that while RUN_SETUP isn't an absolute guarantee against NULL on its own (unlike RUN_SETUP_GENTLY), the fact that parse_options() exits before my modified function calls ensures repo is never dereferenced when NULL.

I appreciate you taking the time to explain this to me.
Thanks.
Previous: Junio C HamanoNext: Shashank S via GitGitGadget
Message 5 of 14 in “prune-packed: remove USE_THE_REPOSITORY_VARIABLE”
  1. prune-packed: remove USE_THE_REPOSITORY_VARIABLEShashank S via GitGitGadget, Oct 18, 2026
  2. Patrick SteinhardtOct 19, 2026
  3. Shashank SOct 19, 2026
  4. Junio C HamanoOct 19, 2026
  5. Shashank SOct 20, 2026
  6. [Outreachy Patch] prune-packed: remove USE_THE_REPOSITORY_VARIABLEShashank S via GitGitGadget, Oct 19, 2026
  7. Patrick SteinhardtOct 23, 2026
  8. Shashank SOct 24, 2026
  9. prune-packed: remove USE_THE_REPOSITORY_VARIABLEShashank S via GitGitGadget, Oct 24, 2026
  10. Patrick SteinhardtOct 26, 2026
  11. Shashank SOct 27, 2026
  12. prune-packed: remove USE_THE_REPOSITORY_VARIABLEShashank S via GitGitGadget, Oct 27, 2026
  13. Patrick SteinhardtOct 28, 2026
  14. Junio C HamanoOct 28, 2026

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.