summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dc61b10)
raw | patch | inline | side by side (parent: dc61b10)
author | Junio C Hamano <junkio@cox.net> | |
Fri, 13 Apr 2007 10:23:20 +0000 (03:23 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 14 Apr 2007 02:34:35 +0000 (19:34 -0700) |
git-diff -- a/ b/ always defaulted to --no-index, primarily
because the function is_in_index() was implemented quite
incorrectly.
Noticed by Patrick Maaß and Simon Schubert independently,
initial patch was provided by Patrick but I fixed it
differently.
Signed-off-by: Junio C Hamano <junkio@cox.net>
because the function is_in_index() was implemented quite
incorrectly.
Noticed by Patrick Maaß and Simon Schubert independently,
initial patch was provided by Patrick but I fixed it
differently.
Signed-off-by: Junio C Hamano <junkio@cox.net>
diff-lib.c | patch | blob | history |
diff --git a/diff-lib.c b/diff-lib.c
index 5c5b05bfe32bc90484b5bd6a9c171e0f9b04fbd6..7531e20c784c44c0b5d3ecb2057638874a09ce6c 100644 (file)
--- a/diff-lib.c
+++ b/diff-lib.c
}
}
+/*
+ * 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,