mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-06 17:20:22 +00:00
Fix getting status of files containing brackets
This commit is contained in:
parent
e5e71f5e1d
commit
ffbc689c87
21
src/diff.c
21
src/diff.c
@ -20,16 +20,23 @@ static char *diff_prefix_from_pathspec(const git_strarray *pathspec)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* diff prefix will only be leading non-wildcards */
|
/* diff prefix will only be leading non-wildcards */
|
||||||
for (scan = prefix.ptr; *scan && !git__iswildcard(*scan); ++scan);
|
for (scan = prefix.ptr; *scan; ++scan) {
|
||||||
|
if (git__iswildcard(*scan) &&
|
||||||
|
(scan == prefix.ptr || (*(scan - 1) != '\\')))
|
||||||
|
break;
|
||||||
|
}
|
||||||
git_buf_truncate(&prefix, scan - prefix.ptr);
|
git_buf_truncate(&prefix, scan - prefix.ptr);
|
||||||
|
|
||||||
if (prefix.size > 0)
|
if (prefix.size <= 0) {
|
||||||
return git_buf_detach(&prefix);
|
|
||||||
|
|
||||||
git_buf_free(&prefix);
|
git_buf_free(&prefix);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
git_buf_unescape(&prefix);
|
||||||
|
|
||||||
|
return git_buf_detach(&prefix);
|
||||||
|
}
|
||||||
|
|
||||||
static bool diff_pathspec_is_interesting(const git_strarray *pathspec)
|
static bool diff_pathspec_is_interesting(const git_strarray *pathspec)
|
||||||
{
|
{
|
||||||
const char *str;
|
const char *str;
|
||||||
@ -54,7 +61,10 @@ static bool diff_path_matches_pathspec(git_diff_list *diff, const char *path)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
git_vector_foreach(&diff->pathspec, i, match) {
|
git_vector_foreach(&diff->pathspec, i, match) {
|
||||||
int result = p_fnmatch(match->pattern, path, 0);
|
int result = strcmp(match->pattern, path);
|
||||||
|
|
||||||
|
if (result != 0)
|
||||||
|
result = p_fnmatch(match->pattern, path, 0);
|
||||||
|
|
||||||
/* if we didn't match, look for exact dirname prefix match */
|
/* if we didn't match, look for exact dirname prefix match */
|
||||||
if (result == FNM_NOMATCH &&
|
if (result == FNM_NOMATCH &&
|
||||||
@ -826,4 +836,3 @@ int git_diff_merge(
|
|||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,10 +176,12 @@ static int get_one_status(const char *path, unsigned int status, void *data)
|
|||||||
sfi->count++;
|
sfi->count++;
|
||||||
sfi->status = status;
|
sfi->status = status;
|
||||||
|
|
||||||
if (sfi->count > 1 || strcmp(sfi->expected, path) != 0) {
|
if (sfi->count > 1 ||
|
||||||
|
(strcmp(sfi->expected, path) != 0 &&
|
||||||
|
p_fnmatch(sfi->expected, path, 0) != 0)) {
|
||||||
giterr_set(GITERR_INVALID,
|
giterr_set(GITERR_INVALID,
|
||||||
"Ambiguous path '%s' given to git_status_file", sfi->expected);
|
"Ambiguous path '%s' given to git_status_file", sfi->expected);
|
||||||
return -1;
|
return GIT_EAMBIGUOUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user