Skip to content

fix: update repo gob hash if git config mailmap content changes #26

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zimeg
Copy link

@zimeg zimeg commented Apr 27, 2025

Summary

👋 This PR updates the gob hash in cache for a repository if the Git configuration mailmap setting is changed.

Fixes an issue where updates to these configurations were not detected and caused the cache to become stale.

Reviewers

These changes can be tested with either local or global configurations and this branch to confirm the author matches the most recent changes to the mailmap:

$ git clone https://github.com/zimeg/git-who
$ git checkout fix-mailmap-hash
$ go build
$ ./git-who -v -l
...
level=DEBUG msg="running subprocess" package=git cmd="git config --get mailmap.file"
level=DEBUG msg="subprocess exited" package=git code=0
level=DEBUG msg="running subprocess" package=git cmd="git config --get mailmap.blob"
level=DEBUG msg="subprocess exited" package=git code=1
level=DEBUG msg="cache initialized" package=main path=~/.cache/git-who/gob/git-who-1013de4e/811c9dc5.gobs
$ echo "Eden Zimbelman <[email protected]>" > .mailmap
$ ./git-who -v -l
...
level=DEBUG msg="cache initialized" package=main path=~/.cache/git-who/gob/git-who-1013de4e/fcecb5a7.gobs
$ rm .mailmap
$ echo "eden <[email protected]>" > .rolodex
$ git config --local mailmap.file $(pwd)/.rolodex
$ ./git-who -v -l
...
level=DEBUG msg="cache initialized" package=main path=~/.cache/git-who/gob/git-who-1013de4e/54d15544.gobs
$ git config --unset --local mailmap.file
$ git config --local mailmap.blob :0:.rolodex
$ ./git-who -v -l
...
level=DEBUG msg="running subprocess" package=git cmd="git config --get mailmap.blob"
level=DEBUG msg="subprocess exited" package=git code=0
level=DEBUG msg="running subprocess" package=git cmd="git rev-parse --no-flags :0:.rolodex"
level=DEBUG msg="subprocess exited" package=git code=128
level=DEBUG msg="cache initialized" package=main path=~/.cache/git-who/gob/git-who-1013de4e/811c9dc5.gobs
$ git add .rolodex
$ ./git-who -v -l
...
level=DEBUG msg="running subprocess" package=git cmd="git rev-parse --no-flags :0:.rolodex"
level=DEBUG msg="subprocess exited" package=git code=0
level=DEBUG msg="running subprocess" package=git cmd="git cat-file blob f6cd90c45d9bd967e618e991f38737f2143ef637"
level=DEBUG msg="subprocess exited" package=git code=0
level=DEBUG msg="cache initialized" package=main path=~/.cache/git-who/gob/git-who-1013de4e/16ef5e3a.gobs
$ git restore --staged .rolodex
$ rm .rolodex
$ git config --unset --local mailmap.blob

These changes were tested with the following git version:

$ git --version
git version 2.49.0

Notes

The log format used before these changes respects .mailmap and seems to also find Git configurations, even if --no-mailmap is set:

logFormat = "--pretty=format:%H%n%h%n%p%n%aN%n%aE%n%ad%n" // newline
logDiffFormat = "--pretty=format:%H%n%h%n%p%n%aN%n%aE%n%ad"

Also interesting to note is that multiple formats for mailmap can be used at the same time! 📚 ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant