From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org, Elijah Newren <newren@gmail.com>
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 11/17] pathspec retrieval fix
Date: Sun, 5 Sep 2010 16:47:38 +1000 [thread overview]
Message-ID: <1283669264-15759-12-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1283669264-15759-1-git-send-email-pclouds@gmail.com>
In normal repos, when there is no command line argument, it's safe to
say we don't have pathspec. In narrow repos, get_pathspec() in that
case will still generate some pathspecs (the narrow prefix). Make sure
get_pathspec() is always called.
Some commands however, especially plumbings, won't want narrow prefix
to get in the way. Use get_pathspec_narrow(...., 0); in those cases to
disable narrow pathspec rewriting.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/commit.c | 6 ++----
builtin/grep.c | 5 ++---
builtin/ls-files.c | 2 +-
builtin/ls-tree.c | 2 +-
builtin/reset.c | 3 +--
revision.c | 5 +++++
6 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index 66fdd22..d8c5273 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -303,8 +303,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
return get_index_file();
}
- if (*argv)
- pathspec = get_pathspec(prefix, argv);
+ pathspec = get_pathspec(prefix, argv);
if (read_cache_preload(pathspec) < 0)
die("index file corrupt");
@@ -1083,8 +1082,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
handle_untracked_files_arg(&s);
if (show_ignored_in_status)
s.show_ignored_files = 1;
- if (*argv)
- s.pathspec = get_pathspec(prefix, argv);
+ s.pathspec = get_pathspec(prefix, argv);
read_cache_preload(s.pathspec);
refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, s.pathspec, NULL, NULL);
diff --git a/builtin/grep.c b/builtin/grep.c
index cf6c29f..b55a0a4 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -1058,9 +1058,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
verify_filename(prefix, argv[j]);
}
- if (i < argc)
- paths = get_pathspec(prefix, argv + i);
- else if (prefix) {
+ paths = get_pathspec(prefix, argv + i);
+ if (prefix && !paths) {
paths = xcalloc(2, sizeof(const char *));
paths[0] = prefix;
paths[1] = NULL;
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index bb4f612..27610ab 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -565,7 +565,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
if (require_work_tree && !is_inside_work_tree())
setup_work_tree();
- pathspec = get_pathspec(prefix, argv);
+ pathspec = get_pathspec_narrow(prefix, argv, 0);
/* be nice with submodule paths ending in a slash */
if (pathspec)
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index dc86b0d..d37eaa5 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -164,7 +164,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
if (get_sha1(argv[0], sha1))
die("Not a valid object name %s", argv[0]);
- pathspec = get_pathspec(prefix, argv + 1);
+ pathspec = get_pathspec_narrow(prefix, argv + 1, 0);
tree = parse_tree_indirect(sha1);
if (!tree)
die("not a tree object");
diff --git a/builtin/reset.c b/builtin/reset.c
index 1283068..ae96c8b 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -181,8 +181,7 @@ static int interactive_reset(const char *revision, const char **argv,
{
const char **pathspec = NULL;
- if (*argv)
- pathspec = get_pathspec(prefix, argv);
+ pathspec = get_pathspec(prefix, argv);
return run_add_interactive(revision, "--patch=reset", pathspec);
}
diff --git a/revision.c b/revision.c
index ea64970..73fe894 100644
--- a/revision.c
+++ b/revision.c
@@ -1625,6 +1625,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
if (prune_data)
revs->prune_data = get_pathspec(revs->prefix, prune_data);
+ else if (get_narrow_prefix()) {
+ const char *nul = NULL;
+ prune_data = &nul;
+ revs->prune_data = get_pathspec(revs->prefix, prune_data);
+ }
if (revs->def == NULL)
revs->def = opt ? opt->def : NULL;
--
1.7.1.rc1.69.g24c2f7
next prev parent reply other threads:[~2010-09-05 6:50 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-05 6:47 [PATCH 00/17] Narrow clone v3 (was subtree clone) Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` [PATCH 01/17] rev-list: do not do commit simplification if simplify_history = 0 Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` [PATCH 02/17] tree.c: add path_to_sha1() Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` [PATCH 03/17] Introduce $GIT_DIR/narrow Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` [PATCH 04/17] index: make narrow index incompatible with older git Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` [PATCH 05/17] pack-objects: support narrow packs with pathspecs Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` [PATCH 06/17] {fetch,upload}-pack: support narrow repository Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` [PATCH 07/17] unpack-trees: split traverse_trees() code into a separate function Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` [PATCH 08/17] unpack-trees: support unpack trees in narrow repository Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` [PATCH 09/17] cache-tree: only cache tree within narrow area Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` [PATCH 10/17] get_pathspec(): support narrow pathspec rewriting Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` Nguyễn Thái Ngọc Duy [this message]
2010-09-05 6:47 ` [PATCH 12/17] clone: support --narrow option Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` [PATCH 13/17] commit: add narrow's commit_tree version Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` [PATCH 14/17] commit: use commit_narrow_tree() to support narrow repo Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` [PATCH 15/17] write-tree: requires --narrow-base in narrow repository Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` [PATCH 16/17] merge: try to do local merge if possible in narrow repo Nguyễn Thái Ngọc Duy
2010-09-05 6:47 ` [PATCH 17/17] Add narrow clone demonstration test Nguyễn Thái Ngọc Duy
2010-09-05 6:55 ` [PATCH 00/17] Narrow clone v3 (was subtree clone) Sverre Rabbelier
2010-09-05 7:13 ` Nguyen Thai Ngoc Duy
2010-09-05 21:05 ` Elijah Newren
2010-09-06 5:17 ` Elijah Newren
2010-09-06 5:24 ` Nguyen Thai Ngoc Duy
2010-09-06 20:29 ` Sverre Rabbelier
2010-09-06 20:40 ` Elijah Newren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1283669264-15759-12-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=newren@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.