strbuf_branchname(): a wrapper for branch name shorthands
The function takes a user-supplied string that is supposed to be a branch name, and puts it in a strbuf after expanding possible shorthand notation. A handful of open coded sequence to do this in the existing code have been changed to use this helper function. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
7
branch.c
7
branch.c
@ -134,13 +134,8 @@ void create_branch(const char *head,
|
||||
char *real_ref, msg[PATH_MAX + 20];
|
||||
struct strbuf ref = STRBUF_INIT;
|
||||
int forcing = 0;
|
||||
int len;
|
||||
|
||||
len = strlen(name);
|
||||
if (interpret_branch_name(name, &ref) != len) {
|
||||
strbuf_reset(&ref);
|
||||
strbuf_add(&ref, name, len);
|
||||
}
|
||||
strbuf_branchname(&ref, name);
|
||||
strbuf_splice(&ref, 0, 0, "refs/heads/", 11);
|
||||
|
||||
if (check_ref_format(ref.buf))
|
||||
|
Reference in New Issue
Block a user