Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-05-30 05:16:40 +0300
committerJunio C Hamano <gitster@pobox.com>2017-05-30 05:16:40 +0300
commit3c5a78280fa5535050fe83b51cafb9ca51e8d9e8 (patch)
treec4872e1654f52d2e5e9c5160479b26c778697074 /builtin
parent78089b71da60fcf846b2e7029a90db492f1d3a9d (diff)
parent08de9151a8a67f29a3a5a36931298237d78ca736 (diff)
Merge branch 'bw/pathspec-sans-the-index'
Simplify parse_pathspec() codepath and stop it from looking at the default in-core index. * bw/pathspec-sans-the-index: pathspec: convert find_pathspecs_matching_against_index to take an index pathspec: remove PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP ls-files: prevent prune_cache from overeagerly pruning submodules pathspec: remove PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE flag submodule: add die_in_unpopulated_submodule function pathspec: provide a more descriptive die message
Diffstat (limited to 'builtin')
-rw-r--r--builtin/add.c12
-rw-r--r--builtin/check-ignore.c6
-rw-r--r--builtin/ls-files.c31
-rw-r--r--builtin/reset.c1
-rw-r--r--builtin/rm.c3
-rw-r--r--builtin/submodule--helper.c3
6 files changed, 39 insertions, 17 deletions
diff --git a/builtin/add.c b/builtin/add.c
index 36cad00ae6..d9a2491e48 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -17,6 +17,7 @@
#include "revision.h"
#include "bulk-checkin.h"
#include "argv-array.h"
+#include "submodule.h"
static const char * const builtin_add_usage[] = {
N_("git add [<options>] [--] <pathspec>..."),
@@ -135,7 +136,7 @@ static char *prune_directory(struct dir_struct *dir, struct pathspec *pathspec,
*dst++ = entry;
}
dir->nr = dst - dir->entries;
- add_pathspec_matches_against_index(pathspec, seen);
+ add_pathspec_matches_against_index(pathspec, &the_index, seen);
return seen;
}
@@ -379,16 +380,19 @@ int cmd_add(int argc, const char **argv, const char *prefix)
if (read_cache() < 0)
die(_("index file corrupt"));
+ die_in_unpopulated_submodule(&the_index, prefix);
+
/*
* Check the "pathspec '%s' did not match any files" block
* below before enabling new magic.
*/
parse_pathspec(&pathspec, 0,
PATHSPEC_PREFER_FULL |
- PATHSPEC_SYMLINK_LEADING_PATH |
- PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE,
+ PATHSPEC_SYMLINK_LEADING_PATH,
prefix, argv);
+ die_path_inside_submodule(&the_index, &pathspec);
+
if (add_new_files) {
int baselen;
@@ -414,7 +418,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
int i;
if (!seen)
- seen = find_pathspecs_matching_against_index(&pathspec);
+ seen = find_pathspecs_matching_against_index(&pathspec, &the_index);
/*
* file_exists() assumes exact match
diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
index d2293b22e1..c7b8c08897 100644
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -4,6 +4,7 @@
#include "quote.h"
#include "pathspec.h"
#include "parse-options.h"
+#include "submodule.h"
static int quiet, verbose, stdin_paths, show_non_matching, no_index;
static const char * const check_ignore_usage[] = {
@@ -87,16 +88,17 @@ static int check_ignore(struct dir_struct *dir,
parse_pathspec(&pathspec,
PATHSPEC_ALL_MAGIC & ~PATHSPEC_FROMTOP,
PATHSPEC_SYMLINK_LEADING_PATH |
- PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE |
PATHSPEC_KEEP_ORDER,
prefix, argv);
+ die_path_inside_submodule(&the_index, &pathspec);
+
/*
* look for pathspecs matching entries in the index, since these
* should not be ignored, in order to be consistent with
* 'git status', 'git add' etc.
*/
- seen = find_pathspecs_matching_against_index(&pathspec);
+ seen = find_pathspecs_matching_against_index(&pathspec, &the_index);
for (i = 0; i < pathspec.nr; i++) {
full_path = pathspec.items[i].match;
exclude = NULL;
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 530e6ae7f7..b376afc312 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -97,7 +97,7 @@ static void show_dir_entry(const char *tag, struct dir_entry *ent)
{
int len = max_prefix_len;
- if (len >= ent->len)
+ if (len > ent->len)
die("git ls-files: internal error - directory entry not superset of prefix");
if (!dir_path_match(ent, &pathspec, len, ps_matched))
@@ -238,7 +238,7 @@ static void show_ce_entry(const char *tag, const struct cache_entry *ce)
strbuf_addstr(&name, super_prefix);
strbuf_addstr(&name, ce->name);
- if (len >= ce_namelen(ce))
+ if (len > ce_namelen(ce))
die("git ls-files: internal error - cache entry not superset of prefix");
if (recurse_submodules && S_ISGITLINK(ce->ce_mode) &&
@@ -403,6 +403,25 @@ static void prune_cache(const char *prefix, size_t prefixlen)
active_nr = last - pos;
}
+static int get_common_prefix_len(const char *common_prefix)
+{
+ int common_prefix_len;
+
+ if (!common_prefix)
+ return 0;
+
+ common_prefix_len = strlen(common_prefix);
+
+ /*
+ * If the prefix has a trailing slash, strip it so that submodules wont
+ * be pruned from the index.
+ */
+ if (common_prefix[common_prefix_len - 1] == '/')
+ common_prefix_len--;
+
+ return common_prefix_len;
+}
+
/*
* Read the tree specified with --with-tree option
* (typically, HEAD) into stage #1 and then
@@ -624,8 +643,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
"--error-unmatch");
parse_pathspec(&pathspec, 0,
- PATHSPEC_PREFER_CWD |
- PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
+ PATHSPEC_PREFER_CWD,
prefix, argv);
/*
@@ -637,7 +655,9 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
max_prefix = NULL;
else
max_prefix = common_prefix(&pathspec);
- max_prefix_len = max_prefix ? strlen(max_prefix) : 0;
+ max_prefix_len = get_common_prefix_len(max_prefix);
+
+ prune_cache(max_prefix, max_prefix_len);
/* Treat unmatching pathspec elements as errors */
if (pathspec.nr && error_unmatch)
@@ -651,7 +671,6 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
show_killed || show_modified || show_resolve_undo))
show_cached = 1;
- prune_cache(max_prefix, max_prefix_len);
if (with_tree) {
/*
* Basic sanity check; show-stages and show-unmerged
diff --git a/builtin/reset.c b/builtin/reset.c
index 0afe1df250..430602d102 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -257,7 +257,6 @@ static void parse_args(struct pathspec *pathspec,
parse_pathspec(pathspec, 0,
PATHSPEC_PREFER_FULL |
- PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP |
(patch_mode ? PATHSPEC_PREFIX_ORIGIN : 0),
prefix, argv);
}
diff --git a/builtin/rm.c b/builtin/rm.c
index fb79dcab18..7c323d0123 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -271,8 +271,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
die(_("index file corrupt"));
parse_pathspec(&pathspec, 0,
- PATHSPEC_PREFER_CWD |
- PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
+ PATHSPEC_PREFER_CWD,
prefix, argv);
refresh_index(&the_index, REFRESH_QUIET, &pathspec, NULL, NULL);
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 566a5b6a6f..8cc648d85b 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -233,8 +233,7 @@ static int module_list_compute(int argc, const char **argv,
int i, result = 0;
char *ps_matched = NULL;
parse_pathspec(pathspec, 0,
- PATHSPEC_PREFER_FULL |
- PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
+ PATHSPEC_PREFER_FULL,
prefix, argv);
if (pathspec->nr)