Re: [PATCH v3] config.c: split some variables to $GIT_DIR/config.worktree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 14, 2015 at 02:37:39AM +0300, Max Kirillov wrote:
> On Tue, Mar 31, 2015 at 07:14:39PM +0700, Nguyễn Thái Ngọc Duy wrote:
> > core.worktree and core.bare, which are treated specially in 31e26eb [1],
> > are now moved to info/core.worktree and the special treatment reverted.
> <...>
> > -	if (get_common_dir(&sb, gitdir))
> > -		fn = check_repo_format;
> > -	else
> > -		fn = check_repository_format_version;
> 
> By the way, after this '$GIT_DIR/common overrides core.worktree'
> from t1501 started failing. I don't know what would be
> better to do with the case, just remove maybe?

I think that test spots a real problem. In this function, I ignore the
config split when I pass NULL as worktree_config to git_config_early().
Something like this should fix it.

-- 8< --
diff --git a/setup.c b/setup.c
index 61e0403..4799e7d 100644
--- a/setup.c
+++ b/setup.c
@@ -355,10 +355,15 @@ static int check_repo_format(const char *var, const char *value, void *cb)
 static int check_repository_format_gently(const char *gitdir, int *nongit_ok)
 {
 	struct strbuf sb = STRBUF_INIT;
+	struct strbuf sb_wt = STRBUF_INIT;
 	const char *repo_config;
+	const char *worktree_config = NULL;
 	int ret = 0;
 
-	get_common_dir(&sb, gitdir);
+	if (get_common_dir(&sb, gitdir)) {
+		strbuf_addf(&sb_wt, "%s/config.worktree", get_git_dir());
+		worktree_config = sb_wt.buf;
+	}
 	strbuf_addstr(&sb, "/config");
 	repo_config = sb.buf;
 
@@ -371,7 +376,8 @@ static int check_repository_format_gently(const char *gitdir, int *nongit_ok)
 	 * Use a gentler version of git_config() to check if this repo
 	 * is a good one.
 	 */
-	git_config_early(check_repository_format_version, NULL, repo_config, NULL);
+	git_config_early(check_repository_format_version, NULL,
+			 repo_config, worktree_config);
 	if (GIT_REPO_VERSION < repository_format_version) {
 		if (!nongit_ok)
 			die ("Expected git repo version <= %d, found %d",
@@ -383,6 +389,7 @@ static int check_repository_format_gently(const char *gitdir, int *nongit_ok)
 		ret = -1;
 	}
 	strbuf_release(&sb);
+	strbuf_release(&sb_wt);
 	return ret;
 }
 
-- 8< --
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]