Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Lukashov <michael.lukashov@gmail.com>2010-02-17 02:42:55 +0300
committerJunio C Hamano <gitster@pobox.com>2010-02-18 02:11:33 +0300
commit06b65939b083ba1b71043005bf83b4883e98264e (patch)
tree6e4cc7e05c5de790d78abbbdc1f5cd863a38ec7a /xdiff-interface.c
parente923eaeb901ff056421b9007adcbbce271caa7b6 (diff)
refactor duplicated fill_mm() in checkout and merge-recursive
The following function is duplicated: fill_mm Move it to xdiff-interface.c and rename it 'read_mmblob', as suggested by Junio C Hamano. Also, change parameters order for consistency with read_mmfile(). Signed-off-by: Michael Lukashov <michael.lukashov@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'xdiff-interface.c')
-rw-r--r--xdiff-interface.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/xdiff-interface.c b/xdiff-interface.c
index 01f14fb50f..ca5e3fbae8 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -218,6 +218,23 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
return 0;
}
+void read_mmblob(mmfile_t *ptr, const unsigned char *sha1)
+{
+ unsigned long size;
+ enum object_type type;
+
+ if (!hashcmp(sha1, null_sha1)) {
+ ptr->ptr = xstrdup("");
+ ptr->size = 0;
+ return;
+ }
+
+ ptr->ptr = read_sha1_file(sha1, &type, &size);
+ if (!ptr->ptr || type != OBJ_BLOB)
+ die("unable to read blob object %s", sha1_to_hex(sha1));
+ ptr->size = size;
+}
+
#define FIRST_FEW_BYTES 8000
int buffer_is_binary(const char *ptr, unsigned long size)
{