diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-15 21:45:38 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-15 21:45:38 -0700 |
commit | f5cabd13d814bb5c547a13af03bcc42122531141 (patch) | |
tree | 6795adc096e36c7a7f8e6a407297727e61d4d083 | |
parent | 13e897e58072678cdae3ec1db51cc91110dc559d (diff) | |
download | git-f5cabd13d814bb5c547a13af03bcc42122531141.tar.gz |
Encode a few extra flags per index entry.
This will allow us to have the same name in different "states" in the
index at the same time. Which in turn seems to be a very simple way to
merge.
-rw-r--r-- | cache.h | 8 | ||||
-rw-r--r-- | read-tree.c | 2 | ||||
-rw-r--r-- | update-cache.c | 4 |
3 files changed, 9 insertions, 5 deletions
@@ -59,10 +59,14 @@ struct cache_entry { unsigned int ce_gid; unsigned int ce_size; unsigned char sha1[20]; - unsigned short ce_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; @@ -71,7 +75,7 @@ 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_namelen(ce) ntohs((ce)->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) diff --git a/read-tree.c b/read-tree.c index 5c6588da4f..7ee1275b0c 100644 --- a/read-tree.c +++ b/read-tree.c @@ -14,7 +14,7 @@ static int read_one_entry(unsigned char *sha1, const char *base, int baselen, co memset(ce, 0, size); ce->ce_mode = htonl(mode); - ce->ce_namelen = htons(baselen + len); + ce->ce_flags = htons(baselen + len); memcpy(ce->name, base, baselen); memcpy(ce->name + baselen, pathname, len+1); memcpy(ce->sha1, sha1, 20); diff --git a/update-cache.c b/update-cache.c index 065705a9b4..134ba74398 100644 --- a/update-cache.c +++ b/update-cache.c @@ -107,7 +107,7 @@ static int add_file_to_cache(char *path) memcpy(ce->name, path, namelen); fill_stat_cache_info(ce, &st); ce->ce_mode = htonl(st.st_mode); - ce->ce_namelen = htons(namelen); + ce->ce_flags = htons(namelen); if (index_fd(path, namelen, ce, fd, &st) < 0) return -1; @@ -259,7 +259,7 @@ static int add_cacheinfo(char *arg1, char *arg2, char *arg3) memcpy(ce->sha1, sha1, 20); memcpy(ce->name, arg3, len); - ce->ce_namelen = htons(len); + ce->ce_flags = htons(len); ce->ce_mode = htonl(mode); return add_cache_entry(ce, allow_add); } |