Merge branch 'cb/uname-in-untracked' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 19 Aug 2015 21:41:27 +0000 (14:41 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 19 Aug 2015 21:41:28 +0000 (14:41 -0700)
An experimental "untracked cache" feature used uname(2) in a
slightly unportable way.

* cb/uname-in-untracked:
untracked: fix detection of uname(2) failure

1  2 
dir.c
diff --combined dir.c
index 8209f8b8af1e1e3dbc9c166ca351b602de5e6f7a,8d15e475d420ea13b39e07644fa987c75317ea94..1d42811cfb29009d75b95e4d24ebd67f5215e326
--- 1/dir.c
--- 2/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)