71 Commits

Author SHA1 Message Date
nodivbyzero
c67eceb3c2 git: worktree:: apply ProxyOption on Pull. Fixes #840 2023-09-15 07:45:22 -07:00
Stephan
753b0d5cef git: worktree, reset ignored files that are part of the worktree: Fixes #819 2023-09-04 08:13:33 +02: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
Ayman Bagabas
3aa7575a4d fix: git grep bare repositories
Perform grep on `*Repository` instead of `*Worktree`.

Fixes: https://github.com/go-git/go-git/issues/68
2023-04-26 09:07:37 -04:00
mbohy
f848aaf02a git: worktree: check for empty parent dirs during Reset (Fixes #670) (#671)
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).
2023-01-28 20:42:46 +01:00
Paulo Gomes
9490da0f86 Optimize zlib reader and consolidate sync.pools
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>
2022-11-07 14:49:56 +00: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
John Cai
f92011d95f simplified sparse checkout
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.
2021-11-09 08:45:09 -05:00
Norwin
5e64929185 Add RemoteURL to {Fetch,Pull,Push}Options
Can be used to override the URL to operate on:
RemoteName will be ignored for the actual fetch
2021-09-15 15:34:17 +02:00
Jeff Widman
f464d193a2 Minor doc fixes (#287) 2021-04-16 11:49:08 +02:00
hansmi
024d62b96a worktree: Don't remove root directory when cleaning (#230)
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>
2021-01-27 10:49:40 +01:00
Daishan Peng
1b1a61ad07 Add insecureSkipTLS and cabundle (#228)
This PR add insecureSkipTLSVerify and cabundle to any remote http calls
so that https repo with private CA signed can be used. This is the
equivalent of https.sslVerify and GIT_SSL_CAINFO
2021-01-27 10:48:41 +01:00
Axel Christ
81d429bc0f Fix relative submodule resolution
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).
2020-10-28 17:05:05 +01:00
Mitsutaka Naito
e0bd4e88b6 git: worktree, Support relative submodule URL. 2020-10-13 09:54:44 +09:00
Oleg Kovalov
27a034c764 fix goreportcard warnings 2020-07-01 20:51:24 +02:00
Mathias Rüdiger
23e21f0cfc Report "Already up to date" when local repository ahead of remote
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.
2020-06-22 09:09:19 +02:00
Máximo Cuadros
2bdfd91f04 *: migration from gopkg to go modules 2020-03-10 00:40:56 +01:00
Nao YONASHIRO
8beb3ee820 Worktree: improve build index performance. (#1179) 2019-07-25 10:56:22 +02:00
noonehereplzgo
4b689826bf use constant instead of literal string
Signed-off-by: Mohammad Kefah <mo@edraj.io>
2019-06-11 02:41:16 +03:00
Linuxer Wang
d1e34a7675 Keep local changes when checkout branch in worktree.
Signed-off-by: Linuxer Wang <linuxerwang@gmail.com>
2019-05-15 23:02:27 -07:00
Tobias Meinhardt
aad49a3a24 git: remove potentially duplicate check for unstaged files
Signed-off-by: Tobias Meinhardt <tobias.meinhardt89@gmail.com>
2019-03-05 22:54:14 +01:00
Alexey Smirnov
cf6cf0d4b7 worktree: add sentinel error for non-fast-forward pull
Signed-off-by: Alexey Smirnov <unlinkat@gmail.com>
2019-02-07 14:48:32 +05:00
kuba--
75fa41d21c Add Status.IsUntracked function
Signed-off-by: kuba-- <kuba@sourced.tech>
2018-08-29 14:56:25 +02:00
kuba--
0167dabb78 Remove empty dirs when cleaning with Dir opt.
Signed-off-by: kuba-- <kuba@sourced.tech>
2018-08-29 14:38:33 +02:00
Joseph Vusich
d87faeca21 worktree: Don't allow .gitmodules to be a symlink. Fixes CVE-2018-11235
References:
 * https://blogs.msdn.microsoft.com/devops/2018/05/29/announcing-the-may-2018-git-security-vulnerability/
 * https://security-tracker.debian.org/tracker/CVE-2018-11235
 * 10ecfa7649

Signed-off-by: Joseph Vusich <jvusich@amazon.com>
2018-05-30 17:42:15 +00:00
Alan D. Cabrera
e63b032e91 Worktree: Provide ability to add excludes (#825)
Worktree: Provide ability to add excludes
2018-05-11 06:47:25 +02:00
Felix Kollmann
4915f5834d Added support for non-symlink checkouts on Windows when elevated rights are missing
This implementation mimicks the behavior of Git on Windows
Signed-off-by: Felix Kollmann <mail@fkollmann.de>
2018-03-12 15:03:36 +01:00
Daniel Martí
ede92fa7ff all: remove some unused code
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2018-03-01 17:12:58 +00:00
Sunny
4ead334dbd git: Worktree.Grep() support multiple patterns and pathspecs
Signed-off-by: Sunny <me@darkowlzz.space>
2017-12-20 00:32:59 +05:30
Sunny
757a26038e git: worktree, add Grep() method for git grep (#686)
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.
2017-12-12 09:26:08 +01:00
Sunny
e7b02be89f git: worktree, add Clean() method for git clean
This change implement git clean with a `Dir` option. By default, clean
removes only the untracked files in the working directory. If `Dir`
option is set to true, untracked files under other directories are also
cleaned.
2017-12-04 19:10:16 +05:30
Nick Thomas
702718fd59 Support non-force fetches 2017-11-27 11:38:14 -08:00
Máximo Cuadros
caa4dc4729 update to go-billy.v4 and go-git-fixtures.v3
Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
2017-11-23 07:19:39 +01:00
Benjamin Nørgaard
0389a6dd0a Fix spelling Unstagged -> Unstaged 2017-10-08 22:28:20 +02:00
Máximo Cuadros
f1e58e0d30 Worktree.Reset ignore untracked files on Merge mode 2017-09-01 17:26:52 +02:00
Máximo Cuadros
902347aef9 Merge pull request #531 from mcuadros/ref-name
plumbing: moved `Reference.Is*` methods to `ReferenceName.Is*`
2017-08-02 13:42:19 +02:00
Máximo Cuadros
ab65565003 *: use the new API for ReferenceName.Is* methods 2017-08-02 13:13:46 +02:00
Devon Barrett
63b30fba57 reuse Auth method when recursing submodules, fixes #521 2017-07-29 13:12:57 +01:00
Máximo Cuadros
c2561364e3 Merge pull request #513 from mcuadros/worktree-fs
worktree: expose underlying filesystem
2017-07-27 09:30:04 +02:00
Máximo Cuadros
ab590eb898 worktree: expose underlying filesystem 2017-07-26 21:46:49 +02:00
Máximo Cuadros
b0f131a48c remote: pull refactor to match default behaviour 2017-07-26 16:19:06 +02:00
Máximo Cuadros
064051f972 *: package context support in Repository, Remote and Submodule 2017-07-26 06:24:47 +02:00
Máximo Cuadros
460a7278e6 move Repository.Pull to Worktree.Pull 2017-07-24 13:34:40 +02:00
Máximo Cuadros
8738a04708 Merge pull request #493 from src-d/windows
*: several windows support fixes
2017-07-19 22:04:46 +02:00
Máximo Cuadros
e92973bea8 worktree: submodules, missing err validation on load config 2017-07-19 00:34:44 +02:00
Máximo Cuadros
07305b25d9 worktree: close .gitmodule files 2017-07-19 00:22:47 +02:00
Máximo Cuadros
9afc47237c worktree: checkout, create branch 2017-07-18 21:41:34 +02:00
Máximo Cuadros
ad7432333d worktree: fix ioutil import path 2017-06-19 12:33:27 +02:00
Máximo Cuadros
ada10c2978 worktree: support for symlinks 2017-06-19 10:36:37 +02:00
Máximo Cuadros
abb9ec0f3e *: upgrade to go-billy.v3, merge 2017-06-18 12:15:40 +02:00