From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Subject: [PATCH v2 05/19] Add git_config_early() Date: Sun, 21 Mar 2010 17:30:32 +0700 Message-ID: <1269167446-7799-6-git-send-email-pclouds@gmail.com> References: <1269167446-7799-1-git-send-email-pclouds@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Sun Mar 21 11:35:10 2010 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NtIUw-0003HC-4y for gcvg-git-2@lo.gmane.org; Sun, 21 Mar 2010 11:35:10 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753026Ab0CUKe7 convert rfc822-to-quoted-printable (ORCPT ); Sun, 21 Mar 2010 06:34:59 -0400 Received: from mail-gw0-f46.google.com ([74.125.83.46]:54002 "EHLO mail-gw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752996Ab0CUKe6 (ORCPT ); Sun, 21 Mar 2010 06:34:58 -0400 Received: by mail-gw0-f46.google.com with SMTP id a18so509917gwa.19 for ; Sun, 21 Mar 2010 03:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references:mime-version :content-type:content-transfer-encoding; bh=gQwjs3HAYpP6zBU8zr22Wq4FyMbhZc4K/S7un8XQILA=; b=pHhdDmjC/fqc0Ruz4dgkp9R7dgRkXYTapNXFdjVosPBDjSTMX6tQomaM5NpRxdOwtB rRRgs3bK9xixkhWld0/mv1215lle3deXBSFl3jdM6VCLWoJhG3RheClZDLXTzt/S/6wg YIMU1UW2CIj20p9pz4M9HqEEyiWK6BZOIvOXw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:content-transfer-encoding; b=I8yuMXB0ME0UkCNqk/KmVcPkMdmJqjos7LYIQpxxcDoVOMx81LcZK1AjW/BoPn5IGi JY/qUETCPxHtE2ytFv1/J4kz10tElHZrVn5TltNYXpa4Oy2ZBXAPymHHBxPDV9JvV31N Ql/2c9G90wBgwPn0/Mqygdfm337qCDzdtZPvc= Received: by 10.150.118.11 with SMTP id q11mr9994052ybc.40.1269167697896; Sun, 21 Mar 2010 03:34:57 -0700 (PDT) Received: from pclouds@gmail.com ([115.73.230.17]) by mx.google.com with ESMTPS id 20sm1549630iwn.9.2010.03.21.03.34.55 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 21 Mar 2010 03:34:57 -0700 (PDT) Received: by pclouds@gmail.com (sSMTP sendmail emulation); Sun, 21 Mar 2010 17:31:17 +0700 X-Mailer: git-send-email 1.7.0.2.425.gb99f1 In-Reply-To: <1269167446-7799-1-git-send-email-pclouds@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: This version of git_config() will be used during repository setup. As a repository is being set up, $GIT_DIR is not nailed down yet, git_pathdup() should not be used to get $GIT_DIR/config. Signed-off-by: Nguy=E1=BB=85n Th=C3=A1i Ng=E1=BB=8Dc Duy --- cache.h | 1 + config.c | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cache.h b/cache.h index 68412c0..3bd219c 100644 --- a/cache.h +++ b/cache.h @@ -933,6 +933,7 @@ typedef int (*config_fn_t)(const char *, const char= *, void *); extern int git_default_config(const char *, const char *, void *); extern int git_config_from_file(config_fn_t fn, const char *, void *); extern int git_config(config_fn_t fn, void *); +extern int git_config_early(config_fn_t fn, void *, const char *repo_c= onfig); extern int git_parse_ulong(const char *, unsigned long *); extern int git_config_int(const char *, const char *); extern unsigned long git_config_ulong(const char *, const char *); diff --git a/config.c b/config.c index 6963fbe..2d38096 100644 --- a/config.c +++ b/config.c @@ -699,10 +699,9 @@ int git_config_global(void) return !git_env_bool("GIT_CONFIG_NOGLOBAL", 0); } =20 -int git_config(config_fn_t fn, void *data) +int git_config_early(config_fn_t fn, void *data, const char *repo_conf= ig) { int ret =3D 0, found =3D 0; - char *repo_config =3D NULL; const char *home =3D NULL; =20 /* Setting $GIT_CONFIG makes git read _only_ the given config file. *= / @@ -724,17 +723,27 @@ int git_config(config_fn_t fn, void *data) free(user_config); } =20 - repo_config =3D git_pathdup("config"); - if (!access(repo_config, R_OK)) { + if (repo_config && !access(repo_config, R_OK)) { ret +=3D git_config_from_file(fn, repo_config, data); found +=3D 1; } - free(repo_config); if (found =3D=3D 0) return -1; return ret; } =20 +int git_config(config_fn_t fn, void *data) +{ + char *repo_config =3D NULL; + int ret; + + repo_config =3D git_pathdup("config"); + ret =3D git_config_early(fn, data, repo_config); + if (repo_config) + free(repo_config); + return ret; +} + /* * Find all the stuff for git_config_set() below. */ --=20 1.7.0.2.425.gb99f1