Commit a258d8e3 by Carlos Martín Nieto

branch: rename 'tracking' to 'upstream'

The term 'tracking' is overloaded. Help distinguish what we mean by
using 'upstream' for this part of the library.
parent 81b8c9df
...@@ -173,7 +173,7 @@ GIT_EXTERN(int) git_branch_name(const char **out, ...@@ -173,7 +173,7 @@ GIT_EXTERN(int) git_branch_name(const char **out,
* @return 0 on success; GIT_ENOTFOUND when no remote tracking * @return 0 on success; GIT_ENOTFOUND when no remote tracking
* reference exists, otherwise an error code. * reference exists, otherwise an error code.
*/ */
GIT_EXTERN(int) git_branch_tracking( GIT_EXTERN(int) git_branch_upstream(
git_reference **out, git_reference **out,
git_reference *branch); git_reference *branch);
...@@ -195,7 +195,7 @@ GIT_EXTERN(int) git_branch_tracking( ...@@ -195,7 +195,7 @@ GIT_EXTERN(int) git_branch_tracking(
* including the trailing NUL byte; GIT_ENOTFOUND when no remote tracking * including the trailing NUL byte; GIT_ENOTFOUND when no remote tracking
* reference exists, otherwise an error code. * reference exists, otherwise an error code.
*/ */
GIT_EXTERN(int) git_branch_tracking_name( GIT_EXTERN(int) git_branch_upstream_name(
char *tracking_branch_name_out, char *tracking_branch_name_out,
size_t buffer_size, size_t buffer_size,
git_repository *repo, git_repository *repo,
......
...@@ -228,7 +228,7 @@ int git_branch_name(const char **out, git_reference *ref) ...@@ -228,7 +228,7 @@ int git_branch_name(const char **out, git_reference *ref)
return 0; return 0;
} }
static int retrieve_tracking_configuration( static int retrieve_upstream_configuration(
const char **out, const char **out,
git_repository *repo, git_repository *repo,
const char *canonical_branch_name, const char *canonical_branch_name,
...@@ -250,7 +250,7 @@ static int retrieve_tracking_configuration( ...@@ -250,7 +250,7 @@ static int retrieve_tracking_configuration(
return error; return error;
} }
int git_branch_tracking__name( int git_branch_upstream__name(
git_buf *tracking_name, git_buf *tracking_name,
git_repository *repo, git_repository *repo,
const char *canonical_branch_name) const char *canonical_branch_name)
...@@ -266,11 +266,11 @@ int git_branch_tracking__name( ...@@ -266,11 +266,11 @@ int git_branch_tracking__name(
if (!git_reference__is_branch(canonical_branch_name)) if (!git_reference__is_branch(canonical_branch_name))
return not_a_local_branch(canonical_branch_name); return not_a_local_branch(canonical_branch_name);
if ((error = retrieve_tracking_configuration( if ((error = retrieve_upstream_configuration(
&remote_name, repo, canonical_branch_name, "branch.%s.remote")) < 0) &remote_name, repo, canonical_branch_name, "branch.%s.remote")) < 0)
goto cleanup; goto cleanup;
if ((error = retrieve_tracking_configuration( if ((error = retrieve_upstream_configuration(
&merge_name, repo, canonical_branch_name, "branch.%s.merge")) < 0) &merge_name, repo, canonical_branch_name, "branch.%s.merge")) < 0)
goto cleanup; goto cleanup;
...@@ -386,7 +386,7 @@ cleanup: ...@@ -386,7 +386,7 @@ cleanup:
return error; return error;
} }
int git_branch_tracking_name( int git_branch_upstream_name(
char *tracking_branch_name_out, char *tracking_branch_name_out,
size_t buffer_size, size_t buffer_size,
git_repository *repo, git_repository *repo,
...@@ -400,7 +400,7 @@ int git_branch_tracking_name( ...@@ -400,7 +400,7 @@ int git_branch_tracking_name(
if (tracking_branch_name_out && buffer_size) if (tracking_branch_name_out && buffer_size)
*tracking_branch_name_out = '\0'; *tracking_branch_name_out = '\0';
if ((error = git_branch_tracking__name( if ((error = git_branch_upstream__name(
&buf, repo, canonical_branch_name)) < 0) &buf, repo, canonical_branch_name)) < 0)
goto cleanup; goto cleanup;
...@@ -422,14 +422,14 @@ cleanup: ...@@ -422,14 +422,14 @@ cleanup:
return (int)error; return (int)error;
} }
int git_branch_tracking( int git_branch_upstream(
git_reference **tracking_out, git_reference **tracking_out,
git_reference *branch) git_reference *branch)
{ {
int error; int error;
git_buf tracking_name = GIT_BUF_INIT; git_buf tracking_name = GIT_BUF_INIT;
if ((error = git_branch_tracking__name(&tracking_name, if ((error = git_branch_upstream__name(&tracking_name,
git_reference_owner(branch), git_reference_name(branch))) < 0) git_reference_owner(branch), git_reference_name(branch))) < 0)
return error; return error;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "buffer.h" #include "buffer.h"
int git_branch_tracking__name( int git_branch_upstream__name(
git_buf *tracking_name, git_buf *tracking_name,
git_repository *repo, git_repository *repo,
const char *canonical_branch_name); const char *canonical_branch_name);
......
...@@ -705,7 +705,7 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_ve ...@@ -705,7 +705,7 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_ve
if ((error = git_reference_resolve(&resolved_ref, ref)) < 0 || if ((error = git_reference_resolve(&resolved_ref, ref)) < 0 ||
(!git_reference_is_branch(resolved_ref)) || (!git_reference_is_branch(resolved_ref)) ||
(error = git_branch_tracking(&tracking_ref, resolved_ref)) < 0 || (error = git_branch_upstream(&tracking_ref, resolved_ref)) < 0 ||
(error = git_refspec_transform_l(&remote_name, &remote->fetch, git_reference_name(tracking_ref))) < 0) { (error = git_refspec_transform_l(&remote_name, &remote->fetch, git_reference_name(tracking_ref))) < 0) {
/* Not an error if HEAD is orphaned or no tracking branch */ /* Not an error if HEAD is orphaned or no tracking branch */
if (error == GIT_ENOTFOUND) if (error == GIT_ENOTFOUND)
......
...@@ -356,7 +356,7 @@ static int retrieve_remote_tracking_reference(git_reference **base_ref, const ch ...@@ -356,7 +356,7 @@ static int retrieve_remote_tracking_reference(git_reference **base_ref, const ch
goto cleanup; goto cleanup;
} }
if ((error = git_branch_tracking(&tracking, ref)) < 0) if ((error = git_branch_upstream(&tracking, ref)) < 0)
goto cleanup; goto cleanup;
*base_ref = tracking; *base_ref = tracking;
......
...@@ -1327,7 +1327,7 @@ static int lookup_head_remote(git_buf *url, git_repository *repo) ...@@ -1327,7 +1327,7 @@ static int lookup_head_remote(git_buf *url, git_repository *repo)
goto cleanup; goto cleanup;
} }
if ((error = git_branch_tracking(&remote, head)) < 0) if ((error = git_branch_upstream(&remote, head)) < 0)
goto cleanup; goto cleanup;
/* remote should refer to something like refs/remotes/ORIGIN/BRANCH */ /* remote should refer to something like refs/remotes/ORIGIN/BRANCH */
......
...@@ -49,7 +49,7 @@ void test_clone_empty__can_clone_an_empty_local_repo_barely(void) ...@@ -49,7 +49,7 @@ void test_clone_empty__can_clone_an_empty_local_repo_barely(void)
/* ...one can still retrieve the name of the remote tracking reference */ /* ...one can still retrieve the name of the remote tracking reference */
cl_assert_equal_i((int)strlen(expected_tracked_branch_name) + 1, cl_assert_equal_i((int)strlen(expected_tracked_branch_name) + 1,
git_branch_tracking_name(buffer, 1024, g_repo_cloned, local_name)); git_branch_upstream_name(buffer, 1024, g_repo_cloned, local_name));
cl_assert_equal_s(expected_tracked_branch_name, buffer); cl_assert_equal_s(expected_tracked_branch_name, buffer);
......
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
#include "refs.h" #include "refs.h"
static git_repository *repo; static git_repository *repo;
static git_reference *branch, *tracking; static git_reference *branch, *upstream;
void test_refs_branches_tracking__initialize(void) void test_refs_branches_upstream__initialize(void)
{ {
cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git"))); cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
branch = NULL; branch = NULL;
tracking = NULL; upstream = NULL;
} }
void test_refs_branches_tracking__cleanup(void) void test_refs_branches_upstream__cleanup(void)
{ {
git_reference_free(tracking); git_reference_free(upstream);
git_reference_free(branch); git_reference_free(branch);
branch = NULL; branch = NULL;
...@@ -22,43 +22,43 @@ void test_refs_branches_tracking__cleanup(void) ...@@ -22,43 +22,43 @@ void test_refs_branches_tracking__cleanup(void)
repo = NULL; repo = NULL;
} }
void test_refs_branches_tracking__can_retrieve_the_remote_tracking_reference_of_a_local_branch(void) void test_refs_branches_upstream__can_retrieve_the_remote_tracking_reference_of_a_local_branch(void)
{ {
cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/master")); cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/master"));
cl_git_pass(git_branch_tracking(&tracking, branch)); cl_git_pass(git_branch_upstream(&upstream, branch));
cl_assert_equal_s("refs/remotes/test/master", git_reference_name(tracking)); cl_assert_equal_s("refs/remotes/test/master", git_reference_name(upstream));
} }
void test_refs_branches_tracking__can_retrieve_the_local_tracking_reference_of_a_local_branch(void) void test_refs_branches_upstream__can_retrieve_the_local_upstream_reference_of_a_local_branch(void)
{ {
cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/track-local")); cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/track-local"));
cl_git_pass(git_branch_tracking(&tracking, branch)); cl_git_pass(git_branch_upstream(&upstream, branch));
cl_assert_equal_s("refs/heads/master", git_reference_name(tracking)); cl_assert_equal_s("refs/heads/master", git_reference_name(upstream));
} }
void test_refs_branches_tracking__cannot_retrieve_a_remote_tracking_reference_from_a_non_branch(void) void test_refs_branches_upstream__cannot_retrieve_a_remote_upstream_reference_from_a_non_branch(void)
{ {
cl_git_pass(git_reference_lookup(&branch, repo, "refs/tags/e90810b")); cl_git_pass(git_reference_lookup(&branch, repo, "refs/tags/e90810b"));
cl_git_fail(git_branch_tracking(&tracking, branch)); cl_git_fail(git_branch_upstream(&upstream, branch));
} }
void test_refs_branches_tracking__trying_to_retrieve_a_remote_tracking_reference_from_a_plain_local_branch_returns_GIT_ENOTFOUND(void) void test_refs_branches_upstream__trying_to_retrieve_a_remote_tracking_reference_from_a_plain_local_branch_returns_GIT_ENOTFOUND(void)
{ {
cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/subtrees")); cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/subtrees"));
cl_assert_equal_i(GIT_ENOTFOUND, git_branch_tracking(&tracking, branch)); cl_assert_equal_i(GIT_ENOTFOUND, git_branch_upstream(&upstream, branch));
} }
void test_refs_branches_tracking__trying_to_retrieve_a_remote_tracking_reference_from_a_branch_with_no_fetchspec_returns_GIT_ENOTFOUND(void) void test_refs_branches_upstream__trying_to_retrieve_a_remote_tracking_reference_from_a_branch_with_no_fetchspec_returns_GIT_ENOTFOUND(void)
{ {
cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/cannot-fetch")); cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/cannot-fetch"));
cl_assert_equal_i(GIT_ENOTFOUND, git_branch_tracking(&tracking, branch)); cl_assert_equal_i(GIT_ENOTFOUND, git_branch_upstream(&upstream, branch));
} }
static void assert_merge_and_or_remote_key_missing(git_repository *repository, const git_commit *target, const char *entry_name) static void assert_merge_and_or_remote_key_missing(git_repository *repository, const git_commit *target, const char *entry_name)
...@@ -68,12 +68,12 @@ static void assert_merge_and_or_remote_key_missing(git_repository *repository, c ...@@ -68,12 +68,12 @@ static void assert_merge_and_or_remote_key_missing(git_repository *repository, c
cl_assert_equal_i(GIT_OBJ_COMMIT, git_object_type((git_object*)target)); cl_assert_equal_i(GIT_OBJ_COMMIT, git_object_type((git_object*)target));
cl_git_pass(git_branch_create(&branch, repository, entry_name, (git_commit*)target, 0)); cl_git_pass(git_branch_create(&branch, repository, entry_name, (git_commit*)target, 0));
cl_assert_equal_i(GIT_ENOTFOUND, git_branch_tracking(&tracking, branch)); cl_assert_equal_i(GIT_ENOTFOUND, git_branch_upstream(&upstream, branch));
git_reference_free(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) void test_refs_branches_upstream__retrieve_a_remote_tracking_reference_from_a_branch_with_no_remote_returns_GIT_ENOTFOUND(void)
{ {
git_reference *head; git_reference *head;
git_repository *repository; git_repository *repository;
......
...@@ -2,41 +2,41 @@ ...@@ -2,41 +2,41 @@
#include "branch.h" #include "branch.h"
static git_repository *repo; static git_repository *repo;
static git_buf tracking_name; static git_buf upstream_name;
void test_refs_branches_trackingname__initialize(void) void test_refs_branches_upstreamname__initialize(void)
{ {
cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git"))); cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
git_buf_init(&tracking_name, 0); git_buf_init(&upstream_name, 0);
} }
void test_refs_branches_trackingname__cleanup(void) void test_refs_branches_upstreamname__cleanup(void)
{ {
git_buf_free(&tracking_name); git_buf_free(&upstream_name);
git_repository_free(repo); git_repository_free(repo);
repo = NULL; repo = NULL;
} }
void test_refs_branches_trackingname__can_retrieve_the_remote_tracking_reference_name_of_a_local_branch(void) void test_refs_branches_upstreamname__can_retrieve_the_remote_tracking_reference_name_of_a_local_branch(void)
{ {
cl_git_pass(git_branch_tracking__name( cl_git_pass(git_branch_upstream__name(
&tracking_name, repo, "refs/heads/master")); &upstream_name, repo, "refs/heads/master"));
cl_assert_equal_s("refs/remotes/test/master", git_buf_cstr(&tracking_name)); cl_assert_equal_s("refs/remotes/test/master", git_buf_cstr(&upstream_name));
} }
void test_refs_branches_trackingname__can_retrieve_the_local_tracking_reference_name_of_a_local_branch(void) void test_refs_branches_upstreamname__can_retrieve_the_local_upstream_reference_name_of_a_local_branch(void)
{ {
cl_git_pass(git_branch_tracking__name( cl_git_pass(git_branch_upstream__name(
&tracking_name, repo, "refs/heads/track-local")); &upstream_name, repo, "refs/heads/track-local"));
cl_assert_equal_s("refs/heads/master", git_buf_cstr(&tracking_name)); cl_assert_equal_s("refs/heads/master", git_buf_cstr(&upstream_name));
} }
void test_refs_branches_trackingname__can_return_the_size_of_thelocal_tracking_reference_name_of_a_local_branch(void) void test_refs_branches_upstreamname__can_return_the_size_of_thelocal_upstream_reference_name_of_a_local_branch(void)
{ {
cl_assert_equal_i((int)strlen("refs/heads/master") + 1, cl_assert_equal_i((int)strlen("refs/heads/master") + 1,
git_branch_tracking_name(NULL, 0, repo, "refs/heads/track-local")); git_branch_upstream_name(NULL, 0, repo, "refs/heads/track-local"));
} }
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