Skip to content

Commit c3e4193

Browse files
jacob-kellergitster
authored andcommitted
pathspec: expose match_pathspec_with_flags
The do_match_pathspec() function has the DO_MATCH_LEADING_PATHSPEC option to allow pathspecs to match when matching "src" against a pathspec like "src/path/...". This support is not exposed by match_pathspec, and the internal flags to do_match_pathspec are not exposed outside of dir.c Make match_pathspec_with_flags public, and expose the DO_MATCH_LEADING_PATHSPEC and DO_MATCH_DIRECTORY flags. The DO_MATCH_EXCLUDE flag is kept private in dir.c This will be used in a an extension to support pathspec matching in git Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3f4ae4a commit c3e4193

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

dir.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,8 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,
329329
return 1;
330330
}
331331

332+
// DO_MATCH_EXCLUDE is not public
332333
#define DO_MATCH_EXCLUDE (1<<0)
333-
#define DO_MATCH_DIRECTORY (1<<1)
334-
#define DO_MATCH_LEADING_PATHSPEC (1<<2)
335334

336335
/*
337336
* Does the given pathspec match the given name? A match is found if
@@ -551,10 +550,10 @@ static int do_match_pathspec(struct index_state *istate,
551550
return retval;
552551
}
553552

554-
static int match_pathspec_with_flags(struct index_state *istate,
555-
const struct pathspec *ps,
556-
const char *name, int namelen,
557-
int prefix, char *seen, unsigned flags)
553+
int match_pathspec_with_flags(struct index_state *istate,
554+
const struct pathspec *ps,
555+
const char *name, int namelen,
556+
int prefix, char *seen, unsigned flags)
558557
{
559558
int positive, negative;
560559
positive = do_match_pathspec(istate, ps, name, namelen,

pathspec.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ int match_pathspec(struct index_state *istate,
184184
const char *name, int namelen,
185185
int prefix, char *seen, int is_dir);
186186

187+
#define DO_MATCH_DIRECTORY (1<<1)
188+
#define DO_MATCH_LEADING_PATHSPEC (1<<2)
189+
190+
int match_pathspec_with_flags(struct index_state *istate,
191+
const struct pathspec *ps,
192+
const char *name, int namelen,
193+
int prefix, char *seen, unsigned flags);
194+
187195
/*
188196
* Determine whether a pathspec will match only entire index entries (non-sparse
189197
* files and/or entire sparse directories). If the pathspec has the potential to

0 commit comments

Comments
 (0)