#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);
* 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;
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;
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;
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);