From: Junio C Hamano Date: Wed, 30 Jan 2013 16:52:53 +0000 (-0800) Subject: Merge branch 'nd/magic-pathspec-from-root' X-Git-Tag: v1.8.2-rc0~75 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/7b5196909c7773a3ce6d3cd0ba78f42249bf27c3?ds=inline;hp=-c Merge branch 'nd/magic-pathspec-from-root' When giving arguments without "--" disambiguation, object names that come earlier on the command line must not be interpretable as pathspecs and pathspecs that come later on the command line must not be interpretable as object names. Tweak the disambiguation rule so that ":/" (no other string before or after) is always interpreted as a pathspec, to avoid having to say "git cmd -- :/". * nd/magic-pathspec-from-root: grep: avoid accepting ambiguous revision Update :/abc ambiguity check --- 7b5196909c7773a3ce6d3cd0ba78f42249bf27c3 diff --combined setup.c index 1ccfafaa7a,47acc1186f..2e1521b09e --- a/setup.c +++ b/setup.c @@@ -66,7 -66,14 +66,14 @@@ int check_filename(const char *prefix, const char *name; struct stat st; - name = prefix ? prefix_filename(prefix, strlen(prefix), arg) : arg; + if (!prefixcmp(arg, ":/")) { + if (arg[2] == '\0') /* ":/" is root dir, always exists */ + return 1; + name = arg + 2; + } else if (prefix) + name = prefix_filename(prefix, strlen(prefix), arg); + else + name = arg; if (!lstat(name, &st)) return 1; /* file exists */ if (errno == ENOENT || errno == ENOTDIR) @@@ -246,25 -253,6 +253,25 @@@ static const char *prefix_pathspec(cons return prefix_path(prefix, prefixlen, copyfrom); } +/* + * N.B. get_pathspec() is deprecated in favor of the "struct pathspec" + * based interface - see pathspec_magic above. + * + * Arguments: + * - prefix - a path relative to the root of the working tree + * - pathspec - a list of paths underneath the prefix path + * + * Iterates over pathspec, prepending each path with prefix, + * and return the resulting list. + * + * If pathspec is empty, return a singleton list containing prefix. + * + * If pathspec and prefix are both empty, return an empty list. + * + * This is typically used by built-in commands such as add.c, in order + * to normalize argv arguments provided to the built-in into a list of + * paths to process, all relative to the root of the working tree. + */ const char **get_pathspec(const char *prefix, const char **pathspec) { const char *entry = *pathspec;