Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
read-cache.c: make create_from_disk() report number of bytes it consumed
author
Junio C Hamano
<gitster@pobox.com>
Tue, 3 Apr 2012 22:53:11 +0000
(15:53 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 3 Apr 2012 23:24:45 +0000
(16:24 -0700)
The function is the one that is reading from the data stream. It only is
natural to make it responsible for reporting this number, not the caller.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
read-cache.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
d60c49c
)
diff --git
a/read-cache.c
b/read-cache.c
index d8865f5175cab38113a9e5505788584b28655781..58bfb2481dad720ac74af304bc72325102124450 100644
(file)
--- a/
read-cache.c
+++ b/
read-cache.c
@@
-1305,7
+1305,8
@@
static inline uint32_t ntoh_l_force_align(void *p)
#define ntoh_l(var) ntoh_l_force_align(&(var))
#endif
#define ntoh_l(var) ntoh_l_force_align(&(var))
#endif
-static struct cache_entry *create_from_disk(struct ondisk_cache_entry *ondisk)
+static struct cache_entry *create_from_disk(struct ondisk_cache_entry *ondisk,
+ unsigned long *ent_size)
{
struct cache_entry *ce;
size_t len;
{
struct cache_entry *ce;
size_t len;
@@
-1351,6
+1352,7
@@
static struct cache_entry *create_from_disk(struct ondisk_cache_entry *ondisk)
memcpy(ce->name, name, len);
ce->name[len] = '\0';
memcpy(ce->name, name, len);
ce->name[len] = '\0';
+ *ent_size = ondisk_ce_size(ce);
return ce;
}
return ce;
}
@@
-1404,12
+1406,13
@@
int read_index_from(struct index_state *istate, const char *path)
for (i = 0; i < istate->cache_nr; i++) {
struct ondisk_cache_entry *disk_ce;
struct cache_entry *ce;
for (i = 0; i < istate->cache_nr; i++) {
struct ondisk_cache_entry *disk_ce;
struct cache_entry *ce;
+ unsigned long consumed;
disk_ce = (struct ondisk_cache_entry *)((char *)mmap + src_offset);
disk_ce = (struct ondisk_cache_entry *)((char *)mmap + src_offset);
- ce = create_from_disk(disk_ce);
+ ce = create_from_disk(disk_ce
, &consumed
);
set_index_entry(istate, i, ce);
set_index_entry(istate, i, ce);
- src_offset +=
ondisk_ce_size(ce)
;
+ src_offset +=
consumed
;
}
istate->timestamp.sec = st.st_mtime;
istate->timestamp.nsec = ST_MTIME_NSEC(st);
}
istate->timestamp.sec = st.st_mtime;
istate->timestamp.nsec = ST_MTIME_NSEC(st);