refs.c: remove the_repo from substitute_branch_name()

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Apr 6, 2019 at 18:34 UTC 8f56e9d4baa836a4a3cd56767457d6122de7ce1d
3 files changed +17 -8
cache.h
+6 -2
@@ -1468,8 +1468,12 @@ extern int parse_oid_hex(const char *hex, struct object_id *oid, const char **en
1468 #define INTERPRET_BRANCH_LOCAL (1<<0)
1469 #define INTERPRET_BRANCH_REMOTE (1<<1)
1470 #define INTERPRET_BRANCH_HEAD (1<<2)
1471 -extern int interpret_branch_name(const char *str, int len, struct strbuf *,
1472 - unsigned allowed);
1471 +int repo_interpret_branch_name(struct repository *r,
1472 + const char *str, int len,
1473 + struct strbuf *buf,
1474 + unsigned allowed);
1475 +#define interpret_branch_name(str, len, buf, allowed) \
1476 + repo_interpret_branch_name(the_repository, str, len, buf, allowed)
1477 extern int get_oid_mb(const char *str, struct object_id *oid);
1478
1479 extern int validate_headref(const char *ref);
refs.c
+5 -4
@@ -539,10 +539,11 @@ void expand_ref_prefix(struct argv_array *prefixes, const char *prefix)
539 * later free()ing) if the string passed in is a magic short-hand form
540 * to name a branch.
541 */
542 -static char *substitute_branch_name(const char **string, int *len)
542 +static char *substitute_branch_name(struct repository *r,
543 + const char **string, int *len)
544 {
545 struct strbuf buf = STRBUF_INIT;
545 - int ret = interpret_branch_name(*string, *len, &buf, 0);
546 + int ret = repo_interpret_branch_name(r, *string, *len, &buf, 0);
547
548 if (ret == *len) {
549 size_t size;
@@ -556,7 +557,7 @@ static char *substitute_branch_name(const char **string, int *len)
557
558 int dwim_ref(const char *str, int len, struct object_id *oid, char **ref)
559 {
559 - char *last_branch = substitute_branch_name(&str, &len);
560 + char *last_branch = substitute_branch_name(the_repository, &str, &len);
561 int refs_found = expand_ref(str, len, oid, ref);
562 free(last_branch);
563 return refs_found;
@@ -596,7 +597,7 @@ int expand_ref(const char *str, int len, struct object_id *oid, char **ref)
597
598 int dwim_log(const char *str, int len, struct object_id *oid, char **log)
599 {
599 - char *last_branch = substitute_branch_name(&str, &len);
600 + char *last_branch = substitute_branch_name(the_repository, &str, &len);
601 const char **p;
602 int logs_found = 0;
603 struct strbuf path = STRBUF_INIT;
sha1-name.c
+6 -2
@@ -1427,13 +1427,17 @@ static int interpret_branch_mark(const char *name, int namelen,
1427 return len + at;
1428 }
1429
1430 -int interpret_branch_name(const char *name, int namelen, struct strbuf *buf,
1431 - unsigned allowed)
1430 +int repo_interpret_branch_name(struct repository *r,
1431 + const char *name, int namelen,
1432 + struct strbuf *buf,
1433 + unsigned allowed)
1434 {
1435 char *at;
1436 const char *start;
1437 int len;
1438
1439 + if (r != the_repository)
1440 + BUG("interpret_branch_name() does not really use 'r' yet");
1441 if (!namelen)
1442 namelen = strlen(name);
1443