[PATCH v4 1/5] sha1_file: Add index_blob().

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
Date: Tuesday, June 1, 2010 - 7:41 am

When conversion attributes have changed, it
is useful to be able to easily reconvert an
existing blob.

Signed-off-by: Henrik Grubbström <grubba@grubba.org>
---
No changes since v1.

 cache.h     |    1 +
 sha1_file.c |   19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/cache.h b/cache.h
index ebe71c7..004296d 100644
--- a/cache.h
+++ b/cache.h
@@ -482,6 +482,7 @@ extern int ie_match_stat(const struct index_state *, struct cache_entry *, struc
 extern int ie_modified(const struct index_state *, struct cache_entry *, struct stat *, unsigned int);
 
 extern int ce_path_match(const struct cache_entry *ce, const char **pathspec);
+extern int index_blob(unsigned char *dst_sha1, const unsigned char *src_sha1, int write_object, const char *path);
 extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path);
 extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object);
 extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);
diff --git a/sha1_file.c b/sha1_file.c
index 657825e..6e7b999 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2434,6 +2434,25 @@ static int index_mem(unsigned char *sha1, void *buf, size_t size,
 	return ret;
 }
 
+int index_blob(unsigned char *dst_sha1, const unsigned char *src_sha1,
+	       int write_object, const char *path)
+{
+	void *buf;
+	unsigned long buflen = 0;
+	int ret;
+
+	memcpy(dst_sha1, src_sha1, 20);
+	buf = read_object_with_reference(src_sha1, typename(OBJ_BLOB),
+					 &buflen, dst_sha1);
+	if (!buf)
+		return 0;
+
+	ret = index_mem(dst_sha1, buf, buflen, write_object, OBJ_BLOB, path);
+	free(buf);
+
+	return ret;
+}
+
 int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
 	     enum object_type type, const char *path)
 {
-- 
1.7.0.4.369.g81e89

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH v4 0/5] Patches to avoid reporting conversion changes., =?UTF-8?q?Henrik=20G ..., (Tue Jun 1, 7:41 am)
[PATCH v4 1/5] sha1_file: Add index_blob()., =?UTF-8?q?Henrik=20G ..., (Tue Jun 1, 7:41 am)
[PATCH v4 2/5] strbuf: Add strbuf_add_uint32()., =?UTF-8?q?Henrik=20G ..., (Tue Jun 1, 7:41 am)
[PATCH v4 3/5] cache: Keep track of conversion mode changes., =?UTF-8?q?Henrik=20G ..., (Tue Jun 1, 7:41 am)
[PATCH v4 4/5] cache: Add index extension &quot;CONV&quot;., =?UTF-8?q?Henrik=20G ..., (Tue Jun 1, 7:41 am)
[PATCH v4 5/5] t/t0021: Test that conversion changes are d ..., =?UTF-8?q?Henrik=20G ..., (Tue Jun 1, 7:41 am)
Re: [PATCH v4 0/5] Patches to avoid reporting conversion c ..., Henrik Grubbström, (Thu Jun 3, 9:00 am)
Re: [PATCH v4 0/5] Patches to avoid reporting conversion c ..., Henrik Grubbström, (Fri Jun 4, 4:59 am)
Re: [PATCH v4 0/5] Patches to avoid reporting conversion c ..., Henrik Grubbström, (Sun Jun 6, 3:50 am)
Re: [PATCH v4 0/5] Patches to avoid reporting conversion c ..., Finn Arne Gangstad, (Mon Jun 7, 1:59 am)
Re: [PATCH v4 0/5] Patches to avoid reporting conversion c ..., Henrik Grubbström, (Mon Jun 7, 9:37 am)
Re: [PATCH v4 0/5] Patches to avoid reporting conversion c ..., Finn Arne Gangstad, (Mon Jun 7, 12:50 pm)
Re: [PATCH v4 0/5] Patches to avoid reporting conversion c ..., Henrik Grubbström, (Tue Jun 8, 8:52 am)
Re: [PATCH v4 0/5] Patches to avoid reporting conversion c ..., Finn Arne Gangstad, (Wed Jun 9, 7:03 am)
Re: [PATCH v4 0/5] Patches to avoid reporting conversion c ..., Henrik Grubbström, (Wed Jun 9, 11:04 am)
Re: [PATCH v4 0/5] Patches to avoid reporting conversion c ..., Finn Arne Gangstad, (Thu Jun 10, 12:55 pm)