Git fork

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 <gitster@pobox.com>

+23 -23
+1 -1
branch.c
··· 372 372 */ 373 373 int validate_branchname(const char *name, struct strbuf *ref) 374 374 { 375 - if (strbuf_check_branch_ref(ref, name)) { 375 + if (check_branch_ref(ref, name)) { 376 376 int code = die_message(_("'%s' is not a valid branch name"), name); 377 377 advise_if_enabled(ADVICE_REF_SYNTAX, 378 378 _("See `man git check-ref-format`"));
+5 -5
builtin/branch.c
··· 257 257 char *target = NULL; 258 258 int flags = 0; 259 259 260 - strbuf_branchname(&bname, argv[i], allowed_interpret); 260 + copy_branchname(&bname, argv[i], allowed_interpret); 261 261 free(name); 262 262 name = mkpathdup(fmt, bname.buf); 263 263 ··· 579 579 int recovery = 0, oldref_usage = 0; 580 580 struct worktree **worktrees = get_worktrees(); 581 581 582 - if (strbuf_check_branch_ref(&oldref, oldname)) { 582 + if (check_branch_ref(&oldref, oldname)) { 583 583 /* 584 584 * Bad name --- this could be an attempt to rename a 585 585 * ref that we used to allow to be created by accident. ··· 894 894 die(_("cannot give description to detached HEAD")); 895 895 branch_name = head; 896 896 } else if (argc == 1) { 897 - strbuf_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL); 897 + copy_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL); 898 898 branch_name = buf.buf; 899 899 } else { 900 900 die(_("cannot edit description of more than one branch")); ··· 933 933 if (!argc) 934 934 branch = branch_get(NULL); 935 935 else if (argc == 1) { 936 - strbuf_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL); 936 + copy_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL); 937 937 branch = branch_get(buf.buf); 938 938 } else 939 939 die(_("too many arguments to set new upstream")); ··· 963 963 if (!argc) 964 964 branch = branch_get(NULL); 965 965 else if (argc == 1) { 966 - strbuf_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL); 966 + copy_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL); 967 967 branch = branch_get(buf.buf); 968 968 } else 969 969 die(_("too many arguments to unset upstream"));
+1 -1
builtin/check-ref-format.c
··· 42 42 int nongit; 43 43 44 44 setup_git_directory_gently(&nongit); 45 - if (strbuf_check_branch_ref(&sb, arg) || 45 + if (check_branch_ref(&sb, arg) || 46 46 !skip_prefix(sb.buf, "refs/heads/", &name)) 47 47 die("'%s' is not a valid branch name", arg); 48 48 printf("%s\n", name);
+1 -1
builtin/checkout.c
··· 742 742 &branch->oid, &branch->refname, 0)) 743 743 repo_get_oid_committish(the_repository, branch->name, &branch->oid); 744 744 745 - strbuf_branchname(&buf, branch->name, INTERPRET_BRANCH_LOCAL); 745 + copy_branchname(&buf, branch->name, INTERPRET_BRANCH_LOCAL); 746 746 if (strcmp(buf.buf, branch->name)) { 747 747 free(branch->name); 748 748 branch->name = xstrdup(buf.buf);
+1 -1
builtin/merge.c
··· 498 498 char *found_ref = NULL; 499 499 int len, early; 500 500 501 - strbuf_branchname(&bname, remote, 0); 501 + copy_branchname(&bname, remote, 0); 502 502 remote = bname.buf; 503 503 504 504 oidclr(&branch_head, the_repository->hash_algo);
+1 -1
builtin/tag.c
··· 639 639 if (repo_get_oid(the_repository, object_ref, &object)) 640 640 die(_("Failed to resolve '%s' as a valid ref."), object_ref); 641 641 642 - if (strbuf_check_tag_ref(&ref, tag)) 642 + if (check_tag_ref(&ref, tag)) 643 643 die(_("'%s' is not a valid tag name."), tag); 644 644 645 645 if (refs_read_ref(get_main_ref_store(the_repository), ref.buf, &prev))
+4 -4
builtin/worktree.c
··· 432 432 worktrees = NULL; 433 433 434 434 /* 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) && 436 436 refs_ref_exists(get_main_ref_store(the_repository), symref.buf)) { 437 437 is_branch = 1; 438 438 if (!opts->force) ··· 604 604 fprintf_ln(stderr, _("Preparing worktree (new branch '%s')"), new_branch); 605 605 } else { 606 606 struct strbuf s = STRBUF_INIT; 607 - if (!detach && !strbuf_check_branch_ref(&s, branch) && 607 + if (!detach && !check_branch_ref(&s, branch) && 608 608 refs_ref_exists(get_main_ref_store(the_repository), s.buf)) 609 609 fprintf_ln(stderr, _("Preparing worktree (checking out '%s')"), 610 610 branch); ··· 745 745 char *branchname = xstrndup(s, n); 746 746 struct strbuf ref = STRBUF_INIT; 747 747 748 - branch_exists = !strbuf_check_branch_ref(&ref, branchname) && 748 + branch_exists = !check_branch_ref(&ref, branchname) && 749 749 refs_ref_exists(get_main_ref_store(the_repository), 750 750 ref.buf); 751 751 strbuf_release(&ref); ··· 838 838 new_branch = new_branch_force; 839 839 840 840 if (!opts.force && 841 - !strbuf_check_branch_ref(&symref, new_branch) && 841 + !check_branch_ref(&symref, new_branch) && 842 842 refs_ref_exists(get_main_ref_store(the_repository), symref.buf)) 843 843 die_if_checked_out(symref.buf, 0); 844 844 strbuf_release(&symref);
+1 -1
gitweb/gitweb.perl
··· 2094 2094 ( 2095 2095 # The output of "git describe", e.g. v2.10.0-297-gf6727b0 2096 2096 # 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 - 2098 2098 [A-Za-z0-9.-]+ 2099 2099 (?!\.) # refs can't end with ".", see check_refname_format() 2100 2100 -g$regex
+4 -4
refs.c
··· 697 697 return NULL; 698 698 } 699 699 700 - void strbuf_branchname(struct strbuf *sb, const char *name, unsigned allowed) 700 + void copy_branchname(struct strbuf *sb, const char *name, unsigned allowed) 701 701 { 702 702 int len = strlen(name); 703 703 struct interpret_branch_name_options options = { ··· 711 711 strbuf_add(sb, name + used, len - used); 712 712 } 713 713 714 - int strbuf_check_branch_ref(struct strbuf *sb, const char *name) 714 + int check_branch_ref(struct strbuf *sb, const char *name) 715 715 { 716 716 if (startup_info->have_repository) 717 - strbuf_branchname(sb, name, INTERPRET_BRANCH_LOCAL); 717 + copy_branchname(sb, name, INTERPRET_BRANCH_LOCAL); 718 718 else 719 719 strbuf_addstr(sb, name); 720 720 ··· 733 733 return check_refname_format(sb->buf, 0); 734 734 } 735 735 736 - int strbuf_check_tag_ref(struct strbuf *sb, const char *name) 736 + int check_tag_ref(struct strbuf *sb, const char *name) 737 737 { 738 738 if (name[0] == '-') 739 739 return -1;
+4 -4
refs.h
··· 191 191 * If "allowed" is non-zero, restrict the set of allowed expansions. See 192 192 * repo_interpret_branch_name() for details. 193 193 */ 194 - void strbuf_branchname(struct strbuf *sb, const char *name, 194 + void copy_branchname(struct strbuf *sb, const char *name, 195 195 unsigned allowed); 196 196 197 197 /* 198 - * Like strbuf_branchname() above, but confirm that the result is 198 + * Like copy_branchname() above, but confirm that the result is 199 199 * syntactically valid to be used as a local branch name in refs/heads/. 200 200 * 201 201 * The return value is "0" if the result is valid, and "-1" otherwise. 202 202 */ 203 - int strbuf_check_branch_ref(struct strbuf *sb, const char *name); 203 + int check_branch_ref(struct strbuf *sb, const char *name); 204 204 205 205 /* 206 206 * Similar for a tag name in refs/tags/. 207 207 * 208 208 * The return value is "0" if the result is valid, and "-1" otherwise. 209 209 */ 210 - int strbuf_check_tag_ref(struct strbuf *sb, const char *name); 210 + int check_tag_ref(struct strbuf *sb, const char *name); 211 211 212 212 /* 213 213 * A ref_transaction represents a collection of reference updates that