brew update時に出てくるメッセージが気になった

brew update時に出てくる下記のメッセージ エラーではないのでbrew updateはちゃんと実行されるが気になったので調べてみた

Updating Homebrew...
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.

Why does git keep telling me it's “Auto packing the repository in background for optimum performance”? レポジトリが破損している可能性があるのでgit fsckを実行しチェックする

#
cd $(brew --repo)
git fsck
Checking object directories: 100% (256/256), done.
Checking objects: 100% (115424/115424), done.
dangling commit 47f34438e1ac0bd7c094333bc0e45c296a7d37e1

danglingオブジェクトがあった これぐらいならほっておいても大丈夫なのだが気になるので git pruneとgit gcでお掃除と最適化を行う

git prune; git gc
Enumerating objects: 115469, done.
Counting objects: 100% (115469/115469), done.
Delta compression using up to 4 threads
Compressing objects: 100% (27637/27637), done.
Writing objects: 100% (115469/115469), done.
Total 115469 (delta 85009), reused 115410 (delta 84974)

再度、git fsckでチェック

git fsck
Checking object directories: 100% (256/256), done.
Checking objects: 100% (115469/115469), done.

毎度のこの手順をやるのは手間なのでaliasを作っておく

bash

alias brewgc='cd $(brew --repo); git gc; git prune; cd -'

・fish fish 3.0からbashと同様に&&||が使えるようになりました

alias brewgc "cd (brew --repo); and git gc; and git prune; and cd -"