refs.c: add repo_dwim_log()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
d8984c532a
commit
567009033f
21
refs.c
21
refs.c
@ -603,9 +603,11 @@ int expand_ref(struct repository *repo, const char *str, int len,
|
|||||||
return refs_found;
|
return refs_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dwim_log(const char *str, int len, struct object_id *oid, char **log)
|
int repo_dwim_log(struct repository *r, const char *str, int len,
|
||||||
|
struct object_id *oid, char **log)
|
||||||
{
|
{
|
||||||
char *last_branch = substitute_branch_name(the_repository, &str, &len);
|
struct ref_store *refs = get_main_ref_store(r);
|
||||||
|
char *last_branch = substitute_branch_name(r, &str, &len);
|
||||||
const char **p;
|
const char **p;
|
||||||
int logs_found = 0;
|
int logs_found = 0;
|
||||||
struct strbuf path = STRBUF_INIT;
|
struct strbuf path = STRBUF_INIT;
|
||||||
@ -617,13 +619,15 @@ int dwim_log(const char *str, int len, struct object_id *oid, char **log)
|
|||||||
|
|
||||||
strbuf_reset(&path);
|
strbuf_reset(&path);
|
||||||
strbuf_addf(&path, *p, len, str);
|
strbuf_addf(&path, *p, len, str);
|
||||||
ref = resolve_ref_unsafe(path.buf, RESOLVE_REF_READING,
|
ref = refs_resolve_ref_unsafe(refs, path.buf,
|
||||||
&hash, NULL);
|
RESOLVE_REF_READING,
|
||||||
|
&hash, NULL);
|
||||||
if (!ref)
|
if (!ref)
|
||||||
continue;
|
continue;
|
||||||
if (reflog_exists(path.buf))
|
if (refs_reflog_exists(refs, path.buf))
|
||||||
it = path.buf;
|
it = path.buf;
|
||||||
else if (strcmp(ref, path.buf) && reflog_exists(ref))
|
else if (strcmp(ref, path.buf) &&
|
||||||
|
refs_reflog_exists(refs, ref))
|
||||||
it = ref;
|
it = ref;
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
@ -639,6 +643,11 @@ int dwim_log(const char *str, int len, struct object_id *oid, char **log)
|
|||||||
return logs_found;
|
return logs_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dwim_log(const char *str, int len, struct object_id *oid, char **log)
|
||||||
|
{
|
||||||
|
return repo_dwim_log(the_repository, str, len, oid, log);
|
||||||
|
}
|
||||||
|
|
||||||
static int is_per_worktree_ref(const char *refname)
|
static int is_per_worktree_ref(const char *refname)
|
||||||
{
|
{
|
||||||
return !strcmp(refname, "HEAD") ||
|
return !strcmp(refname, "HEAD") ||
|
||||||
|
1
refs.h
1
refs.h
@ -150,6 +150,7 @@ void expand_ref_prefix(struct argv_array *prefixes, const char *prefix);
|
|||||||
|
|
||||||
int expand_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref);
|
int expand_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref);
|
||||||
int repo_dwim_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref);
|
int repo_dwim_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref);
|
||||||
|
int repo_dwim_log(struct repository *r, const char *str, int len, struct object_id *oid, char **ref);
|
||||||
int dwim_ref(const char *str, int len, struct object_id *oid, char **ref);
|
int dwim_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 **ref);
|
int dwim_log(const char *str, int len, struct object_id *oid, char **ref);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user