Skip to contentSkip to conversation

chdir after computing new cwd in check_repository_format_gently

PATCH In review David Reiss 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 chdir after computing new cwd in check_repository_format_gently

In preparation for adding a check before the chdir. This should be a no-op because the cwd is not read in the interim and any nonlocal exits either chdir to an absolute path or die.

---
I sent this in a few weeks ago, but got no response. Probably because I messed up the formatting. Hopefully I'm getting it right this time.

 setup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
setup.c +1 -1
index b8fd476..c54f2b6 100644
@@ -443,7 +443,6 @@ const char *setup_git_directory_gently(int *nongit_ok)
 			check_repository_format_gently(nongit_ok);
 			return NULL;
 		}
-		chdir("..");
 		do {
 			if (!offset) {
 				if (nongit_ok) {
@@ -455,6 +454,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
 				die("Not a git repository");
 			}
 		} while (cwd[--offset] != '/');
+		chdir("..");
 	}
 
 	inside_git_dir = 0;
Signature · 1 line
1.5.4
#1 lore raw

Hi,

Quoted 3 lines · David Reiss

In preparation for adding a check before the chdir. This should be a no-op because the cwd is not read in the interim and any nonlocal exits either chdir to an absolute path or die.

I think it would be clearer if you squashed that commit into the other one.

Ciao,
Dscho