Skip to content

Commit 93e5e04

Browse files
committed
refs: drop strbuf_ prefix from helpers
The helper functions (strbuf_branchname, strbuf_check_branch_ref, and strbuf_check_tag_ref) are about handling branch and tag names, and it is a non-essential fact that these functions use strbuf to hold these names. Rename them to make it clarify that these are more about "ref". Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5bcbde9 commit 93e5e04

File tree

10 files changed

+23
-23
lines changed

10 files changed

+23
-23
lines changed

branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name)
372372
*/
373373
int validate_branchname(const char *name, struct strbuf *ref)
374374
{
375-
if (strbuf_check_branch_ref(ref, name)) {
375+
if (check_branch_ref(ref, name)) {
376376
int code = die_message(_("'%s' is not a valid branch name"), name);
377377
advise_if_enabled(ADVICE_REF_SYNTAX,
378378
_("See `man git check-ref-format`"));

builtin/branch.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
257257
char *target = NULL;
258258
int flags = 0;
259259

260-
strbuf_branchname(&bname, argv[i], allowed_interpret);
260+
copy_branchname(&bname, argv[i], allowed_interpret);
261261
free(name);
262262
name = mkpathdup(fmt, bname.buf);
263263

@@ -579,7 +579,7 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
579579
int recovery = 0, oldref_usage = 0;
580580
struct worktree **worktrees = get_worktrees();
581581

582-
if (strbuf_check_branch_ref(&oldref, oldname)) {
582+
if (check_branch_ref(&oldref, oldname)) {
583583
/*
584584
* Bad name --- this could be an attempt to rename a
585585
* ref that we used to allow to be created by accident.
@@ -894,7 +894,7 @@ int cmd_branch(int argc,
894894
die(_("cannot give description to detached HEAD"));
895895
branch_name = head;
896896
} else if (argc == 1) {
897-
strbuf_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL);
897+
copy_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL);
898898
branch_name = buf.buf;
899899
} else {
900900
die(_("cannot edit description of more than one branch"));
@@ -933,7 +933,7 @@ int cmd_branch(int argc,
933933
if (!argc)
934934
branch = branch_get(NULL);
935935
else if (argc == 1) {
936-
strbuf_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL);
936+
copy_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL);
937937
branch = branch_get(buf.buf);
938938
} else
939939
die(_("too many arguments to set new upstream"));
@@ -963,7 +963,7 @@ int cmd_branch(int argc,
963963
if (!argc)
964964
branch = branch_get(NULL);
965965
else if (argc == 1) {
966-
strbuf_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL);
966+
copy_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL);
967967
branch = branch_get(buf.buf);
968968
} else
969969
die(_("too many arguments to unset upstream"));

builtin/check-ref-format.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static int check_ref_format_branch(const char *arg)
4242
int nongit;
4343

4444
setup_git_directory_gently(&nongit);
45-
if (strbuf_check_branch_ref(&sb, arg) ||
45+
if (check_branch_ref(&sb, arg) ||
4646
!skip_prefix(sb.buf, "refs/heads/", &name))
4747
die("'%s' is not a valid branch name", arg);
4848
printf("%s\n", name);

builtin/checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ static void setup_branch_path(struct branch_info *branch)
742742
&branch->oid, &branch->refname, 0))
743743
repo_get_oid_committish(the_repository, branch->name, &branch->oid);
744744

745-
strbuf_branchname(&buf, branch->name, INTERPRET_BRANCH_LOCAL);
745+
copy_branchname(&buf, branch->name, INTERPRET_BRANCH_LOCAL);
746746
if (strcmp(buf.buf, branch->name)) {
747747
free(branch->name);
748748
branch->name = xstrdup(buf.buf);

builtin/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
498498
char *found_ref = NULL;
499499
int len, early;
500500

501-
strbuf_branchname(&bname, remote, 0);
501+
copy_branchname(&bname, remote, 0);
502502
remote = bname.buf;
503503

504504
oidclr(&branch_head, the_repository->hash_algo);

builtin/tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ int cmd_tag(int argc,
639639
if (repo_get_oid(the_repository, object_ref, &object))
640640
die(_("Failed to resolve '%s' as a valid ref."), object_ref);
641641

642-
if (strbuf_check_tag_ref(&ref, tag))
642+
if (check_tag_ref(&ref, tag))
643643
die(_("'%s' is not a valid tag name."), tag);
644644

645645
if (refs_read_ref(get_main_ref_store(the_repository), ref.buf, &prev))

builtin/worktree.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ static int add_worktree(const char *path, const char *refname,
432432
worktrees = NULL;
433433

434434
/* is 'refname' a branch or commit? */
435-
if (!opts->detach && !strbuf_check_branch_ref(&symref, refname) &&
435+
if (!opts->detach && !check_branch_ref(&symref, refname) &&
436436
refs_ref_exists(get_main_ref_store(the_repository), symref.buf)) {
437437
is_branch = 1;
438438
if (!opts->force)
@@ -604,7 +604,7 @@ static void print_preparing_worktree_line(int detach,
604604
fprintf_ln(stderr, _("Preparing worktree (new branch '%s')"), new_branch);
605605
} else {
606606
struct strbuf s = STRBUF_INIT;
607-
if (!detach && !strbuf_check_branch_ref(&s, branch) &&
607+
if (!detach && !check_branch_ref(&s, branch) &&
608608
refs_ref_exists(get_main_ref_store(the_repository), s.buf))
609609
fprintf_ln(stderr, _("Preparing worktree (checking out '%s')"),
610610
branch);
@@ -745,7 +745,7 @@ static char *dwim_branch(const char *path, char **new_branch)
745745
char *branchname = xstrndup(s, n);
746746
struct strbuf ref = STRBUF_INIT;
747747

748-
branch_exists = !strbuf_check_branch_ref(&ref, branchname) &&
748+
branch_exists = !check_branch_ref(&ref, branchname) &&
749749
refs_ref_exists(get_main_ref_store(the_repository),
750750
ref.buf);
751751
strbuf_release(&ref);
@@ -838,7 +838,7 @@ static int add(int ac, const char **av, const char *prefix)
838838
new_branch = new_branch_force;
839839

840840
if (!opts.force &&
841-
!strbuf_check_branch_ref(&symref, new_branch) &&
841+
!check_branch_ref(&symref, new_branch) &&
842842
refs_ref_exists(get_main_ref_store(the_repository), symref.buf))
843843
die_if_checked_out(symref.buf, 0);
844844
strbuf_release(&symref);

gitweb/gitweb.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2094,7 +2094,7 @@ sub format_log_line_html {
20942094
(
20952095
# The output of "git describe", e.g. v2.10.0-297-gf6727b0
20962096
# or hadoop-20160921-113441-20-g094fb7d
2097-
(?<!-) # see strbuf_check_tag_ref(). Tags can't start with -
2097+
(?<!-) # see check_tag_ref(). Tags can't start with -
20982098
[A-Za-z0-9.-]+
20992099
(?!\.) # refs can't end with ".", see check_refname_format()
21002100
-g$regex

refs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ static char *substitute_branch_name(struct repository *r,
697697
return NULL;
698698
}
699699

700-
void strbuf_branchname(struct strbuf *sb, const char *name, unsigned allowed)
700+
void copy_branchname(struct strbuf *sb, const char *name, unsigned allowed)
701701
{
702702
int len = strlen(name);
703703
struct interpret_branch_name_options options = {
@@ -711,10 +711,10 @@ void strbuf_branchname(struct strbuf *sb, const char *name, unsigned allowed)
711711
strbuf_add(sb, name + used, len - used);
712712
}
713713

714-
int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
714+
int check_branch_ref(struct strbuf *sb, const char *name)
715715
{
716716
if (startup_info->have_repository)
717-
strbuf_branchname(sb, name, INTERPRET_BRANCH_LOCAL);
717+
copy_branchname(sb, name, INTERPRET_BRANCH_LOCAL);
718718
else
719719
strbuf_addstr(sb, name);
720720

@@ -733,7 +733,7 @@ int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
733733
return check_refname_format(sb->buf, 0);
734734
}
735735

736-
int strbuf_check_tag_ref(struct strbuf *sb, const char *name)
736+
int check_tag_ref(struct strbuf *sb, const char *name)
737737
{
738738
if (name[0] == '-')
739739
return -1;

refs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,23 +191,23 @@ char *repo_default_branch_name(struct repository *r, int quiet);
191191
* If "allowed" is non-zero, restrict the set of allowed expansions. See
192192
* repo_interpret_branch_name() for details.
193193
*/
194-
void strbuf_branchname(struct strbuf *sb, const char *name,
194+
void copy_branchname(struct strbuf *sb, const char *name,
195195
unsigned allowed);
196196

197197
/*
198-
* Like strbuf_branchname() above, but confirm that the result is
198+
* Like copy_branchname() above, but confirm that the result is
199199
* syntactically valid to be used as a local branch name in refs/heads/.
200200
*
201201
* The return value is "0" if the result is valid, and "-1" otherwise.
202202
*/
203-
int strbuf_check_branch_ref(struct strbuf *sb, const char *name);
203+
int check_branch_ref(struct strbuf *sb, const char *name);
204204

205205
/*
206206
* Similar for a tag name in refs/tags/.
207207
*
208208
* The return value is "0" if the result is valid, and "-1" otherwise.
209209
*/
210-
int strbuf_check_tag_ref(struct strbuf *sb, const char *name);
210+
int check_tag_ref(struct strbuf *sb, const char *name);
211211

212212
/*
213213
* A ref_transaction represents a collection of reference updates that

0 commit comments

Comments
 (0)