162 Commits

Author SHA1 Message Date
Zhizhen He
32975ee2c7 *: fix some typos
Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
2023-09-08 09:30:43 +08:00
Paulo Gomes
abe49196b8 plumbing: http, Fix empty repos on Git v2.41+
Git v2.41.0 comes with [changes](933e3a4ee2)
that breaks go-git's assumptions for when detecting empty repositories.

Go-git expects a flush instead of the first hash line. Instead, a dummy capabilities^{}
with zero-id is returned. The change aims to allow for identifying
the object format even when cloning empty
repositories.

Signed-off-by: Paulo Gomes <pjbgf@linux.com>
2023-07-01 15:37:24 +01:00
Paulo Gomes
044ba2fc8e Merge pull request #763 from AriehSchneier/dont-add-want-if-have
git: don't add to wants if exists, shallow and depth 1
2023-05-29 14:48:32 +01:00
Arieh Schneier
2dfdcb9985 git: don't add to wants if exists, shallow and depth 1
Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
2023-05-25 09:18:07 +10:00
Arieh Schneier
65a5c71635 git: enable fetch with unqualified references
Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
2023-05-25 08:56:17 +10:00
Arieh Schneier
cdba5330cd git: Fix fetching after shallow clone. Fixes #305
Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
2023-05-24 15:17:02 +10:00
Paulo Gomes
ce08ae04c6 Merge pull request #753 from andrewpollock/add_list_timeout
git: remote, add support for a configurable timeout.
2023-05-20 21:36:18 +01:00
Andrew Pollock
f47bb2d633 git: remote, add support for a configurable timeout.
The previous hard-coded 10 second value is too short for listing large
repositories like https://gitlab.com/gitlab-org/gitlab

Return an error on nonsensical subzero timeout values
2023-05-12 10:32:08 +10:00
Paulo Gomes
9dfaf6acd8 *: Remove redudant err nil checks
Signed-off-by: Paulo Gomes <pjbgf@linux.com>
2023-05-11 21:34:07 +01:00
Sanskar Jaiswal
c2a93140c4 plumbing/transport: add ProxyOptions to specify proxy details
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2023-05-04 11:53:09 +05:30
Paulo Gomes
19b39e1500 git: Add support to ls-remote with peeled references. Fixes #749
A new PeelingOption field was introduced into ListOptions. The new options
include the default (and backwards compatible) IgnorePeeled. Plus another
two variations which either only returns peeled references (OnlyPeeled), or
append peeled references to the list (AppendPeeled).

The ls-remote example was updated to align with upstream, in which peeled
references are appended to the results by default.

A new ErrEmptyUrls error is now returned when List or ListContext do not
receive a URL to work with, to improve overall execution flow.

Signed-off-by: Paulo Gomes <pjbgf@linux.com>
2023-05-03 08:39:07 +01: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
Máximo Cuadros
fe158cd6e1 Merge branch 'master' into jc-push-atomic 2021-12-10 06:51:49 +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
557a1fdcaa remote/addReachableTags: Remove guard before delete
The membership check before attempting to `delete` from the `tags` map
is unnecessary because the operation is a no-op if the item does not
already exist in the map.
2021-11-27 16:39:09 -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
John Cai
589a41ceed Add Atomic to push options
push --atomic allows a push to succeed or fail atomically. If one ref
fails, the whole push fails. This commit allows the user to set Atomic
as an option for a push.
2021-11-03 15:13:09 -04:00
John Cai
7db545b148 Add ForceWithLease Push Option
--force-with-lease allows a push to force push with some safety
measures. If the ref on the remote is what we expect, then the force
push is allowed to happen.
See https://git-scm.com/docs/git-push#Documentation/git-push.txt---force-with-leaseltrefnamegt
for more information
2021-11-02 18:19:46 -04:00
Máximo Cuadros
3211a7a12a Merge pull request #399 from S-Bohn/add-push-options
Remote: PushOptions add push-options
2021-11-01 22:52:38 +01:00
Thibault Jamet
617ae9f34f Add support to push commits per hashes
Using plain git, the command `git push ${sha}:refs/heads/some-branch`
actually ensures that the remote branch `some-branch` points to the
commit `${sha}`.

In the current version of go-git, this results in an "everything is
up to date" error.

When a source reference is not found, check the object storage to find
the sha. If it is found, consider pushing this exact commit.

fixes: #105
2021-10-28 21:48:32 +02:00
Sören Bohn
e729edb00d plumbing: packp, Add encoding for push-options. Fixes #268.
go-git: Add field `Options` to `PushOptions`, wire functionality.
2021-10-26 16:08:54 +02:00
Máximo Cuadros
99457e570d Merge pull request #375 from noerw/add-remoteurl-option
Remote: add RemoteURL to {Fetch,Pull,Push}Options
2021-10-26 12:31:59 +02:00
John Cai
5340c58e39 git: add --follow-tags option for pushes
This PR adds support for the --follow-tags option for pushes.
2021-10-05 13:16:17 -04: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
Nicolas Chagrass
db4233e9e8 remote: patch default timeout for List (#321)
It looks a test value was shipped breaking a lot of the usage of the library.
2021-05-24 22:07:59 +02:00
Marcus Watkins
320db9af8b git: Add support for deepening shallow clones (#311) 2021-05-12 22:39:49 +02:00
Máximo Cuadros
67af9d7223 utils: ioutil, Pipe implementatio 2021-05-02 23:36:12 +02:00
Xiang Xiujuan
67d34902b0 Remote: new ListContext function (#278) 2021-04-21 13:00:26 +02:00
Jeff Widman
f464d193a2 Minor doc fixes (#287) 2021-04-16 11:49:08 +02:00
Andrew Suffield
e5bbc4d109 plumbing: wire up contexts for Transport.AdvertisedReferences (#246)
* plumbing: wire up contexts for Transport.AdvertisedReferences

* add more tests for context wiring
2021-03-26 17:03:49 +01:00
Andrew Suffield
bf3471db54 add RequireRemoteRefs to PushOptions (#258)
The git protocol itself uses a compare-and-swap mechanism, where changes
send the old and new values and the change is only applied if the old
value matches. This is used to implement the --force-with-lease feature
in git push.

go-git populates the `old` field with the current value of the ref that
is read from the remote. We can implement a convenient (albeit more
limited) form of the --force-with-lease feature just by allowing the
caller to specify particular values for this ref.

Callers can then implement complex multi-step atomic operations by
reading the ref themselves at the start of the process, and passing to
in RequireRemoteRefs at the end. This is also a suitable building block
for implementing --force-with-lease (#101), which is mostly an exercise
in computing the correct hash to require. Hence, this appears to be the
most reasonable API to expose.
2021-03-25 11:21:38 +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
andrew2nelson
9d7bd4d4bd Fetch should return a unique error type when ref not found
It can be useful for callers to distinguish between an error of
"couldn't find remote ref" and some other error like "network error".

Creating an explicit error type for this allows consumers to
determine the kind of error using the errors.Is and errors.As
interface added in go1.13
2020-09-02 13:45:28 -07:00
Chris Gavin
711b703b57 git: remote, Fix deleting references when force pushing. 2020-08-28 10:35:37 +01:00
Máximo Cuadros
641ee1dd69 Merge pull request #125 from cristaloleg/minor-linter-fixes
*: minor linter fixes
2020-07-16 21:29:58 +02:00
Oleg Kovalov
95967a9e4d fix slice capacity 2020-07-07 23:22:24 +02:00
Oleg Kovalov
a99446e290 Minor linter fixes 2020-07-06 17:40:53 +02:00
Oleg Kovalov
d872dd9af2 Skip error check explicitly 2020-07-06 16:41:03 +02:00
kappyhappy
b5b511a94e Remote.Push: support force option 2020-05-21 18:12:48 +09:00
Máximo Cuadros
8ecd388ae1 Remote.Fetch: support exact SHA1 refspecs 2020-05-11 00:17:29 +02:00
Máximo Cuadros
2bdfd91f04 *: migration from gopkg to go modules 2020-03-10 00:40:56 +01:00
Christian Muehlhaeuser
af46dd50e9 *: fixed tautological error conditionsautological error conditions
- Added missing error handling around encodeCommitData and prevented shadowing
err.

- Removed tautological error checks.

Signed-off-by: Christian Muehlhaeuser <muesli@gmail.com>
(cherry picked from commit 7d76176416551fc21d98bc17768d158a82281406)
2019-07-29 17:31:40 +02:00
Máximo Cuadros
1edb992dbc Merge pull request #1165 from seletskiy/push-prune
Remote: add Prune option to PushOptions
2019-07-26 18:59:37 +02:00
Stanislav Seletskiy
17ea92a070 send PACK only if non-delete command present
According to:
https://github.com/git/git/blob/master/Documentation/technical/pack-protocol.txt

> The packfile MUST NOT be sent if the only command used is 'delete'.

Signed-off-by: Stanislav Seletskiy <s.seletskiy@gmail.com>
2019-07-25 17:16:12 +03:00
Stanislav Seletskiy
5d9007f27b add Prune option to PushOptions
Signed-off-by: Stanislav Seletskiy <s.seletskiy@gmail.com>
2019-07-25 16:38:47 +03:00
Valentin Cocaud
b4fba7ede1 git : allows to create a Remote without a Repository
Signed-off-by: Valentin Cocaud <v.cocaud@gmail.com>
2019-06-17 22:51:37 +02:00
Javi Fontan
fae29fbd58 git: fix goroutine block while pushing a remote
On session.ReceivePack error the gororutine doing the encoding got
blocked either writing objects to the pipe or sending error to the done
channel. The problem did not cause a perceived problem but left blocked
goroutines.

Signed-off-by: Javi Fontan <jfontan@gmail.com>
2019-03-01 15:33:49 +01:00
Jeremy Stribling
3889c6446d remote: when pushing to a local repo, use local store for ignores
Issue: #909
Signed-off-by: Jeremy Stribling <strib@alum.mit.edu>
2019-02-11 15:13:11 -08:00
Benjamin Ash
1618e1cf32 remote: use reference deltas on push when the remote server does not
support offset deltas

Signed-off-by: Benjamin Ash <bash@intelerad.com>
2018-10-16 16:16:53 -04:00