aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format
Commit message (Collapse)AuthorAgeFilesLines
* plumbing: gitignore, Fix loading of ignored .gitignore files.Wouter Horlings2024-06-172-1/+19
| | | | | | | Stop loading .gitignore files from ignored directories, as this can cause files to be included that should not be. See https://git-scm.com/docs/gitignore#_pattern_format
* plumbing: format, Handle case where fs.Join breaks with C: in WindowsPaulo Gomes2024-05-201-1/+10
| | | | Signed-off-by: Paulo Gomes <pjbgf@linux.com>
* plumbing: Add link to index-format docsAlexander Block2024-04-091-0/+2
|
* plumbing: Add tests for unknown extensions, truncated extensions and invalid ↵Alexander Block2024-04-061-0/+102
| | | | hashes
* plumbing: Implement encodeRawExtension that can be used by testsAlexander Block2024-04-061-1/+33
|
* plumbing: Properly support skipping of non-mandatory extensionsAlexander Block2024-04-061-8/+30
| | | | | | | | | Before this, go-git would prematurely bail out of extensions processing when an unknown extension was encountered. This had two issues: 1. It did not account for mandatory (lower case header) extensions 2. It did not properly update the calculated hash, leading to an "invalid checksum" error.
* plumbing: Properly detect EOF when reading index extensionsAlexander Block2024-04-051-34/+36
| | | | | | | | | Before this, go-git was relying on the peeked header to not include a valid 4 char string header. While doing this, it did not differentiate between the errournously read final hash and an unknown extension. This made it impossible to properly skip unknown optional extensions while detecting EOF early enough.
* *: fix some commentsavoidalone2024-03-121-2/+2
| | | | Signed-off-by: avoidalone <wuguangdong@outlook.com>
* plumbing: format/gitattributes, close file in ReadAttributesFilePeter Kurfer2024-02-052-6/+11
| | | | Fixes #1017
* plumbing: handle pktline erro-line as errorsAyman Bagabas2023-11-233-0/+128
| | | | | | | | | | | | | | | Error when encountering an error-line See https://git-scm.com/docs/pack-protocol Update plumbing/format/pktline/error.go Co-authored-by: Paulo Gomes <paulo.gomes.uk@gmail.com> Update plumbing/format/pktline/error.go Co-authored-by: Paulo Gomes <paulo.gomes.uk@gmail.com> feat: format newline
* utils: move trace to utilsAyman Bagabas2023-11-162-2/+2
| | | | | | | Without exposing `trace`, we can't set a target to enable tracing from out of go-git. Fixes: https://github.com/go-git/go-git/pull/916
* plumbing: format/pktline: trace packetsAyman Bagabas2023-11-152-0/+7
|
* plumbing: format/packfile, Refactor patch deltaPaulo Gomes2023-11-062-113/+79
| | | | | | The changes aim to simplify the code and reduce duplication. Signed-off-by: Paulo Gomes <pjbgf@linux.com>
* plumbing: Optimise memory consumption for filesystem storagePaulo Gomes2023-10-282-50/+247
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* plumbing: commitgraph, Add generation v2 supportAndrew Thornton2023-10-126-54/+255
| | | | | | | | This PR adds in support for generation v2 support and a couple of new walkers to match --date-order etc options on log. This PR also fixes a bug in the chain code and adds more tests. Signed-off-by: Andrew Thornton <art27@cantab.net>
* plumbing: commitgraph, fix types and handle commit-graph-chainsAndrew Thornton2023-10-0814-55/+1265
| | | | | | | | | Unfortunately the original variant makes some incorrect typing assumptions about commit-graphs which make handling graph chains difficult to do correctly. This creates a new subpackage and deprecates the old one. It then adds support commit graph chains. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Merge pull request #855 from 0x34d/fuzzingPaulo Gomes2023-10-032-0/+23
|\ | | | | fuzzing : fuzz testing support for oss-fuzz integration
| * fuzzing : fuzz testing support for oss-fuzz integrationArjun Singh2023-10-022-0/+23
| | | | | | | | Signed-off-by: Arjun Singh <ajsinghyadav00@gmail.com>
* | plumbing: commitgraph, allow SHA256 commit-graphsAndrew Thornton2023-09-302-13/+31
|/ | | | | | | | Since the build-tag sha256 was introduced the commit graph code should be switched to use hash.Size and only use a graph if it has the correct hash version for the version of go-git that is built. Signed-off-by: Andrew Thornton <art27@cantab.net>
* *: Handle paths starting with ~usernameArieh Schneier2023-07-091-16/+2
| | | | Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
* plumbing: gitignore, Allow gitconfig to contain a gitignore relative to any ↵Arieh Schneier2023-06-052-11/+57
| | | | | | user home. Fixes #578 Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
* plumbing: gitignore, fix incorrect parsing. Fixes #500Arieh Schneier2023-05-292-6/+40
| | | | Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
* plumbing: gitignore, TypoJleagle2023-05-251-1/+1
| | | Co-authored-by: Paulo Gomes <paulo.gomes.uk@gmail.com>
* plumbing: gitignore, Allow gitconfig to contain a gitignore relative to user ↵Jleagle2023-05-252-0/+47
| | | | home
* *: Add missing error checksPaulo Gomes2023-05-111-7/+17
| | | | | | | | Some areas of the code base were missing error checks, without them it may be harder to troubleshoot unexpected behaviours. Signed-off-by: Paulo Gomes <pjbgf@linux.com>
* *: Remove use of deprecated io/utilPaulo Gomes2023-05-1111-28/+22
| | | | Signed-off-by: Paulo Gomes <pjbgf@linux.com>
* *: Remove redudant err nil checksPaulo Gomes2023-05-112-9/+2
| | | | Signed-off-by: Paulo Gomes <pjbgf@linux.com>
* Merge pull request #707 from pjbgf/experimental-sha256Paulo Gomes2023-04-1110-22/+74
|\ | | | | *: Add support for initializing SHA256 repositories
| * *: Support variable length plumbing.HashPaulo Gomes2023-03-089-22/+21
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * config: Add Repository Format ExtensionPaulo Gomes2023-03-081-0/+53
| | | | | | | | | | | | Relates to the SHA256 implementation, defined in #706. Signed-off-by: Paulo Gomes <pjbgf@linux.com>
* | plumbing: resolve non-external delta referencesZauberNerd2023-03-232-0/+22
|/ | | | | | | | | | | In a self-contained pack file delta references might point to base objects stored later in the file. In this case we need to replace placeholders for external refs with the actual base object and update the children references. Fixes: #484 Co-authored-by: Markus Wolf <mail@markus-wolf.de>
* sha1: Add collision resistent implementationPaulo Gomes2022-11-255-14/+15
| | | | | | | | | | | | | | | | | | | Implement the same SHA1 collision resistent algorithm used by both the Git CLI and libgit2. Only commits with input that match the unavoidable bit conditions will be further processed, which will result in different hashes. Which is the same behaviour experienced in the Git CLI and Libgit2. Users can override the hash algorithm used with: hash.RegisterHash(crypto.SHA1, sha1.New) xref links: https://github.com/libgit2/libgit2/pull/4136/commits/2dfd1294f7a694bfa9e864a9489ae3cb318a5ed0 https://github.com/git/git/commit/28dc98e343ca4eb370a29ceec4c19beac9b5c01e Signed-off-by: Paulo Gomes <pjbgf@linux.com>
* Merge pull request #354 from dowy/issue/#309-clone-branch-with-hash-in-nameMáximo Cuadros2022-11-172-6/+46
|\ | | | | plumbing: config, Branch name with hash can be cloned. Fixes #309
| * plumbing: config, fix broken unit testsAdrian Pronk2021-07-261-3/+13
| |
| * plumbing: config, support correct escaping as per git-config rulesAdrian Pronk2021-07-252-13/+25
| |
| * plumbing: config, remove duplicated character in setAdrian Pronk2021-07-241-1/+1
| |
| * plumbing: config, Branch name with hash can be cloned. Fixes #309Adrian Pronk2021-07-242-1/+19
| |
* | Merge pull request #586 from blmayer/patch-1Miguel Molina2022-11-071-5/+5
|\ \ | | | | | | Fixed some little typos
| * | Fixed some little typosBrian Mayer2022-09-271-5/+5
| | |
* | | Merge pull request #598 from To1ne/toon-fix-gitattr-crashMáximo Cuadros2022-11-072-0/+11
|\ \ \ | | | | | | | | plumbing: gitattributes, Avoid index out of range
| * | | plumbing: gitattributes, Avoid index out of rangeToon Claes2022-10-122-0/+11
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a path is deeper than the single asterisk pattern the code would crash with a "index out of range". This change checks the length of the remaining pattern before it references an element of that slice. With a single trailing asterisk paths deeper than the pattern should not get the attributes. For example with the following `.gitattributes` file: thirdparty/* linguist-vendored This is how git handles it: $ git check-attr --all thirdparty/README.md thirdparty/README.md: diff: markdown thirdparty/README.md: linguist-vendored: set $ git check-attr --all thirdparty/package/README.md thirdparty/package/README.md: diff: markdown
* | | Optimize zlib reader and consolidate sync.poolsPaulo Gomes2022-11-078-117/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Expands on the optimisations from https://github.com/fluxcd/go-git/pull/5 and ensures that zlib reader does not need to recreate a deflate dictionary at every use. The use of sync pools was consolidated into a new sync utils package. name old time/op new time/op delta Parser-16 7.51ms ± 3% 7.71ms ± 6% ~ (p=0.222 n=5+5) name old alloc/op new alloc/op delta Parser-16 4.65MB ± 3% 1.90MB ± 3% -59.06% (p=0.008 n=5+5) name old allocs/op new allocs/op delta Parser-16 3.48k ± 0% 3.32k ± 0% -4.57% (p=0.016 n=5+4) Signed-off-by: Paulo Gomes <pjbgf@linux.com>
* | | Use Sync.Pool pointers to optimise memory usagePaulo Gomes2022-11-074-9/+53
|/ / | | | | | | Signed-off-by: Paulo Gomes <pjbgf@linux.com>
* | Fix typos (#532)Quanyi Ma2022-09-221-2/+2
| |
* | minor grammatical fixesJon Eskin2022-09-221-1/+1
| |
* | remove packfile and align to test fixturespaul.t2022-01-052-3/+2
| |
* | Merge branch 'master' into codecommit-ref-deltapaul.t2021-12-159-53/+70
|\ \
| * \ Merge branch 'go-git:master' into masterPaul T2021-12-1511-65/+100
| |\ \
| | * \ Merge pull request #425 from abhinav/error-stringsMáximo Cuadros2021-12-113-6/+6
| | |\ \ | | | | | | | | | | error strings: Don't capitalize, use periods, or newlines
| | | * | error strings: Don't capitalize, use periods, or newlinesAbhinav Gupta2021-12-043-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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