summaryrefslogtreecommitdiff
path: root/builtin-add.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-10-31 23:53:22 -0700
committerJunio C Hamano <gitster@pobox.com>2007-10-31 23:53:22 -0700
commit37701381b66ab66234a0a5992f2b107a6507a2fb (patch)
tree3d8c4ae1dc3d88a5ac9a4a071db4b8921939ad7c /builtin-add.c
parentafc05f9f13beded8caf15d8e58d06fd64e0f7808 (diff)
parentd8b7db0abfd0c74478964f5a9b08ad141f4f7f82 (diff)
downloadgit-37701381b66ab66234a0a5992f2b107a6507a2fb.tar.gz
Merge branch 'kh/commit'
* kh/commit: Export rerere() and launch_editor(). Introduce entry point add_interactive and add_files_to_cache Enable wt-status to run against non-standard index file. Enable wt-status output to a given FILE pointer.
Diffstat (limited to 'builtin-add.c')
-rw-r--r--builtin-add.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/builtin-add.c b/builtin-add.c
index b8e6094b21..dbbb05215f 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -12,6 +12,7 @@
#include "diffcore.h"
#include "commit.h"
#include "revision.h"
+#include "run-command.h"
static const char builtin_add_usage[] =
"git-add [-n] [-v] [-f] [--interactive | -i] [-u] [--refresh] [--] <filepattern>...";
@@ -107,7 +108,7 @@ static void update_callback(struct diff_queue_struct *q,
}
}
-static void update(int verbose, const char *prefix, const char **files)
+void add_files_to_cache(int verbose, const char *prefix, const char **files)
{
struct rev_info rev;
init_revisions(&rev, prefix);
@@ -116,8 +117,6 @@ static void update(int verbose, const char *prefix, const char **files)
rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
rev.diffopt.format_callback = update_callback;
rev.diffopt.format_callback_data = &verbose;
- if (read_cache() < 0)
- die("index file corrupt");
run_diff_files(&rev, 0);
}
@@ -151,6 +150,13 @@ static int git_add_config(const char *var, const char *value)
return git_default_config(var, value);
}
+int interactive_add(void)
+{
+ const char *argv[2] = { "add--interactive", NULL };
+
+ return run_command_v_opt(argv, RUN_GIT_CMD);
+}
+
static struct lock_file lock_file;
static const char ignore_error[] =
@@ -170,12 +176,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
add_interactive++;
}
if (add_interactive) {
- const char *args[] = { "add--interactive", NULL };
-
- if (add_interactive != 1 || argc != 2)
+ if (argc != 2)
die("add --interactive does not take any parameters");
- execv_git_cmd(args);
- exit(1);
+ exit(interactive_add());
}
git_config(git_add_config);
@@ -215,7 +218,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
}
if (take_worktree_changes) {
- update(verbose, prefix, argv + i);
+ if (read_cache() < 0)
+ die("index file corrupt");
+ add_files_to_cache(verbose, prefix, argv + i);
goto finish;
}