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

Re: 'git config --edit' unexpected behavior

From
MGMervin Guy <mail@mervin.works>
Date
Apr 10, 2023, 23:05 UTC
Message-ID
<C65981B6-49FA-4A62-84D6-541D3CFF0541@mervin.works>
In-Reply-To
<D6798678-9CC3-416F-B238-F3D28EC910B2@mervin.works>
I'm confident there is an error in the `git config --global -e` pipeline though (very likely git.c), because when using git-aliases the function performs as expected.
My current alias `ec` pointing to the command `!vi $HOME/.gitconfig` - where $HOME is `/root`. The full command looks like `git ec` and works as expected.
Meaning that the only difference between the failed-run and successful-run was calling the git built-in `git config --global -e`.
Show 26 quoted lines
> On Apr 10, 2023, at 16:49, Hello World! <mail@mervin.works> wrote:
> 
> Using the command, the trace says it’s using 'vi /root/.gitconfig' - which is indeed the set editor.
> 
> For more verbosity, the call-chain is 'git.c' (trace: built-in: git config) → 'run_command.c' (trace: run_command: 'vi /root/.gitconfig') which doesn’t seem strange.
>>> On Apr 10, 2023, at 16:25, Jeff King <peff@peff.net> wrote:
>>>  On Mon, Apr 10, 2023 at 03:44:26PM -0400, Mervin Guy wrote:
>>> 
>>> What did you do before the bug happened? (Steps to reproduce your issue)
>>> - Changed my directory to a git-repo I was working on, using 'cd <directory_name>'. Then I ran 'git config --global -e'.
>>> What did you expect to happen? (Expected behavior)
>>> - I exepected the command to display my current-config file, with all settings included, in my editor.
>>> What happened instead? (Actual behavior)
>>> - My config-file was overwritten and displayed a default-setup message, the config-file was lost after this point.
>>> I experimented with different ways of activating the command, but they all led to an overwrite of the file.
>> 
>> That's certainly unexpected. "git config --global -e" works fine for me.
>> And Git itself won't overwrite the file; it will run your editor with
>> the name of the file, and the editor is responsible for any writing.
>> Which editor are you trying to use? Can you try running with:
>> 
>> GIT_TRACE=1 git config --global -e
>> 
>> which should show the editor command that Git runs.
>> 
>> -Peff
Next: Jeff King
Message 1 of 2 in “Re: 'git config --edit' unexpected behavior”
  1. Mervin GuyApr 10, 2023
  2. Jeff KingApr 11, 2023

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.