Skip to content

Commit

Permalink
XDG base directory specification compatibility for Git (#268)
Browse files Browse the repository at this point in the history
Before the Git snowblock symlinked to the default dotfiles within the
home directory, but Git also fully supports the XDG base directory
specification [1]. So in order to get a step further regarding a
"clean home directory root" the files have been moved to the dedicated
XDG directory.

- Global (`--global`) configuration file [2]
  `~/.gitconfig` -> `${XDG_CONFIG_HOME:-$HOME/.config}/git/config`
- Global exclude file [3]
  `~/.gitignore` -> `${XDG_CONFIG_HOME:-$HOME/.config}/git/ignore`
- Global attributes file [4]
  `~/.gitattributes` -> `${XDG_CONFIG_HOME:-$HOME/.config}/git/attributes`

Also the templates and files used in conditional `include` blocks have
also been renamed and moved into a new and cleaner directory structure.

[1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
[2]: https://git-scm.com/docs/git-config#Documentation/git-config.txt---global
[4]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreattributesFile
[3]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreexcludesFile

Closes GH-267

Co-authored-by: Sven Greb <development@svengreb.de>
  • Loading branch information
arcticicestudio and svengreb authored May 5, 2020
1 parent 6ffb486 commit 311fd27
Show file tree
Hide file tree
Showing 16 changed files with 181 additions and 136 deletions.
18 changes: 18 additions & 0 deletions snowblocks/git/attributes.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2016-present Arctic Ice Studio <development@arcticicestudio.com>
# Copyright (c) 2016-present Sven Greb <development@svengreb.de>

# Project: igloo
# Repository: https://github.com/arcticicestudio/igloo
# License: MIT

# Global Git attributes.
# See:
# 1. https://git-scm.com/docs/gitattributes
# 2. https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#Keyword-Expansion
# 3. https://www.gnupg.org
# 4. https://wiki.archlinux.org/index.php/GnuPG

*.igloocrypt filter=git-crypt diff=git-crypt
.gitattributes !filter !diff
.gitignore !filter !diff
.gitmodules !filter !diff
51 changes: 29 additions & 22 deletions snowblocks/git/gitconfig → snowblocks/git/config.conf
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
# Copyright (C) 2016-present Arctic Ice Studio <development@arcticicestudio.com>
# Copyright (C) 2016-present Sven Greb <development@svengreb.de>
# Copyright (c) 2016-present Arctic Ice Studio <development@arcticicestudio.com>
# Copyright (c) 2016-present Sven Greb <development@svengreb.de>

# Project: igloo
# Repository: https://github.com/arcticicestudio/igloo
# License: MIT
# References:
# https://git-scm.com/docs/git-config
# https://git-scm.com/book/tr/v2/Customizing-Git-Git-Configuration#_colors_in_git
# https://git-scm.com/docs/git-config#_conditional_includes
# https://github.com/so-fancy/diff-so-fancy#options

# Global Git configuration.
# See:
# 1. https://git-scm.com/docs/git-config
# 2. https://git-scm.com/book/tr/v2/Customizing-Git-Git-Configuration#_colors_in_git
# 3. https://git-scm.com/docs/git-config#_conditional_includes
# 4. https://git-scm.com/docs/git-config#Documentation/git-config.txt---show-origin
# 5. https://github.com/so-fancy/diff-so-fancy#options

[includeIf "gitdir:~/yggdrasil/"]
path = ~/.gitconfig-auth
path = ./includes/user-arcticicestudio.conf

[includeIf "gitdir:~/yggdrasil/svengreb/"]
path = ~/.gitconfig-auth-svengreb
path = ./includes/user-svengreb.conf

[includeIf "gitdir:~/code/bitbucket/"]
path = ~/.gitconfig-auth
path = ./includes/user-arcticicestudio.conf

[includeIf "gitdir:~/code/bitfroest/"]
path = ~/.gitconfig-auth
path = ./includes/user-arcticicestudio.conf

[includeIf "gitdir:~/code/github/"]
path = ~/.gitconfig-auth
path = ./includes/user-arcticicestudio.conf

[includeIf "gitdir:~/code/github/repositories/communicode/"]
path = ~/.gitconfig-auth-svengreb
path = ./includes/user-svengreb.conf

[includeIf "gitdir:~/code/gitlab/"]
path = ~/.gitconfig-auth
path = ./includes/user-arcticicestudio.conf

[includeIf "gitdir:~/code/incubator/"]
path = ~/.gitconfig-auth
path = ./includes/user-arcticicestudio.conf

[includeIf "gitdir:~/.igloo/"]
path = ~/.gitconfig-auth
path = ./includes/user-arcticicestudio.conf

[includeIf "gitdir:~/code/job/"]
path = ~/.gitconfig-auth-job
path = ./includes/user-job.conf

[core]
repositoryFormatVersion = 0
Expand All @@ -48,12 +51,13 @@
whitespace = tab-in-indent
editor = vim
pager = diff-so-fancy | less --tabs=2 -RFX
attributesfile = ~/.gitattributes
excludesfile = ~/.gitignore
autocrlf = input

[commit]
template = ~/.git-commit-msg
# Unfortunately Git doesn't support relative paths and environment variable expansion for this attribute.
# Therefore the path must be absolute and "hardcoded" instead of either resolving `$XDG_CONFIG_HOME/git`
# or specifying the path relative to the main configuration file.
template = ~/.config/git/includes/templates/commit-github.txt
status = false

[diff]
Expand Down Expand Up @@ -84,7 +88,6 @@
# To fix this problem for interactive patch mode the filter has been temporary changed to the official
# "diff-highlight" tool bundled with Git.
# See https://github.com/git/git/tree/master/contrib/diff-highlight for details.
#diffFilter = diff-so-fancy
diffFilter = diff-highlight

[merge]
Expand Down Expand Up @@ -522,4 +525,8 @@

# Apply workaround to fix exit code handling for IntelliJ as merge tool when running on macOS.
[include]
path = ~/.gitconfig-macos-mergetool-exit-code
path = ./includes/macos_mergetool_exit_code_fix.conf

# Use a different commit message template for job related repositories.
[includeIf "gitdir:~/code/job/"]
path = ./includes/commit_template-job.conf
16 changes: 0 additions & 16 deletions snowblocks/git/gitattributes

This file was deleted.

12 changes: 0 additions & 12 deletions snowblocks/git/gitconfig-auth

This file was deleted.

Binary file removed snowblocks/git/gitconfig-auth-job.igloocrypt
Binary file not shown.
12 changes: 0 additions & 12 deletions snowblocks/git/gitconfig-auth-svengreb

This file was deleted.

12 changes: 6 additions & 6 deletions snowblocks/git/gitignore → snowblocks/git/ignore.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Copyright (C) 2016-present Arctic Ice Studio <development@arcticicestudio.com>
# Copyright (C) 2016-present Sven Greb <development@svengreb.de>
# Copyright (c) 2016-present Arctic Ice Studio <development@arcticicestudio.com>
# Copyright (c) 2016-present Sven Greb <development@svengreb.de>

# Project: igloo
# Repository: https://github.com/arcticicestudio/igloo
# License: MIT
# References:
# https://git-scm.com/docs/gitignore
# http://www.java.com/en/download/help/error_hotspot.xml

# Global exclude pattern.
# See:
# 1. https://git-scm.com/docs/gitignore

# +--------------------+
# + Runtime Extensions +
Expand Down Expand Up @@ -39,7 +40,6 @@
*.bss
*.class
*.jar
hs_err_pid*

# +--- NodeJS ---+
.npm
Expand Down
16 changes: 16 additions & 0 deletions snowblocks/git/includes/commit_template-job.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2016-present Arctic Ice Studio <development@arcticicestudio.com>
# Copyright (c) 2016-present Sven Greb <development@svengreb.de>

# Project: igloo
# Repository: https://github.com/arcticicestudio/igloo
# License: MIT

# Global Git commit message template for job related repositories.
# See:
# 1. https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---templateltfilegt

[commit]
# Unfortunately Git doesn't support relative paths and environment variable expansion for this attribute.
# Therefore the path must be absolute and "hardcoded" instead of either resolving `$XDG_CONFIG_HOME/git`
# or specifying the path relative to the main configuration file.
template = ~/.config/git/includes/templates/commit-job.txt
36 changes: 0 additions & 36 deletions snowblocks/git/includes/gitconfig-macos-mergetool-exit-code

This file was deleted.

34 changes: 34 additions & 0 deletions snowblocks/git/includes/macos_mergetool_exit_code_fix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2016-present Arctic Ice Studio <development@arcticicestudio.com>
# Copyright (c) 2016-present Sven Greb <development@svengreb.de>

# Project: igloo
# Repository: https://github.com/arcticicestudio/igloo
# License: MIT

# When using IntelliJ as `mergetool` and setting `mergetool.intellij.trustExitCode` to `true`,
# the `mergetool.intellij.cmd` gets called for all files immediately.
# When IntelliJ gets closed for the first processed file, all other calls will error because
# the temporary files passed to `idea merge` as parameters are not valid anymore causing the app
# to exit.
#
# Git is not able to interpret or track started IntelliJ process and fails to listen for the
# exit code, causing the calls to be fired immediately.
# This problem can be narrowed down to macOS while it works fine for Linux systems.
#
# To fix the problem `trustExitCode` option is set to `false` and `prompt` to `true` to force Git
# to wait for the user to confirm the merge is completed and the app window has been closed before
# continuing with the next queued file.
# The only impact is that it requires to press the `y` or `n` keys after solving a conflict instead
# of only closing the app window and waiting for it to reopen again for the next file.
# The fix is scoped to macOS so the impact is very small compared to the broken state when it is
# not applied.
#
# In order to dynamically apply the configuration file only for macOS systems, this file is loaded
# through a `[include]` block in the main Git configuration file and only linked by "snowsaw" for
# macOS based hosts.
# See:
# 1. https://github.com/arcticicestudio/igloo/issues/206
# 2. https://git-scm.com/docs/git-mergetool
[mergetool "intellij"]
prompt = true
trustExitCode = false
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@


GH-

Co-authored-by: NAME <EMAIL>
# ----------------------------------------------------------------------
# Ensure to adhere to the Arctic Ice Studio Git Style Guide:
# https://github.com/arcticicestudio/styleguide-git
Binary file not shown.
16 changes: 16 additions & 0 deletions snowblocks/git/includes/user-arcticicestudio.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2016-present Arctic Ice Studio <development@arcticicestudio.com>
# Copyright (c) 2016-present Sven Greb <development@svengreb.de>

# Project: igloo
# Repository: https://github.com/arcticicestudio/igloo
# License: MIT

# Global Git user configuration for "Arctic Ice Studio" repositories.
# See:
# 1. https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup#_your_identity

[user]
name = Arctic Ice Studio
email = development@arcticicestudio.com
signingKey = 0x60C54F1519346085
useConfigOnly = true
Binary file added snowblocks/git/includes/user-job.conf.igloocrypt
Binary file not shown.
16 changes: 16 additions & 0 deletions snowblocks/git/includes/user-svengreb.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2016-present Arctic Ice Studio <development@arcticicestudio.com>
# Copyright (c) 2016-present Sven Greb <development@svengreb.de>

# Project: igloo
# Repository: https://github.com/arcticicestudio/igloo
# License: MIT

# Global Git user configuration for "Sven Greb" repositories.
# See:
# 1. https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup#_your_identity

[user]
name = Sven Greb
email = development@svengreb.de
signingKey = 0x12637B9743D0263D
useConfigOnly = true
Loading

0 comments on commit 311fd27

Please sign in to comment.