diff options
| author | Junio C Hamano <junkio@cox.net> | 2007-04-14 04:18:46 -0700 |
|---|---|---|
| committer | Junio C Hamano <junkio@cox.net> | 2007-04-14 04:18:46 -0700 |
| commit | edb4fd79ec34254fc4a1c35e8834df4c92cb3bfd (patch) | |
| tree | 7a983deb4620bc3de0a26d091381b03b35ea8933 /diff-lib.c | |
| parent | d016a896d4a58a53dbb98cd85ebd033771413079 (diff) | |
| parent | 1fa9bf362acbe2c939c246684ab0fe59aec74ba8 (diff) | |
| download | git-edb4fd79ec34254fc4a1c35e8834df4c92cb3bfd.tar.gz | |
Merge branch 'maint'
* maint:
git-quiltimport complaining yet still working
config.txt: Fix grammatical error in description of http.noEPSV
config.txt: Change pserver to server in description of gitcvs.*
config.txt: Document core.autocrlf
config.txt: Document gitcvs.allbinary
Do not default to --no-index when given two directories.
Use rev-list --reverse in git-rebase.sh
Diffstat (limited to 'diff-lib.c')
| -rw-r--r-- | diff-lib.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/diff-lib.c b/diff-lib.c index 5c5b05bfe3..7531e20c78 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -142,18 +142,34 @@ static int queue_diff(struct diff_options *o, } } +/* + * Does the path name a blob in the working tree, or a directory + * in the working tree? + */ static int is_in_index(const char *path) { - int len = strlen(path); - int pos = cache_name_pos(path, len); - char c; - - if (pos < 0) - return 0; - if (strncmp(active_cache[pos]->name, path, len)) - return 0; - c = active_cache[pos]->name[len]; - return c == '\0' || c == '/'; + int len, pos; + struct cache_entry *ce; + + len = strlen(path); + while (path[len-1] == '/') + len--; + if (!len) + return 1; /* "." */ + pos = cache_name_pos(path, len); + if (0 <= pos) + return 1; + pos = -1 - pos; + while (pos < active_nr) { + ce = active_cache[pos++]; + if (ce_namelen(ce) <= len || + strncmp(ce->name, path, len) || + (ce->name[len] > '/')) + break; /* path cannot be a prefix */ + if (ce->name[len] == '/') + return 1; + } + return 0; } static int handle_diff_files_args(struct rev_info *revs, |
