struct rev_info gains two new field: * .def to store --default argument; * .show_merge 1-bit field. The refactor consists into the following steps: * init_revisions now takes the --default argument to initialize .def properly, instead of getting it through setup_revisions. * setup_revisions has been split in two: parse_revisions that does (almost) only argument parsing, to be more like what parse-options can do, and setup_revisions that does the rest. Many places had no arguments to pass to setup_revisions, and those don't use parse_revisions at all. Signed-off-by: Pierre Habouzit <madcoder@xxxxxxxxxx> --- This is a required patch for revisions parse-optification that splits the logic of revision arguments parsing in parsing, and post-processing. The aim is to replace parsing with parse-opt at some point. The final version (using parse-options) will probably need more rework in revisions.[hc], but I'd like to avoid rebasing this patch over and over, and I'd be glad if it's merged now, as it's not _that_ intrusive. I've been using a git with this patch for a week without issues. builtin-add.c | 4 ++-- builtin-blame.c | 5 +++-- builtin-checkout.c | 7 ++++--- builtin-commit.c | 8 ++++---- builtin-diff-files.c | 8 +++++--- builtin-diff-index.c | 5 +++-- builtin-diff-tree.c | 5 +++-- builtin-diff.c | 8 +++++--- builtin-fast-export.c | 5 +++-- builtin-fmt-merge-msg.c | 4 ++-- builtin-log.c | 20 +++++++++++--------- builtin-pack-objects.c | 5 +++-- builtin-prune.c | 2 +- builtin-reflog.c | 2 +- builtin-rev-list.c | 5 +++-- builtin-revert.c | 4 ++-- builtin-shortlog.c | 5 +++-- bundle.c | 10 ++++++---- diff-lib.c | 2 +- http-push.c | 5 +++-- revision.c | 36 +++++++++++++++++++----------------- revision.h | 7 +++++-- upload-pack.c | 6 +++--- wt-status.c | 12 ++++++------ 24 files changed, 101 insertions(+), 79 deletions(-) diff --git a/builtin-add.c b/builtin-add.c index 820110e..3757369 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -108,8 +108,8 @@ static void update_callback(struct diff_queue_struct *q, void add_files_to_cache(int verbose, const char *prefix, const char **pathspec) { struct rev_info rev; - init_revisions(&rev, prefix); - setup_revisions(0, NULL, &rev, NULL); + init_revisions(&rev, prefix, NULL); + setup_revisions(&rev); rev.prune_data = pathspec; rev.diffopt.output_format = DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = update_callback; diff --git a/builtin-blame.c b/builtin-blame.c index bfd562d..ac5c5eb 100644 --- a/builtin-blame.c +++ b/builtin-blame.c @@ -2323,8 +2323,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix) argv[unk++] = "--"; /* terminate the rev name */ argv[unk] = NULL; - init_revisions(&revs, NULL); - setup_revisions(unk, argv, &revs, NULL); + init_revisions(&revs, NULL, NULL); + parse_revisions(unk, argv, &revs); + setup_revisions(&revs); memset(&sb, 0, sizeof(sb)); /* diff --git a/builtin-checkout.c b/builtin-checkout.c index 6b08016..ff92ef6 100644 --- a/builtin-checkout.c +++ b/builtin-checkout.c @@ -130,7 +130,7 @@ static void show_local_changes(struct object *head) { struct rev_info rev; /* I think we want full paths, even if we're in a subdirectory. */ - init_revisions(&rev, NULL); + init_revisions(&rev, NULL, NULL); rev.abbrev = 0; rev.diffopt.output_format |= DIFF_FORMAT_NAME_STATUS; add_pending_object(&rev, head, NULL); @@ -345,8 +345,9 @@ static void report_tracking(struct branch_info *new, struct checkout_opts *opts) strcpy(symmetric + 40, "..."); strcpy(symmetric + 43, sha1_to_hex(theirs->object.sha1)); - init_revisions(&revs, NULL); - setup_revisions(rev_argc, rev_argv, &revs, NULL); + init_revisions(&revs, NULL, NULL); + parse_revisions(rev_argc, rev_argv, &revs); + setup_revisions(&revs); prepare_revision_walk(&revs); /* ... and count the commits on each side. */ diff --git a/builtin-commit.c b/builtin-commit.c index f49c22e..48dbcaa 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -522,9 +522,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix) if (get_sha1(parent, sha1)) commitable = !!active_nr; else { - init_revisions(&rev, ""); + init_revisions(&rev, "", parent); rev.abbrev = 0; - setup_revisions(0, NULL, &rev, parent); + setup_revisions(&rev); DIFF_OPT_SET(&rev.diffopt, QUIET); DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS); run_diff_index(&rev, 1 /* cached */); @@ -798,8 +798,8 @@ static void print_summary(const char *prefix, const unsigned char *sha1) if (!commit || parse_commit(commit)) die("could not parse newly created commit"); - init_revisions(&rev, prefix); - setup_revisions(0, NULL, &rev, NULL); + init_revisions(&rev, prefix, NULL); + setup_revisions(&rev); rev.abbrev = 0; rev.diff = 1; diff --git a/builtin-diff-files.c b/builtin-diff-files.c index 4abe3c2..1f6f123 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -20,14 +20,16 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix) int result; prefix = setup_git_directory_gently(&nongit); - init_revisions(&rev, prefix); + init_revisions(&rev, prefix, NULL); git_config(git_diff_basic_config); /* no "diff" UI options */ rev.abbrev = 0; if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix)) argc = 0; - else - argc = setup_revisions(argc, argv, &rev, NULL); + else { + argc = parse_revisions(argc, argv, &rev); + setup_revisions(&rev); + } if (!rev.diffopt.output_format) rev.diffopt.output_format = DIFF_FORMAT_RAW; result = run_diff_files_cmd(&rev, argc, argv); diff --git a/builtin-diff-index.c b/builtin-diff-index.c index 2b955de..43dc3bc 100644 --- a/builtin-diff-index.c +++ b/builtin-diff-index.c @@ -16,11 +16,12 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix) int i; int result; - init_revisions(&rev, prefix); + init_revisions(&rev, prefix, NULL); git_config(git_diff_basic_config); /* no "diff" UI options */ rev.abbrev = 0; - argc = setup_revisions(argc, argv, &rev, NULL); + argc = parse_revisions(argc, argv, &rev); + setup_revisions(&rev); for (i = 1; i < argc; i++) { const char *arg = argv[i]; diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c index 832797f..3b03d7a 100644 --- a/builtin-diff-tree.c +++ b/builtin-diff-tree.c @@ -67,12 +67,13 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix) static struct rev_info *opt = &log_tree_opt; int read_stdin = 0; - init_revisions(opt, prefix); + init_revisions(opt, prefix, NULL); git_config(git_diff_basic_config); /* no "diff" UI options */ nr_sha1 = 0; opt->abbrev = 0; opt->diff = 1; - argc = setup_revisions(argc, argv, opt, NULL); + argc = parse_revisions(argc, argv, opt); + setup_revisions(opt); while (--argc > 0) { const char *arg = *++argv; diff --git a/builtin-diff.c b/builtin-diff.c index 444ff2f..19f4111 100644 --- a/builtin-diff.c +++ b/builtin-diff.c @@ -239,13 +239,15 @@ int cmd_diff(int argc, const char **argv, const char *prefix) if (diff_use_color_default == -1) diff_use_color_default = git_use_color_default; - init_revisions(&rev, prefix); + init_revisions(&rev, prefix, NULL); rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index; if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix)) argc = 0; - else - argc = setup_revisions(argc, argv, &rev, NULL); + else { + argc = parse_revisions(argc, argv, &rev); + setup_revisions(&rev); + } if (!rev.diffopt.output_format) { rev.diffopt.output_format = DIFF_FORMAT_PATCH; if (diff_setup_done(&rev.diffopt) < 0) diff --git a/builtin-fast-export.c b/builtin-fast-export.c index e1c5630..4b788e5 100755 --- a/builtin-fast-export.c +++ b/builtin-fast-export.c @@ -374,8 +374,9 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix) /* we handle encodings */ git_config(git_default_config); - init_revisions(&revs, prefix); - argc = setup_revisions(argc, argv, &revs, NULL); + init_revisions(&revs, prefix, NULL); + argc = parse_revisions(argc, argv, &revs); + setup_revisions(&revs); argc = parse_options(argc, argv, options, fast_export_usage, 0); if (argc > 1) usage_with_options (fast_export_usage, options); diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c index ebb3f37..9b84482 100644 --- a/builtin-fmt-merge-msg.c +++ b/builtin-fmt-merge-msg.c @@ -182,7 +182,7 @@ static void shortlog(const char *name, unsigned char *sha1, if (!branch || branch->type != OBJ_COMMIT) return; - setup_revisions(0, NULL, rev, NULL); + setup_revisions(rev); rev->ignore_merges = 1; add_pending_object(rev, branch, name); add_pending_object(rev, &head->object, "^HEAD"); @@ -339,7 +339,7 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix) struct rev_info rev; head = lookup_commit(head_sha1); - init_revisions(&rev, prefix); + init_revisions(&rev, prefix, NULL); rev.commit_format = CMIT_FMT_ONELINE; rev.ignore_merges = 1; rev.limited = 1; diff --git a/builtin-log.c b/builtin-log.c index fe8fc6f..30d13d3 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -58,7 +58,8 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix, DIFF_OPT_SET(&rev->diffopt, RECURSIVE); rev->show_root_diff = default_show_root; rev->subject_prefix = fmt_patch_subject_prefix; - argc = setup_revisions(argc, argv, rev, "HEAD"); + argc = parse_revisions(argc, argv, rev); + setup_revisions(rev); if (rev->diffopt.pickaxe || rev->diffopt.filter) rev->always_show_header = 0; if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) { @@ -243,7 +244,7 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix) if (diff_use_color_default == -1) diff_use_color_default = git_use_color_default; - init_revisions(&rev, prefix); + init_revisions(&rev, prefix, "HEAD"); rev.diff = 1; rev.simplify_history = 0; cmd_log_init(argc, argv, prefix, &rev); @@ -319,7 +320,7 @@ int cmd_show(int argc, const char **argv, const char *prefix) if (diff_use_color_default == -1) diff_use_color_default = git_use_color_default; - init_revisions(&rev, prefix); + init_revisions(&rev, prefix, "HEAD"); rev.diff = 1; rev.combine_merges = 1; rev.dense_combined_merges = 1; @@ -383,7 +384,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix) if (diff_use_color_default == -1) diff_use_color_default = git_use_color_default; - init_revisions(&rev, prefix); + init_revisions(&rev, prefix, "HEAD"); init_reflog_walk(&rev.reflog_info); rev.abbrev_commit = 1; rev.verbose_header = 1; @@ -415,7 +416,7 @@ int cmd_log(int argc, const char **argv, const char *prefix) if (diff_use_color_default == -1) diff_use_color_default = git_use_color_default; - init_revisions(&rev, prefix); + init_revisions(&rev, prefix, "HEAD"); rev.always_show_header = 1; cmd_log_init(argc, argv, prefix, &rev); return cmd_log_walk(&rev); @@ -601,7 +602,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha init_patch_ids(ids); /* given a range a..b get all patch ids for b..a */ - init_revisions(&check_rev, prefix); + init_revisions(&check_rev, prefix, NULL); o1->flags ^= UNINTERESTING; o2->flags ^= UNINTERESTING; add_pending_object(&check_rev, o1, "o1"); @@ -756,7 +757,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) struct strbuf buf; git_config(git_format_config); - init_revisions(&rev, prefix); + init_revisions(&rev, prefix, "HEAD"); rev.commit_format = CMIT_FMT_EMAIL; rev.verbose_header = 1; rev.diff = 1; @@ -900,7 +901,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) if (numbered_files && use_stdout) die ("--numbered-files and --stdout are mutually exclusive."); - argc = setup_revisions(argc, argv, &rev, "HEAD"); + argc = parse_revisions(argc, argv, &rev); + setup_revisions(&rev); if (argc > 1) die ("unrecognized argument: %s", argv[1]); @@ -1095,7 +1097,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) usage(cherry_usage); } - init_revisions(&revs, prefix); + init_revisions(&revs, prefix, NULL); revs.diff = 1; revs.combine_merges = 0; revs.ignore_merges = 1; diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 2799e68..94d0adc 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -1871,9 +1871,10 @@ static void get_object_list(int ac, const char **av) char line[1000]; int flags = 0; - init_revisions(&revs, NULL); + init_revisions(&revs, NULL, NULL); save_commit_buffer = 0; - setup_revisions(ac, av, &revs, NULL); + parse_revisions(ac, av, &revs); + setup_revisions(&revs); while (fgets(line, sizeof(line), stdin) != NULL) { int len = strlen(line); diff --git a/builtin-prune.c b/builtin-prune.c index bb8ead9..c18f8c2 100644 --- a/builtin-prune.c +++ b/builtin-prune.c @@ -146,7 +146,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix) } save_commit_buffer = 0; - init_revisions(&revs, prefix); + init_revisions(&revs, prefix, NULL); mark_reachable_objects(&revs, 1); prune_object_dir(get_object_directory()); diff --git a/builtin-reflog.c b/builtin-reflog.c index 280e24e..133f6f3 100644 --- a/builtin-reflog.c +++ b/builtin-reflog.c @@ -399,7 +399,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix) break; } if (cb.stalefix) { - init_revisions(&cb.revs, prefix); + init_revisions(&cb.revs, prefix, NULL); if (cb.verbose) printf("Marking reachable objects..."); mark_reachable_objects(&cb.revs, 0); diff --git a/builtin-rev-list.c b/builtin-rev-list.c index d0a1416..2a02b07 100644 --- a/builtin-rev-list.c +++ b/builtin-rev-list.c @@ -546,10 +546,11 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) int quiet = 0; git_config(git_default_config); - init_revisions(&revs, prefix); + init_revisions(&revs, prefix, NULL); revs.abbrev = 0; revs.commit_format = CMIT_FMT_UNSPECIFIED; - argc = setup_revisions(argc, argv, &revs, NULL); + argc = parse_revisions(argc, argv, &revs); + setup_revisions(&revs); for (i = 1 ; i < argc; i++) { const char *arg = argv[i]; diff --git a/builtin-revert.c b/builtin-revert.c index 607a2f0..e538dc1 100644 --- a/builtin-revert.c +++ b/builtin-revert.c @@ -251,8 +251,8 @@ static char *help_msg(const unsigned char *sha1) static int index_is_dirty(void) { struct rev_info rev; - init_revisions(&rev, NULL); - setup_revisions(0, NULL, &rev, "HEAD"); + init_revisions(&rev, NULL, "HEAD"); + setup_revisions(&rev); DIFF_OPT_SET(&rev.diffopt, QUIET); DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS); run_diff_index(&rev, 1); diff --git a/builtin-shortlog.c b/builtin-shortlog.c index af31aba..2966bdd 100644 --- a/builtin-shortlog.c +++ b/builtin-shortlog.c @@ -252,8 +252,9 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) argv++; argc--; } - init_revisions(&rev, prefix); - argc = setup_revisions(argc, argv, &rev, NULL); + init_revisions(&rev, prefix, NULL); + argc = parse_revisions(argc, argv, &rev); + setup_revisions(&rev); if (argc > 1) die ("unrecognized argument: %s", argv[1]); diff --git a/bundle.c b/bundle.c index 0ba5df1..24d5009 100644 --- a/bundle.c +++ b/bundle.c @@ -104,7 +104,7 @@ int verify_bundle(struct bundle_header *header, int verbose) int i, ret = 0, req_nr; const char *message = "Repository lacks these prerequisite commits:"; - init_revisions(&revs, NULL); + init_revisions(&revs, NULL, NULL); for (i = 0; i < p->nr; i++) { struct ref_list_entry *e = p->list + i; struct object *o = parse_object(e->sha1); @@ -120,7 +120,8 @@ int verify_bundle(struct bundle_header *header, int verbose) if (revs.pending.nr != p->nr) return ret; req_nr = revs.pending.nr; - setup_revisions(2, argv, &revs, NULL); + parse_revisions(2, argv, &revs); + setup_revisions(&revs); memset(&refs, 0, sizeof(struct object_array)); for (i = 0; i < revs.pending.nr; i++) { @@ -192,7 +193,7 @@ int create_bundle(struct bundle_header *header, const char *path, /* init revs to list objects for pack-objects later */ save_commit_buffer = 0; - init_revisions(&revs, NULL); + init_revisions(&revs, NULL, NULL); /* write prerequisites */ memcpy(argv_boundary + 3, argv + 1, argc * sizeof(const char *)); @@ -226,7 +227,8 @@ int create_bundle(struct bundle_header *header, const char *path, return error("rev-list died"); /* write references */ - argc = setup_revisions(argc, argv, &revs, NULL); + argc = parse_revisions(argc, argv, &revs); + setup_revisions(&revs); if (argc > 1) return error("unrecognized argument: %s'", argv[1]); diff --git a/diff-lib.c b/diff-lib.c index 4581b59..76e1ce2 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -775,7 +775,7 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt) } active_nr = dst - active_cache; - init_revisions(&revs, NULL); + init_revisions(&revs, NULL, NULL); revs.prune_data = opt->paths; tree = parse_tree_indirect(tree_sha1); if (!tree) diff --git a/http-push.c b/http-push.c index 5b23038..65d9f5b 100644 --- a/http-push.c +++ b/http-push.c @@ -2382,8 +2382,9 @@ int main(int argc, char **argv) commit_argv[3] = old_sha1_hex; commit_argc++; } - init_revisions(&revs, setup_git_directory()); - setup_revisions(commit_argc, commit_argv, &revs, NULL); + init_revisions(&revs, setup_git_directory(), NULL); + parse_revisions(commit_argc, commit_argv, &revs); + setup_revisions(&revs); free(new_sha1_hex); if (old_sha1_hex) { free(old_sha1_hex); diff --git a/revision.c b/revision.c index 63bf2c5..bab6228 100644 --- a/revision.c +++ b/revision.c @@ -717,7 +717,7 @@ static int add_parents_only(struct rev_info *revs, const char *arg, int flags) return 1; } -void init_revisions(struct rev_info *revs, const char *prefix) +void init_revisions(struct rev_info *revs, const char *prefix, const char *def) { memset(revs, 0, sizeof(*revs)); @@ -731,6 +731,7 @@ void init_revisions(struct rev_info *revs, const char *prefix) revs->lifo = 1; revs->dense = 1; revs->prefix = prefix; + revs->def = def; revs->max_age = -1; revs->min_age = -1; revs->skip_count = -1; @@ -892,8 +893,7 @@ static void add_grep(struct rev_info *revs, const char *ptn, enum grep_pat_token opt->regflags = REG_NEWLINE; revs->grep_filter = opt; } - append_grep_pattern(revs->grep_filter, ptn, - "command line", 0, what); + append_grep_pattern(revs->grep_filter, ptn, "command line", 0, what); } static void add_header_grep(struct rev_info *revs, const char *field, const char *pattern) @@ -936,9 +936,9 @@ static void add_ignore_packed(struct rev_info *revs, const char *name) * Returns the number of arguments left that weren't recognized * (which are also moved to the head of the argument list) */ -int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def) +int parse_revisions(int argc, const char **argv, struct rev_info *revs) { - int i, flags, seen_dashdash, show_merge; + int i, flags, seen_dashdash; const char **unrecognized = argv + 1; int left = 1; int all_match = 0; @@ -959,7 +959,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch break; } - flags = show_merge = 0; + flags = 0; for (i = 1; i < argc; i++) { const char *arg = argv[i]; if (*arg == '-') { @@ -1047,11 +1047,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch if (!strcmp(arg, "--default")) { if (++i >= argc) die("bad --default argument"); - def = argv[i]; + revs->def = argv[i]; continue; } if (!strcmp(arg, "--merge")) { - show_merge = 1; + revs->show_merge = 1; continue; } if (!strcmp(arg, "--topo-order")) { @@ -1315,18 +1315,23 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch if (revs->grep_filter) { revs->grep_filter->regflags |= regflags; revs->grep_filter->fixed = fixed; + revs->grep_filter->all_match = all_match; } + return left; +} - if (show_merge) +void setup_revisions(struct rev_info *revs) +{ + if (revs->show_merge) prepare_show_merge(revs); - if (def && !revs->pending.nr) { + if (revs->def && !revs->pending.nr) { unsigned char sha1[20]; struct object *object; unsigned mode; - if (get_sha1_with_mode(def, sha1, &mode)) - die("bad default revision '%s'", def); - object = get_reference(revs, def, sha1, 0); - add_pending_object_with_mode(revs, object, def, mode); + if (get_sha1_with_mode(revs->def, sha1, &mode)) + die("bad default revision '%s'", revs->def); + object = get_reference(revs, revs->def, sha1, 0); + add_pending_object_with_mode(revs, object, revs->def, mode); } /* Did the user ask for any diff output? Run the diff! */ @@ -1360,14 +1365,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch die("diff_setup_done failed"); if (revs->grep_filter) { - revs->grep_filter->all_match = all_match; compile_grep_patterns(revs->grep_filter); } if (revs->reverse && revs->reflog_info) die("cannot combine --reverse with --walk-reflogs"); - - return left; } int prepare_revision_walk(struct rev_info *revs) diff --git a/revision.h b/revision.h index c8b3b94..9f727d7 100644 --- a/revision.h +++ b/revision.h @@ -25,6 +25,7 @@ struct rev_info { /* Basic information */ const char *prefix; + const char *def; void *prune_data; unsigned int early_output; @@ -64,6 +65,7 @@ struct rev_info { /* Format info */ unsigned int shown_one:1, + show_merge:1, abbrev_commit:1; enum date_mode date_mode; @@ -108,8 +110,9 @@ struct rev_info { typedef void (*show_early_output_fn_t)(struct rev_info *, struct commit_list *); volatile show_early_output_fn_t show_early_output; -extern void init_revisions(struct rev_info *revs, const char *prefix); -extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def); +extern void init_revisions(struct rev_info *revs, const char *prefix, const char *def); +extern int parse_revisions(int argc, const char **argv, struct rev_info *revs); +extern void setup_revisions(struct rev_info *revs); extern int handle_revision_arg(const char *arg, struct rev_info *revs,int flags,int cant_be_filename); extern int prepare_revision_walk(struct rev_info *revs); diff --git a/upload-pack.c b/upload-pack.c index 660134a..8adf0f8 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -106,7 +106,7 @@ static int do_rev_list(int fd, void *create_full_pack) pack_pipe = fdopen(fd, "w"); if (create_full_pack) use_thin_pack = 0; /* no point doing it */ - init_revisions(&revs, NULL); + init_revisions(&revs, NULL, NULL); revs.tag_objects = 1; revs.tree_objects = 1; revs.blob_objects = 1; @@ -115,7 +115,7 @@ static int do_rev_list(int fd, void *create_full_pack) if (create_full_pack) { const char *args[] = {"rev-list", "--all", NULL}; - setup_revisions(2, args, &revs, NULL); + parse_revisions(2, args, &revs); } else { for (i = 0; i < want_obj.nr; i++) { struct object *o = want_obj.objects[i].item; @@ -128,8 +128,8 @@ static int do_rev_list(int fd, void *create_full_pack) o->flags |= UNINTERESTING; add_pending_object(&revs, o, NULL); } - setup_revisions(0, NULL, &revs, NULL); } + setup_revisions(&revs); if (prepare_revision_walk(&revs)) die("revision walk setup failed"); mark_edges_uninteresting(revs.commits, &revs, show_edge); diff --git a/wt-status.c b/wt-status.c index 32d780a..bf3df7c 100644 --- a/wt-status.c +++ b/wt-status.c @@ -241,8 +241,8 @@ static void wt_status_print_initial(struct wt_status *s) static void wt_status_print_updated(struct wt_status *s) { struct rev_info rev; - init_revisions(&rev, NULL); - setup_revisions(0, NULL, &rev, s->reference); + init_revisions(&rev, NULL, s->reference); + setup_revisions(&rev); rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = wt_status_print_updated_cb; rev.diffopt.format_callback_data = s; @@ -255,8 +255,8 @@ static void wt_status_print_updated(struct wt_status *s) static void wt_status_print_changed(struct wt_status *s) { struct rev_info rev; - init_revisions(&rev, ""); - setup_revisions(0, NULL, &rev, NULL); + init_revisions(&rev, "", NULL); + setup_revisions(&rev); rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = wt_status_print_changed_cb; rev.diffopt.format_callback_data = s; @@ -322,8 +322,8 @@ static void wt_status_print_verbose(struct wt_status *s) if (saved_stdout < 0 ||dup2(fileno(s->fp), STDOUT_FILENO) < 0) die("couldn't redirect stdout\n"); - init_revisions(&rev, NULL); - setup_revisions(0, NULL, &rev, s->reference); + init_revisions(&rev, NULL, s->reference); + setup_revisions(&rev); rev.diffopt.output_format |= DIFF_FORMAT_PATCH; rev.diffopt.detect_rename = 1; run_diff_index(&rev, 1); -- 1.5.4.3.534.g7c43.dirty
Attachment:
pgpGS97IrJPDV.pgp
Description: PGP signature