aboutsummaryrefslogtreecommitdiffstats
path: root/update-cache.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-15 10:44:27 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-15 10:44:27 -0700
commitccc4feb579265266d0a4a73c0c9443ecc0c26ce3 (patch)
tree9999cff451d3a833ca39981d6868fdb452449f13 /update-cache.c
parent27de946d0ee70fad497253bbaab76d2fa7b1c77c (diff)
downloadgit-ccc4feb579265266d0a4a73c0c9443ecc0c26ce3.tar.gz
Convert the index file reading/writing to use network byte order.
This allows using a git tree over NFS with different byte order, and makes it possible to just copy a fully populated repository and have the end result immediately usable (needing just a refresh to update the stat information).
Diffstat (limited to 'update-cache.c')
-rw-r--r--update-cache.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/update-cache.c b/update-cache.c
index 6d37c55a26..85d0591c85 100644
--- a/update-cache.c
+++ b/update-cache.c
@@ -68,18 +68,17 @@ static int index_fd(const char *path, int namelen, struct cache_entry *ce, int f
*/
static void fill_stat_cache_info(struct cache_entry *ce, struct stat *st)
{
- ce->ctime.sec = st->st_ctime;
+ ce->ce_ctime.sec = htonl(st->st_ctime);
+ ce->ce_mtime.sec = htonl(st->st_mtime);
#ifdef NSEC
- ce->ctime.nsec = st->st_ctim.tv_nsec;
+ ce->ce_ctime.nsec = htonl(st->st_ctim.tv_nsec);
+ ce->ce_mtime.nsec = htonl(st->st_mtim.tv_nsec);
#endif
- ce->mtime.sec = st->st_mtime;
-#ifdef NSEC
- ce->mtime.nsec = st->st_mtim.tv_nsec;
-#endif
- ce->st_dev = st->st_dev;
- ce->st_ino = st->st_ino;
- ce->st_uid = st->st_uid;
- ce->st_gid = st->st_gid;
+ ce->ce_dev = htonl(st->st_dev);
+ ce->ce_ino = htonl(st->st_ino);
+ ce->ce_uid = htonl(st->st_uid);
+ ce->ce_gid = htonl(st->st_gid);
+ ce->ce_size = htonl(st->st_size);
}
static int add_file_to_cache(char *path)
@@ -107,9 +106,8 @@ static int add_file_to_cache(char *path)
memset(ce, 0, size);
memcpy(ce->name, path, namelen);
fill_stat_cache_info(ce, &st);
- ce->st_mode = st.st_mode;
- ce->st_size = st.st_size;
- ce->namelen = namelen;
+ ce->ce_mode = htonl(st.st_mode);
+ ce->ce_namelen = htons(namelen);
if (index_fd(path, namelen, ce, fd, &st) < 0)
return -1;
@@ -190,7 +188,6 @@ static struct cache_entry *refresh_entry(struct cache_entry *ce)
updated = malloc(size);
memcpy(updated, ce, size);
fill_stat_cache_info(updated, &st);
- updated->st_size = st.st_size;
return updated;
}