Merge branch 'nd/magic-pathspec'
Use "struct pathspec" interface in more places, instead of array of characters, the latter of which cannot express magic pathspecs (e.g. ":(icase)makefile" that matches both Makefile and makefile). * nd/magic-pathspec: add: lift the pathspec magic restriction on "add -p" pathspec: catch prepending :(prefix) on pathspec with short magicmaint
commit
fadf96abaa
|
|
@ -270,13 +270,7 @@ int interactive_add(int argc, const char **argv, const char *prefix, int patch)
|
||||||
{
|
{
|
||||||
struct pathspec pathspec;
|
struct pathspec pathspec;
|
||||||
|
|
||||||
/*
|
parse_pathspec(&pathspec, 0,
|
||||||
* git-add--interactive itself does not parse pathspec. It
|
|
||||||
* simply passes the pathspec to other builtin commands. Let's
|
|
||||||
* hope all of them support all magic, or we'll need to limit
|
|
||||||
* the magic here.
|
|
||||||
*/
|
|
||||||
parse_pathspec(&pathspec, PATHSPEC_ALL_MAGIC & ~PATHSPEC_FROMTOP,
|
|
||||||
PATHSPEC_PREFER_FULL |
|
PATHSPEC_PREFER_FULL |
|
||||||
PATHSPEC_SYMLINK_LEADING_PATH |
|
PATHSPEC_SYMLINK_LEADING_PATH |
|
||||||
PATHSPEC_PREFIX_ORIGIN,
|
PATHSPEC_PREFIX_ORIGIN,
|
||||||
|
|
|
||||||
|
|
@ -1146,13 +1146,6 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc) {
|
if (argc) {
|
||||||
/*
|
|
||||||
* In patch mode (opts.patch_mode != 0), we pass the
|
|
||||||
* pathspec to an external program, git-add--interactive.
|
|
||||||
* Do not accept any kind of magic that that program
|
|
||||||
* cannot handle. Magic mask is pretty safe to be
|
|
||||||
* lifted for new magic when opts.patch_mode == 0.
|
|
||||||
*/
|
|
||||||
parse_pathspec(&opts.pathspec, 0,
|
parse_pathspec(&opts.pathspec, 0,
|
||||||
opts.patch_mode ? PATHSPEC_PREFIX_ORIGIN : 0,
|
opts.patch_mode ? PATHSPEC_PREFIX_ORIGIN : 0,
|
||||||
prefix, argv);
|
prefix, argv);
|
||||||
|
|
|
||||||
|
|
@ -231,7 +231,9 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
|
||||||
const char *start = elt;
|
const char *start = elt;
|
||||||
if (prefixlen && !literal_global) {
|
if (prefixlen && !literal_global) {
|
||||||
/* Preserve the actual prefix length of each pattern */
|
/* Preserve the actual prefix length of each pattern */
|
||||||
if (long_magic_end) {
|
if (short_magic)
|
||||||
|
die("BUG: prefixing on short magic is not supported");
|
||||||
|
else if (long_magic_end) {
|
||||||
strbuf_add(&sb, start, long_magic_end - start);
|
strbuf_add(&sb, start, long_magic_end - start);
|
||||||
strbuf_addf(&sb, ",prefix:%d", prefixlen);
|
strbuf_addf(&sb, ",prefix:%d", prefixlen);
|
||||||
start = long_magic_end;
|
start = long_magic_end;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
PATHSPEC_GLOB | \
|
PATHSPEC_GLOB | \
|
||||||
PATHSPEC_ICASE)
|
PATHSPEC_ICASE)
|
||||||
|
|
||||||
#define PATHSPEC_ONESTAR 1 /* the pathspec pattern sastisfies GFNM_ONESTAR */
|
#define PATHSPEC_ONESTAR 1 /* the pathspec pattern satisfies GFNM_ONESTAR */
|
||||||
|
|
||||||
struct pathspec {
|
struct pathspec {
|
||||||
const char **_raw; /* get_pathspec() result, not freed by free_pathspec() */
|
const char **_raw; /* get_pathspec() result, not freed by free_pathspec() */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue