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 /tests | |
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 'tests')
-rw-r--r-- | tests/libgit2/online/fetch.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/libgit2/online/fetch.c b/tests/libgit2/online/fetch.c index 7334f7e8b..5beb5b618 100644 --- a/tests/libgit2/online/fetch.c +++ b/tests/libgit2/online/fetch.c @@ -321,3 +321,32 @@ void test_online_fetch__reachable_commit(void) git_object_free(obj); git_remote_free(remote); } + +void test_online_fetch__reachable_commit_without_destination(void) +{ + git_remote *remote; + git_strarray refspecs; + git_object *obj; + git_oid expected_id; + git_str fetchhead = GIT_STR_INIT; + char *refspec = "2c349335b7f797072cf729c4f3bb0914ecb6dec9"; + + refspecs.strings = &refspec; + refspecs.count = 1; + + git_oid_fromstr(&expected_id, "2c349335b7f797072cf729c4f3bb0914ecb6dec9"); + + cl_git_pass(git_remote_create(&remote, _repo, "test", + "https://github.com/libgit2/TestGitRepository")); + cl_git_pass(git_remote_fetch(remote, &refspecs, NULL, NULL)); + + cl_git_fail_with(GIT_ENOTFOUND, git_revparse_single(&obj, _repo, "refs/success")); + + cl_git_pass(git_futils_readbuffer(&fetchhead, "./fetch/.git/FETCH_HEAD")); + cl_assert_equal_s(fetchhead.ptr, + "2c349335b7f797072cf729c4f3bb0914ecb6dec9\t\t'2c349335b7f797072cf729c4f3bb0914ecb6dec9' of https://github.com/libgit2/TestGitRepository\n"); + + git_str_dispose(&fetchhead); + git_object_free(obj); + git_remote_free(remote); +} |