summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 324ccbd)
raw | patch | inline | side by side (parent: 324ccbd)
author | Junio C Hamano <gitster@pobox.com> | |
Sun, 25 Nov 2007 18:10:10 +0000 (10:10 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 25 Nov 2007 18:23:13 +0000 (10:23 -0800) |
This fixes the pathspec interactive_add() passes to the underlying
git-add--interactive helper. When the command was run from a
subdirectory, cmd_add() already has gone up to the toplevel of the work
tree, and the helper will be spawned from there. The pathspec given on
the command line from the user needs to be adjusted for this.
This adds "validate_pathspec()" function in the callchain, but it does
not validate yet. The function can be changed to barf if there are
unmatching pathspec given by the user, but that is not strictly
necessary.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-add--interactive helper. When the command was run from a
subdirectory, cmd_add() already has gone up to the toplevel of the work
tree, and the helper will be spawned from there. The pathspec given on
the command line from the user needs to be adjusted for this.
This adds "validate_pathspec()" function in the callchain, but it does
not validate yet. The function can be changed to barf if there are
unmatching pathspec given by the user, but that is not strictly
necessary.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-add.c | patch | blob | history | |
builtin-commit.c | patch | blob | history | |
commit.h | patch | blob | history |
diff --git a/builtin-add.c b/builtin-add.c
index 7c6a296af13b4245a701f8893cc00aa7f0a41277..865c475ec94d1ea84f6045867cf94b17a3dc2af1 100644 (file)
--- a/builtin-add.c
+++ b/builtin-add.c
free(seen);
}
-int interactive_add(int argc, const char **argv)
+static const char **validate_pathspec(int argc, const char **argv, const char *prefix)
+{
+ const char **pathspec = get_pathspec(prefix, argv);
+
+ return pathspec;
+}
+
+int interactive_add(int argc, const char **argv, const char *prefix)
{
int status;
- const char **args = xcalloc(sizeof(const char *), (argc + 2));
+ const char **args;
+ const char **pathspec = NULL;
+
+ if (argc) {
+ pathspec = validate_pathspec(argc, argv, prefix);
+ if (!pathspec)
+ return -1;
+ }
+ args = xcalloc(sizeof(const char *), (argc + 2));
args[0] = "add--interactive";
- memcpy(&(args[1]), argv, sizeof(const char *) * argc);
+ if (argc)
+ memcpy(&(args[1]), pathspec, sizeof(const char *) * argc);
args[argc + 1] = NULL;
status = run_command_v_opt(args, RUN_GIT_CMD);
argc = parse_options(argc, argv, builtin_add_options,
builtin_add_usage, 0);
if (add_interactive)
- exit(interactive_add(argc, argv));
+ exit(interactive_add(argc, argv, prefix));
git_config(git_default_config);
diff --git a/builtin-commit.c b/builtin-commit.c
index 5d27102a624446030b5b048fa582544def395f21..45e51b1d5f8446b5c6bc6e69f1bf1b95eb870826 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
const char **pathspec = NULL;
if (interactive) {
- interactive_add(argc, argv);
+ interactive_add(argc, argv, prefix);
commit_style = COMMIT_AS_IS;
return get_index_file();
}
diff --git a/commit.h b/commit.h
index 9f0765bd9c30672dc93b4c3fc0eff816d1b3729b..10e2b5d4cfdc7ac129ead711421ccc51d2667f02 100644 (file)
--- a/commit.h
+++ b/commit.h
int in_merge_bases(struct commit *, struct commit **, int);
-extern int interactive_add(int argc, const char **argv);
+extern int interactive_add(int argc, const char **argv, const char *prefix);
extern int rerere(void);
static inline int single_parent(struct commit *commit)