summaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2021-09-09 18:47:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-09-09 21:09:30 (GMT)
commit10a0d6ae64ad4fec12ab2c1ed13d1791dde60371 (patch)
tree77babd696d3936864bdb6d5e4f1849926438a478 /revision.c
parent8eb8dcf94643ca6e7c3f040f3e0bf96e11c7ae47 (diff)
downloadgit-10a0d6ae64ad4fec12ab2c1ed13d1791dde60371.zip
git-10a0d6ae64ad4fec12ab2c1ed13d1791dde60371.tar.gz
git-10a0d6ae64ad4fec12ab2c1ed13d1791dde60371.tar.bz2
revision: remove "submodule" from opt struct
Clean up a TODO in revision.h by removing the "submodule" field from struct setup_revision_opt. This field is only used to specify the ref store to use, so use rev_info->repo to determine the ref store instead. The only users of this field are merge-ort.c and merge-recursive.c. However, both these files specify the superproject as rev_info->repo and the submodule as setup_revision_opt->submodule. In order to be able to pass the submodule as rev_info->repo, all commits must be parsed with the submodule explicitly specified; this patch does that as well. (An incremental solution in which only some commits are parsed with explicit submodule will not work, because if the same commit is parsed twice in different repositories, there will be 2 heap-allocated object structs corresponding to that commit, and any flag set by the revision walking mechanism on one of them will not be reflected onto the other.) Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/revision.c b/revision.c
index cddd054..31fc188 100644
--- a/revision.c
+++ b/revision.c
@@ -2561,8 +2561,7 @@ static int for_each_good_bisect_ref(struct ref_store *refs, each_ref_fn fn, void
return for_each_bisect_ref(refs, fn, cb_data, term_good);
}
-static int handle_revision_pseudo_opt(const char *submodule,
- struct rev_info *revs,
+static int handle_revision_pseudo_opt(struct rev_info *revs,
const char **argv, int *flags)
{
const char *arg = argv[0];
@@ -2570,7 +2569,7 @@ static int handle_revision_pseudo_opt(const char *submodule,
struct ref_store *refs;
int argcount;
- if (submodule) {
+ if (revs->repo != the_repository) {
/*
* We need some something like get_submodule_worktrees()
* before we can go through all worktrees of a submodule,
@@ -2579,9 +2578,8 @@ static int handle_revision_pseudo_opt(const char *submodule,
*/
if (!revs->single_worktree)
BUG("--single-worktree cannot be used together with submodule");
- refs = get_submodule_ref_store(submodule);
- } else
- refs = get_main_ref_store(revs->repo);
+ }
+ refs = get_main_ref_store(revs->repo);
/*
* NOTE!
@@ -2699,12 +2697,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
{
int i, flags, left, seen_dashdash, revarg_opt;
struct strvec prune_data = STRVEC_INIT;
- const char *submodule = NULL;
int seen_end_of_options = 0;
- if (opt)
- submodule = opt->submodule;
-
/* First, search for "--" */
if (opt && opt->assume_dashdash) {
seen_dashdash = 1;
@@ -2733,7 +2727,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
if (!seen_end_of_options && *arg == '-') {
int opts;
- opts = handle_revision_pseudo_opt(submodule,
+ opts = handle_revision_pseudo_opt(
revs, argv + i,
&flags);
if (opts > 0) {