git: fix config location (#2027)

This commit is contained in:
Xiang Fan
2018-01-02 19:23:09 +08:00
committed by fbrosson
parent df87dea2a9
commit 4bd6610df0
2 changed files with 42 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ workflows."
HOMEPAGE="https://git-scm.com/"
COPYRIGHT="2005-2017 Git Authors (see git web site for list)"
LICENSE="GNU GPL v2"
REVISION="1"
REVISION="2"
SOURCE_URI="https://www.kernel.org/pub/software/scm/git/git-$portVersion.tar.xz"
CHECKSUM_SHA256="999c90fd7d45066992cdb87dda35bdff6dfc1d01496118ea718dfb866da4045c"

View File

@@ -129,3 +129,44 @@ index 1cccc3a..076f6fa 100644
--
2.14.2
From 6cc7223d58b1fbb829d462e682ba32b7ebf91404 Mon Sep 17 00:00:00 2001
From: sfanxiang <sfanxiang@gmail.com>
Date: Mon, 1 Jan 2018 13:26:28 +0000
Subject: builtin: config: use xdg_config even if it does not exist
diff --git a/builtin/config.c b/builtin/config.c
index d13daee..2342d34 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -508,22 +508,11 @@ int cmd_config(int argc, const char **argv, const char *prefix)
char *user_config = expand_user_path("~/.gitconfig", 0);
char *xdg_config = xdg_config_home("config");
- if (!user_config)
- /*
- * It is unknown if HOME/.gitconfig exists, so
- * we do not know if we should write to XDG
- * location; error out even if XDG_CONFIG_HOME
- * is set and points at a sane location.
- */
- die("$HOME not set");
-
- if (access_or_warn(user_config, R_OK, 0) &&
- xdg_config && !access_or_warn(xdg_config, R_OK, 0)) {
- given_config_source.file = xdg_config;
- free(user_config);
- } else {
+ if (!xdg_config) {
given_config_source.file = user_config;
- free(xdg_config);
+ } else {
+ given_config_source.file = xdg_config;
+ if (user_config) free(user_config);
}
}
else if (use_system_config)
--
2.15.1