is_refname_available(): convert local variable "dirname" to strbuf
This change wouldn't be worth it by itself, but in a moment we will use the strbuf for more string juggling. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>maint
parent
9ef6eaa287
commit
6075f3076e
12
refs.c
12
refs.c
|
@ -887,9 +887,8 @@ static int is_refname_available(const char *refname,
|
||||||
struct ref_dir *dir)
|
struct ref_dir *dir)
|
||||||
{
|
{
|
||||||
const char *slash;
|
const char *slash;
|
||||||
size_t len;
|
|
||||||
int pos;
|
int pos;
|
||||||
char *dirname;
|
struct strbuf dirname = STRBUF_INIT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For the sake of comments in this function, suppose that
|
* For the sake of comments in this function, suppose that
|
||||||
|
@ -955,11 +954,10 @@ static int is_refname_available(const char *refname,
|
||||||
* names are in the "refs/foo/bar/" namespace, because they
|
* names are in the "refs/foo/bar/" namespace, because they
|
||||||
* *do* conflict.
|
* *do* conflict.
|
||||||
*/
|
*/
|
||||||
len = strlen(refname);
|
strbuf_addstr(&dirname, refname);
|
||||||
dirname = xmallocz(len + 1);
|
strbuf_addch(&dirname, '/');
|
||||||
sprintf(dirname, "%s/", refname);
|
pos = search_ref_dir(dir, dirname.buf, dirname.len);
|
||||||
pos = search_ref_dir(dir, dirname, len + 1);
|
strbuf_release(&dirname);
|
||||||
free(dirname);
|
|
||||||
|
|
||||||
if (pos >= 0) {
|
if (pos >= 0) {
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue