{"thread":{"id":"66599","subject":"[PATCH] init: show absolute path of (re)initialized repository","startedAt":"2026-10-20T05:38:47Z","lastAt":"2026-10-28T15:59:18Z","messageCount":15,"participants":["Matt Hunter","Patrick Steinhardt","Harald Nordgren","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"555494","messageId":"20261020053932.1274210-1-m@lfurio.us","threadId":"66599","inReplyTo":null,"subject":"[PATCH] init: show absolute path of (re)initialized repository","fromName":"Matt Hunter","fromEmail":"m@lfurio.us","sentAt":"2026-10-20T05:38:47Z","receivedAt":"2026-10-20T05:38:47Z","isPatch":true,"sender":{"key":"m@lfurio.us","avatar":"https://avatars.githubusercontent.com/u/14925125?v=4"},"body":"Since 20e38cba3926 (setup: split up concerns of `init_db()`,\n2026-09-10), git-init produces the message:\n\n    Initialized empty Git repository in .git/\n\ninstead of the previous\n\n    Initialized empty Git repository in /full/path/to/repo/.git/\n\nPrior to 20e38cba3926, the code producing this message was in function\ninit_db (renamed at the time to create_repository).  In that context,\nthe git_dir variable was updated by 'git_dir = repo_get_git_dir(repo);'\nearlier in the function, to set the value used in printf.\n\nNone of the discussion [1] around the original patch indicates that this\nchange was intentional, so address the regression by similarly using\nrepo_get_git_dir in this code's new location.\n\nIn this case, git_dir is referencing owned memory that is later freed,\nso declare a new variable to hold the used string.\n\n1: https://lore.kernel.org/git/20260825-pks-odb-write-alternates-at-creation-time-v1-0-911513ba95c3@pks.im/\n\nSigned-off-by: Matt Hunter <m@lfurio.us>\n---\n builtin/init-db.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex 374ed3a74706..a2628568ff6a 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -248,18 +248,19 @@ int cmd_init_db(int argc,\n \tcreate_object_database(the_repository, NULL);\n \n \tif (!quiet) {\n-\t\tint len = strlen(git_dir);\n+\t\tconst char *full_git_dir = repo_get_git_dir(the_repository);\n+\t\tint len = strlen(full_git_dir);\n \n \t\tif (reinit)\n \t\t\tprintf(repo_settings_get_shared_repository(the_repository)\n \t\t\t       ? _(\"Reinitialized existing shared Git repository in %s%s\\n\")\n \t\t\t       : _(\"Reinitialized existing Git repository in %s%s\\n\"),\n-\t\t\t       git_dir, len && git_dir[len-1] != '/' ? \"/\" : \"\");\n+\t\t\t       full_git_dir, len && full_git_dir[len-1] != '/' ? \"/\" : \"\");\n \t\telse\n \t\t\tprintf(repo_settings_get_shared_repository(the_repository)\n \t\t\t       ? _(\"Initialized empty shared Git repository in %s%s\\n\")\n \t\t\t       : _(\"Initialized empty Git repository in %s%s\\n\"),\n-\t\t\t       git_dir, len && git_dir[len-1] != '/' ? \"/\" : \"\");\n+\t\t\t       full_git_dir, len && full_git_dir[len-1] != '/' ? \"/\" : \"\");\n \t}\n \n \tfree(template_dir_to_free);\n\nbase-commit: c51408889c3b372814bc20b9431c3b74d0d268eb\n-- \n2.56.0.257.gf7497c7d27\n\n\n"},{"id":"555502","messageId":"atcQb_V69vvKnxoF@pks.im","threadId":"66599","inReplyTo":"20261020053932.1274210-1-m@lfurio.us","subject":"Re: [PATCH] init: show absolute path of (re)initialized repository","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-20T06:55:43Z","receivedAt":"2026-10-20T06:55:43Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Oct 20, 2026 at 01:38:47AM -0400, Matt Hunter wrote:\n> Since 20e38cba3926 (setup: split up concerns of `init_db()`,\n> 2026-09-10), git-init produces the message:\n> \n>     Initialized empty Git repository in .git/\n> \n> instead of the previous\n> \n>     Initialized empty Git repository in /full/path/to/repo/.git/\n> \n> Prior to 20e38cba3926, the code producing this message was in function\n> init_db (renamed at the time to create_repository).  In that context,\n> the git_dir variable was updated by 'git_dir = repo_get_git_dir(repo);'\n> earlier in the function, to set the value used in printf.\n> \n> None of the discussion [1] around the original patch indicates that this\n> change was intentional, so address the regression by similarly using\n> repo_get_git_dir in this code's new location.\n\nThis indeed wasn't an intentional change. I also confirmed that with\nv2.55 we print the full path.\n\n> In this case, git_dir is referencing owned memory that is later freed,\n> so declare a new variable to hold the used string.\n\nThis sentence doesn't add any value as it simply explains parts that are\nobvious when reading the patch. I'd just drop it.\n\n> diff --git a/builtin/init-db.c b/builtin/init-db.c\n> index 374ed3a74706..a2628568ff6a 100644\n> --- a/builtin/init-db.c\n> +++ b/builtin/init-db.c\n> @@ -248,18 +248,19 @@ int cmd_init_db(int argc,\n>  \tcreate_object_database(the_repository, NULL);\n>  \n>  \tif (!quiet) {\n> -\t\tint len = strlen(git_dir);\n> +\t\tconst char *full_git_dir = repo_get_git_dir(the_repository);\n\nPreviously, in `init_db()` we always assigned `git_dir =\nrepo_get_git_dir(repo)`, so it's clear that this change here does the\nequivalent.\n\n> +\t\tint len = strlen(full_git_dir);\n\nI was wondering whether we want to fix the variable type to be a\n`size_t` while at it. But maybe we should just keep it as-is.\n\n>  \t\tif (reinit)\n>  \t\t\tprintf(repo_settings_get_shared_repository(the_repository)\n>  \t\t\t       ? _(\"Reinitialized existing shared Git repository in %s%s\\n\")\n>  \t\t\t       : _(\"Reinitialized existing Git repository in %s%s\\n\"),\n> -\t\t\t       git_dir, len && git_dir[len-1] != '/' ? \"/\" : \"\");\n> +\t\t\t       full_git_dir, len && full_git_dir[len-1] != '/' ? \"/\" : \"\");\n>  \t\telse\n>  \t\t\tprintf(repo_settings_get_shared_repository(the_repository)\n>  \t\t\t       ? _(\"Initialized empty shared Git repository in %s%s\\n\")\n>  \t\t\t       : _(\"Initialized empty Git repository in %s%s\\n\"),\n> -\t\t\t       git_dir, len && git_dir[len-1] != '/' ? \"/\" : \"\");\n> +\t\t\t       full_git_dir, len && full_git_dir[len-1] != '/' ? \"/\" : \"\");\n>  \t}\n\nThe changes look obviously good to me.\n\nI'm a bit on the fence about whether we want to have a regression test\nor not. It feels like a very specific thing in the user-facing output,\nso it's a bit dubious whether it's really worth it. But on the other\nhand, folks like you seem to care enough to make the test worthwhile, so\nmaybe we should have one?\n\nThanks!\n\nPatrick\n\n"},{"id":"555515","messageId":"DM9JTHREBQOW.3IOHX6OZK3BGQ@lfurio.us","threadId":"66599","inReplyTo":"atcQb_V69vvKnxoF@pks.im","subject":"Re: [PATCH] init: show absolute path of (re)initialized repository","fromName":"Matt Hunter","fromEmail":"m@lfurio.us","sentAt":"2026-10-20T09:13:07Z","receivedAt":"2026-10-20T09:13:07Z","isPatch":true,"sender":{"key":"m@lfurio.us","avatar":"https://avatars.githubusercontent.com/u/14925125?v=4"},"body":"On Tue Oct 20, 2026 at 2:55 AM EDT, Patrick Steinhardt wrote:\n> On Tue, Oct 20, 2026 at 01:38:47AM -0400, Matt Hunter wrote:\n>> \n>> None of the discussion [1] around the original patch indicates that this\n>> change was intentional, so address the regression by similarly using\n>> repo_get_git_dir in this code's new location.\n>\n> This indeed wasn't an intentional change. I also confirmed that with\n> v2.55 we print the full path.\n\nAnd with 2.56 :-)  Output changed right at the beginning of this release\ncycle.\n\n>\n>> In this case, git_dir is referencing owned memory that is later freed,\n>> so declare a new variable to hold the used string.\n>\n> This sentence doesn't add any value as it simply explains parts that are\n> obvious when reading the patch. I'd just drop it.\n\nYeah.. Will do\n\n>\n>> +\t\tint len = strlen(full_git_dir);\n>\n> I was wondering whether we want to fix the variable type to be a\n> `size_t` while at it. But maybe we should just keep it as-is.\n\nIt's not of consequence to this change, but I agree it would be more\ncorrect.  I'll include it.\n\n>\n> I'm a bit on the fence about whether we want to have a regression test\n> or not. It feels like a very specific thing in the user-facing output,\n> so it's a bit dubious whether it's really worth it.\n\nThis is my thought exactly.\n\n> But on the other\n> hand, folks like you seem to care enough to make the test worthwhile, so\n> maybe we should have one?\n\nI could be convinced to add one.  I'll see if additional feedback comes\nin before sending a new revision, but won't plan for a test as of now.\n\nThanks for the review\n\n>\n> Thanks!\n>\n> Patrick\n\n\n"},{"id":"555527","messageId":"atdbFLArbbRRNXNB@pks.im","threadId":"66599","inReplyTo":"DM9JTHREBQOW.3IOHX6OZK3BGQ@lfurio.us","subject":"Re: [PATCH] init: show absolute path of (re)initialized repository","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-20T12:14:12Z","receivedAt":"2026-10-20T12:14:12Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Oct 20, 2026 at 05:13:07AM -0400, Matt Hunter wrote:\n> On Tue Oct 20, 2026 at 2:55 AM EDT, Patrick Steinhardt wrote:\n> > On Tue, Oct 20, 2026 at 01:38:47AM -0400, Matt Hunter wrote:\n> >> \n> >> None of the discussion [1] around the original patch indicates that this\n> >> change was intentional, so address the regression by similarly using\n> >> repo_get_git_dir in this code's new location.\n> >\n> > This indeed wasn't an intentional change. I also confirmed that with\n> > v2.55 we print the full path.\n> \n> And with 2.56 :-)  Output changed right at the beginning of this release\n> cycle.\n\nOh, that's something I missed. Even better then to fix this before it's\npart of any public release :)\n\nPatrick\n\n"},{"id":"555529","messageId":"CAHwyqnVf++okhdjUuVewkK5ZhqbKSoE3TixhpNORdWrMGUA=mw@mail.gmail.com","threadId":"66599","inReplyTo":"atcQb_V69vvKnxoF@pks.im","subject":"Re: [PATCH] init: show absolute path of (re)initialized repository","fromName":"Harald Nordgren","fromEmail":"haraldnordgren@gmail.com","sentAt":"2026-10-20T12:37:05Z","receivedAt":"2026-10-20T12:37:05Z","isPatch":true,"sender":{"key":"haraldnordgren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9569897?v=4"},"body":"> I'm a bit on the fence about whether we want to have a regression test\n> or not. It feels like a very specific thing in the user-facing output,\n> so it's a bit dubious whether it's really worth it. But on the other\n> hand, folks like you seem to care enough to make the test worthwhile, so\n> maybe we should have one?\n\nIt seems self-evident that we need a regression test here. Because\nit's specifically the thing that would have prevented it, and the only\nthing that will prevent a new regression later on :)\n\n\nHarald\n\n"},{"id":"555553","messageId":"atd8mopIi44pMBAC@pks.im","threadId":"66599","inReplyTo":"CAHwyqnVf++okhdjUuVewkK5ZhqbKSoE3TixhpNORdWrMGUA=mw@mail.gmail.com","subject":"Re: [PATCH] init: show absolute path of (re)initialized repository","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-20T14:37:14Z","receivedAt":"2026-10-20T14:37:14Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Oct 20, 2026 at 02:37:05PM +0200, Harald Nordgren wrote:\n> > I'm a bit on the fence about whether we want to have a regression test\n> > or not. It feels like a very specific thing in the user-facing output,\n> > so it's a bit dubious whether it's really worth it. But on the other\n> > hand, folks like you seem to care enough to make the test worthwhile, so\n> > maybe we should have one?\n> \n> It seems self-evident that we need a regression test here. Because\n> it's specifically the thing that would have prevented it, and the only\n> thing that will prevent a new regression later on :)\n\nI wouldn't necessarily say self-evident as the result isn't wrong. It's\nstill correct, even though it has changed compared to the previous\nstatus quo.\n\nPatrick\n\n"},{"id":"555568","messageId":"CAHwyqnWhX0mxz2b5JQfXbtC9ysd2rVVPrnosRV_qdpk9p7J-ow@mail.gmail.com","threadId":"66599","inReplyTo":"atd8mopIi44pMBAC@pks.im","subject":"Re: [PATCH] init: show absolute path of (re)initialized repository","fromName":"Harald Nordgren","fromEmail":"haraldnordgren@gmail.com","sentAt":"2026-10-20T15:32:18Z","receivedAt":"2026-10-20T15:32:18Z","isPatch":true,"sender":{"key":"haraldnordgren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9569897?v=4"},"body":"On Tue, Oct 20, 2026 at 4:37 PM Patrick Steinhardt <ps@pks.im> wrote:\n>\n> On Tue, Oct 20, 2026 at 02:37:05PM +0200, Harald Nordgren wrote:\n> > > I'm a bit on the fence about whether we want to have a regression test\n> > > or not. It feels like a very specific thing in the user-facing output,\n> > > so it's a bit dubious whether it's really worth it. But on the other\n> > > hand, folks like you seem to care enough to make the test worthwhile, so\n> > > maybe we should have one?\n> >\n> > It seems self-evident that we need a regression test here. Because\n> > it's specifically the thing that would have prevented it, and the only\n> > thing that will prevent a new regression later on :)\n>\n> I wouldn't necessarily say self-evident as the result isn't wrong. It's\n> still correct, even though it has changed compared to the previous\n> status quo.\n\nI guess it's semantics. The regression test locks down the behavior,\nso it won't be accidentally changed later on.\n\n\nHarald\n\n"},{"id":"555579","messageId":"xmqqfqy0xrm7.fsf@gitster.g","threadId":"66599","inReplyTo":"atd8mopIi44pMBAC@pks.im","subject":"Re: [PATCH] init: show absolute path of (re)initialized repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-20T16:29:36Z","receivedAt":"2026-10-20T16:29:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Tue, Oct 20, 2026 at 02:37:05PM +0200, Harald Nordgren wrote:\n>> > I'm a bit on the fence about whether we want to have a regression test\n>> > or not. It feels like a very specific thing in the user-facing output,\n>> > so it's a bit dubious whether it's really worth it. But on the other\n>> > hand, folks like you seem to care enough to make the test worthwhile, so\n>> > maybe we should have one?\n>> \n>> It seems self-evident that we need a regression test here. Because\n>> it's specifically the thing that would have prevented it, and the only\n>> thing that will prevent a new regression later on :)\n>\n> I wouldn't necessarily say self-evident as the result isn't wrong. It's\n> still correct, even though it has changed compared to the previous\n> status quo.\n\nIt is correct in the sense that it is not wrong, but we cannot deny\nthat it is much less useful when trying to determine where the new\nrepository was created while reading a transcript that contains an\ninvocation of the 'git init' command.  One would need to go back\nand see where the user in the transcript 'cd'ed to before issuing\nthe command.\n\nThis episode makes me wonder what other details, not captured in our\nexisting tests, users find useful and have grown accustomed to.\n\nThanks.\n\n"},{"id":"555858","messageId":"20261022120749.3567828-1-m@lfurio.us","threadId":"66599","inReplyTo":"20261020053932.1274210-1-m@lfurio.us","subject":"[PATCH v2] init: show absolute path of (re)initialized repository","fromName":"Matt Hunter","fromEmail":"m@lfurio.us","sentAt":"2026-10-22T12:06:32Z","receivedAt":"2026-10-22T12:06:32Z","isPatch":true,"sender":{"key":"m@lfurio.us","avatar":"https://avatars.githubusercontent.com/u/14925125?v=4"},"body":"Since 20e38cba3926 (setup: split up concerns of `init_db()`,\n2026-09-10), git-init produces the message:\n\n    Initialized empty Git repository in .git/\n\ninstead of the previous\n\n    Initialized empty Git repository in /full/path/to/repo/.git/\n\nPrior to 20e38cba3926, the code producing this message was in function\ninit_db (renamed at the time to create_repository).  In that context,\nthe git_dir variable was updated by 'git_dir = repo_get_git_dir(repo);'\nearlier in the function, to set the value used in printf.\n\nNone of the discussion [1] around the original patch indicates that this\nchange was intentional, so address the regression by similarly using\nrepo_get_git_dir in this code's new location.\n\n1: https://lore.kernel.org/git/20260825-pks-odb-write-alternates-at-creation-time-v1-0-911513ba95c3@pks.im/\n\nSigned-off-by: Matt Hunter <m@lfurio.us>\n---\n\n Changes in v2:\n    - len type is updated to size_t\n    - added a regression test (changed my mind on this)\n    - some text is stripped from the patch message\n    - Link to v1: https://patch.msgid.link/20261020053932.1274210-1-m@lfurio.us\n\n builtin/init-db.c | 7 ++++---\n t/t0001-init.sh   | 6 ++++++\n 2 files changed, 10 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex 374ed3a74706..9612d2b8bfca 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -248,18 +248,19 @@ int cmd_init_db(int argc,\n \tcreate_object_database(the_repository, NULL);\n \n \tif (!quiet) {\n-\t\tint len = strlen(git_dir);\n+\t\tconst char *full_git_dir = repo_get_git_dir(the_repository);\n+\t\tsize_t len = strlen(full_git_dir);\n \n \t\tif (reinit)\n \t\t\tprintf(repo_settings_get_shared_repository(the_repository)\n \t\t\t       ? _(\"Reinitialized existing shared Git repository in %s%s\\n\")\n \t\t\t       : _(\"Reinitialized existing Git repository in %s%s\\n\"),\n-\t\t\t       git_dir, len && git_dir[len-1] != '/' ? \"/\" : \"\");\n+\t\t\t       full_git_dir, len && full_git_dir[len-1] != '/' ? \"/\" : \"\");\n \t\telse\n \t\t\tprintf(repo_settings_get_shared_repository(the_repository)\n \t\t\t       ? _(\"Initialized empty shared Git repository in %s%s\\n\")\n \t\t\t       : _(\"Initialized empty Git repository in %s%s\\n\"),\n-\t\t\t       git_dir, len && git_dir[len-1] != '/' ? \"/\" : \"\");\n+\t\t\t       full_git_dir, len && full_git_dir[len-1] != '/' ? \"/\" : \"\");\n \t}\n \n \tfree(template_dir_to_free);\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex f1d227f27167..fbf8a0e41dad 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -1000,4 +1000,10 @@ test_expect_success 'init honors GIT_OBJECT_DIRECTORY' '\n \ttest_path_is_dir custom-odb/info\n '\n \n+test_expect_success 'init shows absolute path to gitdir' '\n+\texpect=\"$(pwd)/init-path\" &&\n+\tgit init init-path >actual &&\n+\ttest_grep \"$expect\" actual\n+'\n+\n test_done\n\nRange-diff against v1:\n1:  c0869122d3fb ! 1:  49d220d97aa8 init: show absolute path of (re)initialized repository\n    @@ Commit message\n         change was intentional, so address the regression by similarly using\n         repo_get_git_dir in this code's new location.\n     \n    -    In this case, git_dir is referencing owned memory that is later freed,\n    -    so declare a new variable to hold the used string.\n    -\n         1: https://lore.kernel.org/git/20260825-pks-odb-write-alternates-at-creation-time-v1-0-911513ba95c3@pks.im/\n     \n         Signed-off-by: Matt Hunter <m@lfurio.us>\n    @@ builtin/init-db.c: int cmd_init_db(int argc,\n      \tif (!quiet) {\n     -\t\tint len = strlen(git_dir);\n     +\t\tconst char *full_git_dir = repo_get_git_dir(the_repository);\n    -+\t\tint len = strlen(full_git_dir);\n    ++\t\tsize_t len = strlen(full_git_dir);\n      \n      \t\tif (reinit)\n      \t\t\tprintf(repo_settings_get_shared_repository(the_repository)\n    @@ builtin/init-db.c: int cmd_init_db(int argc,\n      \t}\n      \n      \tfree(template_dir_to_free);\n    +\n    + ## t/t0001-init.sh ##\n    +@@ t/t0001-init.sh: test_expect_success 'init honors GIT_OBJECT_DIRECTORY' '\n    + \ttest_path_is_dir custom-odb/info\n    + '\n    + \n    ++test_expect_success 'init shows absolute path to gitdir' '\n    ++\texpect=\"$(pwd)/init-path\" &&\n    ++\tgit init init-path >actual &&\n    ++\ttest_grep \"$expect\" actual\n    ++'\n    ++\n    + test_done\n\nbase-commit: 47fdf2208c5b94c8cc01c106b8f7c85efb91c926\n-- \n2.56.0.257.gf7497c7d27\n\n\n"},{"id":"555951","messageId":"atr-Juww5KZN-ugM@pks.im","threadId":"66599","inReplyTo":"20261022120749.3567828-1-m@lfurio.us","subject":"Re: [PATCH v2] init: show absolute path of (re)initialized repository","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-23T06:26:46Z","receivedAt":"2026-10-23T06:26:46Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Thu, Oct 22, 2026 at 08:06:32AM -0400, Matt Hunter wrote:\n> diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n> index f1d227f27167..fbf8a0e41dad 100755\n> --- a/t/t0001-init.sh\n> +++ b/t/t0001-init.sh\n> @@ -1000,4 +1000,10 @@ test_expect_success 'init honors GIT_OBJECT_DIRECTORY' '\n>  \ttest_path_is_dir custom-odb/info\n>  '\n>  \n> +test_expect_success 'init shows absolute path to gitdir' '\n> +\texpect=\"$(pwd)/init-path\" &&\n\nI don't think this extra variable buys us anything, so I'd just drop it.\n\n> +\tgit init init-path >actual &&\n> +\ttest_grep \"$expect\" actual\n> +'\n\nI would have tested for the whole message, which is short enough to be\nreasonable, I'd say.\n\nOther than those nits I'm happy, thanks!\n\nPatrick\n\n"},{"id":"555998","messageId":"DMC7P4CPEV2X.25XRRSBEZCFPH@lfurio.us","threadId":"66599","inReplyTo":"atr-Juww5KZN-ugM@pks.im","subject":"Re: [PATCH v2] init: show absolute path of (re)initialized repository","fromName":"Matt Hunter","fromEmail":"m@lfurio.us","sentAt":"2026-10-23T12:21:11Z","receivedAt":"2026-10-23T12:21:11Z","isPatch":true,"sender":{"key":"m@lfurio.us","avatar":"https://avatars.githubusercontent.com/u/14925125?v=4"},"body":"On Fri Oct 23, 2026 at 2:26 AM EDT, Patrick Steinhardt wrote:\n> On Thu, Oct 22, 2026 at 08:06:32AM -0400, Matt Hunter wrote:\n>>  \n>> +test_expect_success 'init shows absolute path to gitdir' '\n>> +\texpect=\"$(pwd)/init-path\" &&\n>\n> I don't think this extra variable buys us anything, so I'd just drop it.\n>\n>> +\tgit init init-path >actual &&\n>> +\ttest_grep \"$expect\" actual\n>> +'\n>\n> I would have tested for the whole message, which is short enough to be\n> reasonable, I'd say.\n\nI considered this.  I decided on this simpler version since there are\n4 possible messages that could appear at the end of git init.  Do we\nwant separate tests/assertions to check all outputs\n\n    \"Reinitialized existing shared Git repository in %s%s\"\n    \"Reinitialized existing Git repository in %s%s\"\n    \"Initialized empty shared Git repository in %s%s\"\n    \"Initialized empty Git repository in %s%s\"\n\nare as expected?\n\nFurthermore, the final path element is configurable as well, though\nshould just be \".git\" in the case of these tests.  I figured, since the\nactual breakage was about the appearance of the path, then I would just\ntest _that aspect_ of the output in this test.\n\nHow do we feel about this assertion\n\n    echo \"Initialized empty Git repository in $(pwd)/init-path/.git/\" >expect\n    test_cmp expect actual\n\nwhich tests the whole message of just the default case?  The unnecessary\nvariable you point out above is repurposed into a needed tmp file.\n\n"},{"id":"556252","messageId":"at76u_L1yiot329r@pks.im","threadId":"66599","inReplyTo":"DMC7P4CPEV2X.25XRRSBEZCFPH@lfurio.us","subject":"Re: [PATCH v2] init: show absolute path of (re)initialized repository","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-26T07:01:15Z","receivedAt":"2026-10-26T07:01:15Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Fri, Oct 23, 2026 at 08:21:11AM -0400, Matt Hunter wrote:\n> On Fri Oct 23, 2026 at 2:26 AM EDT, Patrick Steinhardt wrote:\n> > On Thu, Oct 22, 2026 at 08:06:32AM -0400, Matt Hunter wrote:\n> >>  \n> >> +test_expect_success 'init shows absolute path to gitdir' '\n> >> +\texpect=\"$(pwd)/init-path\" &&\n> >\n> > I don't think this extra variable buys us anything, so I'd just drop it.\n> >\n> >> +\tgit init init-path >actual &&\n> >> +\ttest_grep \"$expect\" actual\n> >> +'\n> >\n> > I would have tested for the whole message, which is short enough to be\n> > reasonable, I'd say.\n> \n> I considered this.  I decided on this simpler version since there are\n> 4 possible messages that could appear at the end of git init.  Do we\n> want separate tests/assertions to check all outputs\n> \n>     \"Reinitialized existing shared Git repository in %s%s\"\n>     \"Reinitialized existing Git repository in %s%s\"\n>     \"Initialized empty shared Git repository in %s%s\"\n>     \"Initialized empty Git repository in %s%s\"\n> \n> are as expected?\n\nI feel like that'd probably be a bit excessive.\n\n> Furthermore, the final path element is configurable as well, though\n> should just be \".git\" in the case of these tests.  I figured, since the\n> actual breakage was about the appearance of the path, then I would just\n> test _that aspect_ of the output in this test.\n> \n> How do we feel about this assertion\n> \n>     echo \"Initialized empty Git repository in $(pwd)/init-path/.git/\" >expect\n>     test_cmp expect actual\n> \n> which tests the whole message of just the default case?  The unnecessary\n> variable you point out above is repurposed into a needed tmp file.\n\nI'd say that's good enough for now. Thanks!\n\nPatrick\n\n"},{"id":"556600","messageId":"20261028051704.2759358-1-m@lfurio.us","threadId":"66599","inReplyTo":"20261020053932.1274210-1-m@lfurio.us","subject":"[PATCH v3] init: show absolute path of (re)initialized repository","fromName":"Matt Hunter","fromEmail":"m@lfurio.us","sentAt":"2026-10-28T05:16:37Z","receivedAt":"2026-10-28T05:16:37Z","isPatch":true,"sender":{"key":"m@lfurio.us","avatar":"https://avatars.githubusercontent.com/u/14925125?v=4"},"body":"Since 20e38cba3926 (setup: split up concerns of `init_db()`,\n2026-09-10), git-init produces the message:\n\n    Initialized empty Git repository in .git/\n\ninstead of the previous\n\n    Initialized empty Git repository in /full/path/to/repo/.git/\n\nPrior to 20e38cba3926, the code producing this message was in function\ninit_db (renamed at the time to create_repository).  In that context,\nthe git_dir variable was updated by 'git_dir = repo_get_git_dir(repo);'\nearlier in the function, to set the value used in printf.\n\nNone of the discussion [1] around the original patch indicates that this\nchange was intentional, so address the regression by similarly using\nrepo_get_git_dir in this code's new location.\n\n1: https://lore.kernel.org/git/20260825-pks-odb-write-alternates-at-creation-time-v1-0-911513ba95c3@pks.im/\n\nSigned-off-by: Matt Hunter <m@lfurio.us>\n---\n\n Changes in v3:\n    - expand test to cover the full output of the init command\n    - Link to v2: https://patch.msgid.link/20261022120749.3567828-1-m@lfurio.us\n\n Changes in v2:\n    - len type is updated to size_t\n    - added a regression test (changed my mind on this)\n    - some text is stripped from the patch message\n    - Link to v1: https://patch.msgid.link/20261020053932.1274210-1-m@lfurio.us\n\n builtin/init-db.c | 7 ++++---\n t/t0001-init.sh   | 6 ++++++\n 2 files changed, 10 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex 374ed3a74706..9612d2b8bfca 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -248,18 +248,19 @@ int cmd_init_db(int argc,\n \tcreate_object_database(the_repository, NULL);\n \n \tif (!quiet) {\n-\t\tint len = strlen(git_dir);\n+\t\tconst char *full_git_dir = repo_get_git_dir(the_repository);\n+\t\tsize_t len = strlen(full_git_dir);\n \n \t\tif (reinit)\n \t\t\tprintf(repo_settings_get_shared_repository(the_repository)\n \t\t\t       ? _(\"Reinitialized existing shared Git repository in %s%s\\n\")\n \t\t\t       : _(\"Reinitialized existing Git repository in %s%s\\n\"),\n-\t\t\t       git_dir, len && git_dir[len-1] != '/' ? \"/\" : \"\");\n+\t\t\t       full_git_dir, len && full_git_dir[len-1] != '/' ? \"/\" : \"\");\n \t\telse\n \t\t\tprintf(repo_settings_get_shared_repository(the_repository)\n \t\t\t       ? _(\"Initialized empty shared Git repository in %s%s\\n\")\n \t\t\t       : _(\"Initialized empty Git repository in %s%s\\n\"),\n-\t\t\t       git_dir, len && git_dir[len-1] != '/' ? \"/\" : \"\");\n+\t\t\t       full_git_dir, len && full_git_dir[len-1] != '/' ? \"/\" : \"\");\n \t}\n \n \tfree(template_dir_to_free);\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex f1d227f27167..5d438dcc2804 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -1000,4 +1000,10 @@ test_expect_success 'init honors GIT_OBJECT_DIRECTORY' '\n \ttest_path_is_dir custom-odb/info\n '\n \n+test_expect_success 'init shows absolute path to gitdir' '\n+\techo \"Initialized empty Git repository in $(pwd)/init-path/.git/\" >expect &&\n+\tgit init init-path >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n\nRange-diff against v2:\n1:  49d220d97aa8 ! 1:  6c9adee7702b init: show absolute path of (re)initialized repository\n    @@ t/t0001-init.sh: test_expect_success 'init honors GIT_OBJECT_DIRECTORY' '\n      '\n      \n     +test_expect_success 'init shows absolute path to gitdir' '\n    -+\texpect=\"$(pwd)/init-path\" &&\n    ++\techo \"Initialized empty Git repository in $(pwd)/init-path/.git/\" >expect &&\n     +\tgit init init-path >actual &&\n    -+\ttest_grep \"$expect\" actual\n    ++\ttest_cmp expect actual\n     +'\n     +\n      test_done\n\nbase-commit: 47fdf2208c5b94c8cc01c106b8f7c85efb91c926\n-- \n2.56.0.333.g9ad7b1359b\n\n\n"},{"id":"556603","messageId":"auGePs3hkgJ85JlV@pks.im","threadId":"66599","inReplyTo":"20261028051704.2759358-1-m@lfurio.us","subject":"Re: [PATCH v3] init: show absolute path of (re)initialized repository","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-28T07:03:26Z","receivedAt":"2026-10-28T07:03:26Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Oct 28, 2026 at 01:16:37AM -0400, Matt Hunter wrote:\n>  Changes in v3:\n>     - expand test to cover the full output of the init command\n>     - Link to v2: https://patch.msgid.link/20261022120749.3567828-1-m@lfurio.us\n\nThanks, I'm happy with this version.\n\nPatrick\n\n"},{"id":"556676","messageId":"xmqqecd9ddex.fsf@gitster.g","threadId":"66599","inReplyTo":"auGePs3hkgJ85JlV@pks.im","subject":"Re: [PATCH v3] init: show absolute path of (re)initialized repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-28T15:59:18Z","receivedAt":"2026-10-28T15:59:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Wed, Oct 28, 2026 at 01:16:37AM -0400, Matt Hunter wrote:\n>>  Changes in v3:\n>>     - expand test to cover the full output of the init command\n>>     - Link to v2: https://patch.msgid.link/20261022120749.3567828-1-m@lfurio.us\n>\n> Thanks, I'm happy with this version.\n>\n> Patrick\n\nThanks.  Marked as ready for 'next'.\n\n"}]}