summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b319ef7)
raw | patch | inline | side by side (parent: b319ef7)
author | Thomas Rast <trast@student.ethz.ch> | |
Thu, 13 Aug 2009 12:29:41 +0000 (14:29 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 14 Aug 2009 19:40:09 +0000 (12:40 -0700) |
This moves the call setup for 'git add--interactive' to a separate
function, as other users will call it without running
validate_pathspec() first.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
function, as other users will call it without running
validate_pathspec() first.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-add.c | patch | blob | history | |
commit.h | patch | blob | history |
diff --git a/builtin-add.c b/builtin-add.c
index 581a2a17480cc0ffa47a942ff58da4499aeac41d..c422a62f32eda6b9e45bb2c7f8a26c32896f3f39 100644 (file)
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -131,27 +131,27 @@ static const char **validate_pathspec(int argc, const char **argv, const char *p
return pathspec;
}
-int interactive_add(int argc, const char **argv, const char *prefix)
+int run_add_interactive(const char *revision, const char *patch_mode,
+ const char **pathspec)
{
- int status, ac;
+ int status, ac, pc = 0;
const char **args;
- const char **pathspec = NULL;
- if (argc) {
- pathspec = validate_pathspec(argc, argv, prefix);
- if (!pathspec)
- return -1;
- }
+ if (pathspec)
+ while (pathspec[pc])
+ pc++;
- args = xcalloc(sizeof(const char *), (argc + 4));
+ args = xcalloc(sizeof(const char *), (pc + 5));
ac = 0;
args[ac++] = "add--interactive";
- if (patch_interactive)
- args[ac++] = "--patch";
+ if (patch_mode)
+ args[ac++] = patch_mode;
+ if (revision)
+ args[ac++] = revision;
args[ac++] = "--";
- if (argc) {
- memcpy(&(args[ac]), pathspec, sizeof(const char *) * argc);
- ac += argc;
+ if (pc) {
+ memcpy(&(args[ac]), pathspec, sizeof(const char *) * pc);
+ ac += pc;
}
args[ac] = NULL;
return status;
}
+int interactive_add(int argc, const char **argv, const char *prefix)
+{
+ const char **pathspec = NULL;
+
+ if (argc) {
+ pathspec = validate_pathspec(argc, argv, prefix);
+ if (!pathspec)
+ return -1;
+ }
+
+ return run_add_interactive(NULL,
+ patch_interactive ? "--patch" : NULL,
+ pathspec);
+}
+
static int edit_patch(int argc, const char **argv, const char *prefix)
{
char *file = xstrdup(git_path("ADD_EDIT.patch"));
diff --git a/commit.h b/commit.h
index ba9f63813eba004ae409eba8741266a074161239..339f1f6f041d2a2af1305021a8b047f1a5962c16 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, const char *prefix);
+extern int run_add_interactive(const char *revision, const char *patch_mode,
+ const char **pathspec);
static inline int single_parent(struct commit *commit)
{