git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/4] Refactoring: remove duplicated code from builtin-checkout.c and merge-recursive.c

From
Michael Lukashov <michael.lukashov@gmail.com>
Date
Feb 14, 2010, 21:27 UTC
Message-ID
<1266182863-5048-4-git-send-email-michael.lukashov@gmail.com>
In-Reply-To
<1266182863-5048-1-git-send-email-michael.lukashov@gmail.com>
The following functions are duplicated:
  fill_mm
Signed-off-by: Michael Lukashov <michael.lukashov@gmail.com>
---
 builtin-checkout.c |   18 ------------------
 merge-recursive.c  |    2 +-
 merge-recursive.h  |    3 +++
 3 files changed, 4 insertions(+), 19 deletions(-)
diff --git a/builtin-checkout.c b/builtin-checkout.c
index 5277817..e53e857 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -128,24 +128,6 @@ static int checkout_stage(int stage, struct cache_entry *ce, int pos,
 		     (stage == 2) ? "our" : "their");
 }
 
-/* NEEDSWORK: share with merge-recursive */
-static void fill_mm(const unsigned char *sha1, mmfile_t *mm)
-{
-	unsigned long size;
-	enum object_type type;
-
-	if (!hashcmp(sha1, null_sha1)) {
-		mm->ptr = xstrdup("");
-		mm->size = 0;
-		return;
-	}
-
-	mm->ptr = read_sha1_file(sha1, &type, &size);
-	if (!mm->ptr || type != OBJ_BLOB)
-		die("unable to read blob object %s", sha1_to_hex(sha1));
-	mm->size = size;
-}
-
 static int checkout_merged(int pos, struct checkout *state)
 {
 	struct cache_entry *ce = active_cache[pos];
diff --git a/merge-recursive.c b/merge-recursive.c
index cb53b01..5999ae2 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -599,7 +599,7 @@ struct merge_file_info
 		 merge:1;
 };
 
-static void fill_mm(const unsigned char *sha1, mmfile_t *mm)
+void fill_mm(const unsigned char *sha1, mmfile_t *mm)
 {
 	unsigned long size;
 	enum object_type type;
diff --git a/merge-recursive.h b/merge-recursive.h
index be8410a..ccc4002 100644
--- a/merge-recursive.h
+++ b/merge-recursive.h
@@ -2,6 +2,7 @@
 #define MERGE_RECURSIVE_H
 
 #include "string-list.h"
+#include "xdiff/xdiff.h"
 
 struct merge_options {
 	const char *branch1;
@@ -53,4 +54,6 @@ int merge_recursive_generic(struct merge_options *o,
 void init_merge_options(struct merge_options *o);
 struct tree *write_tree_from_memory(struct merge_options *o);
 
+void fill_mm(const unsigned char *sha1, mmfile_t *mm);
+
 #endif
-- 
1.7.0.1571.g856c2
Previous: Michael LukashovNext: Tay Ray Chuan
Message 5 of 12 in “Refactoring: remove duplicated code from transport.c and builtin-send-pack.c”
  1. 1/4 Refactoring: remove duplicated code from transport.c and builtin-send-pack.cMichael Lukashov, Feb 14, 2010
  2. 2/4 Refactoring: connect.c: move duplicated code to get_host_and_portMichael Lukashov, Feb 14, 2010
  3. Johannes SixtFeb 15, 2010
  4. 3/4 Refactoring: move duplicated code from builtin-pack-objects.c and fast-import.c to object.cMichael Lukashov, Feb 14, 2010
  5. 4/4 Refactoring: remove duplicated code from builtin-checkout.c and merge-recursive.cMichael Lukashov, Feb 14, 2010
  6. Tay Ray ChuanFeb 15, 2010
  7. Jeff KingFeb 15, 2010
  8. Junio C HamanoFeb 15, 2010
  9. Jeff KingFeb 15, 2010
  10. Ilari LiusvaaraFeb 15, 2010
  11. Daniel BarkalowFeb 15, 2010
  12. Larry D'AnnaFeb 15, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.