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

Re: git init BUG when gitconfig has includeIf

From
Patrick Steinhardt <ps@pks.im>
Date
May 22, 2024, 08:27 UTC
Message-ID
<Zk2sc-649Pz77_G-@tanuki>
In-Reply-To
<D1G108TQBWK4.2XW34J29NCAHG@protonmail.com>
On Wed, May 22, 2024 at 08:21:50AM +0000, Heghedus Razvan wrote:
Show 33 quoted lines
> On Wed May 22, 2024 at 11:06 AM EEST, Patrick Steinhardt wrote:
> > On Tue, May 21, 2024 at 04:46:23PM +0000, Heghedus Razvan wrote:
> > > On Tue May 21, 2024 at 7:36 PM EEST, Junio C Hamano wrote:
> > > > Heghedus Razvan <heghedus.razvan@protonmail.com> writes:
> > Aha! Seems like this only happens when re-initializing an already
> > existent repository, that's what's missing. In that case we do already
> > have `the_repository->gitdir` set even though we did not yet set up the
> > ref storage format. I'll investigate and send a patch.
> >
> > Can you confirm that this is what you see, or do you also see this when
> > creating an entirely new repository?
> 
> Hi Patrick,
> 
> Thanks for looking into this. It seems that the issue happens only when
> the folder for the repo exists.
> 
> Eg:
> $ mkdir new_folder
> $ cd new_folder
> $ git init . 
> 
> or
> $ mkdir new_folder
> $ git init new_folder
> 
> But directly running `git init new_folder` when there is no `new_folder`
> works fine.
> 
> FYI, I just did these tests on master (4365c6fcf9).
> 
> Regards,
> Razvan

Indeed, thanks for clarifying. From the following three tests, the latter two fail:

diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index b131d665db..c1c7c307d3 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -678,4 +678,21 @@ test_expect_success 'branch -m with the initial branch' '
    test_cmp expect actual
 '
 
+test_expect_success 'init with includeIf.onbranch condition' '
+	test_when_finished "rm -rf repo" &&
+	git -c includeIf.onbranch:main.path=something init repo
+'
+
+test_expect_success 'init with includeIf.onbranch condition with existing directory' '
+	test_when_finished "rm -rf repo" &&
+	mkdir repo &&
+	git -c includeIf.onbranch:main.path=something init repo
+'
+
+test_expect_success 're-init with includeIf.onbranch condition' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	git -c includeIf.onbranch:main.path=something init repo
+'
+
 test_done

I've got a fix ready that I'll send upstream later today.

Patrick
Previous: Heghedus RazvanNext: Patrick Steinhardt
Message 6 of 14 in “git init BUG when gitconfig has includeIf”
  1. Heghedus RazvanMay 21, 2024
  2. Junio C HamanoMay 21, 2024
  3. Heghedus RazvanMay 21, 2024
  4. Patrick SteinhardtMay 22, 2024
  5. Heghedus RazvanMay 22, 2024
  6. Patrick SteinhardtMay 22, 2024
  7. setup: fix bug with "includeIf.onbranch" when initializing dirPatrick Steinhardt, May 22, 2024
  8. Heghedus RazvanMay 22, 2024
  9. Junio C HamanoMay 22, 2024
  10. Junio C HamanoMay 23, 2024
  11. Patrick SteinhardtMay 23, 2024
  12. setup: fix bug with "includeIf.onbranch" when initializing dirJunio C Hamano, May 23, 2024
  13. [rPATCH v2] setup: fix bug with "includeIf.onbranch" when initializing dirJunio C Hamano, May 23, 2024
  14. Patrick SteinhardtMay 23, 2024

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.