git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: git@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Sean <seanlkml@sympatico.ca>, Linus Torvalds <torvalds@osdl.org>
Subject: Re: [RFC] Renaming environment variables.
Date: Mon, 09 May 2005 22:45:42 -0700	[thread overview]
Message-ID: <7voebjr5vd.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <Pine.LNX.4.21.0505092012340.30848-100000@iabervon.org> (Daniel Barkalow's message of "Mon, 9 May 2005 20:38:53 -0400 (EDT)")

>>>>> "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",...
>> 
>> 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.



  parent reply	other threads:[~2005-05-10  5:38 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-06 23:35 [PATCH] Introduce SHA1_FILE_DIRECTORIES Junio C Hamano
2005-05-07  0:20 ` Sean
2005-05-07  0:24   ` Junio C Hamano
2005-05-07  0:32     ` Sean
2005-05-07  6:31       ` Junio C Hamano
2005-05-07 19:51         ` Junio C Hamano
2005-05-09 13:33           ` H. Peter Anvin
2005-05-09 16:38             ` Junio C Hamano
2005-05-09 16:41               ` Sean
2005-05-09 18:03                 ` H. Peter Anvin
2005-05-09 18:50                   ` Junio C Hamano
2005-05-09 20:05                     ` [RFC] Renaming environment variables Junio C Hamano
2005-05-09 20:15                       ` Thomas Glanzmann
2005-05-10  0:32                         ` Petr Baudis
2005-05-09 21:04                       ` Sean
2005-05-09 23:08                       ` Daniel Barkalow
2005-05-10  0:09                         ` Junio C Hamano
2005-05-10  0:13                           ` Petr Baudis
2005-05-10  0:22                             ` Junio C Hamano
2005-05-10  0:27                               ` Petr Baudis
2005-05-10  0:38                           ` Daniel Barkalow
2005-05-10  0:44                             ` Petr Baudis
2005-05-10  0:53                               ` Daniel Barkalow
2005-05-10  5:45                             ` Junio C Hamano [this message]
2005-05-10  6:25                               ` Introducing GIT_DIR environment variable Junio C Hamano
2005-05-10 23:39                                 ` Alex Riesen
2005-05-10  2:16                         ` [RFC] Renaming environment variables Junio C Hamano
2005-05-10  3:23                           ` Daniel Barkalow
2005-05-10  0:25                       ` Petr Baudis
2005-05-10  1:02                         ` 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=7voebjr5vd.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    --cc=hpa@zytor.com \
    --cc=seanlkml@sympatico.ca \
    --cc=torvalds@osdl.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).