summaryrefslogtreecommitdiff
path: root/branch.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-12-09 13:37:05 -0800
committerJunio C Hamano <gitster@pobox.com>2011-12-09 13:37:05 -0800
commita4043aeafed7962716a513e38ca1d5e192e7e831 (patch)
treee48b94c2e8073ad86e2e8e0801766e217e0397b1 /branch.c
parent1ee740e66975adbab080301ebd364e253be3d513 (diff)
parentd050464541d51ab65863218d93b351de3392f476 (diff)
downloadgit-a4043aeafed7962716a513e38ca1d5e192e7e831.tar.gz
Merge branch 'jc/request-pull-show-head-4'
* jc/request-pull-show-head-4: request-pull: use the annotated tag contents fmt-merge-msg.c: Fix an "dubious one-bit signed bitfield" sparse error environment.c: Fix an sparse "symbol not declared" warning builtin/log.c: Fix an "Using plain integer as NULL pointer" warning fmt-merge-msg: use branch.$name.description request-pull: use the branch description request-pull: state what commit to expect request-pull: modernize style branch: teach --edit-description option format-patch: use branch description in cover letter branch: add read_branch_desc() helper function Conflicts: builtin/branch.c
Diffstat (limited to 'branch.c')
-rw-r--r--branch.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/branch.c b/branch.c
index 025a97be02..d91a099fdd 100644
--- a/branch.c
+++ b/branch.c
@@ -136,6 +136,37 @@ 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;
+ 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) {
+ strbuf_release(&name);
+ return -1;
+ }
+ if (cb.value)
+ strbuf_addstr(buf, cb.value);
+ strbuf_release(&name);
+ return 0;
+}
+
int validate_new_branchname(const char *name, struct strbuf *ref,
int force, int attr_only)
{