Commit Graph

20 Commits

Author SHA1 Message Date
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
brian m. carlson
d9e4683956
fs: expose repository permissions
We have several places in the code base where we have a Filesystem
object but no Configuration object, namely in the transfer queue.  Pass
the repository permissions down into the Filesystem object and expose
them using the same interface as the config object, so we can use either
one as the instance when calling tools.MkdirAll.
2018-12-13 17:51:02 +00:00
Taylor Blau
df3fcefdf1 fs/fs.go: strings.HasPrefix typo
existsAlternate supposes a valid alternate string, and sanitizes it. One
case of this is unquoting a quoted string using strconv.Unquote, which
we trigger if and only if the string begins with a double-quote
character, ".

This function was extracted from a similar-looking function that ignores
comments (i.e., those strings beginning with '#'), so a typo was made
here.

This patch fixes that.
2018-07-16 13:32:54 -05:00
Taylor Blau
7bcfa6d15e fs/fs.go: fix some compilation issues 2018-07-16 10:56:40 -05:00
Taylor Blau
a38b8efd8f fs/fs.go: support alternates from environment variable
The Git documentation also mentions that the
"$GIT_ALTERNATE_OBJECT_DIRECTORIES" environment variable is a valid way
to configure object database remotes [1]:

  2. You could be using the `objects/info/alternates` or
     `$GIT_ALTERNATE_OBJECT_DIRECTORIES` mechanisms to borrow objects
     from other object stores.

Let's support the same by using the last commit, taking in a handle on
the operating-system configuration and using that in addition to the
list found in .git/objects/info/alternates.

[1]: https://git-scm.com/docs/gitrepository-layout#gitrepository-layout-objectsinfoalternates
2018-07-09 11:42:49 -05:00
Taylor Blau
483537ea36 fs/fs.go: extract func existsAlternate()
In a subsequent commit, we will support reading a list of ODB alternates
from the OS environment variable, "$GIT_ALTERNATE_OBJECT_DIRECTORIES".

To prepare for this, let's extract a function that determines whether or
not a given string is suitable as an alternates directory.
2018-07-09 11:42:49 -05:00
Taylor Blau
da8617245c fs: support multiple object alternates
Like in upstream Git, Git LFS supports "object database alternates"
(described in [1]) to link several object databases together.

We have supported this feature since [2] but read the entire
.git/objects/info/alternates in one single buffer via ioutil.ReadFile
and checked if a directory existed at that location.

If a user specified multiple alternates, then this will fail. Git LFS
will look for a directory that has newlines in it, when what it should
be doing is splitting that list by the '\n' character and checking each
directory if it exists.

Let's do that, and also return a []string, instead of a single string,
to indicate that there might be multiple alternates in a repository.

[1]: https://git-scm.com/docs/gitrepository-layout#gitrepository-layout-objectsinfoalternates
[2]: https://github.com/git-lfs/git-lfs/pull/1007/files
2018-07-09 11:14:08 -05:00
Christian Buehlmann
29991a37b2 apply goimports 2018-06-13 16:56:46 +02:00
Christian Buehlmann
00de87a544 add unittests 2018-06-27 00:57:05 +02:00
Christian Buehlmann
030fcb9b92 fix handling of pathnames containing escaped runes 2018-06-25 06:49:53 +02:00
rick olson
739128a3fd lfs: remove LocalMediaPath() 2017-10-25 11:31:15 -06:00
rick olson
cbb0d59fa8 localstorage: move object scanning logic to fs package 2017-10-25 09:49:46 -06:00
rick olson
cdc7946740 replace Readdirnames() with FastWalkGitRepo() 2017-10-25 09:31:50 -06:00
rick olson
10dc9749f4 lfs: move ObjectExistsOfSize to fs package 2017-10-24 19:20:09 -06:00
rick olson
e9121fda74 lfs: move tmp cleanup to fs package 2017-10-24 19:16:14 -06:00
rick olson
1cfb016669 lfs,localstorage: remove TempFile config in favor of fs package 2017-10-24 18:59:36 -06:00
rick olson
737850e5ad fs: create logdir 2017-10-24 16:21:15 -06:00
rick olson
4efd95d2e8 fs: leave git/work dir to config 2017-10-24 15:58:42 -06:00
rick olson
8d1776b70d lfs: kill lfs.LocalReferenceDir in favor of *fs.Filesystem 2017-10-24 15:35:14 -06:00
rick olson
5ff73f36bf config: extract fs package 2017-10-24 15:22:13 -06:00