Skip to content

Commit 4a39f79

Browse files
committed
resolve-undo: allow plumbing to clear the information
At the Porcelain level, operations such as merge that populate an initially cleanly merged index with conflicted entries clear the resolve-undo information upfront. Give scripted Porcelains a way to do the same, by implementing "update-index --clear-resolve-info". With this, a scripted Porcelain may "update-index --clear-resolve-info" first and repeatedly run "update-index --cacheinfo" to stuff unmerged entries to the index, to be resolved by the user with "git add" and stuff. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9d9a2f4 commit 4a39f79

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

builtin-update-index.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "tree-walk.h"
1010
#include "builtin.h"
1111
#include "refs.h"
12+
#include "resolve-undo.h"
1213

1314
/*
1415
* Default to not allowing changes to the list of files. The
@@ -703,6 +704,10 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
703704
verbose = 1;
704705
continue;
705706
}
707+
if (!strcmp(path, "--clear-resolve-undo")) {
708+
resolve_undo_clear();
709+
continue;
710+
}
706711
if (!strcmp(path, "-h") || !strcmp(path, "--help"))
707712
usage(update_index_usage);
708713
die("unknown option %s", path);

t/t2030-unresolve-info.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,16 @@ test_expect_success 'rm records reset clears' '
8585
check_resolve_undo discarded
8686
'
8787

88+
test_expect_success 'plumbing clears' '
89+
prime_resolve_undo &&
90+
test_tick &&
91+
git commit -m merged &&
92+
echo committing keeps &&
93+
check_resolve_undo kept file initial:file second:file third:file &&
94+
95+
echo plumbing clear &&
96+
git update-index --clear-resolve-undo &&
97+
check_resolve_undo cleared
98+
'
99+
88100
test_done

0 commit comments

Comments
 (0)