diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-05-18 22:39:56 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-05-18 22:39:56 -0700 |
commit | 636e87d705c2d6cc53d58eac31b689779d00b292 (patch) | |
tree | a3de44b428a21e7bbcae6099a903e77fc9c9db16 /sha1_file.c | |
parent | 1c9eecff97beab2d425397dc624281dff5c0be5c (diff) | |
parent | d07ef715757ab1c2436c59adca92484fa46b2b41 (diff) | |
download | git-636e87d705c2d6cc53d58eac31b689779d00b292.tar.gz |
Merge branch 'maint'
* maint:
Documentation/gitdiffcore: fix order in pickaxe description
Documentation: fix minor inconsistency
Documentation: rebase -i ignores options passed to "git am"
hash_object: correction for zero length file
Diffstat (limited to 'sha1_file.c')
-rw-r--r-- | sha1_file.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sha1_file.c b/sha1_file.c index 28c056e074..b2074e7a8e 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -2448,6 +2448,8 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, else ret = -1; strbuf_release(&sbuf); + } else if (!size) { + ret = index_mem(sha1, NULL, size, write_object, type, path); } else if (size <= SMALL_FILE_SIZE) { char *buf = xmalloc(size); if (size == read_in_full(fd, buf, size)) @@ -2456,12 +2458,11 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, else ret = error("short read %s", strerror(errno)); free(buf); - } else if (size) { + } else { void *buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); ret = index_mem(sha1, buf, size, write_object, type, path); munmap(buf, size); - } else - ret = index_mem(sha1, NULL, size, write_object, type, path); + } close(fd); return ret; } |