diff options
Diffstat (limited to 'dir.c')
| -rw-r--r-- | dir.c | 29 |
1 files changed, 21 insertions, 8 deletions
@@ -18,7 +18,6 @@ #include "gettext.h" #include "name-hash.h" #include "object-file.h" -#include "object-store-ll.h" #include "path.h" #include "refs.h" #include "repository.h" @@ -398,9 +397,12 @@ static int match_pathspec_item(struct index_state *istate, strncmp(item->match, name - prefix, item->prefix)) return 0; - if (item->attr_match_nr && - !match_pathspec_attrs(istate, name - prefix, namelen + prefix, item)) - return 0; + if (item->attr_match_nr) { + if (!istate) + BUG("magic PATHSPEC_ATTR requires an index"); + if (!match_pathspec_attrs(istate, name - prefix, namelen + prefix, item)) + return 0; + } /* If the match was just the prefix, we matched */ if (!*match) @@ -519,7 +521,8 @@ static int do_match_pathspec(struct index_state *istate, ( exclude && !(ps->items[i].magic & PATHSPEC_EXCLUDE))) continue; - if (seen && seen[i] == MATCHED_EXACTLY) + if (seen && seen[i] == MATCHED_EXACTLY && + ps->items[i].nowildcard_len == ps->items[i].len) continue; /* * Make exclude patterns optional and never report @@ -577,6 +580,16 @@ int match_pathspec(struct index_state *istate, prefix, seen, flags); } +int match_leading_pathspec(struct index_state *istate, + const struct pathspec *ps, + const char *name, int namelen, + int prefix, char *seen, int is_dir) +{ + unsigned flags = is_dir ? DO_MATCH_DIRECTORY | DO_MATCH_LEADING_PATHSPEC : 0; + return match_pathspec_with_flags(istate, ps, name, namelen, + prefix, seen, flags); +} + /** * Check if a submodule is a superset of the pathspec */ @@ -4035,7 +4048,7 @@ static void connect_wt_gitdir_in_nested(const char *sub_worktree, */ i++; - sub = submodule_from_path(&subrepo, null_oid(), ce->name); + sub = submodule_from_path(&subrepo, null_oid(the_hash_algo), ce->name); if (!sub || !is_submodule_active(&subrepo, ce->name)) /* .gitmodules broken or inactive sub */ continue; @@ -4063,12 +4076,12 @@ void connect_work_tree_and_git_dir(const char *work_tree_, /* Prepare .git file */ strbuf_addf(&gitfile_sb, "%s/.git", work_tree_); - if (safe_create_leading_directories_const(gitfile_sb.buf)) + if (safe_create_leading_directories_const(the_repository, gitfile_sb.buf)) die(_("could not create directories for %s"), gitfile_sb.buf); /* Prepare config file */ strbuf_addf(&cfg_sb, "%s/config", git_dir_); - if (safe_create_leading_directories_const(cfg_sb.buf)) + if (safe_create_leading_directories_const(the_repository, cfg_sb.buf)) die(_("could not create directories for %s"), cfg_sb.buf); git_dir = real_pathdup(git_dir_, 1); |
