diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2023-01-20 22:33:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-20 22:33:36 +0000 |
commit | 2347eb3263c49723d539ba84959aca3a445de509 (patch) | |
tree | 51b225c1199f633e04ce1cd2939e3085c9f2362c /src | |
parent | 4d47ad6fc5c413093e7ffae50e0f8ecfba431696 (diff) | |
parent | 211c97195e2ebcf68e27782715eb756823ad5a91 (diff) | |
download | libgit2-2347eb3263c49723d539ba84959aca3a445de509.tar.gz |
Merge pull request #6362 from sven-of-cord/main
push: revparse refspec source, so you can push things that are not refs
Diffstat (limited to 'src')
-rw-r--r-- | src/libgit2/push.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/libgit2/push.c b/src/libgit2/push.c index d477b4f0d..e1502d337 100644 --- a/src/libgit2/push.c +++ b/src/libgit2/push.c @@ -385,11 +385,18 @@ static int calculate_work(git_push *push) git_vector_foreach(&push->specs, i, spec) { if (spec->refspec.src && spec->refspec.src[0]!= '\0') { /* This is a create or update. Local ref must exist. */ - if (git_reference_name_to_id( - &spec->loid, push->repo, spec->refspec.src) < 0) { - git_error_set(GIT_ERROR_REFERENCE, "no such reference '%s'", spec->refspec.src); + + git_object *obj; + int error = git_revparse_single(&obj, push->repo, spec->refspec.src); + + if (error < 0) { + git_object_free(obj); + git_error_set(GIT_ERROR_REFERENCE, "src refspec %s does not match any", spec->refspec.src); return -1; } + + git_oid_cpy(git_object_id(obj), &spec->loid); + git_object_free(obj); } /* Remote ref may or may not (e.g. during create) already exist. */ |