Commit Graph

13 Commits

Author SHA1 Message Date
Cody Krieger
8a484d0aed
invoke git-config with --includes to ensure it always evaluates include.* directives
Per git-config's man page, include.* directives are not respected by
default when asked to evaluate a specific file (whether via --global,
--file /path/to/.gitconfig, or GIT_CONFIG=/path/to/.gitconfig).

This patch ensures that, if GIT_CONFIG is set in the environment when
e.g. git-lfs-push is invoked, config directives from included files are
evaluated.

This is important if, for example, an included file contains a
url.<foo>.insteadOf directive or lfs.<foo>.locksverify directive that's
shared between many repositories.
2021-03-03 14:26:26 -08:00
brian m. carlson
263b434e97
config: optionally read .lfsconfig from the repository
Currently we only read .lfsconfig from the working tree.  This is better
than nothing, but it means that if there's an LFS file that starts with
a name earlier than .lfsconfig, we won't read the proper config file,
and we won't use any LFS remote URLs that are located in that file.

If the file is missing, let's additionally read from the index, if
there's a working tree, and then from HEAD.  If the repository is bare,
let's just read from HEAD.  This is very similar to what Git does for
.gitmodules.

It does, however, differ in one significant way: Git will read from the
index first if it's doing a checkout, since that might have newer
information.  We don't do that here, since it's not totally clear that
we can articulate all the cases where that occurs in Git LFS, but we
explicitly allow for the possibility of changing the behavior in the
future and document the feature accordingly.

We no longer read the file .lfsconfig from a bare repository, but that
we did this in the first place was very questionable and pretty clearly
a bug, so it's intentional that we no longer do.
2020-08-06 20:04:00 +00:00
Billy Keyes
f953f1eb38 subprocess: trace all command execution
Trace all command execution at the time when the command starts.
Previously, only "simple" execution created trace entries, leading to
mysterious gaps in trace logs where time passed but it looked like
nothing was happening.
2020-07-01 12:13:29 -07:00
Chris Darroch
6e11149a79 add per-worktree configuration option
We add a --worktree option to "git lfs install" and "git lfs
uninstall" and pass it through to "git config", but only when
the Git version is at least 2.20.0, as prior Git versions do
not support the --worktree option.
2020-06-26 14:56:04 -07:00
Chris Darroch
dfb5c7f702 git/config.go: correct comments and reorder funcs
We do some minor housekeeping to correct and clarify comments
which didn't match their find/set/unset functions, and we move
one function so we have a consistent ordering within each type.
2020-06-26 01:57:09 -07:00
brian m. carlson
9a51ea0f46
Pass environment variables into object scanner
We're going to need the environment variables in the object scanner, so
pass the appropriate Environment instance down into the object scanner.
Use an interface to avoid an import loop between the git and config
packages.

Note that the environment is not yet used, but will be in a future
commit.
2019-08-15 17:39:32 +00:00
brian m. carlson
b53c8b27b6
git: provide a read-only configuration object
There are some cases, notably in tests, where we do not want to write to
the filesystem.  In such cases, it's better to return an error and let
each call site determine whether or not that error should be fatal.

Add a NewReadOnlyConfig constructor that works the same way as the
existing constructor, but simply sets a flag to block any writes.  Make
the functions that write to the filesystem go through a wrapper that
checks for read-only status and have them fail.
2018-10-26 15:27:54 +00:00
rick olson
e807aa3192 git: remove static Config, keep Version() static 2017-10-25 20:23:43 -06:00
rick olson
7d003a17c6 git: run 'config' from dir based on *Configuration 2017-10-25 19:46:36 -06:00
rick olson
7b39e24efd git: remove unused arg 2017-10-25 19:20:35 -06:00
rick olson
226d5e4759 git: teach Configuration to run in correct dir 2017-10-25 13:47:13 -06:00
rick olson
46aa268a4f commands: remove git.Config references 2017-10-18 12:52:24 -06:00
rick olson
21988b514d move git config parsing to git pkg 2017-10-18 12:22:45 -06:00