Re: [PATCH] git-init: set core.worktree if GIT_WORK_TREE is specified

Subsystems: the rest

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] git-init: set core.worktree if GIT_WORK_TREE is specified

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:19

Linus Torvalds [off-list ref] writes:
On Wed, 4 Jul 2007, Matthias Lederhofer wrote:
quoted
quoted
+	if (!getcwd(cwd, sizeof(cwd)) || cwd[0] != '/')
+		die("Unable to read current working directory");
Dscho just pointed out that this causes problems on windows.  The same
is also in setup_git_directory_gently and was there before I touched
it, introduced by Linus in d288a700.  What was the original reason to
do this?  Are there implementations of getcwd which return a relative
path?
Just remove the check for cwd[0] being '/'.
Ok, will do this.

-- >8 --
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Wed, 4 Jul 2007 09:23:17 -0700 (PDT)
Subject: Do not check if getcwd() result begins with a slash

It's just me being too kernel-oriented - inside the kernel, a d_path() 
return value pathname can be either a real path, or something like 
"pipe:[8003]", and the difference is the '/' at the beginning.

In user space, and for getcwd(), the check doesn't make sense. So please 
just remove it, and sorry for my idiotic "I've worked with the kernel for 
too damn long" programming mistakes.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Forged-signature-by: Junio C Hamano [off-list ref]

---

 setup.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/setup.c b/setup.c
index 01f74d4..bb26f3a 100644
--- a/setup.c
+++ b/setup.c
@@ -211,7 +211,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
 	if (!gitdirenv) {
 		int len, offset;
 
-		if (!getcwd(cwd, sizeof(cwd)-1) || cwd[0] != '/')
+		if (!getcwd(cwd, sizeof(cwd)-1))
 			die("Unable to read current working directory");
 
 		offset = len = strlen(cwd);
@@ -271,7 +271,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
 		die("Not a git repository: '%s'", gitdirenv);
 	}
 
-	if (!getcwd(cwd, sizeof(cwd)-1) || cwd[0] != '/')
+	if (!getcwd(cwd, sizeof(cwd)-1))
 		die("Unable to read current working directory");
 	if (chdir(gitdirenv)) {
 		if (nongit_ok) {
@@ -281,7 +281,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
 		die("Cannot change directory to $%s '%s'",
 			GIT_DIR_ENVIRONMENT, gitdirenv);
 	}
-	if (!getcwd(gitdir, sizeof(gitdir)-1) || gitdir[0] != '/')
+	if (!getcwd(gitdir, sizeof(gitdir)-1))
 		die("Unable to read current working directory");
 	if (chdir(cwd))
 		die("Cannot come back to cwd");
@@ -340,7 +340,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
 			die("Cannot change directory to working tree '%s'",
 				gitworktree);
 	}
-	if (!getcwd(worktree, sizeof(worktree)-1) || worktree[0] != '/')
+	if (!getcwd(worktree, sizeof(worktree)-1))
 		die("Unable to read current working directory");
 	strcat(worktree, "/");
 	inside_work_tree = !prefixcmp(cwd, worktree);

Re: [PATCH] git-init: set core.worktree if GIT_WORK_TREE is specified

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2016-06-15 22:43:19


On Wed, 4 Jul 2007, Junio C Hamano wrote:
Ok, will do this.
Ack.
From: Linus Torvalds <torvalds@linux-foundation.org>
I don't think you need to credit me, or forge my sign-off for stuff like 
this where I didn't actually send out a patch.

I'd suggest instead just committing it as yours, but maybe with the 
explanation saying something like "Linus explains: <explanation>" instead.

But hey, you can do it your way too, your choice.

		Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help