Bug#777612: etckeeper should read XDG_CONFIG_HOME/git/config
Package: etckeeper
Version: 1.16
Severity: wishlist
Tags: patch
A small patch to read $XDG_CONFIG_HOME/git/config if $HOME/.gitconfig file does not exist.
-- System Information:
Debian Release: 8.0
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 3.18.0-trunk-amd64 (SMP w/6 CPU cores)
Locale: LANG=fr_FR.utf8, LC_CTYPE=fr_FR.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages etckeeper depends on:
ii debconf [debconf-2.0] 1.5.55
ii git 1:2.1.4+next.20141218-2
Versions of packages etckeeper recommends:
ii systemd-cron [cron-daemon] 1.3.1+ds1-2
Versions of packages etckeeper suggests:
ii sudo 1.8.11p2-1.1
-- debconf information excluded
>From 028252e6a6ea11f6903cbb531e61583519d6ce17 Mon Sep 17 00:00:00 2001
From: Ro Pelloux <rodolphe@damsy.net>
Date: Tue, 10 Feb 2015 17:47:32 +0100
Subject: [PATCH] Try $XDG_CONFIG_HOME/git/config if $HOME/.gitconfig does not
exist.
---
commit.d/50vcs-commit | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/commit.d/50vcs-commit b/commit.d/50vcs-commit
index 7c6173f..a53df40 100755
--- a/commit.d/50vcs-commit
+++ b/commit.d/50vcs-commit
@@ -44,13 +44,17 @@ if [ "$VCS" = git ] && [ -d .git ]; then
# Use user.name and user.email from the gitconfig belonging
# to the user who became root.
USER_HOME="$(perl -e 'print ((getpwnam(shift()))[7])' "$USER")"
- if [ -n "$USER_HOME" ] && [ -e "$USER_HOME/.gitconfig" ]; then
+ GITCONFIG="$USER_HOME/.gitconfig"
+ if [ ! -e GITCONFIG ]; then
+ GITCONFIG="${XDG_CONFIG_HOME:-$USER_HOME/.config}/git/config"
+ fi
+ if [ -n "$USER_HOME" ] && [ -e $GITCONFIG ]; then
if [ -z "$GIT_AUTHOR_NAME" ]; then
- GIT_AUTHOR_NAME="$(git config -f "$USER_HOME/.gitconfig" user.name)" || true
+ GIT_AUTHOR_NAME="$(git config -f $GITCONFIG user.name)" || true
export GIT_AUTHOR_NAME
fi
if [ -z "$GIT_AUTHOR_EMAIL" ]; then
- GIT_AUTHOR_EMAIL="$(git config -f "$USER_HOME/.gitconfig" user.email)" || true
+ GIT_AUTHOR_EMAIL="$(git config -f $GITCONFIG user.email)" || true
export GIT_AUTHOR_EMAIL
fi
fi
--
2.2.1.209.g41e5f3a
Reply to: