From a552de75eb01f78046feaf7dc88e5e4833624ad5 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 21 Mar 2009 13:17:30 -0700 Subject: 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 --- strbuf.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'strbuf.c') diff --git a/strbuf.c b/strbuf.c index bfbd81632e..a60b0ad67d 100644 --- a/strbuf.c +++ b/strbuf.c @@ -357,3 +357,12 @@ int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint) return len; } + +int strbuf_branchname(struct strbuf *sb, const char *name) +{ + int len = strlen(name); + if (interpret_branch_name(name, sb) == len) + return 0; + strbuf_add(sb, name, len); + return len; +} -- cgit v1.2.3