{"thread":{"id":"19117","subject":"Project Setup Problem","startedAt":"2009-04-29T00:22:56Z","lastAt":"2009-04-29T03:21:01Z","messageCount":2,"participants":["Jason Brice","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"112584","messageId":"loom.20090429T001456-24@post.gmane.org","threadId":"19117","inReplyTo":null,"subject":"Project Setup Problem","fromName":"Jason Brice","fromEmail":"jason@sbh.co.nz","sentAt":"2009-04-29T00:22:56Z","receivedAt":"2009-04-29T00:22:56Z","isPatch":false,"sender":{"key":"jason@sbh.co.nz","avatar":null},"body":"Hi,\n\nI am very new to git and I am trying to create my first project. After running:\n\"git init\", I ran \"git add .\" but I get the following error message:\nfatal: pathspec '' did not match any files\n\nI am running on CentOS 4.7 on a CPanel/WHM server. The git install is in a \nuser's account space.\n\nThanks,\nJason\n"},{"id":"112587","messageId":"20090429032101.GA8826@coredump.intra.peff.net","threadId":"19117","inReplyTo":"loom.20090429T001456-24@post.gmane.org","subject":"Re: Project Setup Problem","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-04-29T03:21:01Z","receivedAt":"2009-04-29T03:21:01Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Apr 29, 2009 at 12:22:56AM +0000, Jason Brice wrote:\n\n> I am very new to git and I am trying to create my first project. After running:\n> \"git init\", I ran \"git add .\" but I get the following error message:\n> fatal: pathspec '' did not match any files\n\nProbably because you don't have any files, thus there was nothing to\nmatch. You can't add or commit in git until there is something to add or\ncommit.\n\nIf you do have files and you got that message, then that is a problem\n(and let us know).\n\nAll that being said, the error message is not especially helpful. In\nparticular, showing '' when the user asked for '.' can look like a bug\n(when in fact it is an artifact of how git translates the pathspecs\ninternally).\n\nThe point of that message is to warn the user of typos or other\nmistakes (see f259339). But pointing to an existing but empty directory\nprobably shouldn't generate a warning. And in fact, neither \"mkdir foo\n&& cd foo && git add .\" nor \"mkdir foo && git add foo\" generates a\nwarning. It is really just that the empty pathspec for the root doesn't\nwork (because it fools our lstat() call).\n\nI suspect, but didn't carefully investigate, that this is actually a\nregression introduced by my ancient e96980e (builtin-add: simplify (and\nincrease accuracy of) exclude handling, 2007-06-12) which reorganized\nthat section of code a bit. I did a quick check, which contains f259339\nbut not e96980e, and it treats \"git add .\" in an empty project root as a\nno-op.\n\nJunio, I think we should apply the patch below. It is a bugfix, but\nobviously this is not a critical bug (the impact is small, and it has\nbeen around for 2 years already), and given that we are so late in the\nrelease cycle, it is probably fine to wait for post-1.6.3.\n\n-- >8 --\nSubject: [PATCH] add: don't complain when adding empty project root\n\nWe try to warn the user if one of their pathspecs caused no\nmatches, as it may have been a typo. However, we disable the\nwarning if the pathspec points to an existing file, since\nthat means it is not a typo but simply an empty directory.\n\nUnfortunately, the file_exists() test was broken for one\nspecial case: the pathspec of the project root is just \"\".\nThis patch detects this special case and acts as if the file\nexists (which it must, since it is the project root).\n\nThe user-visible effect is that this:\n\n  $ mkdir repo && cd repo && git init && git add .\n\nused to complain like:\n\n  fatal: pathspec '' did not match any files\n\nbut now is a silent no-op.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin-add.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-add.c b/builtin-add.c\nindex 314380e..bee45f0 100644\n--- a/builtin-add.c\n+++ b/builtin-add.c\n@@ -63,7 +63,7 @@ static void prune_directory(struct dir_struct *dir, const char **pathspec, int p\n \tfill_pathspec_matches(pathspec, seen, specs);\n \n \tfor (i = 0; i < specs; i++) {\n-\t\tif (!seen[i] && !file_exists(pathspec[i]))\n+\t\tif (!seen[i] && pathspec[i][0] && !file_exists(pathspec[i]))\n \t\t\tdie(\"pathspec '%s' did not match any files\",\n \t\t\t\t\tpathspec[i]);\n \t}\n-- \n1.6.3.rc3.188.g92147.dirty\n"}]}