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

Re: [PATCH] git-init: set core.workdir when GIT_WORK_DIR is specified

From
MLMatthias Lederhofer <matled@gmx.net>
Date
Mar 18, 2007, 11:18 UTC
Message-ID
<20070318111800.GA15147@moooo.ath.cx>
In-Reply-To
<7vr6rnlyzt.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
Show 19 quoted lines
> Matthias Lederhofer <matled@gmx.net> writes:
> >  * git init does not show the expansion of GIT_WORK_TREE to an
> >    absolute path, this might confuse the user
> 
> If the feature might confuse the user without extra output, it
> probably is confusing to begin with, with or without it, so one
> option might be to refuse relative path when running git-init.
> 
> However, as long as the expansion to absolute path is done
> correctly, I do not think there is any room for confusion.  Who
> would want a feature that lets you set work-tree to ../.., so
> that no matter where in the working tree you cd around, git
> assumes that the toplevel is two level up?  If you record the
> work tree location in the configuration, you would want it to be
> stable, and I do not think anybody would expect it be stored as
> relative.  So I thought having the printf() would be a good way
> for debugging the absolute expansion, but after that I do not
> think it is needed (but again, I may well be missing some issues
> you've thought about, so please tell me otherwise).

I really don't know what people would expect from git --work-tree=foo init and therefore I thought it might help to tell them "core.worktree = /path/to/foo". For example one could think this would work (without the message in brackets):

    ~/foo$ export GIT_DIR=`pwd`/repository.git
    ~/foo$ mkdir src
    ~/foo$ git --work-tree=src init
   [core.worktree = /home/user/foo/src]
    Initialized empty Git repository in /home/user/foo/repository.git/
    ~/foo$ cd ..; mv foo bar; cd bar
    ~/bar$ export GIT_DIR=`pwd`/repository.git

With the message in brackets it would be clear what breaks after renaming the directory.

Note: git config core.worktree ../src fails after moving the working
tree because the value of core.worktree checked for validity.
Either run
    $ git --work-tree=. config [args]
or just do
    $ git --work-tree=src init
again in the new location and git-init will set core.worktree again.
Previous: Junio C HamanoNext: Matthias Lederhofer
Message 16 of 18 in “git-init: set core.workdir when GIT_WORK_DIR is specified”
  1. git-init: set core.workdir when GIT_WORK_DIR is specifiedMatthias Lederhofer, Mar 17, 2007
  2. Junio C HamanoMar 17, 2007
  3. Matthias LederhoferMar 17, 2007
  4. Matthias LederhoferMar 17, 2007
  5. 1/5 rev-parse: --is-bare-repository optionMatthias Lederhofer, Mar 17, 2007
  6. 2/5 test git-rev-parseMatthias Lederhofer, Mar 17, 2007
  7. test git-rev-parseMatthias Lederhofer, Mar 27, 2007
  8. 3/5 introduce GIT_WORK_TREE environment variableMatthias Lederhofer, Mar 17, 2007
  9. Matthias LederhoferMar 18, 2007
  10. Matthias LederhoferMar 18, 2007
  11. Matthias LederhoferMar 18, 2007
  12. Junio C HamanoMar 18, 2007
  13. 4/5 test GIT_WORK_TREEMatthias Lederhofer, Mar 17, 2007
  14. 5/5 git-init: set core.worktree when GIT_WORK_TREE is specifiedMatthias Lederhofer, Mar 17, 2007
  15. Junio C HamanoMar 18, 2007
  16. Matthias LederhoferMar 18, 2007
  17. Matthias LederhoferMar 18, 2007
  18. Johannes SchindelinMar 19, 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.