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>2013-10-18 02:55:13 +0400
committerJunio C Hamano <gitster@pobox.com>2013-10-18 02:55:14 +0400
commitbe98d915bec9aadcf746192ce0c5ddc19926b8bb (patch)
tree43a1901eb05eb53e4f2105a3469e4529688cc66c /builtin
parentf52752d36a98d0e5a70242d615d0f36f84936b45 (diff)
parent2c63d6eb46da4ef0abc9c040c927818e437d2fcc (diff)
Merge branch 'jk/trailing-slash-in-pathspec'
Code refactoring. * jk/trailing-slash-in-pathspec: reset: handle submodule with trailing slash rm: re-use parse_pathspec's trailing-slash removal
Diffstat (limited to 'builtin')
-rw-r--r--builtin/reset.c8
-rw-r--r--builtin/rm.c20
2 files changed, 10 insertions, 18 deletions
diff --git a/builtin/reset.c b/builtin/reset.c
index 1a53448772..f2f9d55392 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -143,7 +143,6 @@ static int read_from_tree(const struct pathspec *pathspec,
opt.output_format = DIFF_FORMAT_CALLBACK;
opt.format_callback = update_index_from_diff;
- read_cache();
if (do_diff_cache(tree_sha1, &opt))
return 1;
diffcore_std(&opt);
@@ -169,7 +168,7 @@ static void set_reflog_message(struct strbuf *sb, const char *action,
static void die_if_unmerged_cache(int reset_type)
{
- if (is_merge() || read_cache() < 0 || unmerged_cache())
+ if (is_merge() || unmerged_cache())
die(_("Cannot do a %s reset in the middle of a merge."),
_(reset_type_names[reset_type]));
@@ -220,8 +219,13 @@ static void parse_args(struct pathspec *pathspec,
}
}
*rev_ret = rev;
+
+ if (read_cache() < 0)
+ die(_("index file corrupt"));
+
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 9b59ab3a64..3a0e0eaab7 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -298,22 +298,10 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
if (read_cache() < 0)
die(_("index file corrupt"));
- /*
- * Drop trailing directory separators from directories so we'll find
- * submodules in the index.
- */
- for (i = 0; i < argc; i++) {
- size_t pathlen = strlen(argv[i]);
- if (pathlen && is_dir_sep(argv[i][pathlen - 1]) &&
- is_directory(argv[i])) {
- do {
- pathlen--;
- } while (pathlen && is_dir_sep(argv[i][pathlen - 1]));
- argv[i] = xmemdupz(argv[i], pathlen);
- }
- }
-
- parse_pathspec(&pathspec, 0, PATHSPEC_PREFER_CWD, prefix, argv);
+ parse_pathspec(&pathspec, 0,
+ PATHSPEC_PREFER_CWD |
+ PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
+ prefix, argv);
refresh_index(&the_index, REFRESH_QUIET, &pathspec, NULL, NULL);
seen = xcalloc(pathspec.nr, 1);