git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Document HOME environment variable
@ 2024-12-09 19:18 M Hickford via GitGitGadget
  2024-12-09 23:47 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: M Hickford via GitGitGadget @ 2024-12-09 19:18 UTC (permalink / raw)
  To: git; +Cc: M Hickford, Alejandro Barreto

From: Alejandro Barreto <alejandro.barreto@ni.com>

Git documentation refers to $HOME and $XDG_CONFIG_HOME often, but does
not specify how or where these values come from on Windows where neither
is set by default. The new documentation reflects the behavior of
setup_windows_environment() in compat/mingw.c.

Signed-off-by: Alejandro Barreto <alejandro.barreto@ni.com>
Signed-off-by: M Hickford <mirth.hickford@gmail.com>
---
    Document how $HOME is set on Windows
    
    CC: Alejandro Barreto alejandro.barreto@ni.com, Johannes Schindelin
    johannes.schindelin@gmx.de
    
    Fixes https://github.com/git-for-windows/git/issues/5282

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1834%2Fhickford%2Fhome-docs-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1834/hickford/home-docs-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1834

 Documentation/git.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index d15a8697625..47509c9e1a3 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -477,6 +477,14 @@ their values the same way as Boolean valued configuration variables, e.g.
 
 Here are the variables:
 
+System
+~~~~~~~~~~~~~~~~~~
+`HOME`::
+	Specifies the path to the user's home directory. On Windows, if
+	unset, Git will set a process environment variable equal to:
+	`$HOMEDRIVE$HOMEPATH` if both `$HOMEDRIVE` and `$HOMEPATH` exist;
+	otherwise `$USERPROFILE` if `$USERPROFILE` exists.
+
 The Git Repository
 ~~~~~~~~~~~~~~~~~~
 These environment variables apply to 'all' core Git commands. Nb: it

base-commit: cc01bad4a9f566cf4453c7edd6b433851b0835e2
-- 
gitgitgadget

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

* Re: [PATCH] Document HOME environment variable
  2024-12-09 19:18 [PATCH] Document HOME environment variable M Hickford via GitGitGadget
@ 2024-12-09 23:47 ` Junio C Hamano
  2024-12-10  8:01   ` Johannes Sixt
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2024-12-09 23:47 UTC (permalink / raw)
  To: M Hickford via GitGitGadget; +Cc: git, M Hickford, Alejandro Barreto

"M Hickford via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Alejandro Barreto <alejandro.barreto@ni.com>
>
> Git documentation refers to $HOME and $XDG_CONFIG_HOME often, but does
> not specify how or where these values come from on Windows where neither
> is set by default. The new documentation reflects the behavior of
> setup_windows_environment() in compat/mingw.c.

Makes sense.  As long as the logic to make this fallback is in my
tree (as opposed to being implemented by a set of GfW/minGit add-on
patches), its documentation should also be in my tree.

Will queue.

> +System
> +~~~~~~~~~~~~~~~~~~
> +`HOME`::
> +	Specifies the path to the user's home directory. On Windows, if
> +	unset, Git will set a process environment variable equal to:
> +	`$HOMEDRIVE$HOMEPATH` if both `$HOMEDRIVE` and `$HOMEPATH` exist;
> +	otherwise `$USERPROFILE` if `$USERPROFILE` exists.

I wondered what the reaction by the readers on non-Windows would be,
but hopefully they would read this to mean that HOME will not be
mucked with, even if they leave it unset (or they take it granted
that HOME is set somewhere while they log in and they do not have to
worry about it), so it may be OK.

Just out of curiousity, is Git the only thing that uses $HOME on
Windows?  Or among may other programs on Windows that use $HOME, is
the way Git gives a fall-back value out of these three variables
unusual and deserves documentation?

Thanks.

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

* Re: [PATCH] Document HOME environment variable
  2024-12-09 23:47 ` Junio C Hamano
@ 2024-12-10  8:01   ` Johannes Sixt
  2024-12-10  9:20     ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Sixt @ 2024-12-10  8:01 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, M Hickford, Alejandro Barreto, M Hickford via GitGitGadget

Am 10.12.24 um 00:47 schrieb Junio C Hamano:
> "M Hickford via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
>> From: Alejandro Barreto <alejandro.barreto@ni.com>
>> +System
>> +~~~~~~~~~~~~~~~~~~
>> +`HOME`::
>> +	Specifies the path to the user's home directory. On Windows, if
>> +	unset, Git will set a process environment variable equal to:
>> +	`$HOMEDRIVE$HOMEPATH` if both `$HOMEDRIVE` and `$HOMEPATH` exist;
>> +	otherwise `$USERPROFILE` if `$USERPROFILE` exists.

Makes sense and matches the implementation in compat/mingw.c. GfW uses
the same method with with additional checks for existence of the
$HOMEDRIVE$HOMEPATH combination.

> I wondered what the reaction by the readers on non-Windows would be,
> but hopefully they would read this to mean that HOME will not be
> mucked with, even if they leave it unset (or they take it granted
> that HOME is set somewhere while they log in and they do not have to
> worry about it), so it may be OK.

Since all Windows specific text is in a single sentence, I think it is
difficult to misread. I would leave away the colon, though.

> Just out of curiousity, is Git the only thing that uses $HOME on
> Windows?  Or among may other programs on Windows that use $HOME, is
> the way Git gives a fall-back value out of these three variables
> unusual and deserves documentation?

No Windows native program uses $HOME. Only POSIX-derived tools would
consider doing so. So, I would answer your question: yes, Git is the
"only" one insisting in HOME being set. We are free to choose how we set
it, and the way we do it makes the most sense for Git's purpose. It is
certainly useful to document how we do it.

-- Hannes


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

* Re: [PATCH] Document HOME environment variable
  2024-12-10  8:01   ` Johannes Sixt
@ 2024-12-10  9:20     ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2024-12-10  9:20 UTC (permalink / raw)
  To: Johannes Sixt
  Cc: git, M Hickford, Alejandro Barreto, M Hickford via GitGitGadget

Johannes Sixt <j6t@kdbg.org> writes:

>> Just out of curiousity, is Git the only thing that uses $HOME on
>> Windows?  Or among may other programs on Windows that use $HOME, is
>> the way Git gives a fall-back value out of these three variables
>> unusual and deserves documentation?
>
> No Windows native program uses $HOME. Only POSIX-derived tools would
> consider doing so. So, I would answer your question: yes, Git is the
> "only" one insisting in HOME being set. We are free to choose how we set
> it, and the way we do it makes the most sense for Git's purpose. It is
> certainly useful to document how we do it.

That's perfect.  I've marked the topic for 'next' already.

Thanks, all.



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

end of thread, other threads:[~2024-12-10  9:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-09 19:18 [PATCH] Document HOME environment variable M Hickford via GitGitGadget
2024-12-09 23:47 ` Junio C Hamano
2024-12-10  8:01   ` Johannes Sixt
2024-12-10  9:20     ` Junio C Hamano

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).