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

Re: [PATCH] Move worktree setup out of setup_git_directory*

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Feb 25, 2008, 13:17 UTC
Message-ID
<fcaeb9bf0802250517x2192b51epf2a162b0a984e99c@mail.gmail.com>
In-Reply-To
<7vr6f1sur3.fsf@gitster.siamese.dyndns.org>
On Mon, Feb 25, 2008 at 8:13 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 14 quoted lines
>   - At startup:
>
>    - If the command always need to run from a repository, call
>      setup_git_directory(), which would complain and die if you
>      are outside.
>
>    - If the command can optionally run in a repository, use
>      setup_git_directory_gently(&nongit_ok); it won't complain
>      but sets nongit_ok to true if run outside a repository.
>
>    In either case, they return prefix string to be used for
>    setup_work_tree() later.
>
>    In either case, there is no chdir() done at this point.

Interesting. It currently does chdir(). But it is pointless now as worktree should not be accessed until setup_work_tree() is called. setup_git_directory* should not return a prefix at all.

Show 10 quoted lines
>   - After calling setup_git_directory(), or you made sure you are
>    in a repository after callilng setup_git_directory_gently(),
>    call setup_work_tree().  This will chdir to the top of the
>    work tree.
>
>   - When you need to know where $GIT_DIR is, call get_git_dir().
>    When you need to know where the work tree is, call
>    get_git_work_tree().  However, it is an error to call these
>    functions before calling setup_git_directory and
>    setup_work_tree.

I guess I just need to verify your statements and put them to Doc/technical/api-setup.txt ;)

-- 
Duy
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 4 in “Move worktree setup out of setup_git_directory*”
  1. Move worktree setup out of setup_git_directory*Nguyễn Thái Ngọc Duy, Feb 24, 2008
  2. Junio C HamanoFeb 25, 2008
  3. Nguyen Thai Ngoc DuyFeb 25, 2008
  4. Junio C HamanoFeb 25, 2008

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.