@matheusbsbs / matheus-bagliano / commits / 5033639c95
Fork 0

merge-recursive: move call_depth to struct merge_options

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>

Miklos Vajna committed Sep 2, 2008 at 23:30 UTC 5033639c951da27fc4d4becbc3e46dc05096ce63
2 files changed +13 -13
merge-recursive.c
+12 -13
@@ -80,12 +80,11 @@ struct stage_data
80 static struct string_list current_file_set = {NULL, 0, 0, 1};
81 static struct string_list current_directory_set = {NULL, 0, 0, 1};
82
83 -static int call_depth = 0;
83 static struct strbuf obuf = STRBUF_INIT;
84
85 static int show(struct merge_options *o, int v)
86 {
88 - return (!call_depth && o->verbosity >= v) || o->verbosity >= 5;
87 + return (!o->call_depth && o->verbosity >= v) || o->verbosity >= 5;
88 }
89
90 static void flush_output(void)
@@ -104,9 +103,9 @@ static void output(struct merge_options *o, int v, const char *fmt, ...)
103 if (!show(o, v))
104 return;
105
107 - strbuf_grow(&obuf, call_depth * 2 + 2);
108 - memset(obuf.buf + obuf.len, ' ', call_depth * 2);
109 - strbuf_setlen(&obuf, obuf.len + call_depth * 2);
106 + strbuf_grow(&obuf, o->call_depth * 2 + 2);
107 + memset(obuf.buf + obuf.len, ' ', o->call_depth * 2);
108 + strbuf_setlen(&obuf, obuf.len + o->call_depth * 2);
109
110 va_start(ap, fmt);
111 len = vsnprintf(obuf.buf + obuf.len, strbuf_avail(&obuf), fmt, ap);
@@ -129,11 +128,11 @@ static void output(struct merge_options *o, int v, const char *fmt, ...)
128 flush_output();
129 }
130
132 -static void output_commit_title(struct commit *commit)
131 +static void output_commit_title(struct merge_options *o, struct commit *commit)
132 {
133 int i;
134 flush_output();
136 - for (i = call_depth; i--;)
135 + for (i = o->call_depth; i--;)
136 fputs(" ", stdout);
137 if (commit->util)
138 printf("virtual %s\n", (char *)commit->util);
@@ -1230,8 +1229,8 @@ int merge_recursive(struct merge_options *o,
1229
1230 if (show(o, 4)) {
1231 output(o, 4, "Merging:");
1233 - output_commit_title(h1);
1234 - output_commit_title(h2);
1232 + output_commit_title(o, h1);
1233 + output_commit_title(o, h2);
1234 }
1235
1236 if (!ca) {
@@ -1242,7 +1241,7 @@ int merge_recursive(struct merge_options *o,
1241 if (show(o, 5)) {
1242 output(o, 5, "found %u common ancestor(s):", commit_list_count(ca));
1243 for (iter = ca; iter; iter = iter->next)
1245 - output_commit_title(iter->item);
1244 + output_commit_title(o, iter->item);
1245 }
1246
1247 merged_common_ancestors = pop_commit(&ca);
@@ -1258,7 +1257,7 @@ int merge_recursive(struct merge_options *o,
1257
1258 for (iter = ca; iter; iter = iter->next) {
1259 const char *saved_b1, *saved_b2;
1261 - call_depth++;
1260 + o->call_depth++;
1261 /*
1262 * When the merge fails, the result contains files
1263 * with conflict markers. The cleanness flag is
@@ -1275,14 +1274,14 @@ int merge_recursive(struct merge_options *o,
1274 NULL, &merged_common_ancestors);
1275 o->branch1 = saved_b1;
1276 o->branch2 = saved_b2;
1278 - call_depth--;
1277 + o->call_depth--;
1278
1279 if (!merged_common_ancestors)
1280 die("merge returned no commit");
1281 }
1282
1283 discard_cache();
1285 - if (!call_depth) {
1284 + if (!o->call_depth) {
1285 read_cache();
1286 index_only = 0;
1287 } else
merge-recursive.h
+1
@@ -9,6 +9,7 @@ struct merge_options {
9 int verbosity;
10 int diff_rename_limit;
11 int merge_rename_limit;
12 + int call_depth;
13 };
14
15 /* merge_trees() but with recursive ancestor consolidation */