зеркало из https://github.com/microsoft/git.git
setup_revisions(): Allow walking history in a submodule
By passing the path to a submodule in opt->submodule, the function can be used to walk history in the named submodule repository, instead of the toplevel repository. Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
0bad611b1e
Коммит
9ef6aeb09f
31
refs.c
31
refs.c
|
@ -721,31 +721,62 @@ int head_ref(each_ref_fn fn, void *cb_data)
|
|||
return do_head_ref(NULL, fn, cb_data);
|
||||
}
|
||||
|
||||
int head_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
return do_head_ref(submodule, fn, cb_data);
|
||||
}
|
||||
|
||||
int for_each_ref(each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
return do_for_each_ref(NULL, "refs/", fn, 0, 0, cb_data);
|
||||
}
|
||||
|
||||
int for_each_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
return do_for_each_ref(submodule, "refs/", fn, 0, 0, cb_data);
|
||||
}
|
||||
|
||||
int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
return do_for_each_ref(NULL, prefix, fn, strlen(prefix), 0, cb_data);
|
||||
}
|
||||
|
||||
int for_each_ref_in_submodule(const char *submodule, const char *prefix,
|
||||
each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
return do_for_each_ref(submodule, prefix, fn, strlen(prefix), 0, cb_data);
|
||||
}
|
||||
|
||||
int for_each_tag_ref(each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
return for_each_ref_in("refs/tags/", fn, cb_data);
|
||||
}
|
||||
|
||||
int for_each_tag_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
return for_each_ref_in_submodule(submodule, "refs/tags/", fn, cb_data);
|
||||
}
|
||||
|
||||
int for_each_branch_ref(each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
return for_each_ref_in("refs/heads/", fn, cb_data);
|
||||
}
|
||||
|
||||
int for_each_branch_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
return for_each_ref_in_submodule(submodule, "refs/heads/", fn, cb_data);
|
||||
}
|
||||
|
||||
int for_each_remote_ref(each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
return for_each_ref_in("refs/remotes/", fn, cb_data);
|
||||
}
|
||||
|
||||
int for_each_remote_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
return for_each_ref_in_submodule(submodule, "refs/remotes/", fn, cb_data);
|
||||
}
|
||||
|
||||
int for_each_replace_ref(each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
return do_for_each_ref(NULL, "refs/replace/", fn, 13, 0, cb_data);
|
||||
|
|
8
refs.h
8
refs.h
|
@ -28,6 +28,14 @@ extern int for_each_replace_ref(each_ref_fn, void *);
|
|||
extern int for_each_glob_ref(each_ref_fn, const char *pattern, void *);
|
||||
extern int for_each_glob_ref_in(each_ref_fn, const char *pattern, const char* prefix, void *);
|
||||
|
||||
extern int head_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data);
|
||||
extern int for_each_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data);
|
||||
extern int for_each_ref_in_submodule(const char *submodule, const char *prefix,
|
||||
each_ref_fn fn, void *cb_data);
|
||||
extern int for_each_tag_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data);
|
||||
extern int for_each_branch_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data);
|
||||
extern int for_each_remote_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data);
|
||||
|
||||
static inline const char *has_glob_specials(const char *pattern)
|
||||
{
|
||||
return strpbrk(pattern, "?*[");
|
||||
|
|
32
revision.c
32
revision.c
|
@ -820,12 +820,12 @@ static void init_all_refs_cb(struct all_refs_cb *cb, struct rev_info *revs,
|
|||
cb->all_flags = flags;
|
||||
}
|
||||
|
||||
static void handle_refs(struct rev_info *revs, unsigned flags,
|
||||
int (*for_each)(each_ref_fn, void *))
|
||||
static void handle_refs(const char *submodule, struct rev_info *revs, unsigned flags,
|
||||
int (*for_each)(const char *, each_ref_fn, void *))
|
||||
{
|
||||
struct all_refs_cb cb;
|
||||
init_all_refs_cb(&cb, revs, flags);
|
||||
for_each(handle_one_ref, &cb);
|
||||
for_each(submodule, handle_one_ref, &cb);
|
||||
}
|
||||
|
||||
static void handle_one_reflog_commit(unsigned char *sha1, void *cb_data)
|
||||
|
@ -1417,14 +1417,14 @@ void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
|
|||
ctx->argc -= n;
|
||||
}
|
||||
|
||||
static int for_each_bad_bisect_ref(each_ref_fn fn, void *cb_data)
|
||||
static int for_each_bad_bisect_ref(const char *submodule, each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
return for_each_ref_in("refs/bisect/bad", fn, cb_data);
|
||||
return for_each_ref_in_submodule(submodule, "refs/bisect/bad", fn, cb_data);
|
||||
}
|
||||
|
||||
static int for_each_good_bisect_ref(each_ref_fn fn, void *cb_data)
|
||||
static int for_each_good_bisect_ref(const char *submodule, each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
return for_each_ref_in("refs/bisect/good", fn, cb_data);
|
||||
return for_each_ref_in_submodule(submodule, "refs/bisect/good", fn, cb_data);
|
||||
}
|
||||
|
||||
static void append_prune_data(const char ***prune_data, const char **av)
|
||||
|
@ -1466,6 +1466,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
|
|||
{
|
||||
int i, flags, left, seen_dashdash, read_from_stdin, got_rev_arg = 0;
|
||||
const char **prune_data = NULL;
|
||||
const char *submodule = NULL;
|
||||
|
||||
if (opt)
|
||||
submodule = opt->submodule;
|
||||
|
||||
/* First, search for "--" */
|
||||
seen_dashdash = 0;
|
||||
|
@ -1490,26 +1494,26 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
|
|||
int opts;
|
||||
|
||||
if (!strcmp(arg, "--all")) {
|
||||
handle_refs(revs, flags, for_each_ref);
|
||||
handle_refs(revs, flags, head_ref);
|
||||
handle_refs(submodule, revs, flags, for_each_ref_submodule);
|
||||
handle_refs(submodule, revs, flags, head_ref_submodule);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "--branches")) {
|
||||
handle_refs(revs, flags, for_each_branch_ref);
|
||||
handle_refs(submodule, revs, flags, for_each_branch_ref_submodule);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "--bisect")) {
|
||||
handle_refs(revs, flags, for_each_bad_bisect_ref);
|
||||
handle_refs(revs, flags ^ UNINTERESTING, for_each_good_bisect_ref);
|
||||
handle_refs(submodule, revs, flags, for_each_bad_bisect_ref);
|
||||
handle_refs(submodule, revs, flags ^ UNINTERESTING, for_each_good_bisect_ref);
|
||||
revs->bisect = 1;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "--tags")) {
|
||||
handle_refs(revs, flags, for_each_tag_ref);
|
||||
handle_refs(submodule, revs, flags, for_each_tag_ref_submodule);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "--remotes")) {
|
||||
handle_refs(revs, flags, for_each_remote_ref);
|
||||
handle_refs(submodule, revs, flags, for_each_remote_ref_submodule);
|
||||
continue;
|
||||
}
|
||||
if (!prefixcmp(arg, "--glob=")) {
|
||||
|
|
|
@ -151,6 +151,7 @@ extern volatile show_early_output_fn_t show_early_output;
|
|||
struct setup_revision_opt {
|
||||
const char *def;
|
||||
void (*tweak)(struct rev_info *, struct setup_revision_opt *);
|
||||
const char *submodule;
|
||||
};
|
||||
|
||||
extern void init_revisions(struct rev_info *revs, const char *prefix);
|
||||
|
|
Загрузка…
Ссылка в новой задаче