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

Re: setup_git_directory_gently contract question?

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
May 27, 2008, 15:32 UTC
Message-ID
<fcaeb9bf0805270832lc779a37gd9e58d0790981788@mail.gmail.com>
In-Reply-To
<8e04b5820805270710v3a06e5c2if2dcf3b94ef40c1f@mail.gmail.com>

On Tue, May 27, 2008 at 9:10 PM, Ciprian Dorin Craciun <ciprian.craciun@gmail.com> wrote:

>    Is the function setup_git_directory_gently supposed to change the
> current working directory, or should it keep the initial one?
It will change if it finds a worktree.
>    What is the meaning of nongit_ok?

Setting it to a non null pointer prevents git from die() when no git repository can be found.

>    Because if I use nongit_ok != NULL, but *nongit_ok == 1, this
> function changes the current working directory to the top of the
> worktree directory.

It returns a directory prefix so that you can still know the original current working directory. You can do as following to have current directory "unchanged"

prefix = setup_git_directory_gently(&nongit_ok); if (prefix) chdir(prefix)

Show 7 quoted lines
>    Thanks,
>    Ciprian Craciun.
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
-- 
Duy
Previous: Ciprian Dorin CraciunNext: Junio C Hamano
Message 3 of 5 in “setup_git_directory_gently contract question?”
  1. Ciprian Dorin CraciunMay 27, 2008
  2. Ciprian Dorin CraciunMay 27, 2008
  3. Nguyen Thai Ngoc DuyMay 27, 2008
  4. Junio C HamanoMay 27, 2008
  5. Ciprian Dorin CraciunMay 28, 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.