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

builtin command's prefix question

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Dec 5, 2007, 16:56 UTC
Message-ID
<fcaeb9bf0712050856t5d730779q82783fdb9876f41@mail.gmail.com>
Hi,
I have been looking at setup_git_directory_gently() lately. From my
understanding, setup_git_directory* will return a string called
"prefix" that is passed to builtin commands. What is the exact meaning
of this prefix? Correct me if I'm wrong. In early (read: no worktree)
days, cwd was moved to working root directory and prefix contained
relative path from working root directory to the original cwd. So it
had a few implications:
 1. A non-empty prefix indicates cwd has been moved
 2. If cwd is moved, it is moved to working root directory
 3. cwd+prefix should point to the current directory at the time the
command was issued (let's call it "user cwd")
Things change a bit since the rise of worktree:
 - If GIT_DIR is set and GIT_WORK_TREE is not, prefix is relative to
the to-be-set-up worktree, but cwd is not changed, so point 3 is gone.
 - If GIT_DIR is not set and GiT_WORK_TREE is,
  - and it is found that user cwd is inside a gitdir (bare repo), cwd
has been moved and prefix is empty, cwd+prefix no longer point to user
cwd
  - for other cases, cwd may not be worktree (the real worktree will
be setup in setup_work_tree or setup_git_directory)

Now that setup_work_tree can move cwd, it should also change prefix to meet point 3. But it does not.

I feel dizzy now. Were my assumptions wrong? What is expected behavior of setup_git_directory_gently()?

-- 
Duy
Next: Junio C Hamano
Message 1 of 7 in “builtin command's prefix question”
  1. Nguyen Thai Ngoc DuyDec 5, 2007
  2. Junio C HamanoDec 5, 2007
  3. Junio C HamanoDec 5, 2007
  4. Junio C HamanoDec 5, 2007
  5. Nguyen Thai Ngoc DuyDec 6, 2007
  6. Johannes SchindelinDec 6, 2007
  7. Junio C HamanoDec 6, 2007

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.