Re: [PATCH] config: introduce an Operating System-specific `includeIf` condition
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 22, 2022, 00:03 UTC
- Message-ID
- <xmqqwn7nua88.fsf@gitster.g>
- In-Reply-To
- <pull.1429.git.1669037992587.gitgitgadget@gmail.com>
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 22 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de> > > It is relatively common for users to maintain identical `~/.gitconfig` > files across all of their setups, using the `includeIf` construct > liberally to adjust the settings to the respective setup as needed. > > In case of Operating System-specific adjustments, Git currently offers > no support to the users and they typically use a work-around like this: > > [includeIf "gitdir:/home/"] > path = ~/.gitconfig-linux > [includeIf "gitdir:/Users/"] > path = ~/.gitconfig-mac > [includeIf "gitdir:C:"] > path = ~/.gitconfig-windows > > However, this is fragile, as it would not even allow to discern between > Operating Systems that happen to host their home directories in > `/home/`, such as Linux and the BSDs. > > Let's introduce a new condition: `os:<uname-s>` where `<uname-s>` is the > system name, i.e. the output of `uname -s`.
As I am not confident enough that we made the best choice that would last forever with the initial attempt when we picked "uname -s" as the way to switch on "OS", I wouldn't call it "OS". Perhaps
[includeIf "uname-s:Linux"] path = ...
would be what I would pick. Other than that, the feature makes quite a lot of sense.