summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-12-03 16:13:06 -0800
committerJunio C Hamano <gitster@pobox.com>2010-12-03 16:13:06 -0800
commit39f04dbaacbb21864547c8cf087697469666d21e (patch)
tree260c02b84f44d35e91284e4771ff238c26805830 /sha1_name.c
parent9bec60d3a52fa10b276214f8d255d6ff05a04b77 (diff)
parente0500293852910c2f44fce61e7eb856adbc20d8a (diff)
downloadgit-39f04dbaacbb21864547c8cf087697469666d21e.tar.gz
Merge branch 'jn/thinner-wrapper'
* jn/thinner-wrapper: Remove pack file handling dependency from wrapper.o pack-objects: mark file-local variable static wrapper: give zlib wrappers their own translation unit strbuf: move strbuf_branchname to sha1_name.c path helpers: move git_mkstemp* to wrapper.c wrapper: move odb_* to environment.c wrapper: move xmmap() to sha1_file.c
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/sha1_name.c b/sha1_name.c
index b48b91c507..2c3a5fb363 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -936,6 +936,24 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
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;
+}
+
+int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
+{
+ strbuf_branchname(sb, name);
+ if (name[0] == '-')
+ return CHECK_REF_FORMAT_ERROR;
+ strbuf_splice(sb, 0, 0, "refs/heads/", 11);
+ return check_ref_format(sb->buf);
+}
+
/*
* This is like "get_sha1_basic()", except it allows "sha1 expressions",
* notably "xyz^" for "parent of xyz"