Skip to content

Commit fadf96a

Browse files
committed
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 magic
2 parents af226bf + 625c330 commit fadf96a

File tree

4 files changed

+5
-16
lines changed

4 files changed

+5
-16
lines changed

builtin/add.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,7 @@ int interactive_add(int argc, const char **argv, const char *prefix, int patch)
270270
{
271271
struct pathspec pathspec;
272272

273-
/*
274-
* git-add--interactive itself does not parse pathspec. It
275-
* simply passes the pathspec to other builtin commands. Let's
276-
* hope all of them support all magic, or we'll need to limit
277-
* the magic here.
278-
*/
279-
parse_pathspec(&pathspec, PATHSPEC_ALL_MAGIC & ~PATHSPEC_FROMTOP,
273+
parse_pathspec(&pathspec, 0,
280274
PATHSPEC_PREFER_FULL |
281275
PATHSPEC_SYMLINK_LEADING_PATH |
282276
PATHSPEC_PREFIX_ORIGIN,

builtin/checkout.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,13 +1146,6 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
11461146
}
11471147

11481148
if (argc) {
1149-
/*
1150-
* In patch mode (opts.patch_mode != 0), we pass the
1151-
* pathspec to an external program, git-add--interactive.
1152-
* Do not accept any kind of magic that that program
1153-
* cannot handle. Magic mask is pretty safe to be
1154-
* lifted for new magic when opts.patch_mode == 0.
1155-
*/
11561149
parse_pathspec(&opts.pathspec, 0,
11571150
opts.patch_mode ? PATHSPEC_PREFIX_ORIGIN : 0,
11581151
prefix, argv);

pathspec.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
231231
const char *start = elt;
232232
if (prefixlen && !literal_global) {
233233
/* Preserve the actual prefix length of each pattern */
234-
if (long_magic_end) {
234+
if (short_magic)
235+
die("BUG: prefixing on short magic is not supported");
236+
else if (long_magic_end) {
235237
strbuf_add(&sb, start, long_magic_end - start);
236238
strbuf_addf(&sb, ",prefix:%d", prefixlen);
237239
start = long_magic_end;

pathspec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
PATHSPEC_GLOB | \
1515
PATHSPEC_ICASE)
1616

17-
#define PATHSPEC_ONESTAR 1 /* the pathspec pattern sastisfies GFNM_ONESTAR */
17+
#define PATHSPEC_ONESTAR 1 /* the pathspec pattern satisfies GFNM_ONESTAR */
1818

1919
struct pathspec {
2020
const char **_raw; /* get_pathspec() result, not freed by free_pathspec() */

0 commit comments

Comments
 (0)