From 7dcc1f4df8c74ec43d9b3e8c97aa985c2663b467 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Fri, 5 Jan 2018 12:03:04 -0800 Subject: submodule: submodule_move_head omits old argument in forced case When using hard reset or forced checkout with the option to recurse into submodules, the submodules need to be reset, too. It turns out that we need to omit the duplicate old argument to read-tree in all forced cases to omit the 2 way merge and use the more assertive behavior of reading the specific new tree into the index and updating the working tree. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- submodule.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'submodule.c') diff --git a/submodule.c b/submodule.c index 2967704317..47ddc9b273 100644 --- a/submodule.c +++ b/submodule.c @@ -1657,7 +1657,9 @@ int submodule_move_head(const char *path, else argv_array_push(&cp.args, "-m"); - argv_array_push(&cp.args, old ? old : EMPTY_TREE_SHA1_HEX); + if (!(flags & SUBMODULE_MOVE_HEAD_FORCE)) + argv_array_push(&cp.args, old ? old : EMPTY_TREE_SHA1_HEX); + argv_array_push(&cp.args, new ? new : EMPTY_TREE_SHA1_HEX); if (run_command(&cp)) { -- cgit v1.2.1