From: Victor Leschuk <vleschuk@gmail.com>
To: Noam Postavsky <npostavs@users.sourceforge.net>, git@vger.kernel.org
Cc: vleschuk@accesssoftek.com
Subject: Re: git --literal-pathspecs add -u says "fatal: pathspec ':/' did not match any files"
Date: Sat, 24 Oct 2015 10:13:54 +0300 [thread overview]
Message-ID: <562B2FB2.4080604@gmail.com> (raw)
In-Reply-To: <CAM-tV--Q=DjTwLk8sZVm7-xMQsGwKmyjy4XiT08QpQ5-dffL0w@mail.gmail.com>
Hello Noam,
The problem is that in the absence of explicit argument we set the list
of files to special path ":/" which means repo root:
if ((0 < addremove_explicit || take_worktree_changes) && !argc) {
static const char *whole[2] = { ":/", NULL };
argc = 1;
argv = whole;
}
And after that we treat it as regular file
if (!seen[i] && path[0] &&
((pathspec.items[i].magic &
(PATHSPEC_GLOB | PATHSPEC_ICASE)) ||
!file_exists(path))) { /* <========
file_exists() here just checks lstat() result */
Maybe it'll make sense to modify file_exists() to treat ":/" specially.
Something like that:
diff --git a/dir.c b/dir.c
index 109ceea..6cae3b9 100644
--- a/dir.c
+++ b/dir.c
@@ -2103,6 +2103,10 @@ int read_directory(struct dir_struct *dir, const
char *path, int len, const stru
int file_exists(const char *f)
{
struct stat sb;
+ if (!strcmp(f, ":/")) {
+ /* ":/" - root dir, always exists */
+ return 1;
+ }
return lstat(f, &sb) == 0;
}
--
Victor
On 10/24/2015 02:39 AM, Noam Postavsky wrote:
> ~/tmp/tmprepo$ git init
> Initialized empty Git repository in /home/npostavs/tmp/tmprepo/.git/
> ~/tmp/tmprepo$ git --literal-pathspecs add -u
> fatal: pathspec ':/' did not match any files
> ~/tmp/tmprepo$ git --version
> git version 2.6.1
>
> It was reported[1] that 2.0.2 and several following versions also fail
> with the same error; I found that version 1.9.5 succeeds.
>
> Adding a "." argument:
>
> git --literal-pathspecs add -u .
>
> succeeds in all versions.
>
> [1]: https://github.com/magit/magit/issues/2354#issuecomment-150665961
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-10-24 7:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-23 23:39 git --literal-pathspecs add -u says "fatal: pathspec ':/' did not match any files" Noam Postavsky
2015-10-24 7:13 ` Victor Leschuk [this message]
2015-10-24 16:55 ` Noam Postavsky
2015-10-24 17:57 ` Re* " 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=562B2FB2.4080604@gmail.com \
--to=vleschuk@gmail.com \
--cc=git@vger.kernel.org \
--cc=npostavs@users.sourceforge.net \
--cc=vleschuk@accesssoftek.com \
/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.
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 NNTP newsgroup(s).