Commit 37849a8e by nulltoken

tracking: fix retrieval of the tracking ref of branch with empty merge and/or remote entry

parent f1bd50d6
......@@ -257,8 +257,8 @@ int git_branch_tracking(
if ((error = retrieve_tracking_configuration(&merge_name, branch, "branch.%s.merge")) < 0)
goto cleanup;
if (remote_name == NULL || merge_name == NULL) {
if (!*remote_name || !*merge_name) {
error = GIT_ENOTFOUND;
goto cleanup;
}
......
......@@ -60,3 +60,35 @@ void test_refs_branches_tracking__trying_to_retrieve_a_remote_tracking_reference
cl_assert_equal_i(GIT_ENOTFOUND, git_branch_tracking(&tracking, branch));
}
static void assert_merge_and_or_remote_key_missing(git_repository *repository, git_object *target, const char *entry_name)
{
git_reference *branch;
cl_git_pass(git_branch_create(&branch, repository, entry_name, target, 0));
cl_assert_equal_i(GIT_ENOTFOUND, git_branch_tracking(&tracking, branch));
git_reference_free(branch);
}
void test_refs_branches_tracking__retrieve_a_remote_tracking_reference_from_a_branch_with_no_remote_returns_GIT_ENOTFOUND(void)
{
git_reference *head;
git_repository *repository;
git_object *target;
repository = cl_git_sandbox_init("testrepo.git");
cl_git_pass(git_repository_head(&head, repository));
cl_git_pass(git_reference_peel(&target, head, GIT_OBJ_COMMIT));
git_reference_free(head);
assert_merge_and_or_remote_key_missing(repository, target, "remoteless");
assert_merge_and_or_remote_key_missing(repository, target, "mergeless");
assert_merge_and_or_remote_key_missing(repository, target, "mergeandremoteless");
git_object_free(target);
cl_git_sandbox_cleanup();
}
......@@ -25,3 +25,12 @@
[branch "cannot-fetch"]
remote = joshaber
merge = refs/heads/cannot-fetch
[branch "remoteless"]
remote =
merge = refs/heads/master
[branch "mergeless"]
remote = test
merge =
[branch "mergeandremoteless"]
remote =
merge =
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment