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

Re: [PATCH v3 2/5] setup: allow for prefix to be passed to git commands

From
BWBrandon Williams <bmwill@google.com>
Date
Mar 17, 2017, 21:00 UTC
Message-ID
<20170317210031.GA63813@google.com>
In-Reply-To
<xmqqy3w363yx.fsf@gitster.mtv.corp.google.com>
On 03/17, Junio C Hamano wrote:
Show 10 quoted lines
> Brandon Williams <bmwill@google.com> writes:
> 
> > ...  I was being cautious with this patch since git didn't currently
> > read GIT_PREFIX.
> 
> Ahh, I forgot about that.  Processes we spawn do expect GIT_PREFIX
> to tell them where the original $cwd was and they also do expect
> that "git" invoked by them would not be affected by GIT_PREFIX
> environment variable.  So we cannot change that now.
> 

Yep. I just ran the test suite locally doing this...it fails on a bunch of stuff :)

> If you recurse into sub-sub module, it is likely that you would want
> to update the TOPLEVEL_PREFIX relative to that sub-sub module you
> are descending into.

So the idea would be that 'super_prefix' would keep getting updated when recursing deeper, but the 'prefix' should stay the same (in what I'm proposing here that is).

Show 10 quoted lines
> 
> That probably also means that processes we spawn now need to also
> pay attention to TOPLEVEL_PREFIX in addition to GIT_PREFIX, and we
> should NOT re-export what we got from TOPLEVEL_PREFIX to GIT_PREFIX.
> I.e. if a "git" process started from src/ subdirectory of the
> superproject that goes into module/sub1/ submodule, top-level prefix
> may export ../src/ to point at the original location, but the
> process that is running in the submodule will be running at the root
> level of the submodule working tree, so its prefix should be NULL or
> "", no?

I don't think that prefix can ever have ".." in it. From what I understand it is always a path from the root of the repository to the cwd that the git command was invoked by. So in your example prefix would be "src/".

Show 8 quoted lines
> 
> Adjusting pathspec and other file references on the caller's side,
> instead of exporting toplevel-prefix to have them adjusted by the
> callee, started to smell more and more like an easier/more correct
> approach to me, but perhaps I haven't thought things deeply enough.
> 
> I dunno.
> 

Yeah, doing all of the adjusting on the caller's side is quite difficult. Getting the pathspecs and file references right seems to be overly complicated if done by the caller. That why I opted to punt to the callee; given enough information (e.g. prefix and super_prefix) the callee should be able to handle both the pathspecs and file references properly.

-- 
Brandon Williams
Previous: Junio C HamanoNext: Junio C Hamano
Message 40 of 48 in “recursing submodules with relative pathspec (grep and ls-files)”
  1. 0/5 recursing submodules with relative pathspec (grep and ls-files)Brandon Williams, Feb 24, 2017
  2. 1/5 grep: illustrate bug when recursing with relative pathspecBrandon Williams, Feb 24, 2017
  3. Duy NguyenFeb 26, 2017
  4. Brandon WilliamsFeb 27, 2017
  5. 2/5 pathspec: add PATHSPEC_FROMROOT flagBrandon Williams, Feb 24, 2017
  6. Stefan BellerFeb 25, 2017
  7. 3/5 grep: fix bug when recuring with relative pathspecBrandon Williams, Feb 24, 2017
  8. Junio C HamanoFeb 28, 2017
  9. Brandon WilliamsMar 2, 2017
  10. 5/5 ls-files: fix bug when recuring with relative pathspecBrandon Williams, Feb 24, 2017
  11. Junio C HamanoFeb 28, 2017
  12. Brandon WilliamsMar 2, 2017
  13. 4/5 ls-files: illustrate bug when recursing with relative pathspecBrandon Williams, Feb 24, 2017
  14. Brandon WilliamsFeb 27, 2017
  15. grep: fix bug when recursing with relative pathspecBrandon Williams, Mar 6, 2017
  16. 0/4 recursing submodules with relative pathspec (grep and ls-files)Brandon Williams, Mar 14, 2017
  17. 1/4 grep: fix help text typoBrandon Williams, Mar 14, 2017
  18. Stefan BellerMar 14, 2017
  19. Brandon WilliamsMar 15, 2017
  20. 2/4 setup: allow for prefix to be passed to git commandsBrandon Williams, Mar 14, 2017
  21. Johannes SchindelinMar 14, 2017
  22. Brandon WilliamsMar 14, 2017
  23. 3/4 grep: fix bug when recursing with relative pathspecBrandon Williams, Mar 14, 2017
  24. Stefan BellerMar 14, 2017
  25. 4/4 ls-files: fix bug when recursing with relative pathspecBrandon Williams, Mar 14, 2017
  26. Stefan BellerMar 14, 2017
  27. Brandon WilliamsMar 15, 2017
  28. 0/5 recursing submodules with relative pathspec (grep and ls-files)Brandon Williams, Mar 17, 2017
  29. 3/5 grep: fix bug when recursing with relative pathspecBrandon Williams, Mar 17, 2017
  30. Duy NguyenMar 21, 2017
  31. Junio C HamanoMar 21, 2017
  32. Brandon WilliamsMar 22, 2017
  33. 5/5 ls-files: fix bug when recursing with relative pathspecBrandon Williams, Mar 17, 2017
  34. 4/5 ls-files: fix typo in variable nameBrandon Williams, Mar 17, 2017
  35. 2/5 setup: allow for prefix to be passed to git commandsBrandon Williams, Mar 17, 2017
  36. Stefan BellerMar 17, 2017
  37. Junio C HamanoMar 17, 2017
  38. Brandon WilliamsMar 17, 2017
  39. Junio C HamanoMar 17, 2017
  40. Brandon WilliamsMar 17, 2017
  41. Junio C HamanoMar 17, 2017
  42. Brandon WilliamsMar 20, 2017
  43. Junio C HamanoMar 21, 2017
  44. Stefan BellerMar 28, 2017
  45. Brandon WilliamsMar 17, 2017
  46. Stefan BellerMar 17, 2017
  47. Brandon WilliamsMar 17, 2017
  48. 1/5 grep: fix help text typoBrandon Williams, Mar 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.