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

Re: [RFC] Renaming environment variables.

From
Junio C Hamano <junkio@cox.net>
Date
May 10, 2005, 05:45 UTC
Message-ID
<7voebjr5vd.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.21.0505092012340.30848-100000@iabervon.org>
>>>>> "DB" == Daniel Barkalow <barkalow@iabervon.org> writes:
DB> On Mon, 9 May 2005, Junio C Hamano wrote:
>> >>>>> "DB" == Daniel Barkalow <barkalow@iabervon.org> writes:
>> 

DB> While we're at it, it would be useful to have one for what is normally DB> ".git",...

Show 6 quoted lines
>> 
>> If you mean the parent directory of ${SHA1_FILE_DIRECTORY}, and
>> your only gripe is about git-init-db creating ".git" in the
>> current working directory regardless of SHA1_FILE_DIRECTORY, I
>> would agree that what git-init-db does is broken.  Not that I
>> have a suggested "right behaviour" for it, though.

DB> It could just create all missing parents of the object directory, which DB> would be better, at least.

I am ambivalent about this. Here is an excerpt from my WIP. I am trying to keep the original semantics of "we create the leading paths only if we default to .git/objects":

$ GIT_DIFF_OPTS=-u8 jit-diff 1: init-db.c # - HEAD: Rename environment variables. # + (working tree)

--- a/init-db.c
+++ b/init-db.c
@@ -22,21 +22,22 @@
  * be the judge.  The default case is to have one DB per managed directory.
  */
 int main(int argc, char **argv)
 {
 	const char *sha1_dir;
 	char *path;
 	int len, i;
 
-	safe_create_dir(".git");
-
-	sha1_dir = gitenv(DB_ENVIRONMENT);
-	if (!sha1_dir) {
-		sha1_dir = DEFAULT_DB_ENVIRONMENT;
+	sha1_dir = get_object_directory();
+	if (!gitenv(DB_ENVIRONMENT) && !gitenv(GIT_DIR_ENVIRONMENT)) {
+		/* We create leading paths only when we fall back
+		 * to local ".git/objects".
+		 */
+		safe_create_dir(DEFAULT_GIT_DIR_ENVIRONMENT);
 		fprintf(stderr, "defaulting to local storage area\n");
 	}
 	len = strlen(sha1_dir);
 	path = xmalloc(len + 40);
 	memcpy(path, sha1_dir, len);
 
 	safe_create_dir(sha1_dir);
 	for (i = 0; i < 256; i++) {

Here DEFAULT_GIT_DIR_ENVIRONMENT is defined as ".git", and the
directory is created only if we do not have GIT_OBJECT_DIRECTORY
nor GIT_DIR environment variables, which should match the intent
of the original by Linus.  Otherwise we at least require the
parent directory of GIT_OBJECT_DIRECTORY to exist.  I think that
is a reasonable default (well that is not something I can take
credit), in that if the user is clued enough to use something
different from the default he should at least know enough to
create the leading paths beforehand (or the script could do that
for him).

Other than this part, I think the code is ready to go.
Previous: Daniel BarkalowNext: Junio C Hamano
Message 24 of 30 in “Introduce SHA1_FILE_DIRECTORIES”
  1. Introduce SHA1_FILE_DIRECTORIESJunio C Hamano, May 6, 2005
  2. SeanMay 7, 2005
  3. Junio C HamanoMay 7, 2005
  4. SeanMay 7, 2005
  5. Junio C HamanoMay 7, 2005
  6. Junio C HamanoMay 7, 2005
  7. H. Peter AnvinMay 9, 2005
  8. Junio C HamanoMay 9, 2005
  9. SeanMay 9, 2005
  10. H. Peter AnvinMay 9, 2005
  11. Junio C HamanoMay 9, 2005
  12. [RFC] Renaming environment variables.Junio C Hamano, May 9, 2005
  13. Thomas GlanzmannMay 9, 2005
  14. Petr BaudisMay 10, 2005
  15. SeanMay 9, 2005
  16. Daniel BarkalowMay 9, 2005
  17. Junio C HamanoMay 10, 2005
  18. Petr BaudisMay 10, 2005
  19. Junio C HamanoMay 10, 2005
  20. Petr BaudisMay 10, 2005
  21. Daniel BarkalowMay 10, 2005
  22. Petr BaudisMay 10, 2005
  23. Daniel BarkalowMay 10, 2005
  24. Junio C HamanoMay 10, 2005
  25. Introducing GIT_DIR environment variable.Junio C Hamano, May 10, 2005
  26. Alex RiesenMay 10, 2005
  27. Junio C HamanoMay 10, 2005
  28. Daniel BarkalowMay 10, 2005
  29. Petr BaudisMay 10, 2005
  30. Junio C HamanoMay 10, 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.