git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] Remove unnecessary call_depth parameter in merge-recursive.
@ 2007-01-14  5:28 Shawn O. Pearce
  2007-01-14 19:35 ` Alex Riesen
  0 siblings, 1 reply; 3+ messages in thread
From: Shawn O. Pearce @ 2007-01-14  5:28 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

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>
---
 merge-recursive.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index b4acbb7..8738f09 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -70,13 +70,13 @@ struct stage_data
 static struct path_list current_file_set = {NULL, 0, 0, 1};
 static struct path_list current_directory_set = {NULL, 0, 0, 1};
 
-static int output_indent = 0;
+static int call_depth = 0;
 
 static void output(const char *fmt, ...)
 {
 	va_list args;
 	int i;
-	for (i = output_indent; i--;)
+	for (i = call_depth; i--;)
 		fputs("  ", stdout);
 	va_start(args, fmt);
 	vfprintf(stdout, fmt, args);
@@ -87,7 +87,7 @@ static void output(const char *fmt, ...)
 static void output_commit_title(struct commit *commit)
 {
 	int i;
-	for (i = output_indent; i--;)
+	for (i = call_depth; i--;)
 		fputs("  ", stdout);
 	if (commit->util)
 		printf("virtual %s\n", (char *)commit->util);
@@ -1095,7 +1095,6 @@ static int merge(struct commit *h1,
 		 struct commit *h2,
 		 const char *branch1,
 		 const char *branch2,
-		 int call_depth /* =0 */,
 		 struct commit_list *ca,
 		 struct commit **result)
 {
@@ -1129,7 +1128,7 @@ static int merge(struct commit *h1,
 	}
 
 	for (iter = ca; iter; iter = iter->next) {
-		output_indent = call_depth + 1;
+		call_depth++;
 		/*
 		 * When the merge fails, the result contains files
 		 * with conflict markers. The cleanness flag is
@@ -1141,17 +1140,16 @@ static int merge(struct commit *h1,
 		merge(merged_common_ancestors, iter->item,
 		      "Temporary merge branch 1",
 		      "Temporary merge branch 2",
-		      call_depth + 1,
 		      NULL,
 		      &merged_common_ancestors);
-		output_indent = call_depth;
+		call_depth--;
 
 		if (!merged_common_ancestors)
 			die("merge returned no commit");
 	}
 
 	discard_cache();
-	if (call_depth == 0) {
+	if (!call_depth) {
 		read_cache();
 		index_only = 0;
 	} else
@@ -1239,7 +1237,7 @@ int main(int argc, char *argv[])
 		struct commit *ancestor = get_ref(bases[i]);
 		ca = commit_list_insert(ancestor, &ca);
 	}
-	clean = merge(h1, h2, branch1, branch2, 0, ca, &result);
+	clean = merge(h1, h2, branch1, branch2, ca, &result);
 
 	if (active_cache_changed &&
 	    (write_cache(index_fd, active_cache, active_nr) ||
-- 
1.5.0.rc1.g4494

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/4] Remove unnecessary call_depth parameter in merge-recursive.
  2007-01-14  5:28 [PATCH 1/4] Remove unnecessary call_depth parameter in merge-recursive Shawn O. Pearce
@ 2007-01-14 19:35 ` Alex Riesen
  2007-01-14 22:44   ` Shawn O. Pearce
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Riesen @ 2007-01-14 19:35 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Junio C Hamano, git

Shawn O. Pearce, Sun, Jan 14, 2007 06:28:33 +0100:
> 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.

Actually, you removed output_indent, not call_depth.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/4] Remove unnecessary call_depth parameter in merge-recursive.
  2007-01-14 19:35 ` Alex Riesen
@ 2007-01-14 22:44   ` Shawn O. Pearce
  0 siblings, 0 replies; 3+ messages in thread
From: Shawn O. Pearce @ 2007-01-14 22:44 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Junio C Hamano, git

Alex Riesen <fork0@t-online.de> wrote:
> Shawn O. Pearce, Sun, Jan 14, 2007 06:28:33 +0100:
> > 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.
> 
> Actually, you removed output_indent, not call_depth.

Yeaaaaa.  That happened because I amended the commit.  The first
version of it kept output_indent and replaced all call_depth with
output_indent.  I was then going to do another patch to rename
output_indent -> call_depth, but I noticed the patch would be
about the same size as that one and would affect the same lines,
so I just amended it.  Then I didn't edit the commit message.

-- 
Shawn.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-01-15 17:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-14  5:28 [PATCH 1/4] Remove unnecessary call_depth parameter in merge-recursive Shawn O. Pearce
2007-01-14 19:35 ` Alex Riesen
2007-01-14 22:44   ` Shawn O. Pearce

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).