mbox series

[0/3] Additional variables for git var

Message ID 20230622195059.320593-1-sandals@crustytoothpaste.net (mailing list archive)
Headers show
Series Additional variables for git var | expand

Message

brian m. carlson June 22, 2023, 7:50 p.m. UTC
On many Unix systems, we have a good idea where Git's configuration
files and the shell it uses are located.  However, there are some
systems where that's not the case, such as Windows and with Homebrew,
where the expected files might be found in another location.

Right now, programs who would like to access things like the system
gitattributes or config file have to guess where the distributor of Git
placed these files, and with runtime relocation, it's not even
guaranteed that these will be in a fixed place from invocation to
invocation.  As a result, we need a way to query Git about the location
of these files.

This series introduces five new configuration variables that refer to
the shell path, the system and global gitattributes files, and the
system and global config files.  The global values are not technically
needed, since they should be computable from the environment alone, but
they are added to make life easier for users.

The shell path is especially useful on Windows, where Git usually
provides the POSIX shell, and is designed to make using programs that
interact with Git or Unix-like environment variables (e.g., `EDITOR` and
`VISUAL`) easier.

The gitattributes files are primarily for the benefit of Git LFS, but of
course the goal is to be generally useful.

The curious reviewer may ask, "Why are these in `git var` and not `git
rev-parse`?"  The answer is that these refer to configuration (albeit
partially at compile time), and thus are like the existing GIT_EDITOR,
and unlike what `git rev-parse` produces, which is almost completely
limited to paths and metadata related specifically to a given
repository.

This should be a relatively straightforward series, but of course any
feedback is welcome.

brian m. carlson (3):
  var: add support for listing the shell
  var: add attributes files locations
  var: add config file locations

 Documentation/git-var.txt | 23 +++++++++
 attr.c                    |  6 +--
 attr.h                    |  4 ++
 builtin/var.c             | 99 +++++++++++++++++++++++++++++++++++----
 t/t0007-git-var.sh        | 98 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 219 insertions(+), 11 deletions(-)