aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_test.go
Commit message (Collapse)AuthorAgeFilesLines
* git: worktree, Align validation with upstream rulesPaulo Gomes2023-12-081-0/+75
| | | | | | | | Some worktree validation rules observed upstream are not checked by go-git, leading to scenarios in which what seems to be a valid repository for go-git is not necessarily the case for the git cli. Signed-off-by: Paulo Gomes <paulo.gomes@suse.com>
* storage: filesystem, Add option to set a specific FS for alternatesPaulo Gomes2023-12-021-11/+20
| | | | | | | | | | | 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>
* Merge pull request #939 from dhoizner/fix-pull-after-shallowPaulo Gomes2023-12-011-0/+36
|\ | | | | git: stop iterating at oldest shallow when pulling. Fixes #305
| * git: stop iterating at oldest shallow when pulling. Fixes #305Dan Hoizner2023-11-271-0/+36
| |
* | git: validate reference namesAyman Bagabas2023-11-301-0/+24
|/ | | | | | | | | | Check reference names format before creating branches/tags/remotes. This should probably be in a lower level somewhere in `plumbing`. Validating the names under `plumbing.NewReference*` is not possible since these functions don't return errors. Fixes: https://github.com/go-git/go-git/issues/929
* plumbing: fix empty uploadpack request errorAyman Bagabas2023-11-161-0/+14
| | | | | | | | | | If we have all what we asked for, finish the session and handle error. This is equivalent of git "Already up to date." message. Fixes: https://github.com/go-git/go-git/issues/328 Fixes: https://github.com/go-git/go-git/issues/638 Fixes: https://github.com/go-git/go-git/issues/157
* *: fix some typosZhizhen He2023-09-081-1/+1
| | | | Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
* git: worktree, reset ignored files that are part of the worktree: Fixes #819Stephan2023-09-041-2/+50
|
* worktree: minor speedup for doAddDirectoryThinkChaos2023-05-301-0/+90
|
* *: Remove use of deprecated io/utilPaulo Gomes2023-05-111-6/+5
| | | | Signed-off-by: Paulo Gomes <pjbgf@linux.com>
* Merge pull request #719 from cbbm142/masterPaulo Gomes2023-05-031-0/+45
|\ | | | | git: worktree, add check to see if file already checked in. Fixes #718
| * Worktree: Status, add check to see if file already checked in [Fixes 718]John Pastore2023-05-011-0/+45
| | | | | | | | Checks if an ignored file was previously checked in. If it was, then the file is not ignored matching native git behavior.
* | fix: git grep bare repositoriesAyman Bagabas2023-04-261-0/+81
|/ | | | | | Perform grep on `*Repository` instead of `*Worktree`. Fixes: https://github.com/go-git/go-git/issues/68
* tests: Avoid use of user's GPG keys during testsPaulo Gomes2023-03-051-1/+1
| | | | | | | | | | | | | The TestPullAdd test uses git CLI to perform a commit. Contributors with signing enabled globally would have their GPG configuration being used to sign that test commit. This behaviour was transparent for contributors that do not use secure keys which requires physical confirmation. The new behaviour disables GPG signing for that test, which was not required as part of the test. Signed-off-by: Paulo Gomes <pjbgf@linux.com>
* git: worktree: check for empty parent dirs during Reset (Fixes #670) (#671)mbohy2023-01-281-0/+51
| | | | | | | | | | When we delete dir1/dir2/file1, we currently check if dir2 becomes empty with the deletion of file1, and if so, we delete dir2. If dir1 becomes empty with the deletion of dir2, we don't notice that, and dir1 is left behind. This commit adds a loop to check each parent directory in the file path for emptiness, removing empty directories along the way until a non-empty directory is found (or an error occurs).
* Worktree: Add, fix add removed files. Fixes #223 (#652)v5.5.2Taketoshi Fujiwara2023-01-051-0/+45
|
* Return error instead of creating empty commitsPaulo Gomes2022-12-031-3/+33
| | | | | | | | | | | | | | | | | | | | BuildTree now returns an ErrEmptyCommit error, when there are no changes to be committed. This can be opted-out via CommitOptions.AllowEmptyCommits. This is a breaking change which enables applications to detect when empty commits are to be created. Some instances in which this can occur is when the fs (e.g. `billy/osfs`) make changes to the underlying files, causing a conflict between what the previous Git worktree state was, and the current state. Changes to the fs implementations are orthogonal to this, and will be dealt with separately. The new behaviour aligns with the Git CLI, in which empty commits returns the error message: 'nothing to commit, working tree clean'. Signed-off-by: Paulo Gomes <pjbgf@linux.com>
* Merge pull request #418 from abhinav/unusedMáximo Cuadros2021-12-101-1/+2
|\ | | | | Remove unused vars/types/funcs/fields
| * Remove unused variables/types/functionsAbhinav Gupta2021-11-271-1/+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.
* | simplified sparse checkoutJohn Cai2021-11-091-0/+32
|/ | | | | | | | | This is the initial logic to support a simple sparse checkout where directories to be included can be specified in CheckoutOptions. This change doesn't fully support the sparse patterns, nor does this change include the optimization to collapse flie entries in ithe index that are excluded via the sparse checkout directory patterns included under the parent directory.
* *: use go-billy instead of os callsMáximo Cuadros2021-05-021-34/+40
|
* worktree: Don't remove root directory when cleaning (#230)hansmi2021-01-271-0/+32
| | | | | | | When using a separate worktree directory while working on a bare repository, cleaning with CleanOptions{Dir: true} would also remove the root worktree directory if empty. Signed-off-by: Michael Hanselmann <public@hansmi.ch>
* Fix relative submodule resolutionAxel Christ2020-10-281-4/+19
| | | | | | | | | | | | | | | | | With the current behavior, the config will always hold the resolved, absolute URL, leavin the user of go-git no choice to determine whether the original URL is relative or not. This changes to employ relative URL resolution only when resolving a submodule to a repository to keep the correct configuration 'unresolved' and intact. Change relative resolution using `filepath.Dir` to `path.Join` while parsing both the 'root' and the relative URL with `net/url.URL`. Adapt test to verify the new behavior. Re-fixes #184 (see comments).
* git: worktree, Support relative submodule URL.Mitsutaka Naito2020-10-131-1/+43
|
* Report "Already up to date" when local repository ahead of remoteMathias Rüdiger2020-06-221-0/+20
| | | | | | | If you run 'git pull', do a commit and run 'git pull' again git will report "Already up to date" whereas go-git would report a reports non-fast-forward update. This commit changes the behavior of go-git to match that of git.
* Support `.git/commondir` repository layoutTimofey Kirillov2020-06-151-0/+75
| | | | | | | | | | | | | | | | 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.
* Worktree.AddWithOptions: improve documentation and interfaceMáximo Cuadros2020-06-141-2/+2
|
* feat: add file with using .gitignore, fixed src-d/go-git#1219jk2k2020-06-101-0/+46
|
* Worktree: revert url change on testMáximo Cuadros2020-03-161-1/+1
|
* ci: based on github actionsv5.0.0Máximo Cuadros2020-03-151-2/+2
|
* *: migration from go-git-fixtures/v4 and go-git/gcfgMáximo Cuadros2020-03-101-1/+1
|
* *: migration from gopkg to go modulesMáximo Cuadros2020-03-101-11/+11
|
* *: avoid unnecessary conversionsChristian Muehlhaeuser2019-07-291-1/+1
| | | | | | | No need to convert these values, they're already of the right type. Signed-off-by: Christian Muehlhaeuser <muesli@gmail.com> (cherry picked from commit a1d8a7ac8bd0e4aff0f27dbb8bb37b8bd13a1346)
* *: 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)
* Keep local changes when checkout branch in worktree.Linuxer Wang2019-05-151-0/+40
| | | | Signed-off-by: Linuxer Wang <linuxerwang@gmail.com>
* worktree: test hardcoded excludes when no gitignore is presentFabian Sabau2019-03-041-0/+28
| | | | Signed-off-by: Fabian Sabau <fabian.sabau+git@gmail.com>
* Merge pull request #1065 from vmarkovtsev/fix-unicodev4.10.0Máximo Cuadros2019-02-141-4/+31
|\ | | | | Remove Unicode normalization in difftree
| * Remove Unicode normalization in difftreeVadim Markovtsev2019-02-111-4/+31
| | | | | | | | | | | | Fixes #1057 Signed-off-by: Vadim Markovtsev <vadim@sourced.tech>
* | worktree: add sentinel error for non-fast-forward pullAlexey Smirnov2019-02-071-1/+1
|/ | | | Signed-off-by: Alexey Smirnov <unlinkat@gmail.com>
* Remove empty dirs when cleaning with Dir opt.kuba--2018-08-291-0/+9
| | | | Signed-off-by: kuba-- <kuba@sourced.tech>
* Worktree: Provide ability to add excludes (#825)Alan D. Cabrera2018-05-111-0/+30
| | | Worktree: Provide ability to add excludes
* git: worktree, Skip special git directory. Fixes #814kuba--2018-04-181-0/+38
| | | | Signed-off-by: kuba-- <kuba@sourced.tech>
* *: skip time consuming testsMáximo Cuadros2018-03-211-0/+9
| | | | Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
* new methods Worktree.[AddGlob|RemoveBlob] and recursive Worktree.[Add|Remove]Máximo Cuadros2018-02-261-14/+125
| | | | Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
* new methods Worktree.[AddGlob|AddDirectory]Máximo Cuadros2018-02-011-0/+160
| | | | Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
* Merge pull request #695 from darkowlzz/grep-multiple-patterns-pathspecMáximo Cuadros2017-12-201-8/+59
|\ | | | | git: Worktree.Grep() support multiple patterns and pathspecs
| * git: Worktree.Grep() support multiple patterns and pathspecsSunny2017-12-201-8/+59
| | | | | | | | Signed-off-by: Sunny <me@darkowlzz.space>
* | *: simplicationferhat elmas2017-12-181-2/+2
|/ | | | | | - no unnecessary err/bool check, uses them directly Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
* git: worktree, add Grep() method for git grep (#686)Sunny2017-12-121-0/+185
| | | This change implemented grep on worktree with options to invert match and specify pathspec. Also, a commit hash or reference can be used to specify the worktree to search.
* storage: filesystem, add support for git alternates (#663)Sunny2017-12-061-0/+30
| | | | This change adds a new method Alternates() in DotGit to check and query alternate source.