mirror of
https://github.com/git/git.git
synced 2024-11-20 16:24:06 +01:00
Do not default to --no-index when given two directories.
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>
This commit is contained in:
parent
dc61b10d98
commit
1ad029b6a1
34
diff-lib.c
34
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;
|
||||
int len, pos;
|
||||
struct cache_entry *ce;
|
||||
|
||||
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 == '/';
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user