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

Re: rev-parse --show-toplevel broken during exec'ed rebase?

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 19, 2018, 22:34 UTC
Message-ID
<xmqqva9adfcf.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180719220929.6550-1-szeder.dev@gmail.com>
SZEDER Gábor <szeder.dev@gmail.com> writes:
Show 41 quoted lines
>> Forgetting the code in git-sh-setup, are we?
>> 
>> git_dir_init() rather specifically set GIT_DIR to the absolute path, and
>> since that variable is already exported, the `exec` commands launched via
>> `git-rebase--interactive` all saw it.
>> 
>> That is the reason why the sequencer.c was taught to set GIT_DIR to an
>> absolute path rathern than not setting it: for backwards compatibility.
>
> GIT_DIR was not exported to 'exec' commands during an interactive
> rebase prior to 18633e1a22 (rebase -i: use the rebase--helper builtin,
> 2017-02-09) (nor was GIT_PREFIX):
>
>   $ git log -Sgit_dir_init master git-rebase*.sh
>   # Nothing.
>   $ git checkout 18633e1a22a6^ && make -j4 prefix=/tmp/BEFORE install
>   <....>
>   $ git checkout 18633e1a22a6 && make -j4 prefix=/tmp/AFTER install
>   <....>
>   $ GIT_EDITOR='sed -i -e "1ix set |grep ^GIT"' /tmp/BEFORE/bin/git rebase -i HEAD^
>   Executing: set |grep ^GIT
>   GIT_CHERRY_PICK_HELP=$'\nWhen you have resolved this problem, run "git rebase --continue".\nIf you prefer to skip this patch, run "git rebase --skip" instead.\nTo check out the original branch and stop rebasing, run "git rebase --abort".\n'
>   GIT_EDITOR='sed -i -e "1ix set |grep ^GIT"'
>   GIT_INTERNAL_GETTEXT_SH_SCHEME=gnu
>   GIT_REFLOG_ACTION='rebase -i (start): checkout HEAD^'
>   warning: notes ref refs/notes/commits is invalid
>   Successfully rebased and updated refs/heads/master.
>   $ GIT_EDITOR='sed -i -e "1ix set |grep ^GIT"' /tmp/AFTER/bin/git rebase -i HEAD^
>   Executing: set |grep ^GIT
>   GIT_CHERRY_PICK_HELP='
>   GIT_DIR='.git'
>   GIT_EDITOR='sed -i -e "1ix set |grep ^GIT"'
>   GIT_INTERNAL_GETTEXT_SH_SCHEME='gnu'
>   GIT_PREFIX=''
>   GIT_REFLOG_ACTION='rebase -i (start): checkout HEAD^'
>   warning: notes ref refs/notes/commits is invalid
>   Successfully rebased and updated refs/heads/master.
>
> And then recently came 226c0ddd0d (exec_cmd: RUNTIME_PREFIX on some
> POSIX systems, 2018-04-10), which then started to export GIT_EXEC_PATH
> to 'exec' commands as well...  

Correct. git-sh-setup does assign to GIT_DIR, but unless the end-user has it exported, it does not export, which has long been very deliberate. But it does not really matter, as exporting BOTH GIT_DIR and GIT_WORK_TREE is a lot easier to understand and probably safe (even though technically a regressing) solution, and fewer and fewer things will be relying on git-sh-setup in the future anyway.

Previous: SZEDER Gábor
Message 22 of 22 in “rev-parse --show-toplevel broken during exec'ed rebase?”
  1. Vitali LovichJul 12, 2018
  2. Vitali LovichJul 12, 2018
  3. Johannes SchindelinJul 12, 2018
  4. Johannes SchindelinJul 12, 2018
  5. Junio C HamanoJul 12, 2018
  6. Vitali LovichJul 12, 2018
  7. brian m. carlsonJul 13, 2018
  8. Jeff KingJul 13, 2018
  9. brian m. carlsonJul 13, 2018
  10. sequencer: pass absolute GIT_WORK_TREE to exec commandsbrian m. carlson, Jul 14, 2018
  11. Jeff KingJul 14, 2018
  12. brian m. carlsonJul 14, 2018
  13. sequencer: pass absolute GIT_WORK_TREE to exec commandsbrian m. carlson, Jul 14, 2018
  14. Jeff KingJul 14, 2018
  15. Johannes SchindelinJul 14, 2018
  16. brian m. carlsonJul 14, 2018
  17. Junio C HamanoJul 16, 2018
  18. Jeff KingJul 16, 2018
  19. Junio C HamanoJul 16, 2018
  20. Johannes SchindelinJul 19, 2018
  21. SZEDER GáborJul 19, 2018
  22. Junio C HamanoJul 19, 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.