From: Junio C Hamano Date: Wed, 19 Aug 2015 21:41:27 +0000 (-0700) Subject: Merge branch 'cb/uname-in-untracked' into maint X-Git-Tag: v2.5.1~16 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b083703ce34b27a0f97d7e2d4d2eec196a53b707?ds=inline;hp=-c Merge branch 'cb/uname-in-untracked' into maint An experimental "untracked cache" feature used uname(2) in a slightly unportable way. * cb/uname-in-untracked: untracked: fix detection of uname(2) failure --- b083703ce34b27a0f97d7e2d4d2eec196a53b707 diff --combined dir.c index 8209f8b8af,8d15e475d4..1d42811cfb --- a/dir.c +++ b/dir.c @@@ -12,7 -12,6 +12,7 @@@ #include "refs.h" #include "wildmatch.h" #include "pathspec.h" +#include "utf8.h" #include "varint.h" #include "ewah/ewok.h" @@@ -394,47 -393,6 +394,47 @@@ int match_pathspec(const struct pathspe return negative ? 0 : positive; } +int report_path_error(const char *ps_matched, + const struct pathspec *pathspec, + const char *prefix) +{ + /* + * Make sure all pathspec matched; otherwise it is an error. + */ + int num, errors = 0; + for (num = 0; num < pathspec->nr; num++) { + int other, found_dup; + + if (ps_matched[num]) + continue; + /* + * The caller might have fed identical pathspec + * twice. Do not barf on such a mistake. + * FIXME: parse_pathspec should have eliminated + * duplicate pathspec. + */ + for (found_dup = other = 0; + !found_dup && other < pathspec->nr; + other++) { + if (other == num || !ps_matched[other]) + continue; + if (!strcmp(pathspec->items[other].original, + pathspec->items[num].original)) + /* + * Ok, we have a match already. + */ + found_dup = 1; + } + if (found_dup) + continue; + + error("pathspec '%s' did not match any file(s) known to git.", + pathspec->items[num].original); + errors++; + } + return errors; +} + /* * Return the length of the "simple" part of a path match limiter. */ @@@ -740,12 -698,7 +740,12 @@@ static int add_excludes(const char *fna } el->filebuf = buf; + + if (skip_utf8_bom(&buf, size)) + size -= buf - el->filebuf; + entry = buf; + for (i = 0; i < size; i++) { if (buf[i] == '\n') { if (entry != buf + i && entry[0] != '#') { @@@ -1848,7 -1801,7 +1848,7 @@@ static const char *get_ident_string(voi if (sb.len) return sb.buf; - if (uname(&uts)) + if (uname(&uts) < 0) die_errno(_("failed to get kernel name and information")); strbuf_addf(&sb, "Location %s, system %s %s %s", get_git_work_tree(), uts.sysname, uts.release, uts.version); @@@ -2188,21 -2141,20 +2188,21 @@@ int remove_dir_recursively(struct strbu void setup_standard_excludes(struct dir_struct *dir) { const char *path; - char *xdg_path; dir->exclude_per_dir = ".gitignore"; + + /* core.excludefile defaulting to $XDG_HOME/git/ignore */ + if (!excludes_file) + excludes_file = xdg_config_home("ignore"); + if (excludes_file && !access_or_warn(excludes_file, R_OK, 0)) + add_excludes_from_file_1(dir, excludes_file, + dir->untracked ? &dir->ss_excludes_file : NULL); + + /* per repository user preference */ path = git_path("info/exclude"); - if (!excludes_file) { - home_config_paths(NULL, &xdg_path, "ignore"); - excludes_file = xdg_path; - } if (!access_or_warn(path, R_OK, 0)) add_excludes_from_file_1(dir, path, dir->untracked ? &dir->ss_info_exclude : NULL); - if (excludes_file && !access_or_warn(excludes_file, R_OK, 0)) - add_excludes_from_file_1(dir, excludes_file, - dir->untracked ? &dir->ss_excludes_file : NULL); } int remove_path(const char *name)