From 2e7a9785c27f00a8f7a06edc1d4c9b2f3fa2eeb9 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 3 Nov 2007 13:12:17 +0000 Subject: git-reset: do not be confused if there is nothing to reset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The purpose of the function update_index_from_diff() (which is the callback function we give do_diff_cache()) is to update those index entries which differ from the given commit. Since do_diff_cache() plays games with the in-memory index, this function discarded the cache and reread it. Then, back in the function read_from_tree() we wrote the index. Of course, this broke down when there were no changes and update_index_from_diff() was not called, and therefore the mangled index was not discarded. The solution is to move the index writing into the function update_index_from_diff(). Noticed by Björn Steinbrink. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t7102-reset.sh | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 't') diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh index f64b1cbf7..cea9afb76 100755 --- a/t/t7102-reset.sh +++ b/t/t7102-reset.sh @@ -402,4 +402,11 @@ test_expect_success 'test resetting the index at give paths' ' ' +test_expect_success 'resetting an unmodified path is a no-op' ' + git reset --hard && + git reset -- file1 && + git diff-files --exit-code && + git diff-index --cached --exit-code HEAD +' + test_done -- cgit v1.2.1