Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorSamuel Lijin <sxlijin@gmail.com>2017-05-18 11:21:53 +0300
committerJunio C Hamano <gitster@pobox.com>2017-05-22 06:14:13 +0300
commitbbf504a9957e8a2a262619641ffa30348d71a76f (patch)
treed9e0897c6250a60b6f2e72c71a8243c9a9653226 /dir.c
parentfb898888491b83c9a3396fb559032ca78807a0c0 (diff)
dir: expose cmp_name() and check_contains()
We want to use cmp_name() and check_contains() (which both compare `struct dir_entry`s, the former in terms of the sort order, the latter in terms of whether one lexically contains another) outside of dir.c, so we have to (1) change their linkage and (2) rename them as appropriate for the global namespace. The second is achieved by renaming cmp_name() to cmp_dir_entry() and check_contains() to check_dir_entry_contains(). Signed-off-by: Samuel Lijin <sxlijin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/dir.c b/dir.c
index 61561ea91d8..31c6e1dac00 100644
--- a/dir.c
+++ b/dir.c
@@ -1805,7 +1805,7 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
return dir_state;
}
-static int cmp_name(const void *p1, const void *p2)
+int cmp_dir_entry(const void *p1, const void *p2)
{
const struct dir_entry *e1 = *(const struct dir_entry **)p1;
const struct dir_entry *e2 = *(const struct dir_entry **)p2;
@@ -1814,7 +1814,7 @@ static int cmp_name(const void *p1, const void *p2)
}
/* check if *out lexically strictly contains *in */
-static int check_contains(const struct dir_entry *out, const struct dir_entry *in)
+int check_dir_entry_contains(const struct dir_entry *out, const struct dir_entry *in)
{
return (out->len < in->len) &&
(out->name[out->len - 1] == '/') &&
@@ -2034,8 +2034,8 @@ int read_directory(struct dir_struct *dir, const char *path,
dir->untracked = NULL;
if (!len || treat_leading_path(dir, path, len, pathspec))
read_directory_recursive(dir, path, len, untracked, 0, pathspec);
- QSORT(dir->entries, dir->nr, cmp_name);
- QSORT(dir->ignored, dir->ignored_nr, cmp_name);
+ QSORT(dir->entries, dir->nr, cmp_dir_entry);
+ QSORT(dir->ignored, dir->ignored_nr, cmp_dir_entry);
/*
* If DIR_SHOW_IGNORED_TOO is set, read_directory_recursive() will
@@ -2048,7 +2048,8 @@ int read_directory(struct dir_struct *dir, const char *path,
/* remove from dir->entries untracked contents of untracked dirs */
for (i = j = 0; j < dir->nr; j++) {
- if (i && check_contains(dir->entries[i - 1], dir->entries[j])) {
+ if (i &&
+ check_dir_entry_contains(dir->entries[i - 1], dir->entries[j])) {
free(dir->entries[j]);
dir->entries[j] = NULL;
} else {