git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/6] Add check_repo_format check for all major operations.

From
MAMartin Atukunda <matlads@dsmagic.com>
Date
Nov 22, 2005, 00:28 UTC
Message-ID
<113261929333-git-send-email-matlads@dsmagic.com>
In-Reply-To
<11326192921291-git-send-email-matlads@dsmagic.com>

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.

This patch adds a check for the repo format version to each of these entry points. This will automatically enable repo format version checking for all the git-* programs.

Signed-Off-By: Martin Atukunda <matlads@dsmagic.com>
---
 environment.c |    3 +++
 path.c        |    1 +
 setup.c       |    3 +++
 3 files changed, 7 insertions(+), 0 deletions(-)

applies-to: 8084b72bfb91efc08a9fa83e0893f21c5f60ad92 5d902692ef7eef2763cadfa646eb9245422579af

diff --git a/environment.c b/environment.c
index 6a961ca..458eff8 100644
--- a/environment.c
+++ b/environment.c
@@ -37,6 +37,9 @@ static void setup_git_env(void)
 	git_graft_file = getenv(GRAFT_ENVIRONMENT);
 	if (!git_graft_file)
 		git_graft_file = strdup(git_path("info/grafts"));
+
+	/* check the repo */
+	check_repo_format();
 }
 
 char *get_git_dir(int recheck_env)
diff --git a/path.c b/path.c
index e322dc0..84cb1c5 100644
--- a/path.c
+++ b/path.c
@@ -199,6 +199,7 @@ char *enter_repo(char *path, int strict)
 	if(access("objects", X_OK) == 0 && access("refs", X_OK) == 0 &&
 	   validate_symref("HEAD") == 0) {
 		putenv("GIT_DIR=.");
+		get_git_dir(1); /* re-read the env variables */
 		return current_dir();
 	}
 
diff --git a/setup.c b/setup.c
index 8597424..934f9a3 100644
--- a/setup.c
+++ b/setup.c
@@ -97,6 +97,9 @@ const char *setup_git_directory(void)
 	static char cwd[PATH_MAX+1];
 	int len, offset;
 
+	get_git_dir(1);
+	check_repo_format();
+
 	/*
 	 * If GIT_DIR is set explicitly, we're not going
 	 * to do any discovery
---
0.99.9.GIT
Previous: Martin AtukundaNext: Junio C Hamano
Message 5 of 12 in “Git Future Proofing”
  1. Martin AtukundaNov 22, 2005
  2. 2/6 Make init-db check repo format version if copying a config file.Martin Atukunda, Nov 22, 2005
  3. 3/6 Make get_git_dir take a flag that makes it re-read the env. variablesMartin Atukunda, Nov 22, 2005
  4. 1/6 Add GIT_REPO_VERSION, and repository_format_versionMartin Atukunda, Nov 22, 2005
  5. 4/6 Add check_repo_format check for all major operations.Martin Atukunda, Nov 22, 2005
  6. Junio C HamanoNov 22, 2005
  7. Martin AtukundaNov 22, 2005
  8. Junio C HamanoNov 22, 2005
  9. Junio C HamanoNov 23, 2005
  10. 5/6 Allow Specification of the conf file to read for git_config operationsMartin Atukunda, Nov 22, 2005
  11. 6/6 Add check for downgrading of repo format version via init-dbMartin Atukunda, Nov 22, 2005
  12. Junio C HamanoNov 22, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.