summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/branch.c12
-rw-r--r--src/refs.c7
-rw-r--r--src/refs.h1
3 files changed, 13 insertions, 7 deletions
diff --git a/src/branch.c b/src/branch.c
index 11ecbe9a1..a50387541 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -323,7 +323,7 @@ int git_branch_remote_name(
char *remote_name_out,
size_t buffer_size,
git_repository *repo,
- git_reference *branch)
+ const char *canonical_branch_name)
{
git_strarray remote_list = {0};
size_t i, remote_name_size;
@@ -332,15 +332,15 @@ int git_branch_remote_name(
int error = 0;
char *remote_name = NULL;
- assert(branch);
+ assert(repo && canonical_branch_name);
if (remote_name_out && buffer_size)
*remote_name_out = '\0';
/* Verify that this is a remote branch */
- if (!git_reference_is_remote(branch)) {
- giterr_set(GITERR_INVALID,
- "Reference '%s' is not a remote branch.", branch->name);
+ if (!git_reference__is_remote(canonical_branch_name)) {
+ giterr_set(GITERR_INVALID, "Reference '%s' is not a remote branch.",
+ canonical_branch_name);
error = GIT_ERROR;
goto cleanup;
}
@@ -358,7 +358,7 @@ int git_branch_remote_name(
/* Defensivly check that we have a fetchspec */
if (fetchspec &&
- git_refspec_dst_matches(fetchspec, branch->name)) {
+ git_refspec_dst_matches(fetchspec, canonical_branch_name)) {
/* If we have not already set out yet, then set
* it to the matching remote name. Otherwise
* multiple remotes match this reference, and it
diff --git a/src/refs.c b/src/refs.c
index 866c230e6..cca3f3ec8 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -1926,10 +1926,15 @@ int git_reference_is_branch(git_reference *ref)
return git_reference__is_branch(ref->name);
}
+int git_reference__is_remote(const char *ref_name)
+{
+ return git__prefixcmp(ref_name, GIT_REFS_REMOTES_DIR) == 0;
+}
+
int git_reference_is_remote(git_reference *ref)
{
assert(ref);
- return git__prefixcmp(ref->name, GIT_REFS_REMOTES_DIR) == 0;
+ return git_reference__is_remote(ref->name);
}
static int peel_error(int error, git_reference *ref, const char* msg)
diff --git a/src/refs.h b/src/refs.h
index 1228cea87..7bd1ae68a 100644
--- a/src/refs.h
+++ b/src/refs.h
@@ -70,6 +70,7 @@ int git_reference__normalize_name(git_buf *buf, const char *name, unsigned int f
int git_reference__is_valid_name(const char *refname, unsigned int flags);
int git_reference__update(git_repository *repo, const git_oid *oid, const char *ref_name);
int git_reference__is_branch(const char *ref_name);
+int git_reference__is_remote(const char *ref_name);
/**
* Lookup a reference by name and try to resolve to an OID.