threads / patch / 66599

patchinit: show absolute path of (re)initialized repository

Subject: [PATCH] init: show absolute path of (re)initialized repository

## tl;dr

Since a September refactor, the message prints ".git/" instead of the full repository path. Read the story.

replies: 14people: 4as markdown or json

Matt Hunter· Oct 20, 2026, 05:38 UTC · lore

Since 20e38cba3926 (setup: split up concerns of `init_db()`, 2026-09-10), git-init produces the message:

    Initialized empty Git repository in .git/
instead of the previous
    Initialized empty Git repository in /full/path/to/repo/.git/

Prior to 20e38cba3926, the code producing this message was in function init_db (renamed at the time to create_repository). In that context, the git_dir variable was updated by 'git_dir = repo_get_git_dir(repo);' earlier in the function, to set the value used in printf.

None of the discussion [1] around the original patch indicates that this change was intentional, so address the regression by similarly using repo_get_git_dir in this code's new location.

In this case, git_dir is referencing owned memory that is later freed, so declare a new variable to hold the used string.

1: https://lore.kernel.org/git/20260825-pks-odb-write-alternates-at-creation-time-v1-0-911513ba95c3@pks.im/
Signed-off-by: Matt Hunter <m@lfurio.us>
---
 builtin/init-db.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Show changes to builtin/init-db.c +4 −3
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 374ed3a74706..a2628568ff6a 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -248,18 +248,19 @@ int cmd_init_db(int argc,
 	create_object_database(the_repository, NULL);
 
 	if (!quiet) {
-		int len = strlen(git_dir);
+		const char *full_git_dir = repo_get_git_dir(the_repository);
+		int len = strlen(full_git_dir);
 
 		if (reinit)
 			printf(repo_settings_get_shared_repository(the_repository)
 			       ? _("Reinitialized existing shared Git repository in %s%s\n")
 			       : _("Reinitialized existing Git repository in %s%s\n"),
-			       git_dir, len && git_dir[len-1] != '/' ? "/" : "");
+			       full_git_dir, len && full_git_dir[len-1] != '/' ? "/" : "");
 		else
 			printf(repo_settings_get_shared_repository(the_repository)
 			       ? _("Initialized empty shared Git repository in %s%s\n")
 			       : _("Initialized empty Git repository in %s%s\n"),
-			       git_dir, len && git_dir[len-1] != '/' ? "/" : "");
+			       full_git_dir, len && full_git_dir[len-1] != '/' ? "/" : "");
 	}
 
 	free(template_dir_to_free);

base-commit: c51408889c3b372814bc20b9431c3b74d0d268eb
-- 
2.56.0.257.gf7497c7d27
Patrick Steinhardt· Oct 20, 2026, 06:55 UTC · re: Matt Hunter · lore

Re: [PATCH] init: show absolute path of (re)initialized repository

On Tue, Oct 20, 2026 at 01:38:47AM -0400, Matt Hunter wrote:
Show 17 quoted lines
> Since 20e38cba3926 (setup: split up concerns of `init_db()`,
> 2026-09-10), git-init produces the message:
> 
>     Initialized empty Git repository in .git/
> 
> instead of the previous
> 
>     Initialized empty Git repository in /full/path/to/repo/.git/
> 
> Prior to 20e38cba3926, the code producing this message was in function
> init_db (renamed at the time to create_repository).  In that context,
> the git_dir variable was updated by 'git_dir = repo_get_git_dir(repo);'
> earlier in the function, to set the value used in printf.
> 
> None of the discussion [1] around the original patch indicates that this
> change was intentional, so address the regression by similarly using
> repo_get_git_dir in this code's new location.

This indeed wasn't an intentional change. I also confirmed that with v2.55 we print the full path.

> In this case, git_dir is referencing owned memory that is later freed,
> so declare a new variable to hold the used string.

This sentence doesn't add any value as it simply explains parts that are obvious when reading the patch. I'd just drop it.

Show 10 quoted lines
> diff --git a/builtin/init-db.c b/builtin/init-db.c
> index 374ed3a74706..a2628568ff6a 100644
> --- a/builtin/init-db.c
> +++ b/builtin/init-db.c
> @@ -248,18 +248,19 @@ int cmd_init_db(int argc,
>  	create_object_database(the_repository, NULL);
>  
>  	if (!quiet) {
> -		int len = strlen(git_dir);
> +		const char *full_git_dir = repo_get_git_dir(the_repository);

Previously, in `init_db()` we always assigned `git_dir = repo_get_git_dir(repo)`, so it's clear that this change here does the equivalent.

> +		int len = strlen(full_git_dir);

I was wondering whether we want to fix the variable type to be a `size_t` while at it. But maybe we should just keep it as-is.

Show 13 quoted lines
>  		if (reinit)
>  			printf(repo_settings_get_shared_repository(the_repository)
>  			       ? _("Reinitialized existing shared Git repository in %s%s\n")
>  			       : _("Reinitialized existing Git repository in %s%s\n"),
> -			       git_dir, len && git_dir[len-1] != '/' ? "/" : "");
> +			       full_git_dir, len && full_git_dir[len-1] != '/' ? "/" : "");
>  		else
>  			printf(repo_settings_get_shared_repository(the_repository)
>  			       ? _("Initialized empty shared Git repository in %s%s\n")
>  			       : _("Initialized empty Git repository in %s%s\n"),
> -			       git_dir, len && git_dir[len-1] != '/' ? "/" : "");
> +			       full_git_dir, len && full_git_dir[len-1] != '/' ? "/" : "");
>  	}
The changes look obviously good to me.

I'm a bit on the fence about whether we want to have a regression test or not. It feels like a very specific thing in the user-facing output, so it's a bit dubious whether it's really worth it. But on the other hand, folks like you seem to care enough to make the test worthwhile, so maybe we should have one?

Thanks!
Patrick
Matt Hunter· Oct 20, 2026, 09:13 UTC · re: Patrick Steinhardt · lore

Re: [PATCH] init: show absolute path of (re)initialized repository

On Tue Oct 20, 2026 at 2:55 AM EDT, Patrick Steinhardt wrote:
Show 8 quoted lines
> On Tue, Oct 20, 2026 at 01:38:47AM -0400, Matt Hunter wrote:
>> 
>> None of the discussion [1] around the original patch indicates that this
>> change was intentional, so address the regression by similarly using
>> repo_get_git_dir in this code's new location.
>
> This indeed wasn't an intentional change. I also confirmed that with
> v2.55 we print the full path.

And with 2.56 :-) Output changed right at the beginning of this release cycle.

Show 6 quoted lines
>
>> In this case, git_dir is referencing owned memory that is later freed,
>> so declare a new variable to hold the used string.
>
> This sentence doesn't add any value as it simply explains parts that are
> obvious when reading the patch. I'd just drop it.
Yeah.. Will do
Show 5 quoted lines
>
>> +		int len = strlen(full_git_dir);
>
> I was wondering whether we want to fix the variable type to be a
> `size_t` while at it. But maybe we should just keep it as-is.

It's not of consequence to this change, but I agree it would be more correct. I'll include it.

>
> I'm a bit on the fence about whether we want to have a regression test
> or not. It feels like a very specific thing in the user-facing output,
> so it's a bit dubious whether it's really worth it.
This is my thought exactly.
> But on the other
> hand, folks like you seem to care enough to make the test worthwhile, so
> maybe we should have one?

I could be convinced to add one. I'll see if additional feedback comes in before sending a new revision, but won't plan for a test as of now.

Thanks for the review
>
> Thanks!
>
> Patrick
Patrick Steinhardt· Oct 20, 2026, 12:14 UTC · re: Matt Hunter · lore

Re: [PATCH] init: show absolute path of (re)initialized repository

On Tue, Oct 20, 2026 at 05:13:07AM -0400, Matt Hunter wrote:
Show 12 quoted lines
> On Tue Oct 20, 2026 at 2:55 AM EDT, Patrick Steinhardt wrote:
> > On Tue, Oct 20, 2026 at 01:38:47AM -0400, Matt Hunter wrote:
> >> 
> >> None of the discussion [1] around the original patch indicates that this
> >> change was intentional, so address the regression by similarly using
> >> repo_get_git_dir in this code's new location.
> >
> > This indeed wasn't an intentional change. I also confirmed that with
> > v2.55 we print the full path.
> 
> And with 2.56 :-)  Output changed right at the beginning of this release
> cycle.

Oh, that's something I missed. Even better then to fix this before it's part of any public release :)

Patrick
Harald Nordgren· Oct 20, 2026, 12:37 UTC · re: Patrick Steinhardt · lore

Re: [PATCH] init: show absolute path of (re)initialized repository

Show 5 quoted lines
> I'm a bit on the fence about whether we want to have a regression test
> or not. It feels like a very specific thing in the user-facing output,
> so it's a bit dubious whether it's really worth it. But on the other
> hand, folks like you seem to care enough to make the test worthwhile, so
> maybe we should have one?

It seems self-evident that we need a regression test here. Because it's specifically the thing that would have prevented it, and the only thing that will prevent a new regression later on :)

Harald
Patrick Steinhardt· Oct 20, 2026, 14:37 UTC · re: Harald Nordgren · lore

Re: [PATCH] init: show absolute path of (re)initialized repository

On Tue, Oct 20, 2026 at 02:37:05PM +0200, Harald Nordgren wrote:
Show 9 quoted lines
> > I'm a bit on the fence about whether we want to have a regression test
> > or not. It feels like a very specific thing in the user-facing output,
> > so it's a bit dubious whether it's really worth it. But on the other
> > hand, folks like you seem to care enough to make the test worthwhile, so
> > maybe we should have one?
> 
> It seems self-evident that we need a regression test here. Because
> it's specifically the thing that would have prevented it, and the only
> thing that will prevent a new regression later on :)

I wouldn't necessarily say self-evident as the result isn't wrong. It's still correct, even though it has changed compared to the previous status quo.

Patrick
Harald Nordgren· Oct 20, 2026, 15:32 UTC · re: Patrick Steinhardt · lore

Re: [PATCH] init: show absolute path of (re)initialized repository

On Tue, Oct 20, 2026 at 4:37 PM Patrick Steinhardt <ps@pks.im> wrote:
Show 15 quoted lines
>
> On Tue, Oct 20, 2026 at 02:37:05PM +0200, Harald Nordgren wrote:
> > > I'm a bit on the fence about whether we want to have a regression test
> > > or not. It feels like a very specific thing in the user-facing output,
> > > so it's a bit dubious whether it's really worth it. But on the other
> > > hand, folks like you seem to care enough to make the test worthwhile, so
> > > maybe we should have one?
> >
> > It seems self-evident that we need a regression test here. Because
> > it's specifically the thing that would have prevented it, and the only
> > thing that will prevent a new regression later on :)
>
> I wouldn't necessarily say self-evident as the result isn't wrong. It's
> still correct, even though it has changed compared to the previous
> status quo.

I guess it's semantics. The regression test locks down the behavior, so it won't be accidentally changed later on.

Harald
Junio C Hamano· Oct 20, 2026, 16:29 UTC · re: Patrick Steinhardt · lore

Re: [PATCH] init: show absolute path of (re)initialized repository

Patrick Steinhardt <ps@pks.im> writes:
Show 14 quoted lines
> On Tue, Oct 20, 2026 at 02:37:05PM +0200, Harald Nordgren wrote:
>> > I'm a bit on the fence about whether we want to have a regression test
>> > or not. It feels like a very specific thing in the user-facing output,
>> > so it's a bit dubious whether it's really worth it. But on the other
>> > hand, folks like you seem to care enough to make the test worthwhile, so
>> > maybe we should have one?
>> 
>> It seems self-evident that we need a regression test here. Because
>> it's specifically the thing that would have prevented it, and the only
>> thing that will prevent a new regression later on :)
>
> I wouldn't necessarily say self-evident as the result isn't wrong. It's
> still correct, even though it has changed compared to the previous
> status quo.

It is correct in the sense that it is not wrong, but we cannot deny that it is much less useful when trying to determine where the new repository was created while reading a transcript that contains an invocation of the 'git init' command. One would need to go back and see where the user in the transcript 'cd'ed to before issuing the command.

This episode makes me wonder what other details, not captured in our existing tests, users find useful and have grown accustomed to.

Thanks.
Matt Hunter· Oct 22, 2026, 12:06 UTC · re: Matt Hunter · lore

[PATCH v2] init: show absolute path of (re)initialized repository

Since 20e38cba3926 (setup: split up concerns of `init_db()`, 2026-09-10), git-init produces the message:

    Initialized empty Git repository in .git/
instead of the previous
    Initialized empty Git repository in /full/path/to/repo/.git/

Prior to 20e38cba3926, the code producing this message was in function init_db (renamed at the time to create_repository). In that context, the git_dir variable was updated by 'git_dir = repo_get_git_dir(repo);' earlier in the function, to set the value used in printf.

None of the discussion [1] around the original patch indicates that this change was intentional, so address the regression by similarly using repo_get_git_dir in this code's new location.

1: https://lore.kernel.org/git/20260825-pks-odb-write-alternates-at-creation-time-v1-0-911513ba95c3@pks.im/
Signed-off-by: Matt Hunter <m@lfurio.us>
---
 Changes in v2:
    - len type is updated to size_t
    - added a regression test (changed my mind on this)
    - some text is stripped from the patch message
    - Link to v1: https://patch.msgid.link/20261020053932.1274210-1-m@lfurio.us
 builtin/init-db.c | 7 ++++---
 t/t0001-init.sh   | 6 ++++++
 2 files changed, 10 insertions(+), 3 deletions(-)
Show changes to 2 files +10 −3

builtin/init-db.c, t/t0001-init.sh

diff --git a/builtin/init-db.c b/builtin/init-db.c
index 374ed3a74706..9612d2b8bfca 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -248,18 +248,19 @@ int cmd_init_db(int argc,
 	create_object_database(the_repository, NULL);
 
 	if (!quiet) {
-		int len = strlen(git_dir);
+		const char *full_git_dir = repo_get_git_dir(the_repository);
+		size_t len = strlen(full_git_dir);
 
 		if (reinit)
 			printf(repo_settings_get_shared_repository(the_repository)
 			       ? _("Reinitialized existing shared Git repository in %s%s\n")
 			       : _("Reinitialized existing Git repository in %s%s\n"),
-			       git_dir, len && git_dir[len-1] != '/' ? "/" : "");
+			       full_git_dir, len && full_git_dir[len-1] != '/' ? "/" : "");
 		else
 			printf(repo_settings_get_shared_repository(the_repository)
 			       ? _("Initialized empty shared Git repository in %s%s\n")
 			       : _("Initialized empty Git repository in %s%s\n"),
-			       git_dir, len && git_dir[len-1] != '/' ? "/" : "");
+			       full_git_dir, len && full_git_dir[len-1] != '/' ? "/" : "");
 	}
 
 	free(template_dir_to_free);
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index f1d227f27167..fbf8a0e41dad 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -1000,4 +1000,10 @@ test_expect_success 'init honors GIT_OBJECT_DIRECTORY' '
 	test_path_is_dir custom-odb/info
 '
 
+test_expect_success 'init shows absolute path to gitdir' '
+	expect="$(pwd)/init-path" &&
+	git init init-path >actual &&
+	test_grep "$expect" actual
+'
+
 test_done

Range-diff against v1:
1:  c0869122d3fb ! 1:  49d220d97aa8 init: show absolute path of (re)initialized repository
    @@ Commit message
         change was intentional, so address the regression by similarly using
         repo_get_git_dir in this code's new location.
     
    -    In this case, git_dir is referencing owned memory that is later freed,
    -    so declare a new variable to hold the used string.
    -
         1: https://lore.kernel.org/git/20260825-pks-odb-write-alternates-at-creation-time-v1-0-911513ba95c3@pks.im/
     
         Signed-off-by: Matt Hunter <m@lfurio.us>
    @@ builtin/init-db.c: int cmd_init_db(int argc,
      	if (!quiet) {
     -		int len = strlen(git_dir);
     +		const char *full_git_dir = repo_get_git_dir(the_repository);
    -+		int len = strlen(full_git_dir);
    ++		size_t len = strlen(full_git_dir);
      
      		if (reinit)
      			printf(repo_settings_get_shared_repository(the_repository)
    @@ builtin/init-db.c: int cmd_init_db(int argc,
      	}
      
      	free(template_dir_to_free);
    +
    + ## t/t0001-init.sh ##
    +@@ t/t0001-init.sh: test_expect_success 'init honors GIT_OBJECT_DIRECTORY' '
    + 	test_path_is_dir custom-odb/info
    + '
    + 
    ++test_expect_success 'init shows absolute path to gitdir' '
    ++	expect="$(pwd)/init-path" &&
    ++	git init init-path >actual &&
    ++	test_grep "$expect" actual
    ++'
    ++
    + test_done

base-commit: 47fdf2208c5b94c8cc01c106b8f7c85efb91c926
-- 
2.56.0.257.gf7497c7d27
Patrick Steinhardt· Oct 23, 2026, 06:26 UTC · re: Matt Hunter · lore

Re: [PATCH v2] init: show absolute path of (re)initialized repository

On Thu, Oct 22, 2026 at 08:06:32AM -0400, Matt Hunter wrote:
Show 10 quoted lines
> diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> index f1d227f27167..fbf8a0e41dad 100755
> --- a/t/t0001-init.sh
> +++ b/t/t0001-init.sh
> @@ -1000,4 +1000,10 @@ test_expect_success 'init honors GIT_OBJECT_DIRECTORY' '
>  	test_path_is_dir custom-odb/info
>  '
>  
> +test_expect_success 'init shows absolute path to gitdir' '
> +	expect="$(pwd)/init-path" &&
I don't think this extra variable buys us anything, so I'd just drop it.
> +	git init init-path >actual &&
> +	test_grep "$expect" actual
> +'

I would have tested for the whole message, which is short enough to be reasonable, I'd say.

Other than those nits I'm happy, thanks!
Patrick
Matt Hunter· Oct 23, 2026, 12:21 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v2] init: show absolute path of (re)initialized repository

On Fri Oct 23, 2026 at 2:26 AM EDT, Patrick Steinhardt wrote:
Show 13 quoted lines
> On Thu, Oct 22, 2026 at 08:06:32AM -0400, Matt Hunter wrote:
>>  
>> +test_expect_success 'init shows absolute path to gitdir' '
>> +	expect="$(pwd)/init-path" &&
>
> I don't think this extra variable buys us anything, so I'd just drop it.
>
>> +	git init init-path >actual &&
>> +	test_grep "$expect" actual
>> +'
>
> I would have tested for the whole message, which is short enough to be
> reasonable, I'd say.

I considered this. I decided on this simpler version since there are 4 possible messages that could appear at the end of git init. Do we want separate tests/assertions to check all outputs

    "Reinitialized existing shared Git repository in %s%s"
    "Reinitialized existing Git repository in %s%s"
    "Initialized empty shared Git repository in %s%s"
    "Initialized empty Git repository in %s%s"
are as expected?

Furthermore, the final path element is configurable as well, though should just be ".git" in the case of these tests. I figured, since the actual breakage was about the appearance of the path, then I would just test _that aspect_ of the output in this test.

How do we feel about this assertion
    echo "Initialized empty Git repository in $(pwd)/init-path/.git/" >expect
    test_cmp expect actual

which tests the whole message of just the default case? The unnecessary variable you point out above is repurposed into a needed tmp file.

Patrick Steinhardt· Oct 26, 2026, 07:01 UTC · re: Matt Hunter · lore

Re: [PATCH v2] init: show absolute path of (re)initialized repository

On Fri, Oct 23, 2026 at 08:21:11AM -0400, Matt Hunter wrote:
Show 25 quoted lines
> On Fri Oct 23, 2026 at 2:26 AM EDT, Patrick Steinhardt wrote:
> > On Thu, Oct 22, 2026 at 08:06:32AM -0400, Matt Hunter wrote:
> >>  
> >> +test_expect_success 'init shows absolute path to gitdir' '
> >> +	expect="$(pwd)/init-path" &&
> >
> > I don't think this extra variable buys us anything, so I'd just drop it.
> >
> >> +	git init init-path >actual &&
> >> +	test_grep "$expect" actual
> >> +'
> >
> > I would have tested for the whole message, which is short enough to be
> > reasonable, I'd say.
> 
> I considered this.  I decided on this simpler version since there are
> 4 possible messages that could appear at the end of git init.  Do we
> want separate tests/assertions to check all outputs
> 
>     "Reinitialized existing shared Git repository in %s%s"
>     "Reinitialized existing Git repository in %s%s"
>     "Initialized empty shared Git repository in %s%s"
>     "Initialized empty Git repository in %s%s"
> 
> are as expected?
I feel like that'd probably be a bit excessive.
Show 12 quoted lines
> Furthermore, the final path element is configurable as well, though
> should just be ".git" in the case of these tests.  I figured, since the
> actual breakage was about the appearance of the path, then I would just
> test _that aspect_ of the output in this test.
> 
> How do we feel about this assertion
> 
>     echo "Initialized empty Git repository in $(pwd)/init-path/.git/" >expect
>     test_cmp expect actual
> 
> which tests the whole message of just the default case?  The unnecessary
> variable you point out above is repurposed into a needed tmp file.
I'd say that's good enough for now. Thanks!
Patrick
Matt Hunter· Oct 28, 2026, 05:16 UTC · re: Matt Hunter · lore

[PATCH v3] init: show absolute path of (re)initialized repository

Since 20e38cba3926 (setup: split up concerns of `init_db()`, 2026-09-10), git-init produces the message:

    Initialized empty Git repository in .git/
instead of the previous
    Initialized empty Git repository in /full/path/to/repo/.git/

Prior to 20e38cba3926, the code producing this message was in function init_db (renamed at the time to create_repository). In that context, the git_dir variable was updated by 'git_dir = repo_get_git_dir(repo);' earlier in the function, to set the value used in printf.

None of the discussion [1] around the original patch indicates that this change was intentional, so address the regression by similarly using repo_get_git_dir in this code's new location.

1: https://lore.kernel.org/git/20260825-pks-odb-write-alternates-at-creation-time-v1-0-911513ba95c3@pks.im/
Signed-off-by: Matt Hunter <m@lfurio.us>
---
 Changes in v3:
    - expand test to cover the full output of the init command
    - Link to v2: https://patch.msgid.link/20261022120749.3567828-1-m@lfurio.us
 Changes in v2:
    - len type is updated to size_t
    - added a regression test (changed my mind on this)
    - some text is stripped from the patch message
    - Link to v1: https://patch.msgid.link/20261020053932.1274210-1-m@lfurio.us
 builtin/init-db.c | 7 ++++---
 t/t0001-init.sh   | 6 ++++++
 2 files changed, 10 insertions(+), 3 deletions(-)
Show changes to 2 files +10 −3

builtin/init-db.c, t/t0001-init.sh

diff --git a/builtin/init-db.c b/builtin/init-db.c
index 374ed3a74706..9612d2b8bfca 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -248,18 +248,19 @@ int cmd_init_db(int argc,
 	create_object_database(the_repository, NULL);
 
 	if (!quiet) {
-		int len = strlen(git_dir);
+		const char *full_git_dir = repo_get_git_dir(the_repository);
+		size_t len = strlen(full_git_dir);
 
 		if (reinit)
 			printf(repo_settings_get_shared_repository(the_repository)
 			       ? _("Reinitialized existing shared Git repository in %s%s\n")
 			       : _("Reinitialized existing Git repository in %s%s\n"),
-			       git_dir, len && git_dir[len-1] != '/' ? "/" : "");
+			       full_git_dir, len && full_git_dir[len-1] != '/' ? "/" : "");
 		else
 			printf(repo_settings_get_shared_repository(the_repository)
 			       ? _("Initialized empty shared Git repository in %s%s\n")
 			       : _("Initialized empty Git repository in %s%s\n"),
-			       git_dir, len && git_dir[len-1] != '/' ? "/" : "");
+			       full_git_dir, len && full_git_dir[len-1] != '/' ? "/" : "");
 	}
 
 	free(template_dir_to_free);
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index f1d227f27167..5d438dcc2804 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -1000,4 +1000,10 @@ test_expect_success 'init honors GIT_OBJECT_DIRECTORY' '
 	test_path_is_dir custom-odb/info
 '
 
+test_expect_success 'init shows absolute path to gitdir' '
+	echo "Initialized empty Git repository in $(pwd)/init-path/.git/" >expect &&
+	git init init-path >actual &&
+	test_cmp expect actual
+'
+
 test_done

Range-diff against v2:
1:  49d220d97aa8 ! 1:  6c9adee7702b init: show absolute path of (re)initialized repository
    @@ t/t0001-init.sh: test_expect_success 'init honors GIT_OBJECT_DIRECTORY' '
      '
      
     +test_expect_success 'init shows absolute path to gitdir' '
    -+	expect="$(pwd)/init-path" &&
    ++	echo "Initialized empty Git repository in $(pwd)/init-path/.git/" >expect &&
     +	git init init-path >actual &&
    -+	test_grep "$expect" actual
    ++	test_cmp expect actual
     +'
     +
      test_done

base-commit: 47fdf2208c5b94c8cc01c106b8f7c85efb91c926
-- 
2.56.0.333.g9ad7b1359b
Patrick Steinhardt· Oct 28, 2026, 07:03 UTC · re: Matt Hunter · lore

Re: [PATCH v3] init: show absolute path of (re)initialized repository

On Wed, Oct 28, 2026 at 01:16:37AM -0400, Matt Hunter wrote:
>  Changes in v3:
>     - expand test to cover the full output of the init command
>     - Link to v2: https://patch.msgid.link/20261022120749.3567828-1-m@lfurio.us
Thanks, I'm happy with this version.
Patrick
Junio C Hamano· Oct 28, 2026, 15:59 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v3] init: show absolute path of (re)initialized repository

Patrick Steinhardt <ps@pks.im> writes:
Show 8 quoted lines
> On Wed, Oct 28, 2026 at 01:16:37AM -0400, Matt Hunter wrote:
>>  Changes in v3:
>>     - expand test to cover the full output of the init command
>>     - Link to v2: https://patch.msgid.link/20261022120749.3567828-1-m@lfurio.us
>
> Thanks, I'm happy with this version.
>
> Patrick
Thanks.  Marked as ready for 'next'.

← back to recent threads