diff options
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 109 |
1 files changed, 68 insertions, 41 deletions
diff --git a/revision.c b/revision.c index b33cc1d106..0ae1c76db3 100644 --- a/revision.c +++ b/revision.c @@ -1,12 +1,11 @@ -#include "cache.h" -#include "alloc.h" +#include "git-compat-util.h" #include "config.h" #include "environment.h" #include "gettext.h" #include "hex.h" #include "object-name.h" #include "object-file.h" -#include "object-store.h" +#include "object-store-ll.h" #include "tag.h" #include "blob.h" #include "tree.h" @@ -31,7 +30,9 @@ #include "bisect.h" #include "packfile.h" #include "worktree.h" +#include "read-cache.h" #include "setup.h" +#include "sparse-index.h" #include "strvec.h" #include "trace2.h" #include "commit-reach.h" @@ -44,6 +45,7 @@ #include "list-objects-filter-options.h" #include "resolve-undo.h" #include "parse-options.h" +#include "wildmatch.h" volatile show_early_output_fn_t show_early_output; @@ -1558,7 +1560,7 @@ void init_ref_exclusions(struct ref_exclusions *exclusions) void clear_ref_exclusions(struct ref_exclusions *exclusions) { string_list_clear(&exclusions->excluded_refs, 0); - string_list_clear(&exclusions->hidden_refs, 0); + strvec_clear(&exclusions->hidden_refs); exclusions->hidden_refs_configured = 0; } @@ -1572,7 +1574,9 @@ struct exclude_hidden_refs_cb { const char *section; }; -static int hide_refs_config(const char *var, const char *value, void *cb_data) +static int hide_refs_config(const char *var, const char *value, + const struct config_context *ctx UNUSED, + void *cb_data) { struct exclude_hidden_refs_cb *cb = cb_data; cb->exclusions->hidden_refs_configured = 1; @@ -2195,39 +2199,6 @@ static void read_pathspec_from_stdin(struct strbuf *sb, strvec_push(prune, sb->buf); } -static void read_revisions_from_stdin(struct rev_info *revs, - struct strvec *prune) -{ - struct strbuf sb; - int seen_dashdash = 0; - int save_warning; - - save_warning = warn_on_object_refname_ambiguity; - warn_on_object_refname_ambiguity = 0; - - strbuf_init(&sb, 1000); - while (strbuf_getline(&sb, stdin) != EOF) { - int len = sb.len; - if (!len) - break; - if (sb.buf[0] == '-') { - if (len == 2 && sb.buf[1] == '-') { - seen_dashdash = 1; - break; - } - die("options not supported in --stdin mode"); - } - if (handle_revision_arg(sb.buf, revs, 0, - REVARG_CANNOT_BE_FILENAME)) - die("bad revision '%s'", sb.buf); - } - if (seen_dashdash) - read_pathspec_from_stdin(&sb, prune); - - strbuf_release(&sb); - warn_on_object_refname_ambiguity = save_warning; -} - static void add_grep(struct rev_info *revs, const char *ptn, enum grep_pat_token what) { append_grep_pattern(&revs->grep_filter, ptn, "command line", 0, what); @@ -2670,7 +2641,7 @@ static int for_each_bisect_ref(struct ref_store *refs, each_ref_fn fn, struct strbuf bisect_refs = STRBUF_INIT; int status; strbuf_addf(&bisect_refs, "refs/bisect/%s", term); - status = refs_for_each_fullref_in(refs, bisect_refs.buf, fn, cb_data); + status = refs_for_each_fullref_in(refs, bisect_refs.buf, NULL, fn, cb_data); strbuf_release(&bisect_refs); return status; } @@ -2816,6 +2787,53 @@ static int handle_revision_pseudo_opt(struct rev_info *revs, return 1; } +static void read_revisions_from_stdin(struct rev_info *revs, + struct strvec *prune, + int *flags) +{ + struct strbuf sb; + int seen_dashdash = 0; + int seen_end_of_options = 0; + int save_warning; + + save_warning = warn_on_object_refname_ambiguity; + warn_on_object_refname_ambiguity = 0; + + strbuf_init(&sb, 1000); + while (strbuf_getline(&sb, stdin) != EOF) { + if (!sb.len) + break; + + if (!strcmp(sb.buf, "--")) { + seen_dashdash = 1; + break; + } + + if (!seen_end_of_options && sb.buf[0] == '-') { + const char *argv[] = { sb.buf, NULL }; + + if (!strcmp(sb.buf, "--end-of-options")) { + seen_end_of_options = 1; + continue; + } + + if (handle_revision_pseudo_opt(revs, argv, flags) > 0) + continue; + + die(_("invalid option '%s' in --stdin mode"), sb.buf); + } + + if (handle_revision_arg(sb.buf, revs, 0, + REVARG_CANNOT_BE_FILENAME)) + die("bad revision '%s'", sb.buf); + } + if (seen_dashdash) + read_pathspec_from_stdin(&sb, prune); + + strbuf_release(&sb); + warn_on_object_refname_ambiguity = save_warning; +} + static void NORETURN diagnose_missing_default(const char *def) { int flags; @@ -2888,7 +2906,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s } if (revs->read_from_stdin++) die("--stdin given twice?"); - read_revisions_from_stdin(revs, &prune_data); + read_revisions_from_stdin(revs, &prune_data, &flags); continue; } @@ -2952,7 +2970,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s if (!revs->def) revs->def = opt ? opt->def : NULL; if (opt && opt->tweak) - opt->tweak(revs, opt); + opt->tweak(revs); if (revs->show_merge) prepare_show_merge(revs); if (revs->def && !revs->pending.nr && !revs->rev_input_given) { @@ -3058,6 +3076,11 @@ static void release_revisions_mailmap(struct string_list *mailmap) static void release_revisions_topo_walk_info(struct topo_walk_info *info); +static void free_void_commit_list(void *list) +{ + free_commit_list(list); +} + void release_revisions(struct rev_info *revs) { free_commit_list(revs->commits); @@ -3075,6 +3098,10 @@ void release_revisions(struct rev_info *revs) diff_free(&revs->pruning); reflog_walk_info_release(revs->reflog_info); release_revisions_topo_walk_info(revs->topo_walk_info); + clear_decoration(&revs->children, free_void_commit_list); + clear_decoration(&revs->merge_simplification, free); + clear_decoration(&revs->treesame, free); + line_log_free(revs); } static void add_child(struct rev_info *revs, struct commit *parent, struct commit *child) |