From: Nguyen Thai Ngoc Duy Date: Fri, 25 Mar 2011 12:56:35 GMT Subject: Re: git-add says 'pathspec did not match any files' for git repository in / Message-ID: <20110325125635.GA28118@do> In-Reply-To: <20110325100254.GH30350@login.drsnuggles.stderr.nl> On Fri, Mar 25, 2011 at 11:02:54AM +0100, Matthijs Kooijman wrote: > Hey folks, > > I've been using git for keeping config files using a repository in /. > In 1.7.4.1, this seems to be broken again. Committing, diffing and > status work this time, but git add gives a pathspec did not match any > files error when adding a file while the current working directory is > not /. We have t1509 to guard these cases (and it does indeed show breakages). The problem is that the test requires chroot and cannot be run automatically. I need to think of writing better tests. The following makes t1509 pass again for me. You may want to try and see if it fixes it for you. diff --git a/setup.c b/setup.c index 03cd84f..c18ea9c 100644 --- a/setup.c +++ b/setup.c @@ -390,15 +390,25 @@ static const char *setup_explicit_git_dir(const char *gitdirenv, return NULL; } - if (!prefixcmp(cwd, worktree) && - cwd[strlen(worktree)] == '/') { /* cwd inside worktree */ - set_git_dir(real_path(gitdirenv)); - if (chdir(worktree)) - die_errno("Could not chdir to '%s'", worktree); - cwd[len++] = '/'; - cwd[len] = '\0'; - free(gitfile); - return cwd + strlen(worktree) + 1; + if (!prefixcmp(cwd, worktree)) { + if (strlen(worktree) == offset_1st_component(worktree)) { + set_git_dir(real_path(gitdirenv)); + if (chdir(worktree)) + die_errno("Could not chdir to '%s'", worktree); + cwd[len++] = '/'; + cwd[len] = '\0'; + free(gitfile); + return cwd + offset_1st_component(worktree); + } + if (cwd[strlen(worktree)] == '/') { /* cwd inside worktree */ + set_git_dir(real_path(gitdirenv)); + if (chdir(worktree)) + die_errno("Could not chdir to '%s'", worktree); + cwd[len++] = '/'; + cwd[len] = '\0'; + free(gitfile); + return cwd + strlen(worktree) + 1; + } } /* cwd outside worktree */ -- Duy