aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem
Commit message (Collapse)AuthorAgeFilesLines
* storage: filesystem, Add option to set a specific FS for alternatesPaulo Gomes2023-12-023-53/+178
| | | | | | | | | | | Introduces the option to set a FS for alternates, enabling more flexible cross FS sharing of alternates. If none is set, falls back to the current FS used for the object storage. The changes only process a given path once, and if an alternates dir is not valid, exits with error - aligning behaviour with upstream. Signed-off-by: Paulo Gomes <paulo.gomes@suse.com>
* plumbing: Optimise memory consumption for filesystem storagePaulo Gomes2023-10-281-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, as part of building the index representation, the resolveObject func would create an interim plumbing.MemoryObject, which would then be saved into storage via storage.SetEncodedObject. This meant that objects would be unnecessarily loaded into memory, to then be saved into disk. The changes streamlines this process by: - Introducing the LazyObjectWriter interface which enables the write operation to take places directly against the filesystem-based storage. - Leverage multi-writers to process the input data once, while targeting multiple writers (e.g. hasher and storage). An additional change relates to the caching of object info children within Parser.get. The cache is now skipped when a seekable filesystem is being used. The impact of the changes can be observed when using seekable filesystem storages, especially when cloning large repositories. The stats below were captured by adapting the BenchmarkPlainClone test to clone https://github.com/torvalds/linux.git: pkg: github.com/go-git/go-git/v5 cpu: Intel(R) Core(TM) i9-10885H CPU @ 2.40GHz │ /tmp/old │ /tmp/new │ │ sec/op │ sec/op vs base │ PlainClone-16 41.68 ± 17% 48.04 ± 9% +15.27% (p=0.015 n=6) │ /tmp/old │ /tmp/new │ │ B/op │ B/op vs base │ PlainClone-16 1127.8Mi ± 7% 256.7Mi ± 50% -77.23% (p=0.002 n=6) │ /tmp/old │ /tmp/new │ │ allocs/op │ allocs/op vs base │ PlainClone-16 3.125M ± 0% 3.800M ± 0% +21.60% (p=0.002 n=6) Notice that on average the memory consumption per operation is over 75% smaller. The time per operation increased by 15%, which may actual be less on long running applications, due to the decreased GC pressure and the garbage collection costs. Signed-off-by: Paulo Gomes <pjbgf@linux.com>
* git: clone --shared implementedenverbisevac2023-10-082-1/+36
|
* storage: filesystem/dotgit, add support for tmp_objdir prefixSavely Krasovsky2023-07-202-3/+26
|
* *: Remove use of deprecated io/utilPaulo Gomes2023-05-113-8/+5
| | | | Signed-off-by: Paulo Gomes <pjbgf@linux.com>
* storage: filesystem, Populate index before use. Fixes #148Arieh Schneier2023-05-042-0/+25
| | | | Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
* storage: filesystem/dotgit, Improve load packed-refsForce Charlie2023-04-251-42/+38
|
* Merge pull request #707 from pjbgf/experimental-sha256Paulo Gomes2023-04-112-7/+10
|\ | | | | *: Add support for initializing SHA256 repositories
| * *: Support variable length plumbing.HashPaulo Gomes2023-03-082-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | dotgit: fix deleted references test in windowsJavi Fontan2023-03-071-2/+3
| | | | | | | | Signed-off-by: Javi Fontan <jfontan@gmail.com>
* | dotgit: test skip deleted referencesJavi Fontan2023-03-071-0/+67
| | | | | | | | | | | | | | Checks that reading references it correctly skips deleted directories and files. Signed-off-by: Javi Fontan <jfontan@gmail.com>
* | dotgit: fix a filesystem race in Refs/walkReferencesTreeMichael Muré2023-01-141-0/+5
|/ | | | | | | | | | | | 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.
* Use Sync.Pool pointers to optimise memory usagePaulo Gomes2022-11-071-1/+13
| | | | Signed-off-by: Paulo Gomes <pjbgf@linux.com>
* minor grammatical fixesJon Eskin2022-09-221-1/+1
|
* Merge pull request #425 from abhinav/error-stringsMáximo Cuadros2021-12-111-1/+1
|\ | | | | error strings: Don't capitalize, use periods, or newlines
| * error strings: Don't capitalize, use periods, or newlinesAbhinav Gupta2021-12-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge pull request #418 from abhinav/unusedMáximo Cuadros2021-12-102-2/+2
|\ \ | | | | | | Remove unused vars/types/funcs/fields
| * | Remove unused variables/types/functionsAbhinav Gupta2021-11-272-2/+2
| |/ | | | | | | | | | | | | | | [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.
* / storage: filesystem, switch from os.SEEK_* to io.Seek* (#421)Abhinav Gupta2021-12-102-5/+6
|/ | | | | | | 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`.
* plumbing: format/packfile, prevent large objects from being read into memory ↵zeripath2021-06-304-10/+156
| | | | | | | | | | | | | | | 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>
* Revert "plumbing: format/packfile, prevent large objects from being read ↵v5.4.2zeripath2021-06-022-87/+1
| | | | | into memory completely (#303)" (#329) This reverts commit 720c192831a890d0a36b4c6720b60411fa4a0159.
* plumbing: format/packfile, prevent large objects from being read into memory ↵v5.4.0zeripath2021-05-122-1/+87
| | | | | | | | | | | 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>
* *: use go-billy instead of os callsMáximo Cuadros2021-05-026-114/+93
|
* Support partial hashes in Repository.ResolveRevision.David Symonds2020-07-164-3/+157
| | | | | | | | | | | | | 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.
* fix goreportcard warningsOleg Kovalov2020-07-012-3/+3
|
* Support `.git/commondir` repository layoutTimofey Kirillov2020-06-153-0/+241
| | | | | | | | | | | | | | | | 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.
* Merge pull request #73 from WKBae/close_objectv5.1.0Máximo Cuadros2020-05-241-0/+2
|\ | | | | Close Reader & Writer of EncodedObject after use
| * Close Reader & Writer of EncodedObject after useKyungmin Bae2020-05-241-0/+2
| |
* | config: ReadConfig and LoadConfig from scopesMáximo Cuadros2020-05-241-15/+2
| |
* | Revert "Merge pull request #20 from quorumcontrol/feature/other-configs"Máximo Cuadros2020-05-243-86/+22
|/ | | | | This reverts commit 3127ad9a44a2ee935502816065dfe39f494f583d, reversing changes made to 73c52edaad2dae256be61bd1dbbab08e1092f58e.
* storage/filesystem: dotgit, sanity check provided reference pathKyle Evans2020-04-232-1/+12
| | | | | | | | | | 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>
* storage/filesystem: dotgit, add a test for reading refs from a directoryKyle Evans2020-04-231-1/+13
| | | | | | 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.
* Fix dotgit testsWes Morgan2020-04-061-3/+3
|
* Add Merged configWes Morgan2020-04-062-19/+83
| | | | ...for reading and writing global (~/.git/config) and reading system (/etc/gitconfig) configs in addition to local repo config
* ci: based on github actionsv5.0.0Máximo Cuadros2020-03-151-15/+3
|
* *: migration from go-git-fixtures/v4 and go-git/gcfgMáximo Cuadros2020-03-105-25/+11
|
* *: migration from gopkg to go modulesMáximo Cuadros2020-03-1017-62/+62
|
* Merge pull request #6 from go-git/pr-1153Máximo Cuadros2020-03-102-4/+10
|\ | | | | storage/filesystem: dotgit, unable to work with .git folder with temporal packfiles
| * storage/filesystem: dotgit, Change the order of checking packfile name ↵Yuichi Watanabe2019-05-171-1/+1
| | | | | | | | | | | | prefix and suffix. Fixes #1149 Signed-off-by: Yuichi Watanabe <yuichi.watanabe.ja@gmail.com>
| * storage/filesystem: dotgit, Add prefix check to packfile name. Fixes #1149Yuichi Watanabe2019-05-171-4/+5
| | | | | | | | Signed-off-by: Yuichi Watanabe <yuichi.watanabe.ja@gmail.com>
| * storage/filesystem: dotgit, Reproduce packfile parse error. Fixes #1149Yuichi Watanabe2019-05-171-0/+5
| | | | | | | | Signed-off-by: Yuichi Watanabe <yuichi.watanabe.ja@gmail.com>
* | *: added missing error checks in testsChristian Muehlhaeuser2019-07-291-0/+1
| | | | | | | | | | | | | | | | | | | | 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)
* | Worktree: improve build index performance. (#1179)Nao YONASHIRO2019-07-251-1/+7
|/
* Merge pull request #1123 from saracen/object-storage-open-packfileMáximo Cuadros2019-04-234-49/+138
|\ | | | | filesystem: ObjectStorage, MaxOpenDescriptors option
| * filesystem: ObjectStorage, MaxOpenDescriptors optionArran Walker2019-04-224-49/+138
| | | | | | | | | | | | | | | | 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>
* | plumbing: format/index perf, buffered reads, reflection removalArran Walker2019-04-211-1/+2
|/ | | | | | | | | | 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>
* Merge pull request #1006 from mcuadros/transactional-storageMáximo Cuadros2019-02-021-1/+2
|\ | | | | storage: transactional, new storage with transactional capabilities
| * storage: new storage.ErrReferenceHasChanged error and test for ↵Máximo Cuadros2018-12-101-1/+2
| | | | | | | | | | | | CheckAndSetReference Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
* | storage/filesystem: check file object before using cacheJavi Fontan2019-01-302-5/+21
| | | | | | | | | | | | | | | | | | | | 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>
* | storage/dotgit: test setRef with a non rwfsJavi Fontan2018-12-101-1/+24
| | | | | | | | Signed-off-by: Javi Fontan <jfontan@gmail.com>