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

Re: git rebase -i --exec and changing directory

From
Junio C Hamano <gitster@pobox.com>
Date
May 28, 2018, 02:45 UTC
Message-ID
<xmqqfu2clcqo.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<3465c994-3917-cd45-bb8e-d1121f60bfb4@talktalk.net>
Phillip Wood <phillip.wood@talktalk.net> writes:
Show 10 quoted lines
> I tried your recipe and got the same result as you. However I think it
> could be a problem with 'git status' rather than 'git rebase
> --exec'. If I run your recipe in /tmp/a and do
>
> cd dir
> GIT_DIR=/tmp/a/.git git status
>
> I get the same result as when running 'git status' from 'git rebase
> --exec' So I think the problem might have something to do with GIT_DIR
> being set in the environment when 'git status' is run
Yup.  

When GIT_DIR environment variable appears without GIT_WORKING_TREE, "git" assumes that you are starting it at the root level of the working tree. In your example, if there is README at the top-level but dir/README is not there, "status" would report that you removed it. You can unset GIT_DIR in your --exec script if you know that Git would find the right repository when run from your script.

Previous: Philip Oakley
Message 8 of 8 in “git rebase -i --exec and changing directory”
  1. Ondrej MosnáčekMay 19, 2018
  2. Ondrej MosnáčekMay 27, 2018
  3. Philip OakleyMay 27, 2018
  4. Ondrej MosnáčekMay 27, 2018
  5. Phillip WoodMay 27, 2018
  6. Philip OakleyMay 27, 2018
  7. Philip OakleyMay 27, 2018
  8. Junio C HamanoMay 28, 2018

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.