X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=cache.h;h=bce48b00df855fdd4adf83ca875a17d16b359f54;hb=f5cabd13d814bb5c547a13af03bcc42122531141;hp=07598d469a15db2c10d36e627c0e77dea065b8ef;hpb=4bb04f2190d526f8917663f0be62d8026e1ed100;p=git.git diff --git a/cache.h b/cache.h index 07598d46..bce48b00 100644 --- a/cache.h +++ b/cache.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -24,9 +25,9 @@ #define CACHE_SIGNATURE 0x44495243 /* "DIRC" */ struct cache_header { - unsigned int signature; - unsigned int version; - unsigned int entries; + unsigned int hdr_signature; + unsigned int hdr_version; + unsigned int hdr_entries; unsigned char sha1[20]; }; @@ -44,21 +45,28 @@ struct cache_time { * dev/ino/uid/gid/size are also just tracked to the low 32 bits * Again - this is just a (very strong in practice) heuristic that * the inode hasn't changed. + * + * We save the fields in big-endian order to allow using the + * index file over NFS transparently. */ struct cache_entry { - struct cache_time ctime; - struct cache_time mtime; - unsigned int st_dev; - unsigned int st_ino; - unsigned int st_mode; - unsigned int st_uid; - unsigned int st_gid; - unsigned int st_size; + struct cache_time ce_ctime; + struct cache_time ce_mtime; + unsigned int ce_dev; + unsigned int ce_ino; + unsigned int ce_mode; + unsigned int ce_uid; + unsigned int ce_gid; + unsigned int ce_size; unsigned char sha1[20]; - unsigned short namelen; + unsigned short ce_flags; char name[0]; }; +#define CE_NAMEMASK (0x0fff) +#define CE_STAGE1 (0x1000) +#define CE_STAGE2 (0x2000) + const char *sha1_file_directory; struct cache_entry **active_cache; unsigned int active_nr, active_alloc; @@ -67,7 +75,8 @@ unsigned int active_nr, active_alloc; #define DEFAULT_DB_ENVIRONMENT ".git/objects" #define cache_entry_size(len) ((offsetof(struct cache_entry,name) + (len) + 8) & ~7) -#define ce_size(ce) cache_entry_size((ce)->namelen) +#define ce_namelen(ce) (CE_NAMEMASK & ntohs((ce)->ce_flags)) +#define ce_size(ce) cache_entry_size(ce_namelen(ce)) #define alloc_nr(x) (((x)+16)*3/2) @@ -104,7 +113,10 @@ extern int get_sha1_hex(const char *hex, unsigned char *sha1); extern char *sha1_to_hex(const unsigned char *sha1); /* static buffer result! */ /* General helper functions */ -extern void usage(const char *err, ...); +extern void usage(const char *err); +extern void die(const char *err, ...); +extern int error(const char *err, ...); + extern int cache_name_compare(const char *name1, int len1, const char *name2, int len2); #endif /* CACHE_H */