@matheusbsbs / matheus-bagliano / commits / 63889639bb
Fork 0

Remove unnecessary call_depth parameter in merge-recursive.

Because the output_indent always matches the call_depth value there is no reason to pass around the call_depth to the merge function during each recursive invocation. This is a simple refactoring that will make the code easier to follow later on as I start to add output verbosity controls. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Shawn O. Pearce committed Jan 14, 2007 at 00:28 UTC 63889639bbb47399b5ede784b1afe48679d52bb2
1 file changed +7 -9
merge-recursive.c
+7 -9
@@ -70,13 +70,13 @@ struct stage_data
70 static struct path_list current_file_set = {NULL, 0, 0, 1};
71 static struct path_list current_directory_set = {NULL, 0, 0, 1};
72
73 -static int output_indent = 0;
73 +static int call_depth = 0;
74
75 static void output(const char *fmt, ...)
76 {
77 va_list args;
78 int i;
79 - for (i = output_indent; i--;)
79 + for (i = call_depth; i--;)
80 fputs(" ", stdout);
81 va_start(args, fmt);
82 vfprintf(stdout, fmt, args);
@@ -87,7 +87,7 @@ static void output(const char *fmt, ...)
87 static void output_commit_title(struct commit *commit)
88 {
89 int i;
90 - for (i = output_indent; i--;)
90 + for (i = call_depth; i--;)
91 fputs(" ", stdout);
92 if (commit->util)
93 printf("virtual %s\n", (char *)commit->util);
@@ -1095,7 +1095,6 @@ static int merge(struct commit *h1,
1095 struct commit *h2,
1096 const char *branch1,
1097 const char *branch2,
1098 - int call_depth /* =0 */,
1098 struct commit_list *ca,
1099 struct commit **result)
1100 {
@@ -1129,7 +1128,7 @@ static int merge(struct commit *h1,
1128 }
1129
1130 for (iter = ca; iter; iter = iter->next) {
1132 - output_indent = call_depth + 1;
1131 + call_depth++;
1132 /*
1133 * When the merge fails, the result contains files
1134 * with conflict markers. The cleanness flag is
@@ -1141,17 +1140,16 @@ static int merge(struct commit *h1,
1140 merge(merged_common_ancestors, iter->item,
1141 "Temporary merge branch 1",
1142 "Temporary merge branch 2",
1144 - call_depth + 1,
1143 NULL,
1144 &merged_common_ancestors);
1147 - output_indent = call_depth;
1145 + call_depth--;
1146
1147 if (!merged_common_ancestors)
1148 die("merge returned no commit");
1149 }
1150
1151 discard_cache();
1154 - if (call_depth == 0) {
1152 + if (!call_depth) {
1153 read_cache();
1154 index_only = 0;
1155 } else
@@ -1239,7 +1237,7 @@ int main(int argc, char *argv[])
1237 struct commit *ancestor = get_ref(bases[i]);
1238 ca = commit_list_insert(ancestor, &ca);
1239 }
1242 - clean = merge(h1, h2, branch1, branch2, 0, ca, &result);
1240 + clean = merge(h1, h2, branch1, branch2, ca, &result);
1241
1242 if (active_cache_changed &&
1243 (write_cache(index_fd, active_cache, active_nr) ||