Commit 7a51ed66 authored by Linus Torvalds's avatar Linus Torvalds

Make on-disk index representation separate from in-core one

This converts the index explicitly on read and write to its on-disk
format, allowing the in-core format to contain more flags, and be
simpler.

In particular, the in-core format is now host-endian (as opposed to the
on-disk one that is network endian in order to be able to be shared
across machines) and as a result we can dispense with all the
htonl/ntohl on accesses to the cache_entry fields.

This will make it easier to make use of various temporary flags that do
not exist in the on-disk format.
Signed-off-by: default avatarLinus Torvalds <[email protected]>
parent ce33288e
......@@ -1946,7 +1946,7 @@ static int read_file_or_gitlink(struct cache_entry *ce, struct strbuf *buf)
if (!ce)
return 0;
if (S_ISGITLINK(ntohl(ce->ce_mode))) {
if (S_ISGITLINK(ce->ce_mode)) {
strbuf_grow(buf, 100);
strbuf_addf(buf, "Subproject commit %s\n", sha1_to_hex(ce->sha1));
} else {
......@@ -2023,7 +2023,7 @@ static int check_to_create_blob(const char *new_name, int ok_if_exists)
static int verify_index_match(struct cache_entry *ce, struct stat *st)
{
if (S_ISGITLINK(ntohl(ce->ce_mode))) {
if (S_ISGITLINK(ce->ce_mode)) {
if (!S_ISDIR(st->st_mode))
return -1;
return 0;
......@@ -2082,12 +2082,12 @@ static int check_patch(struct patch *patch, struct patch *prev_patch)
return error("%s: does not match index",
old_name);
if (cached)
st_mode = ntohl(ce->ce_mode);
st_mode = ce->ce_mode;
} else if (stat_ret < 0)
return error("%s: %s", old_name, strerror(errno));
if (!cached)
st_mode = ntohl(ce_mode_from_stat(ce, st.st_mode));
st_mode = ce_mode_from_stat(ce, st.st_mode);
if (patch->is_new < 0)
patch->is_new = 0;
......@@ -2388,7 +2388,7 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned
ce = xcalloc(1, ce_size);
memcpy(ce->name, path, namelen);
ce->ce_mode = create_ce_mode(mode);
ce->ce_flags = htons(namelen);
ce->ce_flags = namelen;
if (S_ISGITLINK(mode)) {
const char *s = buf;
......
......@@ -2092,7 +2092,7 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
if (!mode) {
int pos = cache_name_pos(path, len);
if (0 <= pos)
mode = ntohl(active_cache[pos]->ce_mode);
mode = active_cache[pos]->ce_mode;
else
/* Let's not bother reading from HEAD tree */
mode = S_IFREG | 0644;
......
......@@ -156,7 +156,7 @@ static int list_paths(struct path_list *list, const char *with_tree,
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
if (ce->ce_flags & htons(CE_UPDATE))
if (ce->ce_flags & CE_UPDATE)
continue;
if (!pathspec_match(pattern, m, ce->name, 0))
continue;
......
......@@ -765,7 +765,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
struct blob *blob;
struct object *obj;
mode = ntohl(active_cache[i]->ce_mode);
mode = active_cache[i]->ce_mode;
if (S_ISGITLINK(mode))
continue;
blob = lookup_blob(active_cache[i]->sha1);
......
......@@ -331,7 +331,7 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
struct cache_entry *ce = active_cache[i];
char *name;
int kept;
if (!S_ISREG(ntohl(ce->ce_mode)))
if (!S_ISREG(ce->ce_mode))
continue;
if (!pathspec_matches(paths, ce->name))
continue;
......@@ -387,7 +387,7 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
for (nr = 0; nr < active_nr; nr++) {
struct cache_entry *ce = active_cache[nr];
if (!S_ISREG(ntohl(ce->ce_mode)))
if (!S_ISREG(ce->ce_mode))
continue;
if (!pathspec_matches(paths, ce->name))
continue;
......
......@@ -189,7 +189,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
return;
if (tag && *tag && show_valid_bit &&
(ce->ce_flags & htons(CE_VALID))) {
(ce->ce_flags & CE_VALID)) {
static char alttag[4];
memcpy(alttag, tag, 3);
if (isalpha(tag[0]))
......@@ -210,7 +210,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
} else {
printf("%s%06o %s %d\t",
tag,
ntohl(ce->ce_mode),
ce->ce_mode,
abbrev ? find_unique_abbrev(ce->sha1,abbrev)
: sha1_to_hex(ce->sha1),
ce_stage(ce));
......@@ -242,7 +242,7 @@ static void show_files(struct dir_struct *dir, const char *prefix)
continue;
if (show_unmerged && !ce_stage(ce))
continue;
if (ce->ce_flags & htons(CE_UPDATE))
if (ce->ce_flags & CE_UPDATE)
continue;
show_ce_entry(ce_stage(ce) ? tag_unmerged : tag_cached, ce);
}
......@@ -350,7 +350,7 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
struct cache_entry *ce = active_cache[i];
if (!ce_stage(ce))
continue;
ce->ce_flags |= htons(CE_STAGEMASK);
ce->ce_flags |= CE_STAGEMASK;
}
if (prefix) {
......@@ -379,7 +379,7 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
*/
if (last_stage0 &&
!strcmp(last_stage0->name, ce->name))
ce->ce_flags |= htons(CE_UPDATE);
ce->ce_flags |= CE_UPDATE;
}
}
}
......
......@@ -45,8 +45,7 @@ static int read_cache_unmerged(void)
continue;
cache_tree_invalidate_path(active_cache_tree, ce->name);
last = ce;
ce->ce_mode = 0;
ce->ce_flags &= ~htons(CE_STAGEMASK);
ce->ce_flags |= CE_REMOVE;
}
*dst++ = ce;
}
......
......@@ -149,8 +149,8 @@ static int find_conflict(struct path_list *conflict)
if (ce_stage(e2) == 2 &&
ce_stage(e3) == 3 &&
ce_same_name(e2, e3) &&
S_ISREG(ntohl(e2->ce_mode)) &&
S_ISREG(ntohl(e3->ce_mode))) {
S_ISREG(e2->ce_mode) &&
S_ISREG(e3->ce_mode)) {
path_list_insert((const char *)e2->name, conflict);
i++; /* skip over both #2 and #3 */
}
......
......@@ -47,10 +47,10 @@ static int mark_valid(const char *path)
if (0 <= pos) {
switch (mark_valid_only) {
case MARK_VALID:
active_cache[pos]->ce_flags |= htons(CE_VALID);
active_cache[pos]->ce_flags |= CE_VALID;
break;
case UNMARK_VALID:
active_cache[pos]->ce_flags &= ~htons(CE_VALID);
active_cache[pos]->ce_flags &= ~CE_VALID;
break;
}
cache_tree_invalidate_path(active_cache_tree, path);
......@@ -95,7 +95,7 @@ static int add_one_path(struct cache_entry *old, const char *path, int len, stru
size = cache_entry_size(len);
ce = xcalloc(1, size);
memcpy(ce->name, path, len);
ce->ce_flags = htons(len);
ce->ce_flags = len;
fill_stat_cache_info(ce, st);
ce->ce_mode = ce_mode_from_stat(old, st->st_mode);
......@@ -139,7 +139,7 @@ static int process_directory(const char *path, int len, struct stat *st)
/* Exact match: file or existing gitlink */
if (pos >= 0) {
struct cache_entry *ce = active_cache[pos];
if (S_ISGITLINK(ntohl(ce->ce_mode))) {
if (S_ISGITLINK(ce->ce_mode)) {
/* Do nothing to the index if there is no HEAD! */
if (resolve_gitlink_ref(path, "HEAD", sha1) < 0)
......@@ -183,7 +183,7 @@ static int process_file(const char *path, int len, struct stat *st)
int pos = cache_name_pos(path, len);
struct cache_entry *ce = pos < 0 ? NULL : active_cache[pos];
if (ce && S_ISGITLINK(ntohl(ce->ce_mode)))
if (ce && S_ISGITLINK(ce->ce_mode))
return error("%s is already a gitlink, not replacing", path);
return add_one_path(ce, path, len, st);
......@@ -226,7 +226,7 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
ce->ce_flags = create_ce_flags(len, stage);
ce->ce_mode = create_ce_mode(mode);
if (assume_unchanged)
ce->ce_flags |= htons(CE_VALID);
ce->ce_flags |= CE_VALID;
option = allow_add ? ADD_CACHE_OK_TO_ADD : 0;
option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;
if (add_cache_entry(ce, option))
......@@ -246,14 +246,14 @@ static void chmod_path(int flip, const char *path)
if (pos < 0)
goto fail;
ce = active_cache[pos];
mode = ntohl(ce->ce_mode);
mode = ce->ce_mode;
if (!S_ISREG(mode))
goto fail;
switch (flip) {
case '+':
ce->ce_mode |= htonl(0111); break;
ce->ce_mode |= 0111; break;
case '-':
ce->ce_mode &= htonl(~0111); break;
ce->ce_mode &= ~0111; break;
default:
goto fail;
}
......
......@@ -320,13 +320,13 @@ static int update_one(struct cache_tree *it,
}
else {
sha1 = ce->sha1;
mode = ntohl(ce->ce_mode);
mode = ce->ce_mode;
entlen = pathlen - baselen;
}
if (mode != S_IFGITLINK && !missing_ok && !has_sha1_file(sha1))
return error("invalid object %s", sha1_to_hex(sha1));
if (!ce->ce_mode)
if (ce->ce_flags & CE_REMOVE)
continue; /* entry being removed */
strbuf_grow(&buffer, entlen + 100);
......
......@@ -94,48 +94,66 @@ struct cache_time {
* We save the fields in big-endian order to allow using the
* index file over NFS transparently.
*/
struct ondisk_cache_entry {
struct cache_time ctime;
struct cache_time mtime;
unsigned int dev;
unsigned int ino;
unsigned int mode;
unsigned int uid;
unsigned int gid;
unsigned int size;
unsigned char sha1[20];
unsigned short flags;
char name[FLEX_ARRAY]; /* more */
};
struct cache_entry {
struct cache_time ce_ctime;
struct cache_time ce_mtime;
unsigned int ce_ctime;
unsigned int 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 int ce_flags;
unsigned char sha1[20];
unsigned short ce_flags;
char name[FLEX_ARRAY]; /* more */
};
#define CE_NAMEMASK (0x0fff)
#define CE_STAGEMASK (0x3000)
#define CE_UPDATE (0x4000)
#define CE_VALID (0x8000)
#define CE_STAGESHIFT 12
#define create_ce_flags(len, stage) htons((len) | ((stage) << CE_STAGESHIFT))
#define ce_namelen(ce) (CE_NAMEMASK & ntohs((ce)->ce_flags))
/* In-memory only */
#define CE_UPDATE (0x10000)
#define CE_REMOVE (0x20000)
#define create_ce_flags(len, stage) ((len) | ((stage) << CE_STAGESHIFT))
#define ce_namelen(ce) (CE_NAMEMASK & (ce)->ce_flags)
#define ce_size(ce) cache_entry_size(ce_namelen(ce))
#define ce_stage(ce) ((CE_STAGEMASK & ntohs((ce)->ce_flags)) >> CE_STAGESHIFT)
#define ondisk_ce_size(ce) ondisk_cache_entry_size(ce_namelen(ce))
#define ce_stage(ce) ((CE_STAGEMASK & (ce)->ce_flags) >> CE_STAGESHIFT)
#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
static inline unsigned int create_ce_mode(unsigned int mode)
{
if (S_ISLNK(mode))
return htonl(S_IFLNK);
return S_IFLNK;
if (S_ISDIR(mode) || S_ISGITLINK(mode))
return htonl(S_IFGITLINK);
return htonl(S_IFREG | ce_permissions(mode));
return S_IFGITLINK;
return S_IFREG | ce_permissions(mode);
}
static inline unsigned int ce_mode_from_stat(struct cache_entry *ce, unsigned int mode)
{
extern int trust_executable_bit, has_symlinks;
if (!has_symlinks && S_ISREG(mode) &&
ce && S_ISLNK(ntohl(ce->ce_mode)))
ce && S_ISLNK(ce->ce_mode))
return ce->ce_mode;
if (!trust_executable_bit && S_ISREG(mode)) {
if (ce && S_ISREG(ntohl(ce->ce_mode)))
if (ce && S_ISREG(ce->ce_mode))
return ce->ce_mode;
return create_ce_mode(0666);
}
......@@ -146,14 +164,14 @@ static inline unsigned int ce_mode_from_stat(struct cache_entry *ce, unsigned in
S_ISLNK(mode) ? S_IFLNK : S_ISDIR(mode) ? S_IFDIR : S_IFGITLINK)
#define cache_entry_size(len) ((offsetof(struct cache_entry,name) + (len) + 8) & ~7)
#define ondisk_cache_entry_size(len) ((offsetof(struct ondisk_cache_entry,name) + (len) + 8) & ~7)
struct index_state {
struct cache_entry **cache;
unsigned int cache_nr, cache_alloc, cache_changed;
struct cache_tree *cache_tree;
time_t timestamp;
void *mmap;
size_t mmap_size;
void *alloc;
};
extern struct index_state the_index;
......
......@@ -37,7 +37,7 @@ static int get_mode(const char *path, int *mode)
if (!path || !strcmp(path, "/dev/null"))
*mode = 0;
else if (!strcmp(path, "-"))
*mode = ntohl(create_ce_mode(0666));
*mode = create_ce_mode(0666);
else if (stat(path, &st))
return error("Could not access '%s'", path);
else
......@@ -384,7 +384,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
continue;
}
else
dpath->mode = ntohl(ce_mode_from_stat(ce, st.st_mode));
dpath->mode = ce_mode_from_stat(ce, st.st_mode);
while (i < entries) {
struct cache_entry *nce = active_cache[i];
......@@ -398,10 +398,10 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
*/
stage = ce_stage(nce);
if (2 <= stage) {
int mode = ntohl(nce->ce_mode);
int mode = nce->ce_mode;
num_compare_stages++;
hashcpy(dpath->parent[stage-2].sha1, nce->sha1);
dpath->parent[stage-2].mode = ntohl(ce_mode_from_stat(nce, mode));
dpath->parent[stage-2].mode = ce_mode_from_stat(nce, mode);
dpath->parent[stage-2].status =
DIFF_STATUS_MODIFIED;
}
......@@ -442,15 +442,15 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
}
if (silent_on_removed)
continue;
diff_addremove(&revs->diffopt, '-', ntohl(ce->ce_mode),
diff_addremove(&revs->diffopt, '-', ce->ce_mode,
ce->sha1, ce->name, NULL);
continue;
}
changed = ce_match_stat(ce, &st, ce_option);
if (!changed && !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
continue;
oldmode = ntohl(ce->ce_mode);
newmode = ntohl(ce_mode_from_stat(ce, st.st_mode));
oldmode = ce->ce_mode;
newmode = ce_mode_from_stat(ce, st.st_mode);
diff_change(&revs->diffopt, oldmode, newmode,
ce->sha1, (changed ? null_sha1 : ce->sha1),
ce->name, NULL);
......@@ -471,7 +471,7 @@ static void diff_index_show_file(struct rev_info *revs,
struct cache_entry *ce,
unsigned char *sha1, unsigned int mode)
{
diff_addremove(&revs->diffopt, prefix[0], ntohl(mode),
diff_addremove(&revs->diffopt, prefix[0], mode,
sha1, ce->name, NULL);
}
......@@ -550,14 +550,14 @@ static int show_modified(struct rev_info *revs,
p->len = pathlen;
memcpy(p->path, new->name, pathlen);
p->path[pathlen] = 0;
p->mode = ntohl(mode);
p->mode = mode;
hashclr(p->sha1);
memset(p->parent, 0, 2 * sizeof(struct combine_diff_parent));
p->parent[0].status = DIFF_STATUS_MODIFIED;
p->parent[0].mode = ntohl(new->ce_mode);
p->parent[0].mode = new->ce_mode;
hashcpy(p->parent[0].sha1, new->sha1);
p->parent[1].status = DIFF_STATUS_MODIFIED;
p->parent[1].mode = ntohl(old->ce_mode);
p->parent[1].mode = old->ce_mode;
hashcpy(p->parent[1].sha1, old->sha1);
show_combined_diff(p, 2, revs->dense_combined_merges, revs);
free(p);
......@@ -569,9 +569,6 @@ static int show_modified(struct rev_info *revs,
!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
return 0;
mode = ntohl(mode);
oldmode = ntohl(oldmode);
diff_change(&revs->diffopt, oldmode, mode,
old->sha1, sha1, old->name, NULL);
return 0;
......@@ -628,7 +625,7 @@ static int diff_cache(struct rev_info *revs,
cached, match_missing))
break;
diff_unmerge(&revs->diffopt, ce->name,
ntohl(ce->ce_mode), ce->sha1);
ce->ce_mode, ce->sha1);
break;
case 3:
diff_unmerge(&revs->diffopt, ce->name,
......@@ -664,7 +661,7 @@ static void mark_merge_entries(void)
struct cache_entry *ce = active_cache[i];
if (!ce_stage(ce))
continue;
ce->ce_flags |= htons(CE_STAGEMASK);
ce->ce_flags |= CE_STAGEMASK;
}
}
......@@ -722,8 +719,7 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
cache_tree_invalidate_path(active_cache_tree,
ce->name);
last = ce;
ce->ce_mode = 0;
ce->ce_flags &= ~htons(CE_STAGEMASK);
ce->ce_flags |= CE_REMOVE;
}
*dst++ = ce;
}
......
......@@ -391,7 +391,7 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)
break;
if (endchar == '/')
return index_directory;
if (!endchar && S_ISGITLINK(ntohl(ce->ce_mode)))
if (!endchar && S_ISGITLINK(ce->ce_mode))
return index_gitdir;
}
return index_nonexistent;
......
......@@ -103,7 +103,7 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout
int fd;
long wrote;
switch (ntohl(ce->ce_mode) & S_IFMT) {
switch (ce->ce_mode & S_IFMT) {
char *new;
struct strbuf buf;
unsigned long size;
......@@ -129,7 +129,7 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout
strcpy(path, ".merge_file_XXXXXX");
fd = mkstemp(path);
} else
fd = create_file(path, ntohl(ce->ce_mode));
fd = create_file(path, ce->ce_mode);
if (fd < 0) {
free(new);
return error("git-checkout-index: unable to create file %s (%s)",
......@@ -221,7 +221,7 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *t
unlink(path);
if (S_ISDIR(st.st_mode)) {
/* If it is a gitlink, leave it alone! */
if (S_ISGITLINK(ntohl(ce->ce_mode)))
if (S_ISGITLINK(ce->ce_mode))
return 0;
if (!state->force)
return error("%s is a directory", path);
......
......@@ -48,7 +48,7 @@ static int merge_entry(int pos, const char *path)
break;
found++;
strcpy(hexbuf[stage], sha1_to_hex(ce->sha1));
sprintf(ownbuf[stage], "%o", ntohl(ce->ce_mode));
sprintf(ownbuf[stage], "%o", ce->ce_mode);
arguments[stage] = hexbuf[stage];
arguments[stage + 4] = ownbuf[stage];
} while (++pos < active_nr);
......
......@@ -333,7 +333,7 @@ static struct path_list *get_unmerged(void)
item->util = xcalloc(1, sizeof(struct stage_data));
}
e = item->util;
e->stages[ce_stage(ce)].mode = ntohl(ce->ce_mode);
e->stages[ce_stage(ce)].mode = ce->ce_mode;
hashcpy(e->stages[ce_stage(ce)].sha, ce->sha1);
}
......
......@@ -176,7 +176,7 @@ static void add_cache_refs(struct rev_info *revs)
* lookup_blob() on them, to avoid populating the hash table
* with invalid information
*/
if (S_ISGITLINK(ntohl(active_cache[i]->ce_mode)))
if (S_ISGITLINK(active_cache[i]->ce_mode))
continue;
lookup_blob(active_cache[i]->sha1);
......
This diff is collapsed.
......@@ -695,7 +695,7 @@ int get_sha1_with_mode(const char *name, unsigned char *sha1, unsigned *mode)
break;
if (ce_stage(ce) == stage) {
hashcpy(sha1, ce->sha1);
*mode = ntohl(ce->ce_mode);
*mode = ce->ce_mode;
return 0;
}
pos++;
......
......@@ -142,8 +142,8 @@ static int cmp_cache_name_compare(const void *a_, const void *b_)
ce1 = *((const struct cache_entry **)a_);
ce2 = *((const struct cache_entry **)b_);
return cache_name_compare(ce1->name, ntohs(ce1->ce_flags),
ce2->name, ntohs(ce2->ce_flags));
return cache_name_compare(ce1->name, ce1->ce_flags,
ce2->name, ce2->ce_flags);
}
int read_tree(struct tree *tree, int stage, const char **match)
......
......@@ -289,7 +289,6 @@ static struct checkout state;
static void check_updates(struct cache_entry **src, int nr,
struct unpack_trees_options *o)
{
unsigned short mask = htons(CE_UPDATE);
unsigned cnt = 0, total = 0;
struct progress *progress = NULL;
char last_symlink[PATH_MAX];
......@@ -297,7 +296,7 @@ static void check_updates(struct cache_entry **src, int nr,
if (o->update && o->verbose_update) {
for (total = cnt = 0; cnt < nr; cnt++) {
struct cache_entry *ce = src[cnt];
if (!ce->ce_mode || ce->ce_flags & mask)
if (ce->ce_flags & (CE_UPDATE | CE_REMOVE))
total++;
}
......@@ -310,15 +309,15 @@ static void check_updates(struct cache_entry **src, int nr,
while (nr--) {
struct cache_entry *ce = *src++;
if (!ce->ce_mode || ce->ce_flags & mask)
if (ce->ce_flags & (CE_UPDATE | CE_REMOVE))
display_progress(progress, ++cnt);
if (!ce->ce_mode) {
if (ce->ce_flags & CE_REMOVE) {
if (o->update)
unlink_entry(ce->name, last_symlink);
continue;
}
if (ce->ce_flags & mask) {
ce->ce_flags &= ~mask;
if (ce->ce_flags & CE_UPDATE) {
ce->ce_flags &= ~CE_UPDATE;
if (o->update) {
checkout_entry(ce, &state, NULL);
*last_symlink = '\0';
......@@ -408,7 +407,7 @@ static void verify_uptodate(struct cache_entry *ce,
* submodules that are marked to be automatically
* checked out.
*/
if (S_ISGITLINK(ntohl(ce->ce_mode)))
if (S_ISGITLINK(ce->ce_mode))
return;
errno = 0;
}
......@@ -450,7 +449,7 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
int cnt = 0;
unsigned char sha1[20];
if (S_ISGITLINK(ntohl(ce->ce_mode)) &&
if (S_ISGITLINK(ce->ce_mode) &&
resolve_gitlink_ref(ce->name, "HEAD", sha1) == 0) {
/* If we are not going to update the submodule, then
* we don't care.
......@@ -481,7 +480,7 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
*/
if (!ce_stage(ce)) {
verify_uptodate(ce, o);
ce->ce_mode = 0;
ce->ce_flags |= CE_REMOVE;
}
cnt++;
}
......@@ -568,7 +567,7 @@ static void verify_absent(struct cache_entry *ce, const char *action,
cnt = cache_name_pos(ce->name, strlen(ce->name));
if (0 <= cnt) {
struct cache_entry *ce = active_cache[cnt];
if (!ce_stage(ce) && !ce->ce_mode)
if (ce->ce_flags & CE_REMOVE)
return;
}
......@@ -580,7 +579,7 @@ static void verify_absent(struct cache_entry *ce, const char *action,
static int merged_entry(struct cache_entry *merge, struct cache_entry *old,
struct unpack_trees_options *o)
{
merge->ce_flags |= htons(CE_UPDATE);
merge->ce_flags |= CE_UPDATE;
if (old) {
/*
* See if we can re-use the old CE directly?
......@@ -601,7 +600,7 @@ static int merged_entry(struct cache_entry *merge, struct cache_entry *old,
invalidate_ce_path(merge);
}
merge->ce_flags &= ~htons(CE_STAGEMASK);
merge->ce_flags &= ~CE_STAGEMASK;
add_cache_entry(merge, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
return 1;
}
......@@ -613,7 +612,7 @@ static int deleted_entry(struct cache_entry *ce, struct cache_entry *old,
verify_uptodate(old, o);
else
verify_absent(ce, "removed", o);
ce->ce_mode = 0;
ce->ce_flags |= CE_REMOVE;
add_cache_entry(ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
invalidate_ce_path(ce);
return 1;
......@@ -634,7 +633,7 @@ static void show_stage_entry(FILE *o,
else
fprintf(o, "%s%06o %s %d\t%s\n",
label,
ntohl(ce->ce_mode),
ce->ce_mode,
sha1_to_hex(ce->sha1),
ce_stage(ce),
ce->name);
......@@ -920,7 +919,7 @@ int oneway_merge(struct cache_entry **src,
struct stat st;
if (lstat(old->name, &st) ||
ce_match_stat(old, &st, CE_MATCH_IGNORE_VALID))
old->ce_flags |= htons(CE_UPDATE);
old->ce_flags |= CE_UPDATE;
}
return keep_entry(old, o);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment