Skip to contentSkip to conversation

revisions: refactor init_revisions and setup_revisions.

PATCH New Pierre Habouzit 1 participant 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 revisions: refactor init_revisions and setup_revisions.

struct rev_info gains two new field:
* .def to store --default argument;
* .show_merge 1-bit field.

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.

---

This patch was submitted long time ago, Junio did some remarks I've now integrated (wrt the default argument that I passed to init_revisions once, and now is back as a setup_revisions argument).

 builtin-add.c           |    2 +-
 builtin-blame.c         |    3 ++-
 builtin-checkout.c      |    3 ++-
 builtin-commit.c        |    4 ++--
 builtin-diff-files.c    |    3 ++-
 builtin-diff-index.c    |    3 ++-
 builtin-diff-tree.c     |    3 ++-
 builtin-diff.c          |    3 ++-
 builtin-fast-export.c   |    3 ++-
 builtin-fmt-merge-msg.c |    2 +-
 builtin-log.c           |    7 ++++---
 builtin-pack-objects.c  |    3 ++-
 builtin-rev-list.c      |    3 ++-
 builtin-revert.c        |    2 +-
 builtin-shortlog.c      |    3 ++-
 bundle.c                |    6 ++++--
 http-push.c             |    3 ++-
 revision.c              |   32 ++++++++++++++++++--------------
 revision.h              |    7 +++++--
 upload-pack.c           |    4 ++--
 wt-status.c             |    6 +++---
 21 files changed, 63 insertions(+), 42 deletions(-)
builtin-add.c +1 -1
index 1da22ee..c60d310 100644
@@ -121,7 +121,7 @@ int add_files_to_cache(const char *prefix, const char **pathspec, int flags)
 	struct update_callback_data data;
 	struct rev_info rev;
 	init_revisions(&rev, prefix);
-	setup_revisions(0, NULL, &rev, NULL);
+	setup_revisions(&rev, NULL);
 	rev.prune_data = pathspec;
 	rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
 	rev.diffopt.format_callback = update_callback;
builtin-blame.c +2 -1
index cf41511..1e26b88 100644
@@ -2425,7 +2425,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 	argv[unk] = NULL;
 
 	init_revisions(&revs, NULL);
-	setup_revisions(unk, argv, &revs, NULL);
+	parse_revisions(unk, argv, &revs);
+	setup_revisions(&revs, NULL);
 	memset(&sb, 0, sizeof(sb));
 
 	sb.revs = &revs;
builtin-checkout.c +2 -1
index 1ea017f..9d83fdb 100644
@@ -357,7 +357,8 @@ static void report_tracking(struct branch_info *new, struct checkout_opts *opts)
 	strcpy(symmetric + 43, sha1_to_hex(theirs->object.sha1));
 
 	init_revisions(&revs, NULL);
-	setup_revisions(rev_argc, rev_argv, &revs, NULL);
+	parse_revisions(rev_argc, rev_argv, &revs);
+	setup_revisions(&revs, NULL);
 	prepare_revision_walk(&revs);
 
 	/* ... and count the commits on each side. */
builtin-commit.c +2 -2
index 07872c8..59b3dc2 100644
@@ -600,7 +600,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
 		else {
 			init_revisions(&rev, "");
 			rev.abbrev = 0;
-			setup_revisions(0, NULL, &rev, parent);
+			setup_revisions(&rev, parent);
 			DIFF_OPT_SET(&rev.diffopt, QUIET);
 			DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
 			run_diff_index(&rev, 1 /* cached */);
@@ -834,7 +834,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
 		die("could not parse newly created commit");
 
 	init_revisions(&rev, prefix);
-	setup_revisions(0, NULL, &rev, NULL);
+	setup_revisions(&rev, NULL);
 
 	rev.abbrev = 0;
 	rev.diff = 1;
builtin-diff-files.c +2 -1
index 384d871..e7e202a 100644
@@ -23,7 +23,8 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
 	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
 	rev.abbrev = 0;
 
-	argc = setup_revisions(argc, argv, &rev, NULL);
+	argc = parse_revisions(argc, argv, &rev);
+	setup_revisions(&rev, NULL);
 	while (1 < argc && argv[1][0] == '-') {
 		if (!strcmp(argv[1], "--base"))
 			rev.max_count = 1;
builtin-diff-index.c +2 -1
index 2f44ebf..286a9de 100644
@@ -20,7 +20,8 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
 	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
 	rev.abbrev = 0;
 
-	argc = setup_revisions(argc, argv, &rev, NULL);
+	argc = parse_revisions(argc, argv, &rev);
+	setup_revisions(&rev, NULL);
 	for (i = 1; i < argc; i++) {
 		const char *arg = argv[i];
 
builtin-diff-tree.c +2 -1
index 9d2a48f..0900175 100644
@@ -72,7 +72,8 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
 	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, NULL);
 
 	while (--argc > 0) {
 		const char *arg = *++argv;
builtin-diff.c +2 -1
index 4c289e7..a92dbd4 100644
@@ -283,7 +283,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 
 	if (nongit)
 		die("Not a git repository");
-	argc = setup_revisions(argc, argv, &rev, NULL);
+	argc = parse_revisions(argc, argv, &rev);
+	setup_revisions(&rev, NULL);
 	if (!rev.diffopt.output_format) {
 		rev.diffopt.output_format = DIFF_FORMAT_PATCH;
 		if (diff_setup_done(&rev.diffopt) < 0)
builtin-fast-export.c +2 -1
index 1dfc01e..59b60b5 100755
@@ -371,7 +371,8 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
 	git_config(git_default_config, NULL);
 
 	init_revisions(&revs, prefix);
-	argc = setup_revisions(argc, argv, &revs, NULL);
+	argc = parse_revisions(argc, argv, &revs);
+	setup_revisions(&revs, NULL);
 	argc = parse_options(argc, argv, options, fast_export_usage, 0);
 	if (argc > 1)
 		usage_with_options (fast_export_usage, options);
builtin-fmt-merge-msg.c +1 -1
index b892621..dad81b8 100644
@@ -187,7 +187,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, NULL);
 	rev->ignore_merges = 1;
 	add_pending_object(rev, branch, name);
 	add_pending_object(rev, &head->object, "^HEAD");
builtin-log.c +4 -3
index 9817d6f..dde7192 100644
@@ -68,8 +68,8 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
 	if (default_date_mode)
 		rev->date_mode = parse_date_format(default_date_mode);
 
-	argc = setup_revisions(argc, argv, rev, "HEAD");
-
+	argc = parse_revisions(argc, argv, rev);
+	setup_revisions(rev, "HEAD");
 	if (rev->diffopt.pickaxe || rev->diffopt.filter)
 		rev->always_show_header = 0;
 	if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {
@@ -927,7 +927,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, "HEAD");
 	if (argc > 1)
 		die ("unrecognized argument: %s", argv[1]);
 
builtin-pack-objects.c +2 -1
index 70d2f5d..46a8abc 100644
@@ -1981,7 +1981,8 @@ static void get_object_list(int ac, const char **av)
 
 	init_revisions(&revs, NULL);
 	save_commit_buffer = 0;
-	setup_revisions(ac, av, &revs, NULL);
+	parse_revisions(ac, av, &revs);
+	setup_revisions(&revs, NULL);
 
 	while (fgets(line, sizeof(line), stdin) != NULL) {
 		int len = strlen(line);
builtin-rev-list.c +2 -1
index 11a7eae..ed60227 100644
@@ -605,7 +605,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 	init_revisions(&revs, prefix);
 	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, NULL);
 
 	for (i = 1 ; i < argc; i++) {
 		const char *arg = argv[i];
builtin-revert.c +1 -1
index 0270f9b..0adff14 100644
@@ -253,7 +253,7 @@ static int index_is_dirty(void)
 {
 	struct rev_info rev;
 	init_revisions(&rev, NULL);
-	setup_revisions(0, NULL, &rev, "HEAD");
+	setup_revisions(&rev, "HEAD");
 	DIFF_OPT_SET(&rev.diffopt, QUIET);
 	DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
 	run_diff_index(&rev, 1);
builtin-shortlog.c +2 -1
index e6a2865..3428bf6 100644
@@ -256,7 +256,8 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
 		argc--;
 	}
 	init_revisions(&rev, prefix);
-	argc = setup_revisions(argc, argv, &rev, NULL);
+	argc = parse_revisions(argc, argv, &rev);
+	setup_revisions(&rev, NULL);
 	if (argc > 1)
 		die ("unrecognized argument: %s", argv[1]);
 
bundle.c +4 -2
index 0ba5df1..c4848d7 100644
@@ -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, NULL);
 
 	memset(&refs, 0, sizeof(struct object_array));
 	for (i = 0; i < revs.pending.nr; i++) {
@@ -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, NULL);
 	if (argc > 1)
 		return error("unrecognized argument: %s'", argv[1]);
 
http-push.c +2 -1
index f173dcd..fa757ff 100644
@@ -2406,7 +2406,8 @@ int main(int argc, char **argv)
 			commit_argc++;
 		}
 		init_revisions(&revs, setup_git_directory());
-		setup_revisions(commit_argc, commit_argv, &revs, NULL);
+		parse_revisions(commit_argc, commit_argv, &revs);
+		setup_revisions(&revs, NULL);
 		free(new_sha1_hex);
 		if (old_sha1_hex) {
 			free(old_sha1_hex);
revision.c +18 -14
index 5a1a948..4abe410 100644
@@ -964,9 +964,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;
@@ -987,7 +987,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 == '-') {
@@ -1075,11 +1075,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")) {
@@ -1361,18 +1361,25 @@ 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, const char *def)
+{
+	if (revs->def == NULL)
+		revs->def = def;
+	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! */
@@ -1406,7 +1413,6 @@ 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);
 	}
 
@@ -1423,8 +1429,6 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 
 	if (revs->reflog_info && revs->graph)
 		die("cannot combine --walk-reflogs with --graph");
-
-	return left;
 }
 
 static void add_child(struct rev_info *revs, struct commit *parent, struct commit *child)
revision.h +5 -2
index dcf08e0..72ab144 100644
@@ -25,6 +25,7 @@ struct rev_info {
 
 	/* Basic information */
 	const char *prefix;
+	const char *def;
 	void *prune_data;
 	unsigned int early_output;
 
@@ -65,8 +66,9 @@ struct rev_info {
 
 	/* Format info */
 	unsigned int	shown_one:1,
-			abbrev_commit:1,
+			show_merge:1,
 			use_terminator:1,
+			abbrev_commit:1,
 			missing_newline:1;
 	enum date_mode date_mode;
 
@@ -116,7 +118,8 @@ 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 int parse_revisions(int argc, const char **argv, struct rev_info *revs);
+extern void setup_revisions(struct rev_info *revs, const char *def);
 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);
upload-pack.c +2 -2
index b46dd36..9d031fc 100644
@@ -116,7 +116,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;
@@ -129,8 +129,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, NULL);
 	if (prepare_revision_walk(&revs))
 		die("revision walk setup failed");
 	mark_edges_uninteresting(revs.commits, &revs, show_edge);
wt-status.c +3 -3
index 5b4d74c..7fa6f59 100644
@@ -204,7 +204,7 @@ 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);
+	setup_revisions(&rev, s->reference);
 	rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
 	rev.diffopt.format_callback = wt_status_print_updated_cb;
 	rev.diffopt.format_callback_data = s;
@@ -218,7 +218,7 @@ static void wt_status_print_changed(struct wt_status *s)
 {
 	struct rev_info rev;
 	init_revisions(&rev, "");
-	setup_revisions(0, NULL, &rev, NULL);
+	setup_revisions(&rev, NULL);
 	rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
 	rev.diffopt.format_callback = wt_status_print_changed_cb;
 	rev.diffopt.format_callback_data = s;
@@ -306,7 +306,7 @@ static void wt_status_print_verbose(struct wt_status *s)
 	struct rev_info rev;
 
 	init_revisions(&rev, NULL);
-	setup_revisions(0, NULL, &rev, s->reference);
+	setup_revisions(&rev, s->reference);
 	rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
 	rev.diffopt.detect_rename = 1;
 	rev.diffopt.file = s->fp;
Signature · 1 line
1.5.6.rc0.145.ge0aba
#1 lore raw

PATCH 1/1 revisions: move traversal bit-fields to masks.

---

This work is preliminary to anything you could do to migrate revisions and diff options parsing to parseopt. I use it for many months now.

 builtin-commit.c        |    8 +-
 builtin-diff-files.c    |    6 +-
 builtin-diff-tree.c     |    2 +-
 builtin-diff.c          |   14 ++-
 builtin-fmt-merge-msg.c |    6 +-
 builtin-log.c           |   64 ++++++++-------
 builtin-rev-list.c      |   25 +++---
 combine-diff.c          |    8 +-
 diff-lib.c              |   10 +-
 graph.c                 |   10 ++-
 list-objects.c          |    6 +-
 log-tree.c              |   42 +++++-----
 pretty.c                |    6 +-
 reachable.c             |    6 +-
 revision.c              |  202 +++++++++++++++++++++++-----------------------
 revision.h              |   95 +++++++++++++----------
 upload-pack.c           |    8 +-
 17 files changed, 272 insertions(+), 246 deletions(-)
builtin-commit.c +4 -4
index 59b3dc2..4fc7eaa 100644
@@ -837,14 +837,14 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
 	setup_revisions(&rev, NULL);
 
 	rev.abbrev = 0;
-	rev.diff = 1;
+	REV_DIFF_SET(&rev, DIFF);
+	REV_DIFF_SET(&rev, VERBOSE_HEADER);
+	REV_DIFF_SET(&rev, SHOW_ROOT_DIFF);
 	rev.diffopt.output_format =
 		DIFF_FORMAT_SHORTSTAT | DIFF_FORMAT_SUMMARY;
 
-	rev.verbose_header = 1;
-	rev.show_root_diff = 1;
 	get_commit_format("format:%h: %s", &rev);
-	rev.always_show_header = 0;
+	REV_DIFF_CLR(&rev, ALWAYS_SHOW_HEADER);
 	rev.diffopt.detect_rename = 1;
 	rev.diffopt.rename_limit = 100;
 	rev.diffopt.break_opt = 0;
builtin-diff-files.c +4 -2
index e7e202a..cb7a318 100644
@@ -52,8 +52,10 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
 		usage(diff_files_usage);
 
 	if (rev.max_count == -1 &&
-	    (rev.diffopt.output_format & DIFF_FORMAT_PATCH))
-		rev.combine_merges = rev.dense_combined_merges = 1;
+	    (rev.diffopt.output_format & DIFF_FORMAT_PATCH)) {
+		REV_DIFF_SET(&rev, COMBINE_MERGES);
+		REV_DIFF_SET(&rev, DENSE_COMBINED_MERGES);
+	}
 
 	if (read_cache() < 0) {
 		perror("read_cache");
builtin-diff-tree.c +1 -1
index 0900175..9a34a36 100644
@@ -71,7 +71,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
 	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
 	nr_sha1 = 0;
 	opt->abbrev = 0;
-	opt->diff = 1;
+	REV_DIFF_SET(opt, DIFF);
 	argc = parse_revisions(argc, argv, opt);
 	setup_revisions(opt, NULL);
 
builtin-diff.c +9 -5
index a92dbd4..acf50aa 100644
@@ -170,15 +170,17 @@ static int builtin_diff_combined(struct rev_info *revs,
 	if (argc > 1)
 		usage(builtin_diff_usage);
 
-	if (!revs->dense_combined_merges && !revs->combine_merges)
-		revs->dense_combined_merges = revs->combine_merges = 1;
+	if (!REV_DIFF_TST(revs, DENSE_COMBINED_MERGES) && !REV_DIFF_TST(revs, COMBINE_MERGES)) {
+		REV_DIFF_SET(revs, DENSE_COMBINED_MERGES);
+		REV_DIFF_SET(revs, COMBINE_MERGES);
+	}
 	parent = xmalloc(ents * sizeof(*parent));
 	/* Again, the revs are all reverse */
 	for (i = 0; i < ents; i++)
 		hashcpy((unsigned char *)(parent + i),
 			ent[ents - 1 - i].item->sha1);
 	diff_tree_combined(parent[0], parent + 1, ents - 1,
-			   revs->dense_combined_merges, revs);
+			   REV_DIFF_TST(revs, DENSE_COMBINED_MERGES), revs);
 	return 0;
 }
 
@@ -222,8 +224,10 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv
 	}
 
 	if (revs->max_count == -1 &&
-	    (revs->diffopt.output_format & DIFF_FORMAT_PATCH))
-		revs->combine_merges = revs->dense_combined_merges = 1;
+	    (revs->diffopt.output_format & DIFF_FORMAT_PATCH)) {
+		REV_DIFF_SET(revs, COMBINE_MERGES);
+		REV_DIFF_SET(revs, DENSE_COMBINED_MERGES);
+	}
 
 	if (read_cache() < 0) {
 		perror("read_cache");
builtin-fmt-merge-msg.c +3 -3
index dad81b8..29a1cfe 100644
@@ -188,7 +188,7 @@ static void shortlog(const char *name, unsigned char *sha1,
 		return;
 
 	setup_revisions(rev, NULL);
-	rev->ignore_merges = 1;
+	REV_DIFF_SET(rev, IGNORE_MERGES);
 	add_pending_object(rev, branch, name);
 	add_pending_object(rev, &head->object, "^HEAD");
 	head->object.flags |= UNINTERESTING;
@@ -355,8 +355,8 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 		head = lookup_commit(head_sha1);
 		init_revisions(&rev, prefix);
 		rev.commit_format = CMIT_FMT_ONELINE;
-		rev.ignore_merges = 1;
-		rev.limited = 1;
+		REV_DIFF_SET(&rev, IGNORE_MERGES);
+		REV_TRAV_SET(&rev, LIMITED);
 
 		for (i = 0; i < origins.nr; i++)
 			shortlog(origins.list[i], origins.payload[i],
builtin-log.c +34 -30

150 lines not on this page · raw message

builtin-rev-list.c +13 -12
index ed60227..db61872 100644
@@ -72,19 +72,19 @@ static void show_commit(struct commit *commit)
 			putchar('-');
 		else if (commit->object.flags & UNINTERESTING)
 			putchar('^');
-		else if (revs.left_right) {
+		else if (REV_TRAV_TST(&revs, LEFT_RIGHT)) {
 			if (commit->object.flags & SYMMETRIC_LEFT)
 				putchar('<');
 			else
 				putchar('>');
 		}
 	}
-	if (revs.abbrev_commit && revs.abbrev)
+	if (REV_FMT_TST(&revs, ABBREV_COMMIT) && revs.abbrev)
 		fputs(find_unique_abbrev(commit->object.sha1, revs.abbrev),
 		      stdout);
 	else
 		fputs(sha1_to_hex(commit->object.sha1), stdout);
-	if (revs.print_parents) {
+	if (REV_TRAV_TST(&revs, PRINT_PARENTS)) {
 		struct commit_list *parents = commit->parents;
 		while (parents) {
 			printf(" %s", sha1_to_hex(parents->item->object.sha1));
@@ -106,7 +106,7 @@ static void show_commit(struct commit *commit)
 	else
 		putchar('\n');
 
-	if (revs.verbose_header && commit->buffer) {
+	if (REV_DIFF_TST(&revs, VERBOSE_HEADER) && commit->buffer) {
 		struct strbuf buf;
 		strbuf_init(&buf, 0);
 		pretty_print_commit(revs.commit_format, commit,
@@ -612,7 +612,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 		const char *arg = argv[i];
 
 		if (!strcmp(arg, "--header")) {
-			revs.verbose_header = 1;
+			REV_DIFF_SET(&revs, VERBOSE_HEADER);
 			continue;
 		}
 		if (!strcmp(arg, "--timestamp")) {
@@ -654,25 +654,26 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 		else
 			header_prefix = "commit ";
 	}
-	else if (revs.verbose_header)
+	else if (REV_DIFF_TST(&revs, VERBOSE_HEADER))
 		/* Only --header was specified */
 		revs.commit_format = CMIT_FMT_RAW;
 
 	list = revs.commits;
 
 	if ((!list &&
-	     (!(revs.tag_objects||revs.tree_objects||revs.blob_objects) &&
-	      !revs.pending.nr)) ||
-	    revs.diff)
+		 (!(REV_TRAV_TST(&revs, TAG_OBJECTS) ||
+			REV_TRAV_TST(&revs, TREE_OBJECTS) ||
+			REV_TRAV_TST(&revs, BLOB_OBJECTS)) &&
+	      !revs.pending.nr)) || REV_DIFF_TST(&revs, DIFF))
 		usage(rev_list_usage);
 
-	save_commit_buffer = revs.verbose_header || revs.grep_filter;
+	save_commit_buffer = REV_DIFF_TST(&revs, VERBOSE_HEADER) || revs.grep_filter;
 	if (bisect_list)
-		revs.limited = 1;
+		REV_TRAV_SET(&revs, LIMITED);
 
 	if (prepare_revision_walk(&revs))
 		die("revision walk setup failed");
-	if (revs.tree_objects)
+	if (REV_TRAV_TST(&revs, TREE_OBJECTS))
 		mark_edges_uninteresting(revs.commits, &revs, show_edge);
 
 	if (bisect_list) {
combine-diff.c +4 -4
index 588c58b..9b32bcf 100644
@@ -796,7 +796,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
 		int added = 0;
 		int deleted = 0;
 
-		if (rev->loginfo && !rev->no_commit_id)
+		if (rev->loginfo && !REV_DIFF_TST(rev, NO_COMMIT_ID))
 			show_log(rev);
 		dump_quoted_path(dense ? "diff --cc " : "diff --combined ",
 				 "", elem->path, c_meta, c_reset);
@@ -879,7 +879,7 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re
 	if (!line_termination)
 		inter_name_termination = 0;
 
-	if (rev->loginfo && !rev->no_commit_id)
+	if (rev->loginfo && !REV_DIFF_TST(rev, NO_COMMIT_ID))
 		show_log(rev);
 
 	if (opt->output_format & DIFF_FORMAT_RAW) {
@@ -943,7 +943,7 @@ void diff_tree_combined(const unsigned char *sha1,
 	DIFF_OPT_SET(&diffopts, RECURSIVE);
 	DIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);
 
-	show_log_first = !!rev->loginfo && !rev->no_commit_id;
+	show_log_first = !!rev->loginfo && !REV_DIFF_TST(rev, NO_COMMIT_ID);
 	needsep = 0;
 	/* find set of paths that everybody touches */
 	for (i = 0; i < num_parent; i++) {
@@ -962,7 +962,7 @@ void diff_tree_combined(const unsigned char *sha1,
 
 		if (show_log_first && i == 0) {
 			show_log(rev);
-			if (rev->verbose_header && opt->output_format)
+			if (REV_DIFF_TST(rev, VERBOSE_HEADER) && opt->output_format)
 				putchar(opt->line_termination);
 		}
 		diff_flush(&diffopts);
diff-lib.c +5 -5
index b17722d..777b98f 100644
@@ -140,9 +140,9 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
 			 */
 			i--;
 
-			if (revs->combine_merges && num_compare_stages == 2) {
+			if (REV_DIFF_TST(revs, COMBINE_MERGES) && num_compare_stages == 2) {
 				show_combined_diff(dpath, 2,
-						   revs->dense_combined_merges,
+						   REV_DIFF_TST(revs, DENSE_COMBINED_MERGES),
 						   revs);
 				free(dpath);
 				continue;
@@ -281,7 +281,7 @@ static int show_modified(struct oneway_unpack_data *cbdata,
 		return -1;
 	}
 
-	if (revs->combine_merges && !cached &&
+	if (REV_DIFF_TST(revs, COMBINE_MERGES) && !cached &&
 	    (hashcmp(sha1, old->sha1) || hashcmp(old->sha1, new->sha1))) {
 		struct combine_diff_path *p;
 		int pathlen = ce_namelen(new);
@@ -301,7 +301,7 @@ static int show_modified(struct oneway_unpack_data *cbdata,
 		p->parent[1].status = DIFF_STATUS_MODIFIED;
 		p->parent[1].mode = old->ce_mode;
 		hashcpy(p->parent[1].sha1, old->sha1);
-		show_combined_diff(p, 2, revs->dense_combined_merges, revs);
+		show_combined_diff(p, 2, REV_DIFF_TST(revs, DENSE_COMBINED_MERGES), revs);
 		free(p);
 		return 0;
 	}
@@ -354,7 +354,7 @@ static void do_oneway_diff(struct unpack_trees_options *o,
 	 * "!revs->ignore_merges".
 	 */
 	cached = o->index_only;
-	match_missing = !revs->ignore_merges;
+	match_missing = !REV_DIFF_TST(revs, IGNORE_MERGES);
 
 	if (cached && idx && ce_stage(idx)) {
 		if (tree)
graph.c +6 -4
index 26b8c52..1173440 100644
@@ -196,7 +196,8 @@ static int graph_is_interesting(struct git_graph *graph, struct commit *commit)
 	 * been shown are always interesting, even if they have the
 	 * UNINTERESTING or TREESAME flags set.
 	 */
-	if (graph->revs && graph->revs->boundary) {
+	if (graph->revs && (REV_TRAV_TST(graph->revs, BOUNDARY)
+			|| REV_TRAV_TST(graph->revs, BOUNDARY_OUTPUT))) {
 		if (commit->object.flags & CHILD_SHOWN)
 			return 1;
 	}
@@ -557,10 +558,11 @@ static void graph_output_commit_char(struct git_graph *graph, struct strbuf *sb)
 {
 	/*
 	 * For boundary commits, print 'o'
-	 * (We should only see boundary commits when revs->boundary is set.)
+	 * (We should only see boundary commits when BOUNDARY/BOUNDARY_OUTPUT is set.)
 	 */
 	if (graph->commit->object.flags & BOUNDARY) {
-		assert(graph->revs->boundary);
+		assert (REV_TRAV_TST(graph->revs, BOUNDARY)
+				|| REV_TRAV_TST(graph->revs, BOUNDARY_OUTPUT));
 		strbuf_addch(sb, 'o');
 		return;
 	}
@@ -570,7 +572,7 @@ static void graph_output_commit_char(struct git_graph *graph, struct strbuf *sb)
 	 * come from the left side, and '>' for commits from the right
 	 * side.
 	 */
-	if (graph->revs && graph->revs->left_right) {
+	if (graph->revs && REV_TRAV_TST(graph->revs, LEFT_RIGHT)) {
 		if (graph->commit->object.flags & SYMMETRIC_LEFT)
 			strbuf_addch(sb, '<');
 		else
list-objects.c +3 -3
index c8b8375..b15af12 100644
@@ -16,7 +16,7 @@ static void process_blob(struct rev_info *revs,
 {
 	struct object *obj = &blob->object;
 
-	if (!revs->blob_objects)
+	if (!REV_TRAV_TST(revs, BLOB_OBJECTS))
 		return;
 	if (!obj)
 		die("bad blob object");
@@ -69,7 +69,7 @@ static void process_tree(struct rev_info *revs,
 	struct name_entry entry;
 	struct name_path me;
 
-	if (!revs->tree_objects)
+	if (!REV_TRAV_TST(revs, TREE_OBJECTS))
 		return;
 	if (!obj)
 		die("bad tree object");
@@ -114,7 +114,7 @@ static void mark_edge_parents_uninteresting(struct commit *commit,
 		if (!(parent->object.flags & UNINTERESTING))
 			continue;
 		mark_tree_uninteresting(parent->tree);
-		if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
+		if (REV_TRAV_TST(revs, EDGE_HINT) && !(parent->object.flags & SHOWN)) {
 			parent->object.flags |= SHOWN;
 			show_edge(parent);
 		}
log-tree.c +21 -21

145 lines not on this page · raw message

pretty.c +3 -3
index 8eb39e9..38a9099 100644
@@ -23,7 +23,7 @@ void get_commit_format(const char *arg, struct rev_info *rev)
 		{ "oneline",	1,	CMIT_FMT_ONELINE },
 	};
 
-	rev->use_terminator = 0;
+	REV_FMT_CLR(rev, USE_TERMINATOR);
 	if (!arg || !*arg) {
 		rev->commit_format = CMIT_FMT_DEFAULT;
 		return;
@@ -33,7 +33,7 @@ void get_commit_format(const char *arg, struct rev_info *rev)
 		free(user_format);
 		user_format = xstrdup(cp);
 		if (arg[0] == 't')
-			rev->use_terminator = 1;
+			REV_FMT_SET(rev, USE_TERMINATOR);
 		rev->commit_format = CMIT_FMT_USERFORMAT;
 		return;
 	}
@@ -41,7 +41,7 @@ void get_commit_format(const char *arg, struct rev_info *rev)
 		if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&
 		    !strncmp(arg, cmt_fmts[i].n, strlen(arg))) {
 			if (cmt_fmts[i].v == CMIT_FMT_ONELINE)
-				rev->use_terminator = 1;
+				REV_FMT_SET(rev, USE_TERMINATOR);
 			rev->commit_format = cmt_fmts[i].v;
 			return;
 		}
reachable.c +3 -3
index 3b1c18f..6ee77f9 100644
@@ -203,9 +203,9 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog)
 	 * Set up revision parsing, and mark us as being interested
 	 * in all object types, not just commits.
 	 */
-	revs->tag_objects = 1;
-	revs->blob_objects = 1;
-	revs->tree_objects = 1;
+	REV_TRAV_SET(revs, TAG_OBJECTS);
+	REV_TRAV_SET(revs, BLOB_OBJECTS);
+	REV_TRAV_SET(revs, TREE_OBJECTS);
 
 	/* Add all refs from the index file */
 	add_cache_refs(revs);
revision.c +101 -101

555 lines not on this page · raw message

revision.h +54 -41

107 lines not on this page · raw message

upload-pack.c +4 -4
index 9d031fc..5845488 100644
@@ -108,11 +108,11 @@ static int do_rev_list(int fd, void *create_full_pack)
 	if (create_full_pack)
 		use_thin_pack = 0; /* no point doing it */
 	init_revisions(&revs, NULL);
-	revs.tag_objects = 1;
-	revs.tree_objects = 1;
-	revs.blob_objects = 1;
+	REV_TRAV_SET(revs, TAG_OBJECTS);
+	REV_TRAV_SET(revs, BLOB_OBJECTS);
+	REV_TRAV_SET(revs, TREE_OBJECTS);
 	if (use_thin_pack)
-		revs.edge_hint = 1;
+		REV_TRAV_SET(&revs, EDGE_HINT);
 
 	if (create_full_pack) {
 		const char *args[] = {"rev-list", "--all", NULL};
Signature · 1 line
1.5.6.rc0.145.ge0aba
#2 lore raw

PATCH RESEND 1/1 revisions: move traversal bit-fields to masks.

---

For some reason my previous patch was borked, probably because of a sloppy rebase :/ Please consider that one instead.

 builtin-commit.c        |    8 +-
 builtin-diff-files.c    |    6 +-
 builtin-diff-tree.c     |    2 +-
 builtin-diff.c          |   14 ++-
 builtin-fmt-merge-msg.c |    6 +-
 builtin-log.c           |   64 ++++++++-------
 builtin-rev-list.c      |   25 +++---
 combine-diff.c          |    8 +-
 diff-lib.c              |   10 +-
 graph.c                 |   10 ++-
 list-objects.c          |    6 +-
 log-tree.c              |   42 +++++-----
 pretty.c                |    6 +-
 reachable.c             |    6 +-
 revision.c              |  202 +++++++++++++++++++++++-----------------------
 revision.h              |   95 +++++++++++++----------
 upload-pack.c           |    8 +-
 17 files changed, 272 insertions(+), 246 deletions(-)
builtin-commit.c +4 -4
index 59b3dc2..4fc7eaa 100644
@@ -837,14 +837,14 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
 	setup_revisions(&rev, NULL);
 
 	rev.abbrev = 0;
-	rev.diff = 1;
+	REV_DIFF_SET(&rev, DIFF);
+	REV_DIFF_SET(&rev, VERBOSE_HEADER);
+	REV_DIFF_SET(&rev, SHOW_ROOT_DIFF);
 	rev.diffopt.output_format =
 		DIFF_FORMAT_SHORTSTAT | DIFF_FORMAT_SUMMARY;
 
-	rev.verbose_header = 1;
-	rev.show_root_diff = 1;
 	get_commit_format("format:%h: %s", &rev);
-	rev.always_show_header = 0;
+	REV_DIFF_CLR(&rev, ALWAYS_SHOW_HEADER);
 	rev.diffopt.detect_rename = 1;
 	rev.diffopt.rename_limit = 100;
 	rev.diffopt.break_opt = 0;
builtin-diff-files.c +4 -2
index e7e202a..cb7a318 100644
@@ -52,8 +52,10 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
 		usage(diff_files_usage);
 
 	if (rev.max_count == -1 &&
-	    (rev.diffopt.output_format & DIFF_FORMAT_PATCH))
-		rev.combine_merges = rev.dense_combined_merges = 1;
+	    (rev.diffopt.output_format & DIFF_FORMAT_PATCH)) {
+		REV_DIFF_SET(&rev, COMBINE_MERGES);
+		REV_DIFF_SET(&rev, DENSE_COMBINED_MERGES);
+	}
 
 	if (read_cache() < 0) {
 		perror("read_cache");
builtin-diff-tree.c +1 -1
index 0900175..9a34a36 100644
@@ -71,7 +71,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
 	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
 	nr_sha1 = 0;
 	opt->abbrev = 0;
-	opt->diff = 1;
+	REV_DIFF_SET(opt, DIFF);
 	argc = parse_revisions(argc, argv, opt);
 	setup_revisions(opt, NULL);
 
builtin-diff.c +9 -5
index a92dbd4..acf50aa 100644
@@ -170,15 +170,17 @@ static int builtin_diff_combined(struct rev_info *revs,
 	if (argc > 1)
 		usage(builtin_diff_usage);
 
-	if (!revs->dense_combined_merges && !revs->combine_merges)
-		revs->dense_combined_merges = revs->combine_merges = 1;
+	if (!REV_DIFF_TST(revs, DENSE_COMBINED_MERGES) && !REV_DIFF_TST(revs, COMBINE_MERGES)) {
+		REV_DIFF_SET(revs, DENSE_COMBINED_MERGES);
+		REV_DIFF_SET(revs, COMBINE_MERGES);
+	}
 	parent = xmalloc(ents * sizeof(*parent));
 	/* Again, the revs are all reverse */
 	for (i = 0; i < ents; i++)
 		hashcpy((unsigned char *)(parent + i),
 			ent[ents - 1 - i].item->sha1);
 	diff_tree_combined(parent[0], parent + 1, ents - 1,
-			   revs->dense_combined_merges, revs);
+			   REV_DIFF_TST(revs, DENSE_COMBINED_MERGES), revs);
 	return 0;
 }
 
@@ -222,8 +224,10 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv
 	}
 
 	if (revs->max_count == -1 &&
-	    (revs->diffopt.output_format & DIFF_FORMAT_PATCH))
-		revs->combine_merges = revs->dense_combined_merges = 1;
+	    (revs->diffopt.output_format & DIFF_FORMAT_PATCH)) {
+		REV_DIFF_SET(revs, COMBINE_MERGES);
+		REV_DIFF_SET(revs, DENSE_COMBINED_MERGES);
+	}
 
 	if (read_cache() < 0) {
 		perror("read_cache");
builtin-fmt-merge-msg.c +3 -3
index dad81b8..29a1cfe 100644
@@ -188,7 +188,7 @@ static void shortlog(const char *name, unsigned char *sha1,
 		return;
 
 	setup_revisions(rev, NULL);
-	rev->ignore_merges = 1;
+	REV_DIFF_SET(rev, IGNORE_MERGES);
 	add_pending_object(rev, branch, name);
 	add_pending_object(rev, &head->object, "^HEAD");
 	head->object.flags |= UNINTERESTING;
@@ -355,8 +355,8 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 		head = lookup_commit(head_sha1);
 		init_revisions(&rev, prefix);
 		rev.commit_format = CMIT_FMT_ONELINE;
-		rev.ignore_merges = 1;
-		rev.limited = 1;
+		REV_DIFF_SET(&rev, IGNORE_MERGES);
+		REV_TRAV_SET(&rev, LIMITED);
 
 		for (i = 0; i < origins.nr; i++)
 			shortlog(origins.list[i], origins.payload[i],
builtin-log.c +34 -30

150 lines not on this page · raw message

builtin-rev-list.c +13 -12
index ed60227..db61872 100644
@@ -72,19 +72,19 @@ static void show_commit(struct commit *commit)
 			putchar('-');
 		else if (commit->object.flags & UNINTERESTING)
 			putchar('^');
-		else if (revs.left_right) {
+		else if (REV_TRAV_TST(&revs, LEFT_RIGHT)) {
 			if (commit->object.flags & SYMMETRIC_LEFT)
 				putchar('<');
 			else
 				putchar('>');
 		}
 	}
-	if (revs.abbrev_commit && revs.abbrev)
+	if (REV_FMT_TST(&revs, ABBREV_COMMIT) && revs.abbrev)
 		fputs(find_unique_abbrev(commit->object.sha1, revs.abbrev),
 		      stdout);
 	else
 		fputs(sha1_to_hex(commit->object.sha1), stdout);
-	if (revs.print_parents) {
+	if (REV_TRAV_TST(&revs, PRINT_PARENTS)) {
 		struct commit_list *parents = commit->parents;
 		while (parents) {
 			printf(" %s", sha1_to_hex(parents->item->object.sha1));
@@ -106,7 +106,7 @@ static void show_commit(struct commit *commit)
 	else
 		putchar('\n');
 
-	if (revs.verbose_header && commit->buffer) {
+	if (REV_DIFF_TST(&revs, VERBOSE_HEADER) && commit->buffer) {
 		struct strbuf buf;
 		strbuf_init(&buf, 0);
 		pretty_print_commit(revs.commit_format, commit,
@@ -612,7 +612,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 		const char *arg = argv[i];
 
 		if (!strcmp(arg, "--header")) {
-			revs.verbose_header = 1;
+			REV_DIFF_SET(&revs, VERBOSE_HEADER);
 			continue;
 		}
 		if (!strcmp(arg, "--timestamp")) {
@@ -654,25 +654,26 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 		else
 			header_prefix = "commit ";
 	}
-	else if (revs.verbose_header)
+	else if (REV_DIFF_TST(&revs, VERBOSE_HEADER))
 		/* Only --header was specified */
 		revs.commit_format = CMIT_FMT_RAW;
 
 	list = revs.commits;
 
 	if ((!list &&
-	     (!(revs.tag_objects||revs.tree_objects||revs.blob_objects) &&
-	      !revs.pending.nr)) ||
-	    revs.diff)
+		 (!(REV_TRAV_TST(&revs, TAG_OBJECTS) ||
+			REV_TRAV_TST(&revs, TREE_OBJECTS) ||
+			REV_TRAV_TST(&revs, BLOB_OBJECTS)) &&
+	      !revs.pending.nr)) || REV_DIFF_TST(&revs, DIFF))
 		usage(rev_list_usage);
 
-	save_commit_buffer = revs.verbose_header || revs.grep_filter;
+	save_commit_buffer = REV_DIFF_TST(&revs, VERBOSE_HEADER) || revs.grep_filter;
 	if (bisect_list)
-		revs.limited = 1;
+		REV_TRAV_SET(&revs, LIMITED);
 
 	if (prepare_revision_walk(&revs))
 		die("revision walk setup failed");
-	if (revs.tree_objects)
+	if (REV_TRAV_TST(&revs, TREE_OBJECTS))
 		mark_edges_uninteresting(revs.commits, &revs, show_edge);
 
 	if (bisect_list) {
combine-diff.c +4 -4
index 588c58b..9b32bcf 100644
@@ -796,7 +796,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
 		int added = 0;
 		int deleted = 0;
 
-		if (rev->loginfo && !rev->no_commit_id)
+		if (rev->loginfo && !REV_DIFF_TST(rev, NO_COMMIT_ID))
 			show_log(rev);
 		dump_quoted_path(dense ? "diff --cc " : "diff --combined ",
 				 "", elem->path, c_meta, c_reset);
@@ -879,7 +879,7 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re
 	if (!line_termination)
 		inter_name_termination = 0;
 
-	if (rev->loginfo && !rev->no_commit_id)
+	if (rev->loginfo && !REV_DIFF_TST(rev, NO_COMMIT_ID))
 		show_log(rev);
 
 	if (opt->output_format & DIFF_FORMAT_RAW) {
@@ -943,7 +943,7 @@ void diff_tree_combined(const unsigned char *sha1,
 	DIFF_OPT_SET(&diffopts, RECURSIVE);
 	DIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);
 
-	show_log_first = !!rev->loginfo && !rev->no_commit_id;
+	show_log_first = !!rev->loginfo && !REV_DIFF_TST(rev, NO_COMMIT_ID);
 	needsep = 0;
 	/* find set of paths that everybody touches */
 	for (i = 0; i < num_parent; i++) {
@@ -962,7 +962,7 @@ void diff_tree_combined(const unsigned char *sha1,
 
 		if (show_log_first && i == 0) {
 			show_log(rev);
-			if (rev->verbose_header && opt->output_format)
+			if (REV_DIFF_TST(rev, VERBOSE_HEADER) && opt->output_format)
 				putchar(opt->line_termination);
 		}
 		diff_flush(&diffopts);
diff-lib.c +5 -5
index b17722d..777b98f 100644
@@ -140,9 +140,9 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
 			 */
 			i--;
 
-			if (revs->combine_merges && num_compare_stages == 2) {
+			if (REV_DIFF_TST(revs, COMBINE_MERGES) && num_compare_stages == 2) {
 				show_combined_diff(dpath, 2,
-						   revs->dense_combined_merges,
+						   REV_DIFF_TST(revs, DENSE_COMBINED_MERGES),
 						   revs);
 				free(dpath);
 				continue;
@@ -281,7 +281,7 @@ static int show_modified(struct oneway_unpack_data *cbdata,
 		return -1;
 	}
 
-	if (revs->combine_merges && !cached &&
+	if (REV_DIFF_TST(revs, COMBINE_MERGES) && !cached &&
 	    (hashcmp(sha1, old->sha1) || hashcmp(old->sha1, new->sha1))) {
 		struct combine_diff_path *p;
 		int pathlen = ce_namelen(new);
@@ -301,7 +301,7 @@ static int show_modified(struct oneway_unpack_data *cbdata,
 		p->parent[1].status = DIFF_STATUS_MODIFIED;
 		p->parent[1].mode = old->ce_mode;
 		hashcpy(p->parent[1].sha1, old->sha1);
-		show_combined_diff(p, 2, revs->dense_combined_merges, revs);
+		show_combined_diff(p, 2, REV_DIFF_TST(revs, DENSE_COMBINED_MERGES), revs);
 		free(p);
 		return 0;
 	}
@@ -354,7 +354,7 @@ static void do_oneway_diff(struct unpack_trees_options *o,
 	 * "!revs->ignore_merges".
 	 */
 	cached = o->index_only;
-	match_missing = !revs->ignore_merges;
+	match_missing = !REV_DIFF_TST(revs, IGNORE_MERGES);
 
 	if (cached && idx && ce_stage(idx)) {
 		if (tree)
graph.c +6 -4
index 26b8c52..1173440 100644
@@ -196,7 +196,8 @@ static int graph_is_interesting(struct git_graph *graph, struct commit *commit)
 	 * been shown are always interesting, even if they have the
 	 * UNINTERESTING or TREESAME flags set.
 	 */
-	if (graph->revs && graph->revs->boundary) {
+	if (graph->revs && (REV_TRAV_TST(graph->revs, BOUNDARY)
+			|| REV_TRAV_TST(graph->revs, BOUNDARY_OUTPUT))) {
 		if (commit->object.flags & CHILD_SHOWN)
 			return 1;
 	}
@@ -557,10 +558,11 @@ static void graph_output_commit_char(struct git_graph *graph, struct strbuf *sb)
 {
 	/*
 	 * For boundary commits, print 'o'
-	 * (We should only see boundary commits when revs->boundary is set.)
+	 * (We should only see boundary commits when BOUNDARY/BOUNDARY_OUTPUT is set.)
 	 */
 	if (graph->commit->object.flags & BOUNDARY) {
-		assert(graph->revs->boundary);
+		assert (REV_TRAV_TST(graph->revs, BOUNDARY)
+				|| REV_TRAV_TST(graph->revs, BOUNDARY_OUTPUT));
 		strbuf_addch(sb, 'o');
 		return;
 	}
@@ -570,7 +572,7 @@ static void graph_output_commit_char(struct git_graph *graph, struct strbuf *sb)
 	 * come from the left side, and '>' for commits from the right
 	 * side.
 	 */
-	if (graph->revs && graph->revs->left_right) {
+	if (graph->revs && REV_TRAV_TST(graph->revs, LEFT_RIGHT)) {
 		if (graph->commit->object.flags & SYMMETRIC_LEFT)
 			strbuf_addch(sb, '<');
 		else
list-objects.c +3 -3
index c8b8375..b15af12 100644
@@ -16,7 +16,7 @@ static void process_blob(struct rev_info *revs,
 {
 	struct object *obj = &blob->object;
 
-	if (!revs->blob_objects)
+	if (!REV_TRAV_TST(revs, BLOB_OBJECTS))
 		return;
 	if (!obj)
 		die("bad blob object");
@@ -69,7 +69,7 @@ static void process_tree(struct rev_info *revs,
 	struct name_entry entry;
 	struct name_path me;
 
-	if (!revs->tree_objects)
+	if (!REV_TRAV_TST(revs, TREE_OBJECTS))
 		return;
 	if (!obj)
 		die("bad tree object");
@@ -114,7 +114,7 @@ static void mark_edge_parents_uninteresting(struct commit *commit,
 		if (!(parent->object.flags & UNINTERESTING))
 			continue;
 		mark_tree_uninteresting(parent->tree);
-		if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
+		if (REV_TRAV_TST(revs, EDGE_HINT) && !(parent->object.flags & SHOWN)) {
 			parent->object.flags |= SHOWN;
 			show_edge(parent);
 		}
log-tree.c +21 -21

145 lines not on this page · raw message

pretty.c +3 -3
index 8eb39e9..38a9099 100644
@@ -23,7 +23,7 @@ void get_commit_format(const char *arg, struct rev_info *rev)
 		{ "oneline",	1,	CMIT_FMT_ONELINE },
 	};
 
-	rev->use_terminator = 0;
+	REV_FMT_CLR(rev, USE_TERMINATOR);
 	if (!arg || !*arg) {
 		rev->commit_format = CMIT_FMT_DEFAULT;
 		return;
@@ -33,7 +33,7 @@ void get_commit_format(const char *arg, struct rev_info *rev)
 		free(user_format);
 		user_format = xstrdup(cp);
 		if (arg[0] == 't')
-			rev->use_terminator = 1;
+			REV_FMT_SET(rev, USE_TERMINATOR);
 		rev->commit_format = CMIT_FMT_USERFORMAT;
 		return;
 	}
@@ -41,7 +41,7 @@ void get_commit_format(const char *arg, struct rev_info *rev)
 		if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&
 		    !strncmp(arg, cmt_fmts[i].n, strlen(arg))) {
 			if (cmt_fmts[i].v == CMIT_FMT_ONELINE)
-				rev->use_terminator = 1;
+				REV_FMT_SET(rev, USE_TERMINATOR);
 			rev->commit_format = cmt_fmts[i].v;
 			return;
 		}
reachable.c +3 -3
index 3b1c18f..6ee77f9 100644
@@ -203,9 +203,9 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog)
 	 * Set up revision parsing, and mark us as being interested
 	 * in all object types, not just commits.
 	 */
-	revs->tag_objects = 1;
-	revs->blob_objects = 1;
-	revs->tree_objects = 1;
+	REV_TRAV_SET(revs, TAG_OBJECTS);
+	REV_TRAV_SET(revs, BLOB_OBJECTS);
+	REV_TRAV_SET(revs, TREE_OBJECTS);
 
 	/* Add all refs from the index file */
 	add_cache_refs(revs);
revision.c +101 -101

555 lines not on this page · raw message

revision.h +54 -41

107 lines not on this page · raw message

upload-pack.c +4 -4
index 9d031fc..78bc4b8 100644
@@ -108,11 +108,11 @@ static int do_rev_list(int fd, void *create_full_pack)
 	if (create_full_pack)
 		use_thin_pack = 0; /* no point doing it */
 	init_revisions(&revs, NULL);
-	revs.tag_objects = 1;
-	revs.tree_objects = 1;
-	revs.blob_objects = 1;
+	REV_TRAV_SET(&revs, TAG_OBJECTS);
+	REV_TRAV_SET(&revs, BLOB_OBJECTS);
+	REV_TRAV_SET(&revs, TREE_OBJECTS);
 	if (use_thin_pack)
-		revs.edge_hint = 1;
+		REV_TRAV_SET(&revs, EDGE_HINT);
 
 	if (create_full_pack) {
 		const char *args[] = {"rev-list", "--all", NULL};
Signature · 1 line
1.5.6.rc0.145.gbc48c