1863
return dtype;
1864
}
1865
1866
-static enum path_treatment treat_one_path(struct dir_struct *dir,
1867
- struct untracked_cache_dir *untracked,
1868
- struct index_state *istate,
1869
- struct strbuf *path,
1870
- int baselen,
1871
- const struct pathspec *pathspec,
1872
- int dtype)
1873
-{
1874
- int exclude;
1875
- int has_path_in_index = !!index_file_exists(istate, path->buf, path->len, ignore_case);
1866
+static enum path_treatment treat_path_fast(struct dir_struct *dir,
1867
+ struct untracked_cache_dir *untracked,
1868
+ struct cached_dir *cdir,
1869
+ struct index_state *istate,
1870
+ struct strbuf *path,
1871
+ int baselen,
1872
+ const struct pathspec *pathspec)
1873
+{
1874
+ strbuf_setlen(path, baselen);
1875
+ if (!cdir->ucd) {
1876
+ strbuf_addstr(path, cdir->file);
1877
+ return path_untracked;
1878
+ }
1879
+ strbuf_addstr(path, cdir->ucd->name);
1880
+ /* treat_one_path() does this before it calls treat_directory() */
1881
+ strbuf_complete(path, '/');
1882
+ if (cdir->ucd->check_only)
1883
+ /*
1884
+ * check_only is set as a result of treat_directory() getting
1885
+ * to its bottom. Verify again the same set of directories
1886
+ * with check_only set.
1887
+ */
1888
+ return read_directory_recursive(dir, istate, path->buf, path->len,
1889
+ cdir->ucd, 1, 0, pathspec);
1890
+ /*
1891
+ * We get path_recurse in the first run when
1892
+ * directory_exists_in_index() returns index_nonexistent. We
1893
+ * are sure that new changes in the index does not impact the
1894
+ * outcome. Return now.
1895
+ */
1896
+ return path_recurse;
1897
+}
1898
+
1899
+static enum path_treatment treat_path(struct dir_struct *dir,
1900
+ struct untracked_cache_dir *untracked,
1901
+ struct cached_dir *cdir,
1902
+ struct index_state *istate,
1903
+ struct strbuf *path,
1904
+ int baselen,
1905
+ const struct pathspec *pathspec)
1906
+{
1907
+ int has_path_in_index, dtype, exclude;
1908
enum path_treatment path_treatment;
1909
1878
- dtype = resolve_dtype(dtype, istate, path->buf, path->len);
1910
+ if (!cdir->d_name)
1911
+ return treat_path_fast(dir, untracked, cdir, istate, path,
1912
+ baselen, pathspec);
1913
+ if (is_dot_or_dotdot(cdir->d_name) || !fspathcmp(cdir->d_name, ".git"))
1914
+ return path_none;
1915
+ strbuf_setlen(path, baselen);
1916
+ strbuf_addstr(path, cdir->d_name);
1917
+ if (simplify_away(path->buf, path->len, pathspec))
1918
+ return path_none;
1919
+
1920
+ dtype = resolve_dtype(cdir->d_type, istate, path->buf, path->len);
1921
1922
/* Always exclude indexed files */
1923
+ has_path_in_index = !!index_file_exists(istate, path->buf, path->len,
1924
+ ignore_case);
1925
if (dtype != DT_DIR && has_path_in_index)
1926
return path_none;
1927
1986
}
1987
}
1988
1945
-static enum path_treatment treat_path_fast(struct dir_struct *dir,
1946
- struct untracked_cache_dir *untracked,
1947
- struct cached_dir *cdir,
1948
- struct index_state *istate,
1949
- struct strbuf *path,
1950
- int baselen,
1951
- const struct pathspec *pathspec)
1952
-{
1953
- strbuf_setlen(path, baselen);
1954
- if (!cdir->ucd) {
1955
- strbuf_addstr(path, cdir->file);
1956
- return path_untracked;
1957
- }
1958
- strbuf_addstr(path, cdir->ucd->name);
1959
- /* treat_one_path() does this before it calls treat_directory() */
1960
- strbuf_complete(path, '/');
1961
- if (cdir->ucd->check_only)
1962
- /*
1963
- * check_only is set as a result of treat_directory() getting
1964
- * to its bottom. Verify again the same set of directories
1965
- * with check_only set.
1966
- */
1967
- return read_directory_recursive(dir, istate, path->buf, path->len,
1968
- cdir->ucd, 1, 0, pathspec);
1969
- /*
1970
- * We get path_recurse in the first run when
1971
- * directory_exists_in_index() returns index_nonexistent. We
1972
- * are sure that new changes in the index does not impact the
1973
- * outcome. Return now.
1974
- */
1975
- return path_recurse;
1976
-}
1977
-
1978
-static enum path_treatment treat_path(struct dir_struct *dir,
1979
- struct untracked_cache_dir *untracked,
1980
- struct cached_dir *cdir,
1981
- struct index_state *istate,
1982
- struct strbuf *path,
1983
- int baselen,
1984
- const struct pathspec *pathspec)
1985
-{
1986
- if (!cdir->d_name)
1987
- return treat_path_fast(dir, untracked, cdir, istate, path,
1988
- baselen, pathspec);
1989
- if (is_dot_or_dotdot(cdir->d_name) || !fspathcmp(cdir->d_name, ".git"))
1990
- return path_none;
1991
- strbuf_setlen(path, baselen);
1992
- strbuf_addstr(path, cdir->d_name);
1993
- if (simplify_away(path->buf, path->len, pathspec))
1994
- return path_none;
1995
-
1996
- return treat_one_path(dir, untracked, istate, path, baselen, pathspec,
1997
- cdir->d_type);
1998
-}
1999
-
1989
static void add_untracked(struct untracked_cache_dir *dir, const char *name)
1990
{
1991
if (!dir)