diff options
Diffstat (limited to 'builtin/merge-index.c')
-rw-r--r-- | builtin/merge-index.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/builtin/merge-index.c b/builtin/merge-index.c index c0383fe..270d5f6 100644 --- a/builtin/merge-index.c +++ b/builtin/merge-index.c @@ -1,6 +1,10 @@ -#define USE_THE_INDEX_COMPATIBILITY_MACROS +#define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "hex.h" +#include "read-cache-ll.h" +#include "repository.h" #include "run-command.h" +#include "sparse-index.h" static const char *pgm; static int one_shot, quiet; @@ -12,12 +16,13 @@ static int merge_entry(int pos, const char *path) const char *arguments[] = { pgm, "", "", "", path, "", "", "", NULL }; char hexbuf[4][GIT_MAX_HEXSZ + 1]; char ownbuf[4][60]; + struct child_process cmd = CHILD_PROCESS_INIT; - if (pos >= active_nr) + if (pos >= the_index.cache_nr) die("git merge-index: %s not in the cache", path); found = 0; do { - const struct cache_entry *ce = active_cache[pos]; + const struct cache_entry *ce = the_index.cache[pos]; int stage = ce_stage(ce); if (strcmp(ce->name, path)) @@ -27,11 +32,12 @@ static int merge_entry(int pos, const char *path) xsnprintf(ownbuf[stage], sizeof(ownbuf[stage]), "%o", ce->ce_mode); arguments[stage] = hexbuf[stage]; arguments[stage + 4] = ownbuf[stage]; - } while (++pos < active_nr); + } while (++pos < the_index.cache_nr); if (!found) die("git merge-index: %s not in the cache", path); - if (run_command_v_opt(arguments, 0)) { + strvec_pushv(&cmd.args, arguments); + if (run_command(&cmd)) { if (one_shot) err++; else { @@ -45,7 +51,7 @@ static int merge_entry(int pos, const char *path) static void merge_one_path(const char *path) { - int pos = cache_name_pos(path, strlen(path)); + int pos = index_name_pos(&the_index, path, strlen(path)); /* * If it already exists in the cache as stage0, it's @@ -60,15 +66,15 @@ static void merge_all(void) int i; /* TODO: audit for interaction with sparse-index. */ ensure_full_index(&the_index); - for (i = 0; i < active_nr; i++) { - const struct cache_entry *ce = active_cache[i]; + for (i = 0; i < the_index.cache_nr; i++) { + const struct cache_entry *ce = the_index.cache[i]; if (!ce_stage(ce)) continue; i += merge_entry(i, ce->name)-1; } } -int cmd_merge_index(int argc, const char **argv, const char *prefix) +int cmd_merge_index(int argc, const char **argv, const char *prefix UNUSED) { int i, force_file = 0; @@ -80,7 +86,7 @@ int cmd_merge_index(int argc, const char **argv, const char *prefix) if (argc < 3) usage("git merge-index [-o] [-q] <merge-program> (-a | [--] [<filename>...])"); - read_cache(); + repo_read_index(the_repository); /* TODO: audit for interaction with sparse-index. */ ensure_full_index(&the_index); |