diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2022-03-22 22:16:57 -0400 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-03-23 08:35:24 -0400 |
| commit | a9a7967ac0657fea84ab0aaa97a1cb8f75c29e0e (patch) | |
| tree | 88528016bdebfc6b1009f34a1a4161c798d9e2c6 /src/libgit2 | |
| parent | 8420ac4b8a778d82ce87d05f6484ffc772178a63 (diff) | |
| download | libgit2-a9a7967ac0657fea84ab0aaa97a1cb8f75c29e0e.tar.gz | |
fetch: support OID refspec without dst
Support the ability to create a refspec that is a single object ID
without a destination.
Diffstat (limited to 'src/libgit2')
| -rw-r--r-- | src/libgit2/fetch.c | 7 | ||||
| -rw-r--r-- | src/libgit2/remote.c | 7 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/libgit2/fetch.c b/src/libgit2/fetch.c index 03d38452c..e9f30d9bc 100644 --- a/src/libgit2/fetch.c +++ b/src/libgit2/fetch.c @@ -76,8 +76,11 @@ static int maybe_want_oid(git_remote *remote, git_refspec *spec) GIT_ERROR_CHECK_ALLOC(oid_head); git_oid_fromstr(&oid_head->oid, spec->src); - oid_head->name = git__strdup(spec->dst); - GIT_ERROR_CHECK_ALLOC(oid_head->name); + + if (spec->dst) { + oid_head->name = git__strdup(spec->dst); + GIT_ERROR_CHECK_ALLOC(oid_head->name); + } if (git_vector_insert(&remote->local_heads, oid_head) < 0 || git_vector_insert(&remote->refs, oid_head) < 0) diff --git a/src/libgit2/remote.c b/src/libgit2/remote.c index f6421b9eb..1a79faaab 100644 --- a/src/libgit2/remote.c +++ b/src/libgit2/remote.c @@ -1895,8 +1895,11 @@ static int update_tips_for_spec( if (git_oid__is_hexstr(spec->src)) { git_oid id; - if ((error = git_oid_fromstr(&id, spec->src)) < 0 || - (error = update_ref(remote, spec->dst, &id, log_message, callbacks)) < 0) + if ((error = git_oid_fromstr(&id, spec->src)) < 0) + goto on_error; + + if (spec->dst && + (error = update_ref(remote, spec->dst, &id, log_message, callbacks)) < 0) goto on_error; git_oid_cpy(&oid_head.oid, &id); |
