strbuf: move strbuf_branchname to sha1_name.c
strbuf_branchname is a thin wrapper around interpret_branch_name from sha1_name.o. Most strbuf.o users do not need it. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Nieder committed
Nov 6, 2010 at 06:46 UTC
6bab74e7fb89b7427e5ef24b48a07fe9450c40e7
2 files changed
+18
-18
sha1_name.c
+18
@@ -934,6 +934,24 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
934
return len;
935
}
936
937
+int strbuf_branchname(struct strbuf *sb, const char *name)
938
+{
939
+ int len = strlen(name);
940
+ if (interpret_branch_name(name, sb) == len)
941
+ return 0;
942
+ strbuf_add(sb, name, len);
943
+ return len;
944
+}
945
+
946
+int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
947
+{
948
+ strbuf_branchname(sb, name);
949
+ if (name[0] == '-')
950
+ return CHECK_REF_FORMAT_ERROR;
951
+ strbuf_splice(sb, 0, 0, "refs/heads/", 11);
952
+ return check_ref_format(sb->buf);
953
+}
954
+
955
/*
956
* This is like "get_sha1_basic()", except it allows "sha1 expressions",
957
* notably "xyz^" for "parent of xyz"
strbuf.c
-18
@@ -386,21 +386,3 @@ int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint)
386
387
return len;
388
}
389
-
390
-int strbuf_branchname(struct strbuf *sb, const char *name)
391
-{
392
- int len = strlen(name);
393
- if (interpret_branch_name(name, sb) == len)
394
- return 0;
395
- strbuf_add(sb, name, len);
396
- return len;
397
-}
398
-
399
-int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
400
-{
401
- strbuf_branchname(sb, name);
402
- if (name[0] == '-')
403
- return CHECK_REF_FORMAT_ERROR;
404
- strbuf_splice(sb, 0, 0, "refs/heads/", 11);
405
- return check_ref_format(sb->buf);
406
-}