From be6ff8196d9890c1875a75b96320b863dd1fe815 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 17 Dec 2009 22:23:54 -0800 Subject: builtin-merge.c: use standard active_cache macros Instead of using the low-level index_state interface, use the bog standard active_cache and active_nr macros to access the cache entries when using the default one. Signed-off-by: Junio C Hamano --- builtin-merge.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'builtin-merge.c') diff --git a/builtin-merge.c b/builtin-merge.c index f1c84d759d..6cb804b6ce 100644 --- a/builtin-merge.c +++ b/builtin-merge.c @@ -618,11 +618,10 @@ static void count_diff_files(struct diff_queue_struct *q, static int count_unmerged_entries(void) { - const struct index_state *state = &the_index; int i, ret = 0; - for (i = 0; i < state->cache_nr; i++) - if (ce_stage(state->cache[i])) + for (i = 0; i < active_nr; i++) + if (ce_stage(active_cache[i])) ret++; return ret; -- cgit v1.2.1 From cfc5789ada444423232fa1533f401b5972eb3f6c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 25 Dec 2009 00:30:51 -0800 Subject: resolve-undo: record resolved conflicts in a new index extension section When resolving a conflict using "git add" to create a stage #0 entry, or "git rm" to remove entries at higher stages, remove_index_entry_at() function is eventually called to remove unmerged (i.e. higher stage) entries from the index. Introduce a "resolve_undo_info" structure and keep track of the removed cache entries, and save it in a new index extension section in the index_state. Operations like "read-tree -m", "merge", "checkout [-m] " and "reset" are signs that recorded information in the index is no longer necessary. The data is removed from the index extension when operations start; they may leave conflicted entries in the index, and later user actions like "git add" will record their conflicted states afresh. Signed-off-by: Junio C Hamano --- builtin-merge.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'builtin-merge.c') diff --git a/builtin-merge.c b/builtin-merge.c index 6cb804b6ce..6bc2f7af08 100644 --- a/builtin-merge.c +++ b/builtin-merge.c @@ -24,6 +24,7 @@ #include "rerere.h" #include "help.h" #include "merge-recursive.h" +#include "resolve-undo.h" #define DEFAULT_TWOHEAD (1<<0) #define DEFAULT_OCTOPUS (1<<1) @@ -604,6 +605,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, discard_cache(); if (read_cache() < 0) die("failed to read the cache"); + resolve_undo_clear(); return ret; } } @@ -851,7 +853,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) if (read_cache_unmerged()) die("You are in the middle of a conflicted merge." " (index unmerged)"); - + resolve_undo_clear(); /* * Check if we are _not_ on a detached HEAD, i.e. if there is a * current branch. -- cgit v1.2.1