Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Prevent #3679 from appearing in blame results #13311

Merged
merged 5 commits into from
Jul 18, 2022
Merged
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
13 changes: 13 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Commits in this file will be removed from GitHub blame results.
#
# To use this file locally, use:
# git blame --ignore-revs-file="path/to/.git-blame-ignore-revs" <files>
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
#
# or configure the `blame.ignoreRevsFile` option in your git config.
#
# If ignoring a pull request that was not squash merged, only the merge
# commit needs to be put here. Child commits will be resolved from it.
Comment on lines +8 to +9
Copy link
Contributor

@DMRobertson DMRobertson Jul 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know enough about how git blame works here (https://github.com/git/git/blob/f9b95943b68b6b8ca5a6072f50a08411c6449b55/blame.c#L2582 for the brave), but I'm a little suspicious here. I would guess that the merge commit shows up in blame if and only if

  • the file being blamed was in conflict, and
  • there was a manual merge process: we didn't resolve by just checking out the file at one of the merge parents. (I.e. the merge commit needed to create a new blob object).

Happy to leave this as-is though.

Copy link
Member Author

@anoadragon453 anoadragon453 Jul 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The merge conflict unintuitively does not show up in git blame - the actual commit does. However, only adding the merge commit to .git-blame-ignore-revs actually removed the changes from git blame.

I was mostly guessing that git blame follows children of merge commits based off the description of the `--first-parent option.

One can try it themselves with:

merge commit:

git blame --ignore-rev 8b3d9b6b199abb87246f982d5db356f1966db925 tests/api/test_auth.py

vs.

git blame --ignore-rev a001038b92c4f0082cad60e5e87d0bd01374c9de tests/api/test_auth.py

and searching for 8b3d9b. You'll see that the latter makes no difference... unintuitively.


# Run black (#3679).
8b3d9b6b199abb87246f982d5db356f1966db925

# Black reformatting (#5482).
32e7c9e7f20b57dd081023ac42d6931a8da9b3a3

Expand Down
1 change: 1 addition & 0 deletions changelog.d/13311.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent formatting changes of [#3679](https://github.com/matrix-org/synapse/pull/3679) from appearing in `git blame`.