aboutsummaryrefslogtreecommitdiffstats
path: root/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c56
1 files changed, 37 insertions, 19 deletions
diff --git a/dir.c b/dir.c
index e3ddd5b529..02873f59ea 100644
--- a/dir.c
+++ b/dir.c
@@ -7,6 +7,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
@@ -17,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"
@@ -302,7 +302,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,
*size_out = 0;
*data_out = NULL;
- data = repo_read_object_file(the_repository, oid, &type, &sz);
+ data = odb_read_object(the_repository->objects, oid, &type, &sz);
if (!data || type != OBJ_BLOB) {
free(data);
return -1;
@@ -397,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)
@@ -518,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
@@ -576,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
*/
@@ -1056,6 +1070,8 @@ static void do_invalidate_gitignore(struct untracked_cache_dir *dir)
{
int i;
dir->valid = 0;
+ for (size_t i = 0; i < dir->untracked_nr; i++)
+ free(dir->untracked[i]);
dir->untracked_nr = 0;
for (i = 0; i < dir->dirs_nr; i++)
do_invalidate_gitignore(dir->dirs[i]);
@@ -1083,15 +1099,13 @@ static void invalidate_directory(struct untracked_cache *uc,
uc->dir_invalidated++;
dir->valid = 0;
+ for (size_t i = 0; i < dir->untracked_nr; i++)
+ free(dir->untracked[i]);
dir->untracked_nr = 0;
for (i = 0; i < dir->dirs_nr; i++)
dir->dirs[i]->recurse = 0;
}
-static int add_patterns_from_buffer(char *buf, size_t size,
- const char *base, int baselen,
- struct pattern_list *pl);
-
/* Flags for add_patterns() */
#define PATTERN_NOFOLLOW (1<<0)
@@ -1181,9 +1195,9 @@ static int add_patterns(const char *fname, const char *base, int baselen,
return 0;
}
-static int add_patterns_from_buffer(char *buf, size_t size,
- const char *base, int baselen,
- struct pattern_list *pl)
+int add_patterns_from_buffer(char *buf, size_t size,
+ const char *base, int baselen,
+ struct pattern_list *pl)
{
char *orig = buf;
int i, lineno = 1;
@@ -2868,14 +2882,14 @@ static void set_untracked_ident(struct untracked_cache *uc)
static unsigned new_untracked_cache_flags(struct index_state *istate)
{
struct repository *repo = istate->repo;
- char *val;
+ const char *val;
/*
* This logic is coordinated with the setting of these flags in
* wt-status.c#wt_status_collect_untracked(), and the evaluation
* of the config setting in commit.c#git_status_config()
*/
- if (!repo_config_get_string(repo, "status.showuntrackedfiles", &val) &&
+ if (!repo_config_get_string_tmp(repo, "status.showuntrackedfiles", &val) &&
!strcmp(val, "all"))
return 0;
@@ -3450,7 +3464,7 @@ void setup_standard_excludes(struct dir_struct *dir)
char *get_sparse_checkout_filename(void)
{
- return git_pathdup("info/sparse-checkout");
+ return repo_git_path(the_repository, "info/sparse-checkout");
}
int get_sparse_checkout_patterns(struct pattern_list *pl)
@@ -3573,6 +3587,8 @@ static void write_one_dir(struct untracked_cache_dir *untracked,
* for safety..
*/
if (!untracked->valid) {
+ for (size_t i = 0; i < untracked->untracked_nr; i++)
+ free(untracked->untracked[i]);
untracked->untracked_nr = 0;
untracked->check_only = 0;
}
@@ -3905,6 +3921,8 @@ static void invalidate_one_directory(struct untracked_cache *uc,
{
uc->dir_invalidated++;
ucd->valid = 0;
+ for (size_t i = 0; i < ucd->untracked_nr; i++)
+ free(ucd->untracked[i]);
ucd->untracked_nr = 0;
}
@@ -4030,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;
@@ -4058,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);