Commit Graph

14 Commits

Author SHA1 Message Date
brian m. carlson
da4fdef00b
Support SHA-256 repositories
Git will start to support SHA-256 as a hash for repositories in the near
future.  Let's update gitobj to version 2 to support SHA-256
repositories properly.  We initialize the repository based on the
extensions.objectFormat value, if one is provided, since this is the
configuration key that represents the hash algorithm.

Vendor the proper dependencies in place.
2020-07-29 20:53:44 +00:00
brian m. carlson
0588a7da0e
git: add a function to open an object database
We have two places in our code where we use gitobj to open an object
database.  Our calls will soon be more complex since we must account for
hash algorithm options, so move this code into a function that we can
reuse.
2020-07-29 20:53:44 +00:00
brian m. carlson
412f582706
git: pass Git environment to object scanner
Currently, we only need the operating system environment to pass to the
object scanner, but when we start processing SHA-256 repositories, we'll
also need to know about the Git configuration as well to determine the
extensions.objectFormat value (which specifies the hash algorithm).
Let's pass the Git environment, as well as the OS environment, down to
our object scanner.
2020-07-29 20:53:43 +00:00
brian m. carlson
2a3581e1c7
Ensure proper alternate handling with gitobj
There are two ways to specify an alternate in Git: via the repository
file or via the environment. gitobj recently learned how to accept the
contents of an environment variable and use it, so pass the environment
variable when creating a new object database.

When performing a fetch, we don't use the object scanner, but we do when
performing a push. To make sure that we're exercising the object scanner
and gitobj adequately, simulate a push using alternates as well.
2019-08-15 17:39:32 +00: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
27601bb0c0
git: close object database when done
When we're done with the object database, close it, so we in turn close
the pack files and free the file descriptors associated with them.
2019-01-15 18:53:09 +00:00
brian m. carlson
f1a395228a
git: close blob objects when finished
When we read a tree, commit, or tag from gitobj, the object is
automatically closed for us, since these objects are relatively small
and can be read and parsed all in memory.  However, blob objects may be
large, so we return a reader which can be used to read the data from the
object.

In order to properly clean up after ourselves, including closing any
object files which may open, we need to call Close on the blob after
reading it.  Otherwise, we'll eventually run out of file descriptors,
causing us to silently hang.  Restore the reset function that was
removed in e3fcde74 ("git: replace object scanner with one based on
gitobj", 2018-09-05) and ensure we close objects and reset the object
scanner between every call to Scan.
2018-11-20 19:27:05 +00:00
brian m. carlson
e3fcde746a git: replace object scanner with one based on gitobj
Currently, our object scanner is based on calling git cat-file --batch.
This is less efficient than reading the objects ourselves in process, so
update the object scanner to use our gitobj package instead.

Remove the reset function from the object scanner, since it is no longer
used.  Also, since we no longer need to worry about reading too much
data from git cat-file --batch, switch the io.LimitedReader to a plain
io.Reader to simplify the code.

Note that in the tests we now specify the object ID of the pointer item
to scan since we no longer can implicitly read from a fake buffer.
Consequently, we no longer look for a trailing entry, since that won't
succeed anymore.
2018-09-11 18:43:27 +00:00
Lars Schneider
4a686891fa git: use wrapper functions to call Git with Git LFS disabled
The only side effect of this refactoring should be that the Git LFS
is disabled for the Git subprocess. No other functional changes are
intended.
2017-08-21 13:37:48 +02:00
Taylor Blau
76154ea3cb Merge branch 'master' into status-missing-objects 2017-08-08 16:43:03 -06:00
Taylor Blau
c7581be6b0 git/odb: fix closing object database test 2017-07-31 10:45:56 -06:00
Taylor Blau
bfa08115e4 git: use missing object error in ObjectScanner.Scan 2017-07-24 15:08:00 -06:00
Taylor Blau
3d1884edb5 git: teach 'missingErr' type and IsMissingObject() 2017-07-24 15:07:36 -06:00
Taylor Blau
3075284223 git: implement git.ObjectScanner type to read object contents 2017-04-04 14:14:02 -06:00