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] <branch>" 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 <gitster@pobox.com>
This commit is contained in:
@ -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.
|
||||
|
Reference in New Issue
Block a user