]> granicus.if.org Git - git/commitdiff
refs.c: remove the_repo from substitute_branch_name()
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 6 Apr 2019 11:34:26 +0000 (18:34 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 Apr 2019 08:26:32 +0000 (17:26 +0900)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
refs.c
sha1-name.c

diff --git a/cache.h b/cache.h
index ac92421f3a8bc814da3f01731f2d8d8a52dc8364..fcb24b5781c6bc8232613f191e5ce40481828d90 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1468,8 +1468,12 @@ extern int parse_oid_hex(const char *hex, struct object_id *oid, const char **en
 #define INTERPRET_BRANCH_LOCAL (1<<0)
 #define INTERPRET_BRANCH_REMOTE (1<<1)
 #define INTERPRET_BRANCH_HEAD (1<<2)
-extern int interpret_branch_name(const char *str, int len, struct strbuf *,
-                                unsigned allowed);
+int repo_interpret_branch_name(struct repository *r,
+                              const char *str, int len,
+                              struct strbuf *buf,
+                              unsigned allowed);
+#define interpret_branch_name(str, len, buf, allowed) \
+       repo_interpret_branch_name(the_repository, str, len, buf, allowed)
 extern int get_oid_mb(const char *str, struct object_id *oid);
 
 extern int validate_headref(const char *ref);
diff --git a/refs.c b/refs.c
index 3dde824aab6eaba3440b851fdf1f9a4d817c763f..44df0497965ba296d26c58db59fb36ebf1012ab4 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -539,10 +539,11 @@ void expand_ref_prefix(struct argv_array *prefixes, const char *prefix)
  * later free()ing) if the string passed in is a magic short-hand form
  * to name a branch.
  */
-static char *substitute_branch_name(const char **string, int *len)
+static char *substitute_branch_name(struct repository *r,
+                                   const char **string, int *len)
 {
        struct strbuf buf = STRBUF_INIT;
-       int ret = interpret_branch_name(*string, *len, &buf, 0);
+       int ret = repo_interpret_branch_name(r, *string, *len, &buf, 0);
 
        if (ret == *len) {
                size_t size;
@@ -556,7 +557,7 @@ static char *substitute_branch_name(const char **string, int *len)
 
 int dwim_ref(const char *str, int len, struct object_id *oid, char **ref)
 {
-       char *last_branch = substitute_branch_name(&str, &len);
+       char *last_branch = substitute_branch_name(the_repository, &str, &len);
        int   refs_found  = expand_ref(str, len, oid, ref);
        free(last_branch);
        return refs_found;
@@ -596,7 +597,7 @@ int expand_ref(const char *str, int len, struct object_id *oid, char **ref)
 
 int dwim_log(const char *str, int len, struct object_id *oid, char **log)
 {
-       char *last_branch = substitute_branch_name(&str, &len);
+       char *last_branch = substitute_branch_name(the_repository, &str, &len);
        const char **p;
        int logs_found = 0;
        struct strbuf path = STRBUF_INIT;
index 6dda2c16df1026e50b7d9be255b6bbfc4e92725c..d535bb82f7be8e46b9a76b309322b3cc49981cc5 100644 (file)
@@ -1427,13 +1427,17 @@ static int interpret_branch_mark(const char *name, int namelen,
        return len + at;
 }
 
-int interpret_branch_name(const char *name, int namelen, struct strbuf *buf,
-                         unsigned allowed)
+int repo_interpret_branch_name(struct repository *r,
+                              const char *name, int namelen,
+                              struct strbuf *buf,
+                              unsigned allowed)
 {
        char *at;
        const char *start;
        int len;
 
+       if (r != the_repository)
+               BUG("interpret_branch_name() does not really use 'r' yet");
        if (!namelen)
                namelen = strlen(name);