217 Commits

Author SHA1 Message Date
enverbisevac
479d3e952e git: clone --shared implemented 2023-10-08 00:40:30 +02:00
Savely Krasovsky
939ad4a432 storage: filesystem/dotgit, add support for tmp_objdir prefix 2023-07-20 20:55:07 +03:00
Paulo Gomes
096b3cc16b *: Remove use of deprecated io/util
Signed-off-by: Paulo Gomes <pjbgf@linux.com>
2023-05-11 21:59:37 +01:00
Arieh Schneier
7d183c99d0 storage: filesystem, Populate index before use. Fixes #148
Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
2023-05-04 07:33:19 +10:00
Force Charlie
ca09e555e4 storage: filesystem/dotgit, Improve load packed-refs 2023-04-25 21:51:46 +08:00
Paulo Gomes
d5b1afd3cc Merge pull request #707 from pjbgf/experimental-sha256
*: Add support for initializing SHA256 repositories
2023-04-11 21:00:47 +01:00
Paulo Gomes
9822ad8573 *: Support variable length plumbing.Hash
The variable length for plumbing.Hash is defined at build time, blocked by
tag sha256.

This approach was a trade-off between keeping backwards compatibility while
making progress towards supporting SHA256 with a small amount of changes.

Relates to the SHA256 implementation, defined in #706.

Signed-off-by: Paulo Gomes <pjbgf@linux.com>
2023-03-08 00:14:59 +00:00
Javi Fontan
660071d48c dotgit: fix deleted references test in windows
Signed-off-by: Javi Fontan <jfontan@gmail.com>
2023-03-07 13:33:20 +01:00
Javi Fontan
16cc29310b dotgit: test skip deleted references
Checks that reading references it correctly skips deleted directories
and files.

Signed-off-by: Javi Fontan <jfontan@gmail.com>
2023-03-07 13:33:20 +01:00
Michael Muré
cfec9e38e6 dotgit: fix a filesystem race in Refs/walkReferencesTree
In walkReferencesTree(), the filesystem is browsed recursively. After a folder
is listed, each child element (directory, file) are inspected.

What can happen is that by the time we get to operate on the child element, it
might have been deleted from the filesystem and we would get a PathError.

In the case of directories there was already a case to avoid bubbling up the error
(we consider that there is no ref there, which is correct), but that was missing
for files. This commit just apply the same logic.
2023-01-14 12:52:56 +01:00
Paulo Gomes
123cdde6f2 Use Sync.Pool pointers to optimise memory usage
Signed-off-by: Paulo Gomes <pjbgf@linux.com>
2022-11-07 14:41:07 +00:00
Jon Eskin
af1efaa7df minor grammatical fixes 2022-09-22 10:08:02 +02:00
Máximo Cuadros
f0b111ab70 Merge pull request #425 from abhinav/error-strings
error strings: Don't capitalize, use periods, or newlines
2021-12-11 12:02:17 +01:00
Máximo Cuadros
e60e348f61 Merge pull request #418 from abhinav/unused
Remove unused vars/types/funcs/fields
2021-12-10 06:58:09 +01:00
Abhinav Gupta
1a8f803f55 storage: filesystem, switch from os.SEEK_* to io.Seek* (#421)
The `os.SEEK_*` constants have been deprecated since Go 1.7.
It is now recommended to use the equivalent `io.Seek*` constants.

Switch `os.SEEK_CUR` to `io.SeekCurrent`,
and `os.SEEK_SET` to `io.SeekStart`.
2021-12-10 06:42:38 +01:00
Abhinav Gupta
0dcebfb72b error strings: Don't capitalize, use periods, or newlines
Per [Go Code Review Comments][1],

> Error strings should not be capitalized (unless beginning with proper
> nouns or acronyms) or end with punctuation

staticcheck's [ST1005][2] also complains about these. For example,

```
object_walker.go:63:10: error strings should not be capitalized (ST1005)
object_walker.go:101:10: error strings should not be capitalized (ST1005)
object_walker.go:101:10: error strings should not end with punctuation or a newline (ST1005)
plumbing/format/commitgraph/file.go:17:26: error strings should not be capitalized (ST1005)
```

This fixes all instances of this issue reported by staticcheck.

  [1]: https://github.com/golang/go/wiki/CodeReviewComments#error-strings
  [2]: https://staticcheck.io/docs/checks/#ST1005
2021-12-04 15:40:53 -08:00
Abhinav Gupta
07a8bcc71a Remove unused variables/types/functions
[staticcheck](https://staticcheck.io/) reported a number of unused
fields, functions, types, and variables across the code.

Where possible, use them (assert unchecked errors in tests, for example)
and otherwise remove them.
2021-11-27 16:39:09 -08:00
zeripath
b4368b2a2c plumbing: format/packfile, prevent large objects from being read into memory completely (#330)
This PR adds code to prevent large objects from being read into memory
from packfiles or the filesystem.

Objects greater than 1Mb are now no longer directly stored in the cache
or read completely into memory.

This PR differs and improves the previous broken #323 by fixing several
bugs in the reader and transparently wrapping ReaderAt as a Reader.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-30 10:25:19 +02:00
zeripath
da810275bf Revert "plumbing: format/packfile, prevent large objects from being read into memory completely (#303)" (#329)
This reverts commit 720c192831.
2021-06-02 11:03:28 +02:00
zeripath
720c192831 plumbing: format/packfile, prevent large objects from being read into memory completely (#303)
This PR adds code to prevent large objects from being read into memory from packfiles or the filesystem.

Objects greater than 1Mb are now no longer directly stored in the cache
or read completely into memory.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-12 22:42:07 +02:00
Máximo Cuadros
01df753699 *: use go-billy instead of os calls 2021-05-02 23:40:08 +02:00
David Symonds
e28d9c90aa Support partial hashes in Repository.ResolveRevision.
Like `git rev-parse <prefix>`, this enumerates the hashes of objects
with the given prefix and adds them to the list of candidates for
resolution.

This has an exhaustive slow path, which requires enumerating all objects
and filtering each one, but also a couple of fast paths for common
cases. There's room for future work to make this faster; TODOs have been
left for that.

Fixes #135.
2020-07-16 12:53:37 +10:00
Oleg Kovalov
27a034c764 fix goreportcard warnings 2020-07-01 20:51:24 +02:00
Timofey Kirillov
63c42e530e Support .git/commondir repository layout
Git creates `.git/commondir` when there are custom worktrees (see "git worktree add" related commands).

`.git/commondir` in such case contains a link to another dot-git repository tree, which could contain some folders like:
 - objects;
 - config;
 - refs;
 - etc.

In this PR a new dotgit.RepositoryFilesystem struct is defined, which is billy.Filesystem interface compatible object-wrapper, that can handle commondir and dispatch all operations to the correct file path.

`git.PlainOpen` remain unchanged, but `git.PlainOpenWithOptions` has a new option: `PlainOpenOptions.EnableDotGitCommonDir=true|false` (which is false by default). When `EnableDotGitCommonDir=true` repository-open procedure will read `.git/commondir` (if it exists) and then create dotgit.RepositoryFilesystem object initialized with 2 filesystems. This object then passed into storage and then into dotgit.DotGit as `billy.Filesystem` interface. This object will catch all filesystem operations and dispatch to the correct repository-filesystem (dot-git or common-dot-git) according to the rules described in the doc: https://git-scm.com/docs/gitrepository-layout#Documentation/gitrepository-layout.txt. EnableDotGitCommonDir option will only work with the filesystem-backed storage.

Also worktree_test.go has been adopted from an older, already existing existing PR: https://github.com/src-d/go-git/pull/1098. This PR needs new fixtures added in the following PR: https://github.com/go-git/go-git-fixtures/pull/1.
2020-06-15 17:16:42 +03:00
Máximo Cuadros
8019144b65 Merge pull request #73 from WKBae/close_object
Close Reader & Writer of EncodedObject after use
2020-05-24 19:25:08 +02:00
Máximo Cuadros
26d02b3fec config: ReadConfig and LoadConfig from scopes 2020-05-24 11:22:32 +02:00
Máximo Cuadros
c80979499a Revert "Merge pull request #20 from quorumcontrol/feature/other-configs"
This reverts commit 3127ad9a44, reversing
changes made to 73c52edaad.
2020-05-24 09:15:51 +02:00
Kyungmin Bae
10199949b9 Close Reader & Writer of EncodedObject after use 2020-05-24 02:29:58 +09:00
Kyle Evans
63967abe62 storage/filesystem: dotgit, sanity check provided reference path
On some operating systems, read() of a directory fd may actually succeed and
return garbage resembling on-disk contents. As a result, dotgit may return
successful from readReferenceFile() when it should in-fact not.

This fixes readReferenceFile() on FreeBSD.

Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
2020-04-23 18:19:22 -05:00
Kyle Evans
9c7d576132 storage/filesystem: dotgit, add a test for reading refs from a directory
Specifically, the problem demonstrated is that on some OS (e.g. FreeBSD),
read() on a directory will succeed.  The current implementation will accept
that and return incorrect results, rather than rejecting the directory.
2020-04-23 18:19:08 -05:00
Wes Morgan
786d5f55e9 Fix dotgit tests 2020-04-06 13:58:57 -06:00
Wes Morgan
ecb64c0481 Add Merged config
...for reading and writing global (~/.git/config) and reading system (/etc/gitconfig) configs in addition to local repo config
2020-04-06 10:32:06 -06:00
Máximo Cuadros
9d0f15c4fa ci: based on github actions 2020-03-15 21:18:32 +01:00
Máximo Cuadros
2637279338 *: migration from go-git-fixtures/v4 and go-git/gcfg 2020-03-10 01:41:19 +01:00
Máximo Cuadros
2bdfd91f04 *: migration from gopkg to go modules 2020-03-10 00:40:56 +01:00
Máximo Cuadros
586d45a14f Merge pull request #6 from go-git/pr-1153
storage/filesystem: dotgit, unable to work with .git folder with temporal packfiles
2020-03-10 00:03:43 +01:00
Christian Muehlhaeuser
172a0d8a0e *: added missing error checks in tests
When we assign a value to err, make sure to also check for it being nil
afterwards. If those were intentionally unchecked, we should remove the
assignment in the first place. Those checks certainly never harm, but please
review thoroughly and let me know.

Signed-off-by: Christian Muehlhaeuser <muesli@gmail.com>
(cherry picked from commit 19d6f42a4d814a50bd262fbb69a9b670db9756a2)
2019-07-29 17:32:34 +02:00
Nao YONASHIRO
8beb3ee820 Worktree: improve build index performance. (#1179) 2019-07-25 10:56:22 +02:00
Yuichi Watanabe
5132088617 storage/filesystem: dotgit, Change the order of checking packfile name prefix and suffix. Fixes #1149
Signed-off-by: Yuichi Watanabe <yuichi.watanabe.ja@gmail.com>
2019-05-17 14:25:55 +09:00
Yuichi Watanabe
1da0bac9d6 storage/filesystem: dotgit, Add prefix check to packfile name. Fixes #1149
Signed-off-by: Yuichi Watanabe <yuichi.watanabe.ja@gmail.com>
2019-05-17 14:13:34 +09:00
Yuichi Watanabe
bcaede8471 storage/filesystem: dotgit, Reproduce packfile parse error. Fixes #1149
Signed-off-by: Yuichi Watanabe <yuichi.watanabe.ja@gmail.com>
2019-05-17 13:58:30 +09:00
Máximo Cuadros
eb243ba9a5 Merge pull request #1123 from saracen/object-storage-open-packfile
filesystem: ObjectStorage, MaxOpenDescriptors option
2019-04-23 00:49:04 +02:00
Arran Walker
f5c23dae1f filesystem: ObjectStorage, MaxOpenDescriptors option
The MaxOpenDescriptors option provides a middle ground solution between keeping
all packfiles open (as offered by the KeepDescriptors option) and keeping none
open.

Signed-off-by: Arran Walker <arran.walker@fiveturns.org>
2019-04-22 22:44:21 +00:00
Arran Walker
5598068360 plumbing: format/index perf, buffered reads, reflection removal
Large performance increase by buffering reads.

There were a few instances where binary.Read() would end up using reflection on
&plumbing.Hash, rather than treating it as a byte slice. This has now been
resolved.

Signed-off-by: Arran Walker <arran.walker@fiveturns.org>
2019-04-21 14:38:51 +00:00
Máximo Cuadros
d1b5bceb22 Merge pull request #1006 from mcuadros/transactional-storage
storage: transactional, new storage with transactional capabilities
2019-02-02 13:08:52 +01:00
Javi Fontan
51b01ef90c storage/filesystem: check file object before using cache
If the cache is shared between several repositories getFromUnpacked can
erroneously return an object from other repository.

This decreases performance a little bit as there's an extra fs operation
when the object is in the cache but is correct when the cache is shared.

Signed-off-by: Javi Fontan <jfontan@gmail.com>
2019-01-30 18:58:38 +01:00
Javi Fontan
681855bf2c storage/dotgit: test setRef with a non rwfs
Signed-off-by: Javi Fontan <jfontan@gmail.com>
2018-12-10 23:27:14 +01:00
Javi Fontan
46c0d2e913 storage/dotgit: use fs capabilities in setRef
Do not use tags to check if the filesystem is able to open files
in read/write mode.

Signed-off-by: Javi Fontan <jfontan@gmail.com>
2018-12-10 22:46:45 +01:00
Máximo Cuadros
a2b39f540e storage: new storage.ErrReferenceHasChanged error and test for CheckAndSetReference
Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
2018-12-10 14:46:45 +01:00
Filip Navara
8f52c5099e plumbing: format/packfile, performance optimizations for reading large commit histories (#963)
Signed-off-by: Filip Navara <navara@emclient.com>
2018-11-28 01:29:41 +01:00