Commit Graph

29 Commits

Author SHA1 Message Date
brian m. carlson
f4f8fae03d
commands: canonicalize certain Git environment variables
When we use certain Git environment variables to find the Git directory
and the working tree, we want those values to work regardless of what
directory we're in.  Currently we don't change the working directory,
but we soon will in order to mimic Git's behavior.  In order to make
relative values of these environment variables work correctly once we
change directories, let's turn them into absolute canonical paths when
we set up the repository.

We save the old environment variables into a variable and pass this
variable to the helper for the git lfs env command, which wants to print
the original values, not our modified ones.  Note that we can't make the
canonicalization conditional on the subcommand being run because the
configuration structure has been initialized by the time we get to
argument parsing and the configuration code invokes Git upon
initialization.

Because the Cygwin path canonicalization invokes a subprocess on Windows
and the subprocess code caches the environment, we must also reset the
cache after adjusting these environment variables so that future
subprocess invocations, like those for Git, work as expected with the
updated environment.
2020-10-14 16:49:23 +00:00
Chris Darroch
590881e54c
commands: support git lfs help config invocation
Because "config" is not a command, Cobra returns an error when
the user invokes "git lfs help config" on the command line,
so we just print an error message and the generic usage
instead of returning the same content as one gets from
"man git-lfs-config" for git-lfs-config(5).

This differs from Git's own support for running, for instance,
"git help gitrepository-layout" for gitrepository-layout(5)
or "git help githooks" for githooks(5).

Therefore we specifically check if the supplied argument
to the "help" command is "config" and in that case look up
a dummy argument so we can proceed.
2020-03-10 14:03:40 +00:00
brian m. carlson
a9543e7c89
commands: print help output with --help
If the user invokes "git-lfs --help", we tell them that there's no usage
text found for "--help".  This isn't very helpful.  Since what the user
probably wanted was to invoke the general help output, let's do that by
rewriting the command to "git-lfs", which is the topic for the general
help output.
2020-03-10 14:03:40 +00:00
Stephen Gelman
892907ae1c
Fix cobra help command to work properly with newer version of cobra
This was initially broken upstream in
d6bf4ef243.
They tried to fix it with
ded646f978
but functionality was not actually restored.  This takes the help
command code from
ded646f978
and explicitly sets it as the help command.  On one hand this is a bug
that should arguably be fixed upstream, but on the other hand I believe
this is now the way they intend people to use the `help` functionality.
2019-01-17 21:04:19 +00:00
brian m. carlson
cc815f59e6
Use proper repo permissions when creating directories
Honor the repository permssions set with the umask or
core.sharedRepository when creating directories by using tools.MkdirAll.
Pass an appropriate configuration or filesystem object through as needed
to ensure that we can query the proper permissions. Add a test that
these code paths work by cloning a new repository and then performing
some operations on it.

Note that in the test, we match patterns with either the setgid bit
clear or set, since it may be set or not depending on whether the system
has SysV or BSD group semantics.
2018-12-13 17:51:02 +00:00
Taylor Blau
1c665a3534 commands/run.go: make --version synonymous with version() 2018-05-21 18:19:33 -07:00
Taylor Blau
6eb3d9009c Revert "Merge pull request #2968 from git-lfs/root---version-flag"
This reverts commit 8355d6c24f55212f8fba2dc34ad34b3e0894e2c5, reversing
changes made to 1e995a7b06d6ecac33c227c295b8088261a56b5d.
2018-05-21 18:12:40 -07:00
Taylor Blau
fd5ae09f84
Merge pull request #2969 from git-lfs/exit-on-unknown-subcommand
commands/run.go: exit 127 on unknown sub-command
2018-04-12 16:07:31 -07:00
Taylor Blau
a4dfae7ccd commands/run.go: return 127 from an unknown sub-command 2018-04-12 12:16:24 -07:00
Taylor Blau
3379c0c161 commands/run.go: teach Run() to return an exit code 2018-04-12 12:16:07 -07:00
Taylor Blau
e37c8bb223 commands: make --version a synonym for 'version' 2018-04-12 11:56:48 -07:00
rick olson
b61a4bcb63 localstorage: exit stage left 2017-10-25 13:23:12 -06:00
rick olson
2fc7ad19a9 config: ResolveGitBasicDirs() is unnecessary now 2017-10-24 18:36:16 -06:00
rick olson
b184b1ce4c config: remove Config global 2017-10-24 13:48:51 -06:00
rick olson
af383dc860 config: move ResolveGitBasicDirs() to *Configuration 2017-10-18 18:18:29 -06:00
rick olson
97fc2ed06b remove reliance on global config filesystem vars 2017-10-18 18:09:33 -06:00
rick olson
d16a320363 don't init api client just to close it 2017-09-29 11:46:13 -06:00
Taylor Blau
dd7c145ee4 commands/help: print helptext to stdout for consistency with Git 2017-05-09 09:32:55 -06:00
risk danger olson
2026b10b15 initializing the api client early loads the git config before config.ResolveGitBasicDirs() runs 2017-04-28 09:06:43 -06:00
risk danger olson
e8ae6abda4 deprecate LoggingStats in favor of LogHTTPStats() 2017-04-27 11:37:59 -06:00
risk danger olson
352e491706 stream the http stats writes 2017-04-27 11:37:59 -06:00
risk danger olson
2435a67205 teach the client about HTTPLogger so it can Close it after the cmd exits 2017-04-27 11:37:59 -06:00
risk danger olson
2ef53ba1fe log http responses in order, not by bucket 2017-04-27 11:37:59 -06:00
risk danger olson
c9a03bb3bc commands: remove last httputil usage 2017-01-04 16:10:53 -07:00
risk danger olson
6a8b010381 fix problems running 'install' in a root dir 2016-11-30 13:56:22 -07:00
risk danger olson
bba8f3b876 update package imports 2016-11-15 10:01:18 -07:00
risk danger olson
60639b0271 put all the command stuff in run.go 2016-09-01 10:28:30 -06:00
risk danger olson
a12cdc889f RegisterCommand() can no longer disable commands
the config is available at init(), so isCommandEnabled() checks can be
pulled out of the RegisterCommand() callback, simplifying its signature.
2016-09-01 10:09:38 -06:00
risk danger olson
e8bf1bd033 move the command init to a separate file 2016-09-01 09:21:48 -06:00