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

Re: git alias always chdir to top

From
Jeff King <peff@peff.net>
Date
Dec 4, 2008, 12:34 UTC
Message-ID
<20081204123402.GA23740@coredump.intra.peff.net>
In-Reply-To
<20081203160852.GA3773@osc.edu>
On Wed, Dec 03, 2008 at 11:08:52AM -0500, Pete Wyckoff wrote:
Show 5 quoted lines
> It looks like handle_alias() uses setup_git_directory_gently() to
> find the .git, which chdir()s up until it gets there.  Is there a
> way to do this without changing the process current working
> directory instead?  I could even handle an environment variable
> saving the original cwd, but that's ickier.

There has been some discussion of refactoring the setup to _not_ do that chdir until later, which should fix your problem. And other problems, too, since aliases can get confused about whether or not we're in a worktree (try "git config alias.st status && cd .git && git st") as a result of the startup sequence. Ideally the _only_ thing to happen before running an alias would be to look at the config to see how to run the alias, and everything else would be "as if" you had just run the alias manually.

So no, there's no way to do it correctly right now. The git commands internally do know the original prefix, but I don't think it is exposed via the environment.

I hope this will get fixed eventually, but refactoring this code is unpleasant enough and I have been busy enough that it hasn't happened yet. You are of course welcome to volunteer. ;)

-Peff
Previous: Pete WyckoffNext: Pete Wyckoff
Message 2 of 3 in “git alias always chdir to top”
  1. Pete WyckoffDec 3, 2008
  2. Jeff KingDec 4, 2008
  3. Pete WyckoffDec 5, 2008

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.