@matheusbsbs / matheus-bagliano / commits / 8f67f8aefb
Fork 0

Make the diff_options bitfields be an unsigned with explicit masks.

reverse_diff was a bit-value in disguise, it's merged in the flags now. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Pierre Habouzit committed Nov 10, 2007 at 20:05 UTC 8f67f8aefb1b751073f8b36fae8be8f72eb93f4a
15 files changed +155 -149
builtin-blame.c
+5 -5
@@ -335,7 +335,7 @@ static struct origin *find_origin(struct scoreboard *sb,
335 * same and diff-tree is fairly efficient about this.
336 */
337 diff_setup(&diff_opts);
338 - diff_opts.recursive = 1;
338 + DIFF_OPT_SET(&diff_opts, RECURSIVE);
339 diff_opts.detect_rename = 0;
340 diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
341 paths[0] = origin->path;
@@ -409,7 +409,7 @@ static struct origin *find_rename(struct scoreboard *sb,
409 const char *paths[2];
410
411 diff_setup(&diff_opts);
412 - diff_opts.recursive = 1;
412 + DIFF_OPT_SET(&diff_opts, RECURSIVE);
413 diff_opts.detect_rename = DIFF_DETECT_RENAME;
414 diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
415 diff_opts.single_follow = origin->path;
@@ -1075,7 +1075,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
1075 return 1; /* nothing remains for this target */
1076
1077 diff_setup(&diff_opts);
1078 - diff_opts.recursive = 1;
1078 + DIFF_OPT_SET(&diff_opts, RECURSIVE);
1079 diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
1080
1081 paths[0] = NULL;
@@ -1093,7 +1093,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
1093 if ((opt & PICKAXE_BLAME_COPY_HARDEST)
1094 || ((opt & PICKAXE_BLAME_COPY_HARDER)
1095 && (!porigin || strcmp(target->path, porigin->path))))
1096 - diff_opts.find_copies_harder = 1;
1096 + DIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);
1097
1098 if (is_null_sha1(target->commit->object.sha1))
1099 do_diff_cache(parent->tree->object.sha1, &diff_opts);
@@ -1102,7 +1102,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
1102 target->commit->tree->object.sha1,
1103 "", &diff_opts);
1104
1105 - if (!diff_opts.find_copies_harder)
1105 + if (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))
1106 diffcore_std(&diff_opts);
1107
1108 retval = 0;
builtin-diff-files.c
+3 -1
@@ -31,5 +31,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
31 if (!rev.diffopt.output_format)
32 rev.diffopt.output_format = DIFF_FORMAT_RAW;
33 result = run_diff_files_cmd(&rev, argc, argv);
34 - return rev.diffopt.exit_with_status ? rev.diffopt.has_changes: result;
34 + if (DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))
35 + return DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0;
36 + return result;
37 }
builtin-diff-index.c
+3 -1
@@ -44,5 +44,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
44 return -1;
45 }
46 result = run_diff_index(&rev, cached);
47 - return rev.diffopt.exit_with_status ? rev.diffopt.has_changes: result;
47 + if (DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))
48 + return DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0;
49 + return result;
50 }
builtin-diff-tree.c
+4 -3
@@ -118,8 +118,8 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
118 }
119
120 if (!read_stdin)
121 - return opt->diffopt.exit_with_status ?
122 - opt->diffopt.has_changes: 0;
121 + return DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS)
122 + && DIFF_OPT_TST(&opt->diffopt, HAS_CHANGES);
123
124 if (opt->diffopt.detect_rename)
125 opt->diffopt.setup |= (DIFF_SETUP_USE_SIZE_CACHE |
@@ -134,5 +134,6 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
134 else
135 diff_tree_stdin(line);
136 }
137 - return opt->diffopt.exit_with_status ? opt->diffopt.has_changes: 0;
137 + return DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS)
138 + && DIFF_OPT_TST(&opt->diffopt, HAS_CHANGES);
139 }
builtin-diff.c
+6 -6
@@ -35,7 +35,7 @@ static void stuff_change(struct diff_options *opt,
35 !hashcmp(old_sha1, new_sha1) && (old_mode == new_mode))
36 return;
37
38 - if (opt->reverse_diff) {
38 + if (DIFF_OPT_TST(opt, REVERSE_DIFF)) {
39 unsigned tmp;
40 const unsigned char *tmp_u;
41 const char *tmp_c;
@@ -253,13 +253,13 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
253 if (diff_setup_done(&rev.diffopt) < 0)
254 die("diff_setup_done failed");
255 }
256 - rev.diffopt.allow_external = 1;
257 - rev.diffopt.recursive = 1;
256 + DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
257 + DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
258
259 /* If the user asked for our exit code then don't start a
260 * pager or we would end up reporting its exit code instead.
261 */
262 - if (!rev.diffopt.exit_with_status)
262 + if (!DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))
263 setup_pager();
264
265 /* Do we have --cached and not have a pending object, then
@@ -363,8 +363,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
363 else
364 result = builtin_diff_combined(&rev, argc, argv,
365 ent, ents);
366 - if (rev.diffopt.exit_with_status)
367 - result = rev.diffopt.has_changes;
366 + if (DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))
367 + result = DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0;
368
369 if (1 < rev.diffopt.skip_stat_unmatch)
370 refresh_index_quietly();
builtin-log.c
+10 -14
@@ -55,13 +55,13 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
55 rev->abbrev = DEFAULT_ABBREV;
56 rev->commit_format = CMIT_FMT_DEFAULT;
57 rev->verbose_header = 1;
58 - rev->diffopt.recursive = 1;
58 + DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
59 rev->show_root_diff = default_show_root;
60 rev->subject_prefix = fmt_patch_subject_prefix;
61 argc = setup_revisions(argc, argv, rev, "HEAD");
62 if (rev->diffopt.pickaxe || rev->diffopt.filter)
63 rev->always_show_header = 0;
64 - if (rev->diffopt.follow_renames) {
64 + if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {
65 rev->always_show_header = 0;
66 if (rev->diffopt.nr_paths != 1)
67 usage("git logs can only follow renames on one pathname at a time");
@@ -185,11 +185,9 @@ int cmd_show(int argc, const char **argv, const char *prefix)
185 struct tag *t = (struct tag *)o;
186
187 printf("%stag %s%s\n\n",
188 - diff_get_color(rev.diffopt.color_diff,
189 - DIFF_COMMIT),
188 + diff_get_color_opt(&rev.diffopt, DIFF_COMMIT),
189 t->tag,
191 - diff_get_color(rev.diffopt.color_diff,
192 - DIFF_RESET));
190 + diff_get_color_opt(&rev.diffopt, DIFF_RESET));
191 ret = show_object(o->sha1, 1);
192 objects[i].item = (struct object *)t->tagged;
193 i--;
@@ -197,11 +195,9 @@ int cmd_show(int argc, const char **argv, const char *prefix)
195 }
196 case OBJ_TREE:
197 printf("%stree %s%s\n\n",
200 - diff_get_color(rev.diffopt.color_diff,
201 - DIFF_COMMIT),
198 + diff_get_color_opt(&rev.diffopt, DIFF_COMMIT),
199 name,
203 - diff_get_color(rev.diffopt.color_diff,
204 - DIFF_RESET));
200 + diff_get_color_opt(&rev.diffopt, DIFF_RESET));
201 read_tree_recursive((struct tree *)o, "", 0, 0, NULL,
202 show_tree_object);
203 break;
@@ -487,7 +483,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
483 rev.combine_merges = 0;
484 rev.ignore_merges = 1;
485 rev.diffopt.msg_sep = "";
490 - rev.diffopt.recursive = 1;
486 + DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
487
488 rev.subject_prefix = fmt_patch_subject_prefix;
489 rev.extra_headers = extra_headers;
@@ -590,8 +586,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
586 if (!rev.diffopt.output_format)
587 rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_PATCH;
588
593 - if (!rev.diffopt.text)
594 - rev.diffopt.binary = 1;
589 + if (!DIFF_OPT_TST(&rev.diffopt, TEXT))
590 + DIFF_OPT_SET(&rev.diffopt, BINARY);
591
592 if (!output_directory && !use_stdout)
593 output_directory = prefix;
@@ -747,7 +743,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
743 revs.diff = 1;
744 revs.combine_merges = 0;
745 revs.ignore_merges = 1;
750 - revs.diffopt.recursive = 1;
746 + DIFF_OPT_SET(&revs.diffopt, RECURSIVE);
747
748 if (add_pending_commit(head, &revs, 0))
749 die("Unknown commit %s", head);
combine-diff.c
+5 -5
@@ -664,7 +664,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
664 int mode_differs = 0;
665 int i, show_hunks;
666 int working_tree_file = is_null_sha1(elem->sha1);
667 - int abbrev = opt->full_index ? 40 : DEFAULT_ABBREV;
667 + int abbrev = DIFF_OPT_TST(opt, FULL_INDEX) ? 40 : DEFAULT_ABBREV;
668 mmfile_t result_file;
669
670 context = opt->context;
@@ -784,7 +784,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
784
785 if (show_hunks || mode_differs || working_tree_file) {
786 const char *abb;
787 - int use_color = opt->color_diff;
787 + int use_color = DIFF_OPT_TST(opt, COLOR_DIFF);
788 const char *c_meta = diff_get_color(use_color, DIFF_METAINFO);
789 const char *c_reset = diff_get_color(use_color, DIFF_RESET);
790 int added = 0;
@@ -836,7 +836,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
836 dump_quoted_path("+++ /dev/", "null", c_meta, c_reset);
837 else
838 dump_quoted_path("+++ b/", elem->path, c_meta, c_reset);
839 - dump_sline(sline, cnt, num_parent, opt->color_diff);
839 + dump_sline(sline, cnt, num_parent, DIFF_OPT_TST(opt, COLOR_DIFF));
840 }
841 free(result);
842
@@ -929,8 +929,8 @@ void diff_tree_combined(const unsigned char *sha1,
929
930 diffopts = *opt;
931 diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
932 - diffopts.recursive = 1;
933 - diffopts.allow_external = 0;
932 + DIFF_OPT_SET(&diffopts, RECURSIVE);
933 + DIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);
934
935 show_log_first = !!rev->loginfo && !rev->no_commit_id;
936 needsep = 0;
diff-lib.c
+13 -11
@@ -121,7 +121,7 @@ static int queue_diff(struct diff_options *o,
121 } else {
122 struct diff_filespec *d1, *d2;
123
124 - if (o->reverse_diff) {
124 + if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
125 unsigned tmp;
126 const char *tmp_c;
127 tmp = mode1; mode1 = mode2; mode2 = tmp;
@@ -188,8 +188,8 @@ static int handle_diff_files_args(struct rev_info *revs,
188 else if (!strcmp(argv[1], "-n") ||
189 !strcmp(argv[1], "--no-index")) {
190 revs->max_count = -2;
191 - revs->diffopt.exit_with_status = 1;
192 - revs->diffopt.no_index = 1;
191 + DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
192 + DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
193 }
194 else if (!strcmp(argv[1], "-q"))
195 *silent = 1;
@@ -207,7 +207,7 @@ static int handle_diff_files_args(struct rev_info *revs,
207 if (!is_in_index(revs->diffopt.paths[0]) ||
208 !is_in_index(revs->diffopt.paths[1])) {
209 revs->max_count = -2;
210 - revs->diffopt.no_index = 1;
210 + DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
211 }
212 }
213
@@ -258,7 +258,7 @@ int setup_diff_no_index(struct rev_info *revs,
258 break;
259 } else if (i < argc - 3 && !strcmp(argv[i], "--no-index")) {
260 i = argc - 3;
261 - revs->diffopt.exit_with_status = 1;
261 + DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
262 break;
263 }
264 if (argc != i + 2 || (!is_outside_repo(argv[i + 1], nongit, prefix) &&
@@ -296,7 +296,7 @@ int setup_diff_no_index(struct rev_info *revs,
296 else
297 revs->diffopt.paths = argv + argc - 2;
298 revs->diffopt.nr_paths = 2;
299 - revs->diffopt.no_index = 1;
299 + DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
300 revs->max_count = -2;
301 if (diff_setup_done(&revs->diffopt) < 0)
302 die("diff_setup_done failed");
@@ -310,7 +310,7 @@ int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv)
310 if (handle_diff_files_args(revs, argc, argv, &silent_on_removed))
311 return -1;
312
313 - if (revs->diffopt.no_index) {
313 + if (DIFF_OPT_TST(&revs->diffopt, NO_INDEX)) {
314 if (revs->diffopt.nr_paths != 2)
315 return error("need two files/directories with --no-index");
316 if (queue_diff(&revs->diffopt, revs->diffopt.paths[0],
@@ -346,7 +346,8 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
346 struct cache_entry *ce = active_cache[i];
347 int changed;
348
349 - if (revs->diffopt.quiet && revs->diffopt.has_changes)
349 + if (DIFF_OPT_TST(&revs->diffopt, QUIET) &&
350 + DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))
351 break;
352
353 if (!ce_path_match(ce, revs->prune_data))
@@ -442,7 +443,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
443 continue;
444 }
445 changed = ce_match_stat(ce, &st, 0);
445 - if (!changed && !revs->diffopt.find_copies_harder)
446 + if (!changed && !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
447 continue;
448 oldmode = ntohl(ce->ce_mode);
449 newmode = ntohl(ce_mode_from_stat(ce, st.st_mode));
@@ -561,7 +562,7 @@ static int show_modified(struct rev_info *revs,
562
563 oldmode = old->ce_mode;
564 if (mode == oldmode && !hashcmp(sha1, old->sha1) &&
564 - !revs->diffopt.find_copies_harder)
565 + !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
566 return 0;
567
568 mode = ntohl(mode);
@@ -581,7 +582,8 @@ static int diff_cache(struct rev_info *revs,
582 struct cache_entry *ce = *ac;
583 int same = (entries > 1) && ce_same_name(ce, ac[1]);
584
584 - if (revs->diffopt.quiet && revs->diffopt.has_changes)
585 + if (DIFF_OPT_TST(&revs->diffopt, QUIET) &&
586 + DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))
587 break;
588
589 if (!ce_path_match(ce, pathspec))
diff.c
+60 -63
@@ -814,10 +814,10 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)
814 }
815
816 /* Find the longest filename and max number of changes */
817 - reset = diff_get_color(options->color_diff, DIFF_RESET);
818 - set = diff_get_color(options->color_diff, DIFF_PLAIN);
819 - add_c = diff_get_color(options->color_diff, DIFF_FILE_NEW);
820 - del_c = diff_get_color(options->color_diff, DIFF_FILE_OLD);
817 + reset = diff_get_color_opt(options, DIFF_RESET);
818 + set = diff_get_color_opt(options, DIFF_PLAIN);
819 + add_c = diff_get_color_opt(options, DIFF_FILE_NEW);
820 + del_c = diff_get_color_opt(options, DIFF_FILE_OLD);
821
822 for (i = 0; i < data->nr; i++) {
823 struct diffstat_file *file = data->files[i];
@@ -1243,8 +1243,8 @@ static void builtin_diff(const char *name_a,
1243 mmfile_t mf1, mf2;
1244 const char *lbl[2];
1245 char *a_one, *b_two;
1246 - const char *set = diff_get_color(o->color_diff, DIFF_METAINFO);
1247 - const char *reset = diff_get_color(o->color_diff, DIFF_RESET);
1246 + const char *set = diff_get_color_opt(o, DIFF_METAINFO);
1247 + const char *reset = diff_get_color_opt(o, DIFF_RESET);
1248
1249 a_one = quote_two("a/", name_a + (*name_a == '/'));
1250 b_two = quote_two("b/", name_b + (*name_b == '/'));
@@ -1277,7 +1277,7 @@ static void builtin_diff(const char *name_a,
1277 goto free_ab_and_return;
1278 if (complete_rewrite) {
1279 emit_rewrite_diff(name_a, name_b, one, two,
1280 - o->color_diff);
1280 + DIFF_OPT_TST(o, COLOR_DIFF));
1281 o->found_changes = 1;
1282 goto free_ab_and_return;
1283 }
@@ -1286,13 +1286,13 @@ static void builtin_diff(const char *name_a,
1286 if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
1287 die("unable to read files to diff");
1288
1289 - if (!o->text &&
1289 + if (!DIFF_OPT_TST(o, TEXT) &&
1290 (diff_filespec_is_binary(one) || diff_filespec_is_binary(two))) {
1291 /* Quite common confusing case */
1292 if (mf1.size == mf2.size &&
1293 !memcmp(mf1.ptr, mf2.ptr, mf1.size))
1294 goto free_ab_and_return;
1295 - if (o->binary)
1295 + if (DIFF_OPT_TST(o, BINARY))
1296 emit_binary_diff(&mf1, &mf2);
1297 else
1298 printf("Binary files %s and %s differ\n",
@@ -1315,7 +1315,7 @@ static void builtin_diff(const char *name_a,
1315 memset(&xecfg, 0, sizeof(xecfg));
1316 memset(&ecbdata, 0, sizeof(ecbdata));
1317 ecbdata.label_path = lbl;
1318 - ecbdata.color_diff = o->color_diff;
1318 + ecbdata.color_diff = DIFF_OPT_TST(o, COLOR_DIFF);
1319 ecbdata.found_changesp = &o->found_changes;
1320 xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
1321 xecfg.ctxlen = o->context;
@@ -1331,11 +1331,11 @@ static void builtin_diff(const char *name_a,
1331 ecb.outf = xdiff_outf;
1332 ecb.priv = &ecbdata;
1333 ecbdata.xm.consume = fn_out_consume;
1334 - if (o->color_diff_words)
1334 + if (DIFF_OPT_TST(o, COLOR_DIFF_WORDS))
1335 ecbdata.diff_words =
1336 xcalloc(1, sizeof(struct diff_words_data));
1337 xdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
1338 - if (o->color_diff_words)
1338 + if (DIFF_OPT_TST(o, COLOR_DIFF_WORDS))
1339 free_diff_words_data(&ecbdata);
1340 }
1341
@@ -1409,7 +1409,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
1409 data.xm.consume = checkdiff_consume;
1410 data.filename = name_b ? name_b : name_a;
1411 data.lineno = 0;
1412 - data.color_diff = o->color_diff;
1412 + data.color_diff = DIFF_OPT_TST(o, COLOR_DIFF);
1413
1414 if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
1415 die("unable to read files to diff");
@@ -1853,7 +1853,7 @@ static void run_diff_cmd(const char *pgm,
1853 struct diff_options *o,
1854 int complete_rewrite)
1855 {
1856 - if (!o->allow_external)
1856 + if (!DIFF_OPT_TST(o, ALLOW_EXTERNAL))
1857 pgm = NULL;
1858 else {
1859 const char *cmd = external_diff_attr(name);
@@ -1951,9 +1951,9 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)
1951 }
1952
1953 if (hashcmp(one->sha1, two->sha1)) {
1954 - int abbrev = o->full_index ? 40 : DEFAULT_ABBREV;
1954 + int abbrev = DIFF_OPT_TST(o, FULL_INDEX) ? 40 : DEFAULT_ABBREV;
1955
1956 - if (o->binary) {
1956 + if (DIFF_OPT_TST(o, BINARY)) {
1957 mmfile_t mf;
1958 if ((!fill_mmfile(&mf, one) && diff_filespec_is_binary(one)) ||
1959 (!fill_mmfile(&mf, two) && diff_filespec_is_binary(two)))
@@ -2045,7 +2045,10 @@ void diff_setup(struct diff_options *options)
2045
2046 options->change = diff_change;
2047 options->add_remove = diff_addremove;
2048 - options->color_diff = diff_use_color_default;
2048 + if (diff_use_color_default)
2049 + DIFF_OPT_SET(options, COLOR_DIFF);
2050 + else
2051 + DIFF_OPT_CLR(options, COLOR_DIFF);
2052 options->detect_rename = diff_detect_rename_default;
2053 }
2054
@@ -2064,7 +2067,7 @@ int diff_setup_done(struct diff_options *options)
2067 if (count > 1)
2068 die("--name-only, --name-status, --check and -s are mutually exclusive");
2069
2067 - if (options->find_copies_harder)
2070 + if (DIFF_OPT_TST(options, FIND_COPIES_HARDER))
2071 options->detect_rename = DIFF_DETECT_COPY;
2072
2073 if (options->output_format & (DIFF_FORMAT_NAME |
@@ -2088,12 +2091,12 @@ int diff_setup_done(struct diff_options *options)
2091 DIFF_FORMAT_SHORTSTAT |
2092 DIFF_FORMAT_SUMMARY |
2093 DIFF_FORMAT_CHECKDIFF))
2091 - options->recursive = 1;
2094 + DIFF_OPT_SET(options, RECURSIVE);
2095 /*
2096 * Also pickaxe would not work very well if you do not say recursive
2097 */
2098 if (options->pickaxe)
2096 - options->recursive = 1;
2099 + DIFF_OPT_SET(options, RECURSIVE);
2100
2101 if (options->detect_rename && options->rename_limit < 0)
2102 options->rename_limit = diff_rename_limit_default;
@@ -2115,9 +2118,9 @@ int diff_setup_done(struct diff_options *options)
2118 * to have found. It does not make sense not to return with
2119 * exit code in such a case either.
2120 */
2118 - if (options->quiet) {
2121 + if (DIFF_OPT_TST(options, QUIET)) {
2122 options->output_format = DIFF_FORMAT_NO_OUTPUT;
2120 - options->exit_with_status = 1;
2123 + DIFF_OPT_SET(options, EXIT_WITH_STATUS);
2124 }
2125
2126 /*
@@ -2125,7 +2128,7 @@ int diff_setup_done(struct diff_options *options)
2128 * upon the first hit. We need to run diff as usual.
2129 */
2130 if (options->pickaxe || options->filter)
2128 - options->quiet = 0;
2131 + DIFF_OPT_CLR(options, QUIET);
2132
2133 return 0;
2134 }
@@ -2188,15 +2191,12 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
2191 options->output_format |= DIFF_FORMAT_PATCH;
2192 else if (!strcmp(arg, "--raw"))
2193 options->output_format |= DIFF_FORMAT_RAW;
2191 - else if (!strcmp(arg, "--patch-with-raw")) {
2194 + else if (!strcmp(arg, "--patch-with-raw"))
2195 options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW;
2193 - }
2194 - else if (!strcmp(arg, "--numstat")) {
2196 + else if (!strcmp(arg, "--numstat"))
2197 options->output_format |= DIFF_FORMAT_NUMSTAT;
2196 - }
2197 - else if (!strcmp(arg, "--shortstat")) {
2198 + else if (!strcmp(arg, "--shortstat"))
2199 options->output_format |= DIFF_FORMAT_SHORTSTAT;
2199 - }
2200 else if (!prefixcmp(arg, "--stat")) {
2201 char *end;
2202 int width = options->stat_width;
@@ -2228,33 +2228,30 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
2228 options->output_format |= DIFF_FORMAT_CHECKDIFF;
2229 else if (!strcmp(arg, "--summary"))
2230 options->output_format |= DIFF_FORMAT_SUMMARY;
2231 - else if (!strcmp(arg, "--patch-with-stat")) {
2231 + else if (!strcmp(arg, "--patch-with-stat"))
2232 options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT;
2233 - }
2233 else if (!strcmp(arg, "-z"))
2234 options->line_termination = 0;
2235 else if (!prefixcmp(arg, "-l"))
2236 options->rename_limit = strtoul(arg+2, NULL, 10);
2237 else if (!strcmp(arg, "--full-index"))
2239 - options->full_index = 1;
2238 + DIFF_OPT_SET(options, FULL_INDEX);
2239 else if (!strcmp(arg, "--binary")) {
2240 options->output_format |= DIFF_FORMAT_PATCH;
2242 - options->binary = 1;
2243 - }
2244 - else if (!strcmp(arg, "-a") || !strcmp(arg, "--text")) {
2245 - options->text = 1;
2241 + DIFF_OPT_SET(options, BINARY);
2242 }
2243 + else if (!strcmp(arg, "-a") || !strcmp(arg, "--text"))
2244 + DIFF_OPT_SET(options, TEXT);
2245 else if (!strcmp(arg, "--name-only"))
2246 options->output_format |= DIFF_FORMAT_NAME;
2247 else if (!strcmp(arg, "--name-status"))
2248 options->output_format |= DIFF_FORMAT_NAME_STATUS;
2249 else if (!strcmp(arg, "-R"))
2252 - options->reverse_diff = 1;
2250 + DIFF_OPT_SET(options, REVERSE_DIFF);
2251 else if (!prefixcmp(arg, "-S"))
2252 options->pickaxe = arg + 2;
2255 - else if (!strcmp(arg, "-s")) {
2253 + else if (!strcmp(arg, "-s"))
2254 options->output_format |= DIFF_FORMAT_NO_OUTPUT;
2257 - }
2255 else if (!prefixcmp(arg, "-O"))
2256 options->orderfile = arg + 2;
2257 else if (!prefixcmp(arg, "--diff-filter="))
@@ -2264,28 +2261,25 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
2261 else if (!strcmp(arg, "--pickaxe-regex"))
2262 options->pickaxe_opts = DIFF_PICKAXE_REGEX;
2263 else if (!prefixcmp(arg, "-B")) {
2267 - if ((options->break_opt =
2268 - diff_scoreopt_parse(arg)) == -1)
2264 + if ((options->break_opt = diff_scoreopt_parse(arg)) == -1)
2265 return -1;
2266 }
2267 else if (!prefixcmp(arg, "-M")) {
2272 - if ((options->rename_score =
2273 - diff_scoreopt_parse(arg)) == -1)
2268 + if ((options->rename_score = diff_scoreopt_parse(arg)) == -1)
2269 return -1;
2270 options->detect_rename = DIFF_DETECT_RENAME;
2271 }
2272 else if (!prefixcmp(arg, "-C")) {
2273 if (options->detect_rename == DIFF_DETECT_COPY)
2279 - options->find_copies_harder = 1;
2280 - if ((options->rename_score =
2281 - diff_scoreopt_parse(arg)) == -1)
2274 + DIFF_OPT_SET(options, FIND_COPIES_HARDER);
2275 + if ((options->rename_score = diff_scoreopt_parse(arg)) == -1)
2276 return -1;
2277 options->detect_rename = DIFF_DETECT_COPY;
2278 }
2279 else if (!strcmp(arg, "--find-copies-harder"))
2286 - options->find_copies_harder = 1;
2280 + DIFF_OPT_SET(options, FIND_COPIES_HARDER);
2281 else if (!strcmp(arg, "--follow"))
2288 - options->follow_renames = 1;
2282 + DIFF_OPT_SET(options, FOLLOW_RENAMES);
2283 else if (!strcmp(arg, "--abbrev"))
2284 options->abbrev = DEFAULT_ABBREV;
2285 else if (!prefixcmp(arg, "--abbrev=")) {
@@ -2296,9 +2290,9 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
2290 options->abbrev = 40;
2291 }
2292 else if (!strcmp(arg, "--color"))
2299 - options->color_diff = 1;
2293 + DIFF_OPT_SET(options, COLOR_DIFF);
2294 else if (!strcmp(arg, "--no-color"))
2301 - options->color_diff = 0;
2295 + DIFF_OPT_CLR(options, COLOR_DIFF);
2296 else if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space"))
2297 options->xdl_opts |= XDF_IGNORE_WHITESPACE;
2298 else if (!strcmp(arg, "-b") || !strcmp(arg, "--ignore-space-change"))
@@ -2306,17 +2300,17 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
2300 else if (!strcmp(arg, "--ignore-space-at-eol"))
2301 options->xdl_opts |= XDF_IGNORE_WHITESPACE_AT_EOL;
2302 else if (!strcmp(arg, "--color-words"))
2309 - options->color_diff = options->color_diff_words = 1;
2303 + options->flags |= DIFF_OPT_COLOR_DIFF | DIFF_OPT_COLOR_DIFF_WORDS;
2304 else if (!strcmp(arg, "--no-renames"))
2305 options->detect_rename = 0;
2306 else if (!strcmp(arg, "--exit-code"))
2313 - options->exit_with_status = 1;
2307 + DIFF_OPT_SET(options, EXIT_WITH_STATUS);
2308 else if (!strcmp(arg, "--quiet"))
2315 - options->quiet = 1;
2309 + DIFF_OPT_SET(options, QUIET);
2310 else if (!strcmp(arg, "--ext-diff"))
2317 - options->allow_external = 1;
2311 + DIFF_OPT_SET(options, ALLOW_EXTERNAL);
2312 else if (!strcmp(arg, "--no-ext-diff"))
2319 - options->allow_external = 0;
2313 + DIFF_OPT_CLR(options, ALLOW_EXTERNAL);
2314 else
2315 return 0;
2316 return 1;
@@ -3071,7 +3065,7 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)
3065 * to determine how many paths were dirty only
3066 * due to stat info mismatch.
3067 */
3074 - if (!diffopt->no_index)
3068 + if (!DIFF_OPT_TST(diffopt, NO_INDEX))
3069 diffopt->skip_stat_unmatch++;
3070 diff_free_filepair(p);
3071 }
@@ -3082,10 +3076,10 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)
3076
3077 void diffcore_std(struct diff_options *options)
3078 {
3085 - if (options->quiet)
3079 + if (DIFF_OPT_TST(options, QUIET))
3080 return;
3081
3088 - if (options->skip_stat_unmatch && !options->find_copies_harder)
3082 + if (options->skip_stat_unmatch && !DIFF_OPT_TST(options, FIND_COPIES_HARDER))
3083 diffcore_skip_stat_unmatch(options);
3084 if (options->break_opt != -1)
3085 diffcore_break(options->break_opt);
@@ -3100,7 +3094,10 @@ void diffcore_std(struct diff_options *options)
3094 diff_resolve_rename_copy();
3095 diffcore_apply_filter(options->filter);
3096
3103 - options->has_changes = !!diff_queued_diff.nr;
3097 + if (diff_queued_diff.nr)
3098 + DIFF_OPT_SET(options, HAS_CHANGES);
3099 + else
3100 + DIFF_OPT_CLR(options, HAS_CHANGES);
3101 }
3102
3103
@@ -3124,7 +3121,7 @@ void diff_addremove(struct diff_options *options,
3121 * Before the final output happens, they are pruned after
3122 * merged into rename/copy pairs as appropriate.
3123 */
3127 - if (options->reverse_diff)
3124 + if (DIFF_OPT_TST(options, REVERSE_DIFF))
3125 addremove = (addremove == '+' ? '-' :
3126 addremove == '-' ? '+' : addremove);
3127
@@ -3139,7 +3136,7 @@ void diff_addremove(struct diff_options *options,
3136 fill_filespec(two, sha1, mode);
3137
3138 diff_queue(&diff_queued_diff, one, two);
3142 - options->has_changes = 1;
3139 + DIFF_OPT_SET(options, HAS_CHANGES);
3140 }
3141
3142 void diff_change(struct diff_options *options,
@@ -3151,7 +3148,7 @@ void diff_change(struct diff_options *options,
3148 char concatpath[PATH_MAX];
3149 struct diff_filespec *one, *two;
3150
3154 - if (options->reverse_diff) {
3151 + if (DIFF_OPT_TST(options, REVERSE_DIFF)) {
3152 unsigned tmp;
3153 const unsigned char *tmp_c;
3154 tmp = old_mode; old_mode = new_mode; new_mode = tmp;
@@ -3165,7 +3162,7 @@ void diff_change(struct diff_options *options,
3162 fill_filespec(two, new_sha1, new_mode);
3163
3164 diff_queue(&diff_queued_diff, one, two);
3168 - options->has_changes = 1;
3165 + DIFF_OPT_SET(options, HAS_CHANGES);
3166 }
3167
3168 void diff_unmerge(struct diff_options *options,
diff.h
+24 -16
@@ -43,26 +43,32 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
43
44 #define DIFF_FORMAT_CALLBACK 0x1000
45
46 +#define DIFF_OPT_RECURSIVE (1 << 0)
47 +#define DIFF_OPT_TREE_IN_RECURSIVE (1 << 1)
48 +#define DIFF_OPT_BINARY (1 << 2)
49 +#define DIFF_OPT_TEXT (1 << 3)
50 +#define DIFF_OPT_FULL_INDEX (1 << 4)
51 +#define DIFF_OPT_SILENT_ON_REMOVE (1 << 5)
52 +#define DIFF_OPT_FIND_COPIES_HARDER (1 << 6)
53 +#define DIFF_OPT_FOLLOW_RENAMES (1 << 7)
54 +#define DIFF_OPT_COLOR_DIFF (1 << 8)
55 +#define DIFF_OPT_COLOR_DIFF_WORDS (1 << 9)
56 +#define DIFF_OPT_HAS_CHANGES (1 << 10)
57 +#define DIFF_OPT_QUIET (1 << 11)
58 +#define DIFF_OPT_NO_INDEX (1 << 12)
59 +#define DIFF_OPT_ALLOW_EXTERNAL (1 << 13)
60 +#define DIFF_OPT_EXIT_WITH_STATUS (1 << 14)
61 +#define DIFF_OPT_REVERSE_DIFF (1 << 15)
62 +#define DIFF_OPT_TST(opts, flag) ((opts)->flags & DIFF_OPT_##flag)
63 +#define DIFF_OPT_SET(opts, flag) ((opts)->flags |= DIFF_OPT_##flag)
64 +#define DIFF_OPT_CLR(opts, flag) ((opts)->flags &= ~DIFF_OPT_##flag)
65 +
66 struct diff_options {
67 const char *filter;
68 const char *orderfile;
69 const char *pickaxe;
70 const char *single_follow;
51 - unsigned recursive:1,
52 - tree_in_recursive:1,
53 - binary:1,
54 - text:1,
55 - full_index:1,
56 - silent_on_remove:1,
57 - find_copies_harder:1,
58 - follow_renames:1,
59 - color_diff:1,
60 - color_diff_words:1,
61 - has_changes:1,
62 - quiet:1,
63 - no_index:1,
64 - allow_external:1,
65 - exit_with_status:1;
71 + unsigned flags;
72 int context;
73 int break_opt;
74 int detect_rename;
@@ -71,7 +77,6 @@ struct diff_options {
77 int output_format;
78 int pickaxe_opts;
79 int rename_score;
74 - int reverse_diff;
80 int rename_limit;
81 int setup;
82 int abbrev;
@@ -105,6 +110,9 @@ enum color_diff {
110 DIFF_WHITESPACE = 7,
111 };
112 const char *diff_get_color(int diff_use_color, enum color_diff ix);
113 +#define diff_get_color_opt(o, ix) \
114 + diff_get_color(DIFF_OPT_TST((o), COLOR_DIFF), ix)
115 +
116
117 extern const char mime_boundary_leader[];
118
log-tree.c
+2 -4
@@ -245,8 +245,7 @@ void show_log(struct rev_info *opt, const char *sep)
245 opt->diffopt.stat_sep = buffer;
246 }
247 } else if (opt->commit_format != CMIT_FMT_USERFORMAT) {
248 - fputs(diff_get_color(opt->diffopt.color_diff, DIFF_COMMIT),
249 - stdout);
248 + fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);
249 if (opt->commit_format != CMIT_FMT_ONELINE)
250 fputs("commit ", stdout);
251 if (commit->object.flags & BOUNDARY)
@@ -266,8 +265,7 @@ void show_log(struct rev_info *opt, const char *sep)
265 diff_unique_abbrev(parent->object.sha1,
266 abbrev_commit));
267 show_decorations(commit);
269 - printf("%s",
270 - diff_get_color(opt->diffopt.color_diff, DIFF_RESET));
268 + printf("%s", diff_get_color_opt(&opt->diffopt, DIFF_RESET));
269 putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n');
270 if (opt->reflog_info) {
271 show_reflog_message(opt->reflog_info,
merge-recursive.c
+1 -1
@@ -366,7 +366,7 @@ static struct path_list *get_renames(struct tree *tree,
366
367 renames = xcalloc(1, sizeof(struct path_list));
368 diff_setup(&opts);
369 - opts.recursive = 1;
369 + DIFF_OPT_SET(&opts, RECURSIVE);
370 opts.detect_rename = DIFF_DETECT_RENAME;
371 opts.rename_limit = rename_limit;
372 opts.output_format = DIFF_FORMAT_NO_OUTPUT;
patch-ids.c
+1 -1
@@ -121,7 +121,7 @@ int init_patch_ids(struct patch_ids *ids)
121 {
122 memset(ids, 0, sizeof(*ids));
123 diff_setup(&ids->diffopts);
124 - ids->diffopts.recursive = 1;
124 + DIFF_OPT_SET(&ids->diffopts, RECURSIVE);
125 if (diff_setup_done(&ids->diffopts) < 0)
126 return error("diff_setup_done failed");
127 return 0;
revision.c
+11 -11
@@ -250,7 +250,7 @@ static void file_add_remove(struct diff_options *options,
250 }
251 tree_difference = diff;
252 if (tree_difference == REV_TREE_DIFFERENT)
253 - options->has_changes = 1;
253 + DIFF_OPT_SET(options, HAS_CHANGES);
254 }
255
256 static void file_change(struct diff_options *options,
@@ -260,7 +260,7 @@ static void file_change(struct diff_options *options,
260 const char *base, const char *path)
261 {
262 tree_difference = REV_TREE_DIFFERENT;
263 - options->has_changes = 1;
263 + DIFF_OPT_SET(options, HAS_CHANGES);
264 }
265
266 static int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree *t2)
@@ -270,7 +270,7 @@ static int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree
270 if (!t2)
271 return REV_TREE_DIFFERENT;
272 tree_difference = REV_TREE_SAME;
273 - revs->pruning.has_changes = 0;
273 + DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
274 if (diff_tree_sha1(t1->object.sha1, t2->object.sha1, "",
275 &revs->pruning) < 0)
276 return REV_TREE_DIFFERENT;
@@ -294,7 +294,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1)
294 init_tree_desc(&empty, "", 0);
295
296 tree_difference = REV_TREE_SAME;
297 - revs->pruning.has_changes = 0;
297 + DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
298 retval = diff_tree(&empty, &real, "", &revs->pruning);
299 free(tree);
300
@@ -662,8 +662,8 @@ void init_revisions(struct rev_info *revs, const char *prefix)
662 revs->abbrev = DEFAULT_ABBREV;
663 revs->ignore_merges = 1;
664 revs->simplify_history = 1;
665 - revs->pruning.recursive = 1;
666 - revs->pruning.quiet = 1;
665 + DIFF_OPT_SET(&revs->pruning, RECURSIVE);
666 + DIFF_OPT_SET(&revs->pruning, QUIET);
667 revs->pruning.add_remove = file_add_remove;
668 revs->pruning.change = file_change;
669 revs->lifo = 1;
@@ -1054,13 +1054,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
1054 }
1055 if (!strcmp(arg, "-r")) {
1056 revs->diff = 1;
1057 - revs->diffopt.recursive = 1;
1057 + DIFF_OPT_SET(&revs->diffopt, RECURSIVE);
1058 continue;
1059 }
1060 if (!strcmp(arg, "-t")) {
1061 revs->diff = 1;
1062 - revs->diffopt.recursive = 1;
1063 - revs->diffopt.tree_in_recursive = 1;
1062 + DIFF_OPT_SET(&revs->diffopt, RECURSIVE);
1063 + DIFF_OPT_SET(&revs->diffopt, TREE_IN_RECURSIVE);
1064 continue;
1065 }
1066 if (!strcmp(arg, "-m")) {
@@ -1242,7 +1242,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
1242 revs->diff = 1;
1243
1244 /* Pickaxe and rename following needs diffs */
1245 - if (revs->diffopt.pickaxe || revs->diffopt.follow_renames)
1245 + if (revs->diffopt.pickaxe || DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))
1246 revs->diff = 1;
1247
1248 if (revs->topo_order)
@@ -1251,7 +1251,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
1251 if (revs->prune_data) {
1252 diff_tree_setup_paths(revs->prune_data, &revs->pruning);
1253 /* Can't prune commits with rename following: the paths change.. */
1254 - if (!revs->diffopt.follow_renames)
1254 + if (!DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))
1255 revs->prune_fn = try_to_simplify_commit;
1256 if (!revs->full_diff)
1257 diff_tree_setup_paths(revs->prune_data, &revs->diffopt);
tree-diff.c
+7 -7
@@ -39,7 +39,7 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, const
39 show_entry(opt, "+", t2, base, baselen);
40 return 1;
41 }
42 - if (!opt->find_copies_harder && !hashcmp(sha1, sha2) && mode1 == mode2)
42 + if (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER) && !hashcmp(sha1, sha2) && mode1 == mode2)
43 return 0;
44
45 /*
@@ -52,10 +52,10 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, const
52 return 0;
53 }
54
55 - if (opt->recursive && S_ISDIR(mode1)) {
55 + if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode1)) {
56 int retval;
57 char *newbase = malloc_base(base, baselen, path1, pathlen1);
58 - if (opt->tree_in_recursive)
58 + if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE))
59 opt->change(opt, mode1, mode2,
60 sha1, sha2, base, path1);
61 retval = diff_tree_sha1(sha1, sha2, newbase, opt);
@@ -206,7 +206,7 @@ static void show_entry(struct diff_options *opt, const char *prefix, struct tree
206 const char *path;
207 const unsigned char *sha1 = tree_entry_extract(desc, &path, &mode);
208
209 - if (opt->recursive && S_ISDIR(mode)) {
209 + if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode)) {
210 enum object_type type;
211 int pathlen = tree_entry_len(path, sha1);
212 char *newbase = malloc_base(base, baselen, path, pathlen);
@@ -257,7 +257,7 @@ int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, stru
257 int baselen = strlen(base);
258
259 for (;;) {
260 - if (opt->quiet && opt->has_changes)
260 + if (DIFF_OPT_TST(opt, QUIET) && DIFF_OPT_TST(opt, HAS_CHANGES))
261 break;
262 if (opt->nr_paths) {
263 skip_uninteresting(t1, base, baselen, opt);
@@ -315,7 +315,7 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
315 q->nr = 0;
316
317 diff_setup(&diff_opts);
318 - diff_opts.recursive = 1;
318 + DIFF_OPT_SET(&diff_opts, RECURSIVE);
319 diff_opts.detect_rename = DIFF_DETECT_RENAME;
320 diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
321 diff_opts.single_follow = opt->paths[0];
@@ -380,7 +380,7 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha
380 init_tree_desc(&t1, tree1, size1);
381 init_tree_desc(&t2, tree2, size2);
382 retval = diff_tree(&t1, &t2, base, opt);
383 - if (opt->follow_renames && diff_might_be_rename()) {
383 + if (DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename()) {
384 init_tree_desc(&t1, tree1, size1);
385 init_tree_desc(&t2, tree2, size2);
386 try_to_follow_renames(&t1, &t2, base, opt);