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

Re: [PATCH] git config: do not create .git/ if it does not exist yet

From
Duy Nguyen <pclouds@gmail.com>
Date
Feb 24, 2016, 11:01 UTC
Message-ID
<CACsJy8BETTY82RuEPD_Hthi3eXRK6WDutjO1RGscfCSun2SfUQ@mail.gmail.com>
In-Reply-To
<20160224082657.GD12511@sigill.intra.peff.net>
On Wed, Feb 24, 2016 at 3:26 PM, Jeff King <peff@peff.net> wrote:
Show 12 quoted lines
> On Wed, Feb 24, 2016 at 08:47:00AM +0100, Johannes Schindelin wrote:
>
>> It is a pilot error to call `git config section.key value` outside of
>> any Git worktree.
>>
>> Let's report that error instead of creating the .git/ directory and
>> writing a fresh config into it.
>
> Hmm.  I get (on my Linux machine):
>
>   $ git config foo.bar baz
>   error: could not lock config file .git/config: No such file or directory

Yep, tried the same thing before I asked about the .git dir thing on gfw list. Same result.

> which makes sense (though still isn't a great error message, and is kind
> of weird if you happen to have a .git directory that isn't a real
> repository).

Known bug. If setup fails to find git dir and somebody (plenty of them in fact) calls get_git_dir(), we automtaically assume git dir is ".git".

> Is Git more aggressive about auto-creating the directory for lockfiles
> on Windows? I tried the exact recipe you gave in the linked thread, just
> to be sure, but I couldn't replicate it.

If .git is created before lockfile code, then the lock should be successfully created. The fix in check_write() fixes it for Johannes, so it must be something between

// if (action == ACTION_SET) {... check_write(); check_argc(argc, 2, 2); value = normalize_value(argv[0], argv[1]); ret = git_config_set_in_file(given_config_source.file, argv[0], value);

I don't see where mkdir() can be called either.

Johannes, maybe you can force a crash in mingw_mkdir to pinpoint this code? Just in case the bug is outside config code.

-- 
Duy
Previous: Junio C HamanoNext: Johannes Schindelin
Message 9 of 16 in “git config: do not create .git/ if it does not exist yet”
  1. git config: do not create .git/ if it does not exist yetJohannes Schindelin, Feb 24, 2016
  2. Jeff KingFeb 24, 2016
  3. John KeepingFeb 24, 2016
  4. Jeff KingFeb 24, 2016
  5. Johannes SchindelinFeb 24, 2016
  6. Johannes SchindelinFeb 24, 2016
  7. Jeff KingFeb 24, 2016
  8. Junio C HamanoFeb 24, 2016
  9. Duy NguyenFeb 24, 2016
  10. git config: report when trying to modify a non-existing repo configJohannes Schindelin, Feb 24, 2016
  11. Duy NguyenFeb 24, 2016
  12. Johannes SchindelinFeb 24, 2016
  13. Duy NguyenFeb 24, 2016
  14. Junio C HamanoFeb 24, 2016
  15. Junio C HamanoFeb 24, 2016
  16. Johannes SchindelinFeb 25, 2016

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.