summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a17ba31)
raw | patch | inline | side by side (parent: a17ba31)
author | Kristian Høgsberg <krh@redhat.com> | |
Tue, 18 Sep 2007 00:06:44 +0000 (20:06 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 27 Sep 2007 08:19:42 +0000 (01:19 -0700) |
This refactors builtin-add.c a little to provide a unique entry point
for launching git add --interactive, which will be used by
builtin-commit too. If we later want to make add --interactive a
builtin or change how it is launched, we just start from this function.
It also exports the private function update() which is used to
add all modified paths to the index as add_files_to_cache().
Signed-off-by: Kristian Høgsberg <krh@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
for launching git add --interactive, which will be used by
builtin-commit too. If we later want to make add --interactive a
builtin or change how it is launched, we just start from this function.
It also exports the private function update() which is used to
add all modified paths to the index as add_files_to_cache().
Signed-off-by: Kristian Høgsberg <krh@redhat.com>
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 f9a65803d8dcbb9ae7eb3a3c61d8ac345b84d1cd..966e14503821025f7782d79409b70f672fc45e45 100644 (file)
--- a/builtin-add.c
+++ b/builtin-add.c
#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>...";
}
}
-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);
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);
}
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[] =
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);
}
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;
}
diff --git a/commit.h b/commit.h
index b779de8cbca74220aeebbc1df194b5f7301f51d0..b50c30e255340ecfcb7167e899ef7c16bc562bd3 100644 (file)
--- a/commit.h
+++ b/commit.h
int depth, int shallow_flag, int not_shallow_flag);
int in_merge_bases(struct commit *, struct commit **, int);
+
+extern int interactive_add(void);
+extern void add_files_to_cache(int verbose, const char *prefix, const char **files);
+
#endif /* COMMIT_H */