Skip to content

blame: respect .git-blame-ignore-revs automatically #1805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions builtin/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,10 @@ int cmd_blame(int argc,
add_pending_object(&revs, &head_commit->object, "HEAD");
}

if (!ignore_revs_file_list.nr) {
string_list_insert(&ignore_revs_file_list, ".git-blame-ignore-revs");
}

init_scoreboard(&sb);
sb.revs = &revs;
sb.contents_from = contents_from;
Expand Down
26 changes: 26 additions & 0 deletions t/t8015-blame-default-ignore-revs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

test_description='default revisions to ignore when blaming'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'blame: default-ignore-revs-file' '
test_commit first-commit hello.txt hello &&

echo world >>hello.txt &&
test_commit second-commit hello.txt &&

sed "1s/hello/hi/" <hello.txt > hello.txt.tmp &&
mv hello.txt.tmp hello.txt &&
test_commit third-commit hello.txt &&

git rev-parse HEAD >ignored-file &&
git blame --ignore-revs-file=ignored-file hello.txt >expect &&
git rev-parse HEAD >.git-blame-ignore-revs &&
git blame hello.txt >actual &&

test_cmp expect actual
'

test_done
Loading