Subject: Re: MinGW port pull request

From: Johannes Sixt <[email-masked]>
Date: Tue, 24 Jun 2008 15:01:13 +0200

Junio C Hamano schrieb:
>  * There is an interaction with dr/ceiling topic that is already in 'next'
>    that needs to be resolved before we merge this in 'next'.
> 
> Parked in 'pu' for now but with a broken merge resolution.

Please amend the merge commit by this to get the correct resolution:
minoffset in the MinGW port and ceil_offset in dr/ceiling are used for the
same purpose where always ceil_offset == minoffset-1.

We need to adjust ceil_offset only if longest_ancestor_length() returned
-1 (i.e. "there is no prefix") to skip the drive prefix ("C:"); because if
there was some prefix, then the return value will already have accounted
for the drive prefix.

-- Hannes

diff --git a/setup.c b/setup.c
index 531f852..39f1648 100644
--- a/setup.c
+++ b/setup.c
@@ -382,7 +382,6 @@ const char *setup_git_directory_gently(int *nongit_ok)
 	const char *gitdirenv;
 	const char *gitfile_dir;
 	int len, offset, ceil_offset;
-	int minoffset = 0;

 	/*
 	 * Let's assume that we are in a git repository.
@@ -433,12 +432,10 @@ const char *setup_git_directory_gently(int

 	if (!getcwd(cwd, sizeof(cwd)-1))
 		die("Unable to read current working directory");
-	if (has_dos_drive_prefix(cwd))
-		minoffset = 2;

 	ceil_offset = longest_ancestor_length(cwd, env_ceiling_dirs);
-	if (ceil_offset < minoffset)
-		ceil_offset = minoffset;
+	if (ceil_offset < 0 && has_dos_drive_prefix(cwd))
+		ceil_offset = 1;

 	/*
 	 * Test in the following order (relative to the cwd):