aboutsummaryrefslogtreecommitdiff
path: root/branch.c
diff options
context:
space:
mode:
Diffstat (limited to 'branch.c')
-rw-r--r--branch.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/branch.c b/branch.c
index 37ac55532..9a2228ebb 100644
--- a/branch.c
+++ b/branch.c
@@ -50,11 +50,11 @@ static int should_setup_rebase(const char *origin)
void install_branch_config(int flag, const char *local, const char *origin, const char *remote)
{
- const char *shortname = skip_prefix(remote, "refs/heads/");
+ const char *shortname = NULL;
struct strbuf key = STRBUF_INIT;
int rebasing = should_setup_rebase(origin);
- if (shortname
+ if (skip_prefix(remote, "refs/heads/", &shortname)
&& !strcmp(local, shortname)
&& !origin) {
warning(_("Not setting branch %s as its own upstream."),
@@ -140,33 +140,17 @@ static int setup_tracking(const char *new_ref, const char *orig_ref,
return 0;
}
-struct branch_desc_cb {
- const char *config_name;
- const char *value;
-};
-
-static int read_branch_desc_cb(const char *var, const char *value, void *cb)
-{
- struct branch_desc_cb *desc = cb;
- if (strcmp(desc->config_name, var))
- return 0;
- free((char *)desc->value);
- return git_config_string(&desc->value, var, value);
-}
-
int read_branch_desc(struct strbuf *buf, const char *branch_name)
{
- struct branch_desc_cb cb;
+ char *v = NULL;
struct strbuf name = STRBUF_INIT;
strbuf_addf(&name, "branch.%s.description", branch_name);
- cb.config_name = name.buf;
- cb.value = NULL;
- if (git_config(read_branch_desc_cb, &cb) < 0) {
+ if (git_config_get_string(name.buf, &v)) {
strbuf_release(&name);
return -1;
}
- if (cb.value)
- strbuf_addstr(buf, cb.value);
+ strbuf_addstr(buf, v);
+ free(v);
strbuf_release(&name);
return 0;
}