git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Atukunda <matlads@dsmagic.com>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 4/6] Add check_repo_format check for all major operations.
Date: Tue, 22 Nov 2005 15:55:23 +0300	[thread overview]
Message-ID: <200511221555.24572.matlads@dsmagic.com> (raw)
In-Reply-To: <7vlkzhf5li.fsf@assigned-by-dhcp.cox.net>

On Tuesday 22 November 2005 11:29, Junio C Hamano wrote:
> Martin Atukunda <matlads@dsmagic.com> writes:
> > The git-* command set uses 3 entry points in order to prepare
> > to work with a git repo: enter_repo, get_git_dir, and obviously
> > setup_git_directory.
>
> Thanks, but I think this one is wrong.
<snip>
> In setup_git_env() you have only read GIT_DIR environment but
> have not done the toplevel discovery.  Especially, this is
> called from get_git_dir(), and you call that as the first thing
> as setup_git_directory().  However, that function is supposed to
> be callable by processes that are in a subdirectory, without
> GIT_DIR explicitly specified, and the place get_git_dir() is
> called in that function is way before the discovery of the
> toplevel happens.  Until then, you do not know where your .git/
> directory or .git/config file is. If you start in Documentation
> subdirectory in git project, your setup_git_directory() would
> first call get_git_dir(), which says "I assume the config file
> is at ./.git/config -- oh there is no such thing".  At that
> point you are checking Documentation/.git/config.
>
> It would happen to work because you intend to allow version 0
> repository for any future version of tool, and even if this
> codepath mistakenly thinks the repository is version 0, it does
> not hurt, as long as your setup_git_directory() calls
> check_repo_format again after doing the toplevel discovery and
> checks the true .git/config file, but I do not think you have
> that call in the current series yet.  Even if you had, this does
> not feel quite right to me.

would something like the following apply in this case: (totally untested :)

--

Add check_repo_format check for setup_git_directory(). This check needs
to be done in 2 cases in this function. first if GIT_DIR is set, and also
after the top_level directory is found.

Signed-Off-By: Martin Atukunda <matlads@dsmagic.com>

diff --git a/setup.c b/setup.c
index 44b9866..45e716a 100644
--- a/setup.c
+++ b/setup.c
@@ -101,8 +101,11 @@ const char *setup_git_directory(void)
 	 * If GIT_DIR is set explicitly, we're not going
 	 * to do any discovery
 	 */
-	if (getenv(GIT_DIR_ENVIRONMENT))
+	if (getenv(GIT_DIR_ENVIRONMENT)) {
+		get_git_dir(1);
+		check_repo_format();
 		return NULL;
+	}
 
 	if (!getcwd(cwd, sizeof(cwd)) || cwd[0] != '/')
 		die("Unable to read current working directory");
@@ -118,6 +121,8 @@ const char *setup_git_directory(void)
 		} while (cwd[--offset] != '/');
 	}
 
+	check_repo_format();
+
 	if (offset == len)
 		return NULL;
 

  reply	other threads:[~2005-11-22 12:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-22  0:28 Git Future Proofing Martin Atukunda
2005-11-22  0:28 ` [PATCH 1/6] Add GIT_REPO_VERSION, and repository_format_version Martin Atukunda
2005-11-22  0:28 ` [PATCH 2/6] Make init-db check repo format version if copying a config file Martin Atukunda
2005-11-22  0:28 ` [PATCH 3/6] Make get_git_dir take a flag that makes it re-read the env. variables Martin Atukunda
2005-11-22  0:28 ` [PATCH 4/6] Add check_repo_format check for all major operations Martin Atukunda
2005-11-22  8:29   ` Junio C Hamano
2005-11-22 12:55     ` Martin Atukunda [this message]
2005-11-22 17:46       ` Junio C Hamano
2005-11-23  0:57         ` Junio C Hamano
2005-11-22  0:28 ` [PATCH 5/6] Allow Specification of the conf file to read for git_config operations Martin Atukunda
2005-11-22  0:28 ` [PATCH 6/6] Add check for downgrading of repo format version via init-db Martin Atukunda
2005-11-22  1:13 ` Git Future Proofing 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=200511221555.24572.matlads@dsmagic.com \
    --to=matlads@dsmagic.com \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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).