feat(git): submodule.recurse を有効化し効いていない ghq.shallow を削除する - #70
Merged
Conversation
サブモジュールを持つリポジトリで checkout / fetch / pull のたびに --recurse-submodules を指定しなくて済むよう submodule.recurse を有効にする。 clone と ls-files は対象外。push では push.recurseSubmodules の既定として 作用し、true は on-demand 相当に解釈される。 あわせて ghq.shallow を削除する。ghq が gitconfig から読むのは ghq.root / ghq.user / ghq.completeUser / ghq.defaultHost / ghq.<url>.vcs / ghq.<url>.root のみで、shallow は CLI フラグ (--shallow) 専用のためこの設定は無視されていた。 実測でも gitconfig のみでは shallow clone にならないことを確認済み。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
サブモジュールを持つリポジトリで
--recurse-submodulesを都度指定しなくて済むよう、global gitconfig にsubmodule.recurse = trueを追加する。あわせて、同ファイルにあった
ghq.shallow = trueを削除する。この設定は ghq に読まれておらず、実際には無視されていた。変更内容
home/dot_config/git/config.tmplに[submodule] recurse = trueを追加home/dot_config/git/config.tmplから[ghq] shallow = trueを削除ghq.shallowが効いていない根拠ghq 1.10.1 (手元) で実測した結果、global に
ghq.shallow = trueがある状態でもフラグなしでは shallow clone にならない。.git/shallowrev-list --count HEAD--shallow明示同一リポジトリ (
github.com/octocat/Hello-World) をGHQ_ROOTだけ変えて clone した結果。ソース側も一致する。
commands.goのフラグ定義は&cli.BoolFlag{Name: "shallow", Usage: "Do a shallow clone"}でSources/EnvVarsを持たず、cmd_get.goのdoGetもshallow: cmd.Bool("shallow")と CLI フラグを読むだけで gitconfig を参照しない。ghq が gitconfig から読むのはghq.root/ghq.user/ghq.completeUser/ghq.defaultHost/ghq.<url>.vcs/ghq.<url>.rootの 6 キーのみで、README.adoc の CONFIGURATION 節にもghq.shallowの記載はない。shallow clone が必要なときは
ghq get --shallow、push できない等の制約を避けたい場合はghq get --partial bloblessを都度指定する。関連 Issue
なし
動作確認
mise run pre-commitが通ったmise run testが通った (sandbox 外で 46/46 pass)mise run dry-runで意図した差分のみであることを確認した → 後述の理由により対象を限定して実行mise run dry-runは--verbose付きで全対象を走らせるため、~/.codex/.env等の secret ファイルが差分に含まれると実値が出力に載る。そのためchezmoi apply --dry-run --verbose ~/.config/git/configと対象を絞って実行した。apply 後の実環境も確認済み。
チェックリスト
補足情報
submodule.recurse = trueの影響範囲はgit help configの記述どおり checkout / fetch / grep / pull / push / read-tree / reset / restore / switch で、clone と ls-files は対象外。注意すべきは push で、
git help pushに「push.recurseSubmodulesは default、ただしsubmodule.recurseが set されている場合は true = on-demand として扱う」とある。つまりこの変更により、push 時にサブモジュール側の未 push コミットがあれば一緒に push されるようになる。この挙動を避けたい場合はpush.recurseSubmodules = noの併記で打ち消せるが、今回は入れていない。一時的に無効化したい場合は
git -c submodule.recurse=0 <command>を使う。