git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Git Conditional Includes Question (possible bug?)
@ 2021-01-29 21:21 Colton Hurst
  2021-01-29 22:54 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Colton Hurst @ 2021-01-29 21:21 UTC (permalink / raw)
  To: git

Hello,

I am attempting to use Git conditional includes, but it does not seem to work for me. Can you please help me find out what I’m doing wrong?

[Expectation]
When I run `cd ~/colton/github/coltonhurst.com` (this is a valid git repo) and then run `git config user.email`, I expect ‘colton@coltonhurst.com’ will be returned.

[Actual Result]
When I run `cd ~/colton/github/coltonhurst.com` (this is a valid git repo) and then run `git config user.email`, nothing is returned.

Is this correct behavior? It seems like Git is not recognizing my `.gitconfig` file, and the configuration is not set correctly.

I’m using git version 2.30.0 with on a Mac version 11.1 (Big Sur)
My main shell is: fish, version 3.1.2
I also have tested & have the same issues using: GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20)

To reproduce, I have the two files at the listed locations:

`.gitconfig` at: `~/`, with the following contents:

[user]
	name = Colton Hurst

[includeIf "gitdir:~/colton/github"]
	path = ~/colton/github/.gitconfig

[includeIf "gitdir:~/colton/sourcehut"]
	path = ~/colton/sourcehut/.gitconfig

`.gitconfig` at: `~/colton/github`, with the following contents:

[user]
	name = Colton Hurst
	email = colton@coltonhurst.com

This is the output from `git bugreport`:

[System Info]
git version:
git version 2.30.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Darwin 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec  2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64
compiler info: clang: 12.0.0 (clang-1200.0.32.28)
libc info: no libc information available
$SHELL (typically, interactive shell): /bin/zsh


Thank you for reading,


cdh


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Git Conditional Includes Question (possible bug?)
  2021-01-29 21:21 Git Conditional Includes Question (possible bug?) Colton Hurst
@ 2021-01-29 22:54 ` Junio C Hamano
  2021-01-31  4:23   ` Colton Hurst
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2021-01-29 22:54 UTC (permalink / raw)
  To: Colton Hurst; +Cc: git

Colton Hurst <colton@coltonhurst.com> writes:

> [Expectation] When I run `cd ~/colton/github/coltonhurst.com`
> (this is a valid git repo) and then run `git config user.email`, I
> expect ‘colton@coltonhurst.com’ will be returned.
>
> [Actual Result] When I run `cd ~/colton/github/coltonhurst.com`
> (this is a valid git repo) and then run `git config user.email`,
> nothing is returned.

The relevant part of the per-user config are

> [user]
> 	name = Colton Hurst

This is not conditional, and applies when you are in the repository.

> [includeIf "gitdir:~/colton/github"]
> 	path = ~/colton/github/.gitconfig

This is conditional, and applies when you are in a repository whose
".git" location matches the glob pattern "~/colton/github".  The
location in question is "~/colton/github/coltonhurst.com", which
does not match the pattern, so it would be skipped.

> [includeIf "gitdir:~/colton/sourcehut"]
> 	path = ~/colton/sourcehut/.gitconfig

Likewise.

So, nobody sets user.email in your example.  Isn't it expected that
nothing is returned?

I wonder what happens when the second one is updated to

> [includeIf "gitdir:~/colton/github/"]
> 	path = ~/colton/github/.gitconfig

as "git config --help" says:

 * If the pattern ends with `/`, `**` will be automatically added. For
   example, the pattern `foo/` becomes `foo/**`. In other words, it
   matches "foo" and everything inside, recursively.

and "~/colton/github/**" as a pattern would match the path to the
repository in question.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Git Conditional Includes Question (possible bug?)
  2021-01-29 22:54 ` Junio C Hamano
@ 2021-01-31  4:23   ` Colton Hurst
  0 siblings, 0 replies; 3+ messages in thread
From: Colton Hurst @ 2021-01-31  4:23 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio,

> as "git config --help" says:
> 
> * If the pattern ends with `/`, `**` will be automatically added. For
>   example, the pattern `foo/` becomes `foo/**`. In other words, it
>   matches "foo" and everything inside, recursively.
> 
> and "~/colton/github/**" as a pattern would match the path to the
> repository in question.

That solved the issue. My email was in the subdirectory config files, but not having the `/` at the end of the path ruined it. Thank you so much for the help!

Have a great day and weekend!


Colton

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-31  4:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-29 21:21 Git Conditional Includes Question (possible bug?) Colton Hurst
2021-01-29 22:54 ` Junio C Hamano
2021-01-31  4:23   ` Colton Hurst

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).