git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <bonzini@gnu.org>
To: <git@vger.kernel.org>
Subject: [PATCH RFC 7/8] config: add git_config_norepo
Date: Mon, 20 Jul 2009 19:49:54 +0200	[thread overview]
Message-ID: <1248112195-3761-8-git-send-email-bonzini@gnu.org> (raw)
In-Reply-To: <1248112195-3761-1-git-send-email-bonzini@gnu.org>

This function will be needed to read the configuration in git-clone
before the new repository is created.

Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
---
 cache.h  |    1 +
 config.c |   37 ++++++++++++++++++++++++++++---------
 2 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/cache.h b/cache.h
index a46bfe6..c349cd1 100644
--- a/cache.h
+++ b/cache.h
@@ -893,6 +893,7 @@ typedef int (*config_fn_t)(const char *, const char *, void *);
 extern int git_tracking_config(const char *, const char *, struct tracking_config *);
 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_norepo(config_fn_t fn, void *);
 extern int git_config(config_fn_t fn, void *);
 extern int git_parse_ulong(const char *, unsigned long *);
 extern int git_config_int(const char *, const char *);
diff --git a/config.c b/config.c
index 37d95a4..d50a261 100644
--- a/config.c
+++ b/config.c
@@ -709,19 +709,14 @@ int git_config_global(void)
 	return !git_env_bool("GIT_CONFIG_NOGLOBAL", 0);
 }
 
-int git_config(config_fn_t fn, void *data)
+static int git_config_extra_repo(config_fn_t fn, void *data, int *found)
 {
-	int ret = 0, found = 0;
-	char *repo_config = NULL;
+	int ret = 0;
 	const char *home = NULL;
-
-	/* Setting $GIT_CONFIG makes git read _only_ the given config file. */
-	if (config_exclusive_filename)
-		return git_config_from_file(fn, config_exclusive_filename, data);
 	if (git_config_system() && !access(git_etc_gitconfig(), R_OK)) {
 		ret += git_config_from_file(fn, git_etc_gitconfig(),
 					    data);
-		found += 1;
+		*found += 1;
 	}
 
 	home = getenv("HOME");
@@ -729,11 +724,35 @@ int git_config(config_fn_t fn, void *data)
 		char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
 		if (!access(user_config, R_OK)) {
 			ret += git_config_from_file(fn, user_config, data);
-			found += 1;
+			*found += 1;
 		}
 		free(user_config);
 	}
+	return ret;
+}
+
+int git_config_norepo(config_fn_t fn, void *data)
+{
+	int ret, found = 0;
+
+	/* Setting $GIT_CONFIG makes git read _only_ the given config file. */
+	if (config_exclusive_filename)
+		return git_config_from_file(fn, config_exclusive_filename, data);
+	ret = git_config_extra_repo (fn, data, &found);
+	if (found == 0)
+		return -1;
+	return ret;
+}
 
+int git_config(config_fn_t fn, void *data)
+{
+	int ret, found = 0;
+	char *repo_config;
+
+	/* Setting $GIT_CONFIG makes git read _only_ the given config file. */
+	if (config_exclusive_filename)
+		return git_config_from_file(fn, config_exclusive_filename, data);
+	ret = git_config_extra_repo (fn, data, &found);
 	repo_config = git_pathdup("config");
 	if (!access(repo_config, R_OK)) {
 		ret += git_config_from_file(fn, repo_config, data);
-- 
1.6.2.5

  parent reply	other threads:[~2009-07-20 17:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-20 17:49 [PATCH RFC 0/8] introduce 'git remote add --push' and 'git clone --push' Paolo Bonzini
2009-07-20 17:49 ` [PATCH RFC 1/8] reintroduce PUSH_DEFAULT_UNSPECIFIED Paolo Bonzini
2009-07-20 17:49 ` [PATCH RFC 2/8] push: add push.default = mirror Paolo Bonzini
2009-07-20 20:46   ` Junio C Hamano
2009-07-20 21:14     ` Paolo Bonzini
2009-07-20 21:34       ` Junio C Hamano
2009-07-20 21:36         ` Paolo Bonzini
2009-07-20 17:49 ` [PATCH RFC 3/8] git remote add: refactor configuration Paolo Bonzini
2009-07-20 17:49 ` [PATCH RFC 4/8] git remote add: add --push option Paolo Bonzini
2009-07-20 17:49 ` [PATCH RFC 5/8] clone: refactoring of building the fetch refspec Paolo Bonzini
2009-07-20 17:49 ` [PATCH RFC 6/8] clone: use setup_remote_config Paolo Bonzini
2009-07-20 17:49 ` Paolo Bonzini [this message]
2009-07-20 17:49 ` [PATCH RFC 8/8] clone: add --push option Paolo Bonzini
2009-07-20 22:15 ` [PATCH RFC 0/8] introduce 'git remote add --push' and 'git clone --push' Junio C Hamano
2009-07-21 10:33   ` Paolo Bonzini
2009-07-21 21:00     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1248112195-3761-8-git-send-email-bonzini@gnu.org \
    --to=bonzini@gnu.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).