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

Re: [PATCH] rev-parse --git-path: fix output when running in a subdirectory

From
Jeff King <peff@peff.net>
Date
Feb 10, 2017, 04:21 UTC
Message-ID
<20170210042115.d4kmdf4obxqwobv4@sigill.intra.peff.net>
In-Reply-To
<xmqqo9ybnie0.fsf@gitster.mtv.corp.google.com>
On Thu, Feb 09, 2017 at 01:50:31PM -0800, Junio C Hamano wrote:
Show 13 quoted lines
> > There is just no way you can "fix" this otherwise. As an occasional shell
> > scripter, you may be tempted to use `$(git rev-parse --show-cdup)$(git
> > rev-parse --git-path filename)`, but of course that breaks in worktrees
> > and if you do not use worktrees you would not even know that your
> > workaround introduced another bug.
> 
> In case it is not clear, I understand all of the above.  
> 
> I was just worried about the people who do *NOT* use worktrees and
> did the obvious "concatenate --cdup with --git-path" and thought
> their script were working happily and well.  By prepending the path
> to the (real) location of the .git in the updated --git-path output
> ourselves, they will complain, our update broke their script.

That concatenating approach is broken in other ways, too. For example, if you have $GIT_DIR set to an absolute path, then --git-path will use that. I don't think we have ever promised that the output of --git-path (or --git-dir) would ever be absolute or relative (in fact, the --git-dir documentation implies that you may get either).

So yes, there could be somebody who is doing this concatenation workaround, but only ever calls their script in a certain way that never triggers the absolute-path variant. They're happy now, and may not be after Dscho's patch. But I really think they are relying on a bogus assumption, and their scripts are already buggy.

-Peff
Previous: Junio C HamanoNext: Duy Nguyen
Message 5 of 27 in “rev-parse --git-path: fix output when running in a subdirectory”
  1. rev-parse --git-path: fix output when running in a subdirectoryJohannes Schindelin, Feb 8, 2017
  2. Junio C HamanoFeb 8, 2017
  3. Johannes SchindelinFeb 9, 2017
  4. Junio C HamanoFeb 9, 2017
  5. Jeff KingFeb 10, 2017
  6. Duy NguyenFeb 9, 2017
  7. Mike RappazzoFeb 9, 2017
  8. Johannes SchindelinFeb 9, 2017
  9. Junio C HamanoFeb 9, 2017
  10. Johannes SchindelinFeb 9, 2017
  11. Junio C HamanoFeb 9, 2017
  12. Mike RappazzoFeb 10, 2017
  13. Johannes SchindelinFeb 10, 2017
  14. 0/2 Fix bugs in rev-parse's output when run in a subdirectoryJohannes Schindelin, Feb 10, 2017
  15. 2/2 rev-parse: fix several options when running in a subdirectoryJohannes Schindelin, Feb 10, 2017
  16. Junio C HamanoFeb 10, 2017
  17. Johannes SchindelinFeb 17, 2017
  18. 1/2 rev-parse tests: add tests executed from a subdirectoryJohannes Schindelin, Feb 10, 2017
  19. Junio C HamanoFeb 10, 2017
  20. Johannes SchindelinFeb 17, 2017
  21. Junio C HamanoFeb 10, 2017
  22. Johannes SchindelinFeb 17, 2017
  23. Junio C HamanoFeb 10, 2017
  24. 0/2 Fix bugs in rev-parse's output when run in a subdirectoryJohannes Schindelin, Feb 17, 2017
  25. 1/2 rev-parse tests: add tests executed from a subdirectoryJohannes Schindelin, Feb 17, 2017
  26. 2/2 rev-parse: fix several options when running in a subdirectoryJohannes Schindelin, Feb 17, 2017
  27. Junio C HamanoFeb 17, 2017

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.