Git development
 help / color / mirror / Atom feed
From: fork0@t-online.de (Alex Riesen)
To: git@vger.kernel.org
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Junio C Hamano <junkio@cox.net>
Subject: [PATCH 4/4] save another call to git-update-index
Date: Fri, 30 Jun 2006 02:27:56 +0200	[thread overview]
Message-ID: <20060630002756.GD22618@steel.home> (raw)

and a small cleanup
---
 merge-recursive.c |   41 ++++++++++++++++++-----------------------
 1 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 9a18e06..f3f8e7d 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -21,7 +21,7 @@ #include "graph.h"
 #include "path-list.h"
 
 #define HAVE_ALLOCA
-#define DEBUG
+/*#define DEBUG*/
 
 #ifdef DEBUG
 #define debug(args, ...) fprintf(stderr, args, ## __VA_ARGS__)
@@ -629,8 +629,10 @@ static struct rename_entry *get_renames(
 					struct tree *bTree,
 					struct index_entry **entries)
 {
+#ifdef DEBUG
 	time_t t = time(0);
 	debug("getRenames ...\n");
+#endif
 	struct rename_entry *renames = NULL;
 	struct rename_entry **rptr = &renames;
 	struct diff_options opts;
@@ -691,22 +693,16 @@ static int update_stages(FILE *up_index,
 {
 	if ( !up_index )
 		return -1;
-	if ( clear ) {
+	if ( clear )
 		fprintf(up_index, "0 %s\t%s", sha1_to_hex(null_sha1), path);
-		fputc('\0', up_index);
-	}
-	if ( omode ) {
+	if ( omode )
 		fprintf(up_index, "0%o %s 1\t%s", omode, sha1_to_hex(osha), path);
-		fputc('\0', up_index);
-	}
-	if ( amode ) {
+	if ( amode )
 		fprintf(up_index, "0%o %s 2\t%s", amode, sha1_to_hex(asha), path);
-		fputc('\0', up_index);
-	}
-	if ( bmode ) {
+	if ( bmode )
 		fprintf(up_index, "0%o %s 3\t%s", bmode, sha1_to_hex(bsha), path);
+	if ( clear || omode || amode || bmode )
 		fputc('\0', up_index);
-	}
 	return 0;
 }
 
@@ -1080,7 +1076,8 @@ static void conflict_rename_rename_2(FIL
 	free(newPath1);
 }
 
-static int process_renames(struct rename_entry *renamesA,
+static int process_renames(FILE* fp,
+			   struct rename_entry *renamesA,
 			   struct rename_entry *renamesB,
 			   const char *branchNameA,
 			   const char *branchNameB)
@@ -1097,7 +1094,6 @@ static int process_renames(struct rename
 	for (sre = renamesB; sre; sre = sre->next)
 		path_list_insert(sre->pair->one->path, &srcNames);
 
-	FILE *fp = git_update_index_pipe();
 	for_each_path(src,&srcNames) {
 		struct rename_entry *renames1, *renames2, *ren1, *ren2;
 		const char *branchName1, *branchName2;
@@ -1282,9 +1278,6 @@ static int process_renames(struct rename
 		}
 	}
 	path_list_clear(&srcNames, 0);
-	if (pclose(fp)) {
-		die("git update-index --index-info failed");
-	}
 	debug("  processRenames done\n");
 	return cleanMerge;
 }
@@ -1467,24 +1460,26 @@ static struct merge_tree_result merge_tr
 		struct rename_entry *re_head, *re_merge;
 		re_head  = get_renames(head, common, head, merge, &entries);
 		re_merge = get_renames(merge, common, head, merge, &entries);
-		result.clean = process_renames(re_head, re_merge,
+		FILE *up_index = git_update_index_pipe();
+		result.clean = process_renames(up_index,
+					       re_head, re_merge,
 					       branch1Name, branch2Name);
 		debug("\tprocessing entries...\n");
-		FILE *fp = git_update_index_pipe();
 		struct index_entry *e;
 		for (e = entries; e; e = e->next) {
 			if (e->processed)
 				continue;
-			if (!process_entry(fp, e, branch1Name, branch2Name))
+			if (!process_entry(up_index, e,
+					   branch1Name, branch2Name))
 				result.clean = 0;
 		}
+		if (pclose(up_index))
+			die("updating entry failed in git update-index");
+
 		free_rename_entries(&re_merge);
 		free_rename_entries(&re_head);
 		free_index_entries(&entries);
 
-		if (pclose(fp))
-			die("updating entry failed in git update-index");
-
 		if (result.clean || index_only)
 			result.tree = git_write_tree();
 		else
-- 
1.4.1.rc1.g17dc

             reply	other threads:[~2006-06-30  0:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-30  0:27 Alex Riesen [this message]
2006-06-30  0:37 ` [PATCH 4/4] save another call to git-update-index Johannes Schindelin
2006-06-30  7:22   ` Alex Riesen
2006-06-30  9:56     ` Johannes Schindelin
2006-06-30 11:33       ` Alex Riesen
2006-06-30 14:43   ` Johannes Schindelin
2006-06-30 14:43   ` [PATCH 1/3] Add read_cache_from() and discard_cache() Johannes Schindelin
2006-06-30 16:44     ` Junio C Hamano
2006-07-01 15:06       ` Johannes Schindelin
2006-07-01 18:51         ` Junio C Hamano
2006-07-02  8:51           ` Johannes Schindelin
2006-07-03 21:04             ` Junio C Hamano
2006-07-04 14:18               ` Johannes Schindelin
2006-07-04 17:41                 ` Junio C Hamano
2006-06-30 14:43   ` [PATCH 2/3] Make refresh_cache_entry() public Johannes Schindelin
2006-06-30 14:44   ` [PATCH 3/3] merge-recursive: avoid the pipe to update-index Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060630002756.GD22618@steel.home \
    --to=fork0@t-online.de \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox