diff --git a/NEWS.adoc b/NEWS.adoc index 5d2568435..10d064ed8 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -33,6 +33,7 @@ Improvements: Bug fixes: + - Prevent staged rename from displaying unstaged changes (GH #472, #491) - Fix corrupt chunk header during staging of single lines. (GH #410) - Fix out of bounds read in graph-v2 module. (GH #402) - Add currently checked out branch to `%(branch)`. (GH #416) diff --git a/src/repo.c b/src/repo.c index fabea294f..882592da5 100644 --- a/src/repo.c +++ b/src/repo.c @@ -155,6 +155,11 @@ index_diff(struct index_diff *diff, bool untracked, bool count_all) if (!count_all && diff->staged && diff->unstaged && (!untracked || diff->untracked)) break; + + /* Skip source filename in rename */ + if (buf.data[0] == 'R') { + io_get(&io, &buf, 0, true); + } } if (io_error(&io)) diff --git a/test/main/show-changes-after-rename-test b/test/main/show-changes-after-rename-test new file mode 100755 index 000000000..c9f48d9bb --- /dev/null +++ b/test/main/show-changes-after-rename-test @@ -0,0 +1,32 @@ +#!/bin/sh +# +# Test case from https://github.com/jonas/tig/issues/472 + +. libtest.sh +. libgit.sh +. "$source_dir/util.sh" + +export LINES=4 + +steps ' + :save-display default.screen +' + +git_init + +test_setup_work_dir() { + echo data >file1 + git add file1 + git_commit -m "commit1" + echo data >file2 + git add file2 + git rm file1 +} + +test_tig + +assert_equals 'default.screen' <