Commit 95cde17c by Vicent Marti

Enforce coding conventions in refs.c

Internal methods are static and without the git prefix.
'Force' methods have a `_f` prefix to match the other 'force' methods.
parent fc1eeb9d
......@@ -87,7 +87,7 @@ GIT_EXTERN(int) git_reference_create_symbolic(git_reference **ref_out, git_repos
* @param target The target of the reference
* @return 0 on success; error code otherwise
*/
GIT_EXTERN(int) git_reference_create_symbolic_force(git_reference **ref_out, git_repository *repo, const char *name, const char *target);
GIT_EXTERN(int) git_reference_create_symbolic_f(git_reference **ref_out, git_repository *repo, const char *name, const char *target);
/**
* Create a new object id reference.
......@@ -125,7 +125,7 @@ GIT_EXTERN(int) git_reference_create_oid(git_reference **ref_out, git_repository
* @param id The object id pointed to by the reference.
* @return 0 on success; error code otherwise
*/
GIT_EXTERN(int) git_reference_create_oid_force(git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id);
GIT_EXTERN(int) git_reference_create_oid_f(git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id);
/**
* Get the OID pointed to by a reference.
......@@ -243,7 +243,7 @@ GIT_EXTERN(int) git_reference_rename(git_reference *ref, const char *new_name);
* and on disk.
*
*/
GIT_EXTERN(int) git_reference_rename_force(git_reference *ref, const char *new_name);
GIT_EXTERN(int) git_reference_rename_f(git_reference *ref, const char *new_name);
/**
* Delete an existing reference
......
......@@ -79,6 +79,11 @@ static int packed_remove_loose(git_repository *repo, git_vector *packing_list);
static int packed_sort(const void *a, const void *b);
static int packed_write(git_repository *repo);
/* internal helpers */
static int reference_create_symbolic(git_reference **ref_out, git_repository *repo, const char *name, const char *target, int force);
static int reference_create_oid(git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id, int force);
static int reference_rename(git_reference *ref, const char *new_name, int force);
/* name normalization */
static int check_valid_ref_char(char ch);
static int normalize_name(char *buffer_out, const char *name, int is_oid_ref);
......@@ -919,7 +924,7 @@ cleanup:
* Internal methods - reference creation
*****************************************/
int git_reference_create_symbolic_internal(git_reference **ref_out, git_repository *repo, const char *name, const char *target, int force)
static int reference_create_symbolic(git_reference **ref_out, git_repository *repo, const char *name, const char *target, int force)
{
char normalized[MAX_GITDIR_TREE_STRUCTURE_PATH_LENGTH];
int error = GIT_SUCCESS, updated = 0;
......@@ -976,7 +981,7 @@ cleanup:
return error;
}
int git_reference_create_oid_internal(git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id, int force)
static int reference_create_oid(git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id, int force)
{
int error = GIT_SUCCESS, updated = 0;
git_reference *ref = NULL, *old_ref = NULL;
......@@ -1036,7 +1041,7 @@ cleanup:
* We also need to re-insert the reference on its corresponding
* in-memory cache, since the caches are indexed by refname.
*/
int git_reference_rename_internal(git_reference *ref, const char *new_name, int force)
static int reference_rename(git_reference *ref, const char *new_name, int force)
{
int error;
char *old_name;
......@@ -1207,22 +1212,22 @@ int git_reference_lookup(git_reference **ref_out, git_repository *repo, const ch
int git_reference_create_symbolic(git_reference **ref_out, git_repository *repo, const char *name, const char *target)
{
return git_reference_create_symbolic_internal(ref_out, repo, name, target, 0);
return reference_create_symbolic(ref_out, repo, name, target, 0);
}
int git_reference_create_symbolic_force(git_reference **ref_out, git_repository *repo, const char *name, const char *target)
int git_reference_create_symbolic_f(git_reference **ref_out, git_repository *repo, const char *name, const char *target)
{
return git_reference_create_symbolic_internal(ref_out, repo, name, target, 1);
return reference_create_symbolic(ref_out, repo, name, target, 1);
}
int git_reference_create_oid(git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id)
{
return git_reference_create_oid_internal(ref_out, repo, name, id, 0);
return reference_create_oid(ref_out, repo, name, id, 0);
}
int git_reference_create_oid_force(git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id)
int git_reference_create_oid_f(git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id)
{
return git_reference_create_oid_internal(ref_out, repo, name, id, 1);
return reference_create_oid(ref_out, repo, name, id, 1);
}
/**
......@@ -1433,12 +1438,12 @@ cleanup:
int git_reference_rename(git_reference *ref, const char *new_name)
{
return git_reference_rename_internal(ref, new_name, 0);
return reference_rename(ref, new_name, 0);
}
int git_reference_rename_force(git_reference *ref, const char *new_name)
int git_reference_rename_f(git_reference *ref, const char *new_name)
{
return git_reference_rename_internal(ref, new_name, 1);
return reference_rename(ref, new_name, 1);
}
int git_reference_resolve(git_reference **resolved_ref, git_reference *ref)
......
......@@ -315,7 +315,7 @@ BEGIN_TEST(overwrite0, "Overwrite an existing symbolic reference")
/* Ensure we can't create it unless we force it to */
must_fail(git_reference_create_symbolic(&ref, repo, ref_name, ref_master_name));
must_pass(git_reference_create_symbolic_force(&ref, repo, ref_name, ref_master_name));
must_pass(git_reference_create_symbolic_f(&ref, repo, ref_name, ref_master_name));
/* Ensure it points to the right place */
must_pass(git_reference_lookup(&ref, repo, ref_name));
......@@ -347,7 +347,7 @@ BEGIN_TEST(overwrite1, "Overwrite an existing object id reference")
/* Ensure we can't overwrite unless we force it */
must_fail(git_reference_create_oid(&ref, repo, ref_name, &id));
must_pass(git_reference_create_oid_force(&ref, repo, ref_name, &id));
must_pass(git_reference_create_oid_f(&ref, repo, ref_name, &id));
/* Ensure it has been overwritten */
must_pass(git_reference_lookup(&ref, repo, ref_name));
......@@ -370,7 +370,7 @@ BEGIN_TEST(overwrite2, "Overwrite an existing object id reference with a symboli
must_pass(git_reference_create_oid(&ref, repo, ref_name, &id));
must_fail(git_reference_create_symbolic(&ref, repo, ref_name, ref_master_name));
must_pass(git_reference_create_symbolic_force(&ref, repo, ref_name, ref_master_name));
must_pass(git_reference_create_symbolic_f(&ref, repo, ref_name, ref_master_name));
/* Ensure it points to the right place */
must_pass(git_reference_lookup(&ref, repo, ref_name));
......@@ -396,7 +396,7 @@ BEGIN_TEST(overwrite3, "Overwrite an existing symbolic reference with an object
must_pass(git_reference_create_symbolic(&ref, repo, ref_name, ref_master_name));
/* It shouldn't overwrite unless we tell it to */
must_fail(git_reference_create_oid(&ref, repo, ref_name, &id));
must_pass(git_reference_create_oid_force(&ref, repo, ref_name, &id));
must_pass(git_reference_create_oid_f(&ref, repo, ref_name, &id));
/* Ensure it points to the right place */
must_pass(git_reference_lookup(&ref, repo, ref_name));
......@@ -622,7 +622,7 @@ BEGIN_TEST(rename5, "can force-rename a reference with the name of an existing r
must_pass(git_reference_lookup(&looked_up_ref, repo, packed_head_name));
/* Can not be renamed to the name of another existing reference. */
must_pass(git_reference_rename_force(looked_up_ref, packed_test_head_name));
must_pass(git_reference_rename_f(looked_up_ref, packed_test_head_name));
/* Check we actually renamed it */
must_pass(git_reference_lookup(&looked_up_ref, repo, packed_test_head_name));
......
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