git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Jeff King <peff@peff.net>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Cc: Junio C Hamano <gitster@pobox.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] git config: do not create .git/ if it does not exist yet
Date: Wed, 24 Feb 2016 18:01:15 +0700	[thread overview]
Message-ID: <CACsJy8BETTY82RuEPD_Hthi3eXRK6WDutjO1RGscfCSun2SfUQ@mail.gmail.com> (raw)
In-Reply-To: <20160224082657.GD12511@sigill.intra.peff.net>

On Wed, Feb 24, 2016 at 3:26 PM, Jeff King <peff@peff.net> wrote:
> 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

  parent reply	other threads:[~2016-02-24 11:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-24  7:47 [PATCH] git config: do not create .git/ if it does not exist yet Johannes Schindelin
2016-02-24  8:26 ` Jeff King
2016-02-24 10:14   ` John Keeping
2016-02-24 10:31     ` Jeff King
2016-02-24 11:31       ` Johannes Schindelin
2016-02-24 12:13         ` Johannes Schindelin
2016-02-24 12:34           ` Jeff King
2016-02-24 18:45           ` Junio C Hamano
2016-02-24 11:01   ` Duy Nguyen [this message]
2016-02-24 12:48 ` [PATCH v2] git config: report when trying to modify a non-existing repo config Johannes Schindelin
2016-02-24 12:59   ` Duy Nguyen
2016-02-24 13:26     ` Johannes Schindelin
2016-02-24 13:29       ` Duy Nguyen
2016-02-24 20:11   ` Junio C Hamano
2016-02-24 22:31     ` Junio C Hamano
2016-02-25 15:54       ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACsJy8BETTY82RuEPD_Hthi3eXRK6WDutjO1RGscfCSun2SfUQ@mail.gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).