diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-11 11:33:58 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-11 11:33:58 -0700 |
commit | 32d197f18d0be74a4d82e8c42513d83423091a22 (patch) | |
tree | e31297f6bcdec878e0054ae10066e2aaa0495fcd | |
parent | cfd88e2b7a1a1d2b0f22173a5cc128adce7391e3 (diff) | |
download | git-32d197f18d0be74a4d82e8c42513d83423091a22.tar.gz git-32d197f18d0be74a4d82e8c42513d83423091a22.tar.xz |
Fix "update-cache" not fixing up the size field as appropriate.
The size field isn't in the tree information, so we need to
update it if the sha1 matches.
-rw-r--r-- | update-cache.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/update-cache.c b/update-cache.c index 68a0ae044..b39185a1f 100644 --- a/update-cache.c +++ b/update-cache.c @@ -123,7 +123,7 @@ static int match_data(int fd, void *buffer, unsigned long size) return 0; } -static int compare_data(struct cache_entry *ce) +static int compare_data(struct cache_entry *ce, unsigned long expected_size) { int match = -1; int fd = open(ce->name, O_RDONLY); @@ -135,7 +135,7 @@ static int compare_data(struct cache_entry *ce) buffer = read_sha1_file(ce->sha1, type, &size); if (buffer) { - if (size == ce->st_size && !strcmp(type, "blob")) + if (size == expected_size && !strcmp(type, "blob")) match = match_data(fd, buffer, size); free(buffer); } @@ -169,19 +169,20 @@ static struct cache_entry *refresh_entry(struct cache_entry *ce) return ce; /* - * If the length has changed, there's no point in trying + * If the mode has changed, there's no point in trying * to refresh the entry - it's not going to match */ - if (changed & (DATA_CHANGED | MODE_CHANGED)) + if (changed & MODE_CHANGED) return NULL; - if (compare_data(ce)) + if (compare_data(ce, st.st_size)) return NULL; size = ce_size(ce); updated = malloc(size); memcpy(updated, ce, size); fill_stat_cache_info(updated, &st); + updated->st_size = st.st_size; return updated; } |