Junio C Hamano <gitster@xxxxxxxxx> writes: >> I am able to reproduce a scenario where, after a 'commit' and a 'stash >> pop' that results in a merge conflict, I need to 'reset' a file twice in >> order to get the index back to HEAD. > > Thanks, you found a bug in "git reset [<commit>] -- path" codepath, it > seems, when dealing with an unmerged path. This patch is probably a wrong way to fix this issue; I have this suspicion that the original code for "reset [<commit>] -- paths..." codepath is correctly designed to deal with unmerged index, and it would probably need a deeper surgery. -- >8 -- Subject: [PATCH] reset [<commit>] paths...: do not mishandle unmerged paths By reading the index with unmerged content before running diff-index with the tree-ish we are reading from, read_from_tree() function ended up stuffing the object name from a wrong stage to the resulting index. Noticed by John Nowak. Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- builtin/reset.c | 2 +- t/t7102-reset.sh | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletions(-) diff --git a/builtin/reset.c b/builtin/reset.c index 98bca04..09c8d2a 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -202,7 +202,7 @@ static int read_from_tree(const char *prefix, const char **argv, index_fd = hold_locked_index(lock, 1); index_was_discarded = 0; - read_cache(); + read_cache_unmerged(); if (do_diff_cache(tree_sha1, &opt)) return 1; diffcore_std(&opt); diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh index f1cfc9a..1784412 100755 --- a/t/t7102-reset.sh +++ b/t/t7102-reset.sh @@ -429,6 +429,21 @@ test_expect_success '--mixed refreshes the index' ' test_i18ncmp expect output ' +test_expect_success 'resetting specific path that is unmerged' ' + F1=$(git rev-parse HEAD:file1) && + F2=$(git rev-parse HEAD:file2) && + F3=$(git rev-parse HEAD:secondfile) && + { + echo "000000 $_z40 0 file2" && + echo "100644 $F1 1 file2" && + echo "100644 $F2 2 file2" && + echo "100644 $F3 3 file2" + } | git update-index --index-info && + git ls-files -u && + test_must_fail git reset HEAD file2 && + git diff-index --exit-code --cached HEAD +' + test_expect_success 'disambiguation (1)' ' git reset --hard && -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html