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

Re: [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set

From
Junio C Hamano <junkio@cox.net>
Date
Mar 12, 2007, 20:05 UTC
Message-ID
<7vird6qlbn.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20070312180837.GA22701@moooo.ath.cx>
Matthias Lederhofer <matled@gmx.net> writes:
Show 7 quoted lines
> I just thought that GIT_WORK_DIR should be relative to the current
> working directory because it's more intuitive, e.g.
>
>     $ git --git-dir=/path/to/repo.git --work-dir=../.. add a
>
> where ../.. matches the path to the toplevel working directory from
> cwd.  But this definitely is annoying when changing directories.

Not so fast. That was a trick suggestion, only meant to see if you have thought through the issues, and you did not have to agree with me so quickly ;-). What I was pointing out was merely that specifying the top as a path relative to the cwd in permanent basis was not useful if you are going to cd around, which is a tautology.

For a one-shot thing, I would agree that being able to say "I am in Documentation/howto directory of the whole thing, so I can name the top of my working tree as ../.." is far more useful and natural than having to say "ehhhh, what is the top of the working tree relative to my repository???". If it is not a one-shot thing and the user expects to cd around, then:

	$ GIT_WORK_DIR=$(pwd)/../..; export GIT_WORK_DIR
	$ git foo ...; git bar ...;

would be more natural, so I do not expect the semantics of relative path would be a big issue in reality, as long as we make it clear that it is relative to cwd.

By the way, I do not find your command line example intuitive at all, whether the --work-dir= parameter is relative or absolute. Do you honestry expect that loooong command line is something people would use in real life?

With $GIT_DIR/workdir support, I would expect that people would do (if what is done is only to add one file and nothing else):

	$ GIT_DIR=/path/to/repo.git git add a
And without $GIT_DIR/workdir support:
	$ GIT_DIR=/path/to/repo.git GIT_WORK_DIR=../.. git add a

If the user is going to work in the working tree for extended period of time, cd'ing around and running multiple git commands:

	$ GIT_DIR=/path/to/repo.git; export GIT_DIR
        $ git foo ; git bar ; cd subdir ; git baz ; ...
And without $GIT_DIR/workdir support, perhaps the user would do:
	$ GIT_DIR=/path/to/repo.git; export GIT_DIR
	$ GIT_WORK_DIR=$(pwd)/../..; export GIT_WORK_DIR
        $ git foo ; git bar ; cd subdir ; git baz ; ...

What I am getting at is that I personally feel that --git-dir= option is already an unnecessary redundancy that is there only to confuse new people by having more than one way to do the same thing, and --work-dir= option seems to be only adding to the same confusion. Do we really want that as an option?

Previous: Matthias LederhoferNext: Matthias Lederhofer
Message 37 of 39 in “[RFC] introduce GIT_WORK_DIR environment variable”
  1. Matthias LederhoferMar 11, 2007
  2. Junio C HamanoMar 11, 2007
  3. Andy ParkinsMar 11, 2007
  4. Matthias LederhoferMar 11, 2007
  5. Junio C HamanoMar 11, 2007
  6. Johannes SchindelinMar 11, 2007
  7. Linus TorvaldsMar 11, 2007
  8. Junio C HamanoMar 11, 2007
  9. Linus TorvaldsMar 11, 2007
  10. A.J. RossiniMar 12, 2007
  11. Andy ParkinsApr 1, 2007
  12. Nguyen Thai Ngoc DuyMar 11, 2007
  13. Matthias LederhoferMar 11, 2007
  14. Nguyen Thai Ngoc DuyMar 11, 2007
  15. Matthias LederhoferMar 11, 2007
  16. Nguyen Thai Ngoc DuyMar 11, 2007
  17. introduce GIT_WORK_DIR environment variableMatthias Lederhofer, Mar 11, 2007
  18. Nguyen Thai Ngoc DuyMar 11, 2007
  19. use $GIT_DIR/workdir as working directory with $GIT_DIRMatthias Lederhofer, Mar 11, 2007
  20. core.workdir config variableMatthias Lederhofer, Mar 13, 2007
  21. core.workdir config variableMatthias Lederhofer, Mar 13, 2007
  22. Shawn O. PearceMar 14, 2007
  23. Junio C HamanoMar 14, 2007
  24. Shawn O. PearceMar 14, 2007
  25. Nguyen Thai Ngoc DuyMar 11, 2007
  26. rev-parse: --is-bare-repository optionMatthias Lederhofer, Mar 11, 2007
  27. git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is setMatthias Lederhofer, Mar 12, 2007
  28. Joshua N PritikinMar 12, 2007
  29. Matthias LederhoferMar 12, 2007
  30. Matthias LederhoferMar 12, 2007
  31. Nguyen Thai Ngoc DuyMar 12, 2007
  32. Matthias LederhoferMar 12, 2007
  33. Junio C HamanoMar 12, 2007
  34. Matthias LederhoferMar 12, 2007
  35. always interpret GIT_WORK_DIR relative to $GIT_DIRMatthias Lederhofer, Mar 12, 2007
  36. GIT_WORK_DIR: documentation for relative pathMatthias Lederhofer, Mar 12, 2007
  37. Junio C HamanoMar 12, 2007
  38. Matthias LederhoferMar 12, 2007
  39. git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is setMatthias Lederhofer, Mar 12, 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.