Merge branch 'ps/reflog-list' into HEAD
"git reflog" learned a "list" subcommand that enumerates known reflogs. * ps/reflog-list: builtin/reflog: introduce subcommand to list reflogs refs: stop resolving ref corresponding to reflogs refs: drop unused params from the reflog iterator callback refs: always treat iterators as ordered refs/files: sort merged worktree and common reflogs refs/files: sort reflogs returned by the reflog iterator dir-iterator: support iteration in sorted order dir-iterator: pass name to `prepare_next_entry_data()` directly
This commit is contained in:
@ -7,11 +7,15 @@
|
||||
#include "wildmatch.h"
|
||||
#include "worktree.h"
|
||||
#include "reflog.h"
|
||||
#include "refs.h"
|
||||
#include "parse-options.h"
|
||||
|
||||
#define BUILTIN_REFLOG_SHOW_USAGE \
|
||||
N_("git reflog [show] [<log-options>] [<ref>]")
|
||||
|
||||
#define BUILTIN_REFLOG_LIST_USAGE \
|
||||
N_("git reflog list")
|
||||
|
||||
#define BUILTIN_REFLOG_EXPIRE_USAGE \
|
||||
N_("git reflog expire [--expire=<time>] [--expire-unreachable=<time>]\n" \
|
||||
" [--rewrite] [--updateref] [--stale-fix]\n" \
|
||||
@ -29,6 +33,11 @@ static const char *const reflog_show_usage[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const char *const reflog_list_usage[] = {
|
||||
BUILTIN_REFLOG_LIST_USAGE,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const char *const reflog_expire_usage[] = {
|
||||
BUILTIN_REFLOG_EXPIRE_USAGE,
|
||||
NULL
|
||||
@ -46,6 +55,7 @@ static const char *const reflog_exists_usage[] = {
|
||||
|
||||
static const char *const reflog_usage[] = {
|
||||
BUILTIN_REFLOG_SHOW_USAGE,
|
||||
BUILTIN_REFLOG_LIST_USAGE,
|
||||
BUILTIN_REFLOG_EXPIRE_USAGE,
|
||||
BUILTIN_REFLOG_DELETE_USAGE,
|
||||
BUILTIN_REFLOG_EXISTS_USAGE,
|
||||
@ -60,8 +70,7 @@ struct worktree_reflogs {
|
||||
struct string_list reflogs;
|
||||
};
|
||||
|
||||
static int collect_reflog(const char *ref, const struct object_id *oid UNUSED,
|
||||
int flags UNUSED, void *cb_data)
|
||||
static int collect_reflog(const char *ref, void *cb_data)
|
||||
{
|
||||
struct worktree_reflogs *cb = cb_data;
|
||||
struct worktree *worktree = cb->worktree;
|
||||
@ -238,6 +247,29 @@ static int cmd_reflog_show(int argc, const char **argv, const char *prefix)
|
||||
return cmd_log_reflog(argc, argv, prefix);
|
||||
}
|
||||
|
||||
static int show_reflog(const char *refname, void *cb_data UNUSED)
|
||||
{
|
||||
printf("%s\n", refname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_reflog_list(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
struct option options[] = {
|
||||
OPT_END()
|
||||
};
|
||||
struct ref_store *ref_store;
|
||||
|
||||
argc = parse_options(argc, argv, prefix, options, reflog_list_usage, 0);
|
||||
if (argc)
|
||||
return error(_("%s does not accept arguments: '%s'"),
|
||||
"list", argv[0]);
|
||||
|
||||
ref_store = get_main_ref_store(the_repository);
|
||||
|
||||
return refs_for_each_reflog(ref_store, show_reflog, NULL);
|
||||
}
|
||||
|
||||
static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
struct cmd_reflog_expire_cb cmd = { 0 };
|
||||
@ -417,6 +449,7 @@ int cmd_reflog(int argc, const char **argv, const char *prefix)
|
||||
parse_opt_subcommand_fn *fn = NULL;
|
||||
struct option options[] = {
|
||||
OPT_SUBCOMMAND("show", &fn, cmd_reflog_show),
|
||||
OPT_SUBCOMMAND("list", &fn, cmd_reflog_list),
|
||||
OPT_SUBCOMMAND("expire", &fn, cmd_reflog_expire),
|
||||
OPT_SUBCOMMAND("delete", &fn, cmd_reflog_delete),
|
||||
OPT_SUBCOMMAND("exists", &fn, cmd_reflog_exists),
|
||||
|
Reference in New Issue
Block a user