diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-11-02 13:37:13 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-11-02 13:37:13 -0800 |
commit | 86e67a088c581da4da36acf0edd8c27b1033e51e (patch) | |
tree | ff6c53429e67c4f44f7c7b07cfa8bcb980c7570a /read-cache.c | |
parent | d11ddaff021be8006e71b43a5205c48f2dac7f18 (diff) | |
parent | 98fa473887d0bebd38d568bb07232a336a642dcf (diff) | |
download | git-86e67a088c581da4da36acf0edd8c27b1033e51e.tar.gz |
Merge branch 'jk/maint-ls-files-other' into maint
* jk/maint-ls-files-other:
refactor handling of "other" files in ls-files and status
Diffstat (limited to 'read-cache.c')
-rw-r--r-- | read-cache.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/read-cache.c b/read-cache.c index 15e1a9d471..967f483f78 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1485,3 +1485,31 @@ int read_index_unmerged(struct index_state *istate) } return unmerged; } + +/* + * Returns 1 if the path is an "other" path with respect to + * the index; that is, the path is not mentioned in the index at all, + * either as a file, a directory with some files in the index, + * or as an unmerged entry. + * + * We helpfully remove a trailing "/" from directories so that + * the output of read_directory can be used as-is. + */ +int index_name_is_other(const struct index_state *istate, const char *name, + int namelen) +{ + int pos; + if (namelen && name[namelen - 1] == '/') + namelen--; + pos = index_name_pos(istate, name, namelen); + if (0 <= pos) + return 0; /* exact match */ + pos = -pos - 1; + if (pos < istate->cache_nr) { + struct cache_entry *ce = istate->cache[pos]; + if (ce_namelen(ce) == namelen && + !memcmp(ce->name, name, namelen)) + return 0; /* Yup, this one exists unmerged */ + } + return 1; +} |