{"thread":{"id":"6368","subject":"[PATCH 1/4] Remove unnecessary call_depth parameter in merge-recursive.","startedAt":"2007-01-14T05:28:33Z","lastAt":"2007-01-14T22:44:57Z","messageCount":3,"participants":["Shawn O. Pearce","Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"31673","messageId":"20070114052832.GA19113@spearce.org","threadId":"6368","inReplyTo":null,"subject":"[PATCH 1/4] Remove unnecessary call_depth parameter in merge-recursive.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-01-14T05:28:33Z","receivedAt":"2007-01-14T05:28:33Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Because the output_indent always matches the call_depth value\nthere is no reason to pass around the call_depth to the merge\nfunction during each recursive invocation.\n\nThis is a simple refactoring that will make the code easier to\nfollow later on as I start to add output verbosity controls.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n merge-recursive.c |   16 +++++++---------\n 1 files changed, 7 insertions(+), 9 deletions(-)\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex b4acbb7..8738f09 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -70,13 +70,13 @@ struct stage_data\n static struct path_list current_file_set = {NULL, 0, 0, 1};\n static struct path_list current_directory_set = {NULL, 0, 0, 1};\n \n-static int output_indent = 0;\n+static int call_depth = 0;\n \n static void output(const char *fmt, ...)\n {\n \tva_list args;\n \tint i;\n-\tfor (i = output_indent; i--;)\n+\tfor (i = call_depth; i--;)\n \t\tfputs(\"  \", stdout);\n \tva_start(args, fmt);\n \tvfprintf(stdout, fmt, args);\n@@ -87,7 +87,7 @@ static void output(const char *fmt, ...)\n static void output_commit_title(struct commit *commit)\n {\n \tint i;\n-\tfor (i = output_indent; i--;)\n+\tfor (i = call_depth; i--;)\n \t\tfputs(\"  \", stdout);\n \tif (commit->util)\n \t\tprintf(\"virtual %s\\n\", (char *)commit->util);\n@@ -1095,7 +1095,6 @@ static int merge(struct commit *h1,\n \t\t struct commit *h2,\n \t\t const char *branch1,\n \t\t const char *branch2,\n-\t\t int call_depth /* =0 */,\n \t\t struct commit_list *ca,\n \t\t struct commit **result)\n {\n@@ -1129,7 +1128,7 @@ static int merge(struct commit *h1,\n \t}\n \n \tfor (iter = ca; iter; iter = iter->next) {\n-\t\toutput_indent = call_depth + 1;\n+\t\tcall_depth++;\n \t\t/*\n \t\t * When the merge fails, the result contains files\n \t\t * with conflict markers. The cleanness flag is\n@@ -1141,17 +1140,16 @@ static int merge(struct commit *h1,\n \t\tmerge(merged_common_ancestors, iter->item,\n \t\t      \"Temporary merge branch 1\",\n \t\t      \"Temporary merge branch 2\",\n-\t\t      call_depth + 1,\n \t\t      NULL,\n \t\t      &merged_common_ancestors);\n-\t\toutput_indent = call_depth;\n+\t\tcall_depth--;\n \n \t\tif (!merged_common_ancestors)\n \t\t\tdie(\"merge returned no commit\");\n \t}\n \n \tdiscard_cache();\n-\tif (call_depth == 0) {\n+\tif (!call_depth) {\n \t\tread_cache();\n \t\tindex_only = 0;\n \t} else\n@@ -1239,7 +1237,7 @@ int main(int argc, char *argv[])\n \t\tstruct commit *ancestor = get_ref(bases[i]);\n \t\tca = commit_list_insert(ancestor, &ca);\n \t}\n-\tclean = merge(h1, h2, branch1, branch2, 0, ca, &result);\n+\tclean = merge(h1, h2, branch1, branch2, ca, &result);\n \n \tif (active_cache_changed &&\n \t    (write_cache(index_fd, active_cache, active_nr) ||\n-- \n1.5.0.rc1.g4494\n"},{"id":"31754","messageId":"20070114193503.GB2378@steel.home","threadId":"6368","inReplyTo":"20070114052832.GA19113@spearce.org","subject":"Re: [PATCH 1/4] Remove unnecessary call_depth parameter in merge-recursive.","fromName":"Alex Riesen","fromEmail":"fork0@t-online.de","sentAt":"2007-01-14T19:35:03Z","receivedAt":"2007-01-14T19:35:03Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Shawn O. Pearce, Sun, Jan 14, 2007 06:28:33 +0100:\n> Because the output_indent always matches the call_depth value\n> there is no reason to pass around the call_depth to the merge\n> function during each recursive invocation.\n\nActually, you removed output_indent, not call_depth.\n"},{"id":"31710","messageId":"20070114224457.GB10888@spearce.org","threadId":"6368","inReplyTo":"20070114193503.GB2378@steel.home","subject":"Re: [PATCH 1/4] Remove unnecessary call_depth parameter in merge-recursive.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-01-14T22:44:57Z","receivedAt":"2007-01-14T22:44:57Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Alex Riesen <fork0@t-online.de> wrote:\n> Shawn O. Pearce, Sun, Jan 14, 2007 06:28:33 +0100:\n> > Because the output_indent always matches the call_depth value\n> > there is no reason to pass around the call_depth to the merge\n> > function during each recursive invocation.\n> \n> Actually, you removed output_indent, not call_depth.\n\nYeaaaaa.  That happened because I amended the commit.  The first\nversion of it kept output_indent and replaced all call_depth with\noutput_indent.  I was then going to do another patch to rename\noutput_indent -> call_depth, but I noticed the patch would be\nabout the same size as that one and would affect the same lines,\nso I just amended it.  Then I didn't edit the commit message.\n\n-- \nShawn.\n"}]}