summaryrefslogtreecommitdiff
path: root/strbuf.h
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-03-14 15:23:18 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-03-14 15:23:18 -0700
commitc809496c97122b7d297e7216c3bfff7262b212e0 (patch)
tree7fc616a9cc1233b41e63ef259d6792e0e074f5f4 /strbuf.h
parentMerge branch 'ab/cond-skip-tests' (diff)
parentcheckout: restrict @-expansions when finding branch (diff)
downloadtgif-c809496c97122b7d297e7216c3bfff7262b212e0.tar.xz
Merge branch 'jk/interpret-branch-name'
"git branch @" created refs/heads/@ as a branch, and in general the code that handled @{-1} and @{upstream} was a bit too loose in disambiguating. * jk/interpret-branch-name: checkout: restrict @-expansions when finding branch strbuf_check_ref_format(): expand only local branches branch: restrict @-expansions when deleting t3204: test git-branch @-expansion corner cases interpret_branch_name: allow callers to restrict expansions strbuf_branchname: add docstring strbuf_branchname: drop return value interpret_branch_name: move docstring to header file interpret_branch_name(): handle auto-namelen for @{-1}
Diffstat (limited to 'strbuf.h')
-rw-r--r--strbuf.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/strbuf.h b/strbuf.h
index cf8e4bf532..80047b1bb7 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -574,7 +574,26 @@ static inline void strbuf_complete_line(struct strbuf *sb)
strbuf_complete(sb, '\n');
}
-extern int strbuf_branchname(struct strbuf *sb, const char *name);
+/*
+ * Copy "name" to "sb", expanding any special @-marks as handled by
+ * interpret_branch_name(). The result is a non-qualified branch name
+ * (so "foo" or "origin/master" instead of "refs/heads/foo" or
+ * "refs/remotes/origin/master").
+ *
+ * Note that the resulting name may not be a syntactically valid refname.
+ *
+ * If "allowed" is non-zero, restrict the set of allowed expansions. See
+ * interpret_branch_name() for details.
+ */
+extern void strbuf_branchname(struct strbuf *sb, const char *name,
+ unsigned allowed);
+
+/*
+ * Like strbuf_branchname() above, but confirm that the result is
+ * syntactically valid to be used as a local branch name in refs/heads/.
+ *
+ * The return value is "0" if the result is valid, and "-1" otherwise.
+ */
extern int strbuf_check_branch_ref(struct strbuf *sb, const char *name);
extern void strbuf_addstr_urlencode(struct strbuf *, const char *,