From abdc3fc84216a9334f40f3b7ce13e20a825697d0 Mon Sep 17 00:00:00 2001 From: Rene Scharfe Date: Sat, 14 Oct 2006 12:45:36 +0200 Subject: Add hash_sha1_file() Most callers of write_sha1_file_prepare() are only interested in the resulting hash but don't care about the returned file name or the header. This patch adds a simple wrapper named hash_sha1_file() which does just that, and converts potential callers. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- cache-tree.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'cache-tree.c') diff --git a/cache-tree.c b/cache-tree.c index 323c68a670..d388848dd2 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -344,12 +344,8 @@ static int update_one(struct cache_tree *it, #endif } - if (dryrun) { - unsigned char hdr[200]; - int hdrlen; - write_sha1_file_prepare(buffer, offset, tree_type, it->sha1, - hdr, &hdrlen); - } + if (dryrun) + hash_sha1_file(buffer, offset, tree_type, it->sha1); else write_sha1_file(buffer, offset, tree_type, it->sha1); free(buffer); -- cgit v1.2.1 From 4903161fb8c74bc583b21d7ffe7abaf223df4253 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 30 Oct 2006 15:29:53 -0800 Subject: Surround "#define DEBUG 0" with "#ifndef DEBUG..#endif" Otherwise "make CFLAGS=-DDEBUG=1" is cumbersome to run. Signed-off-by: Junio C Hamano --- cache-tree.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cache-tree.c') diff --git a/cache-tree.c b/cache-tree.c index d388848dd2..a80326289d 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -2,7 +2,9 @@ #include "tree.h" #include "cache-tree.h" +#ifndef DEBUG #define DEBUG 0 +#endif struct cache_tree *cache_tree(void) { -- cgit v1.2.1 From 3d12d0cfbbda0feb6305d6c53f3cf9aae2330c4c Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Mon, 13 Nov 2006 13:50:00 +0000 Subject: Catch errors when writing an index that contains invalid objects. If git-write-index is called without --missing-ok, it reports invalid objects that it finds in the index. But without this patch it dies right away or may run into an infinite loop. Signed-off-by: Johannes Sixt Signed-off-by: Junio C Hamano --- cache-tree.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cache-tree.c') diff --git a/cache-tree.c b/cache-tree.c index a80326289d..9b73c8669a 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -282,6 +282,8 @@ static int update_one(struct cache_tree *it, baselen + sublen + 1, missing_ok, dryrun); + if (subcnt < 0) + return subcnt; i += subcnt - 1; sub->used = 1; } -- cgit v1.2.1