git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	tfnico@gmail.com, "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH] add: don't complain when adding empty project root
Date: Mon, 23 Dec 2013 16:02:41 +0700	[thread overview]
Message-ID: <1387789361-29036-1-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <CAEcj5uWHpem+5os+3Mc_a42pk6f30i4UiV=LRPdXkoqiy1jQ_w@mail.gmail.com>

This behavior was added in 07d7bed (add: don't complain when adding
empty project root - 2009-04-28) then broken by 84b8b5d (remove
match_pathspec() in favor of match_pathspec_depth() -
2013-07-14). Reinstate it.

Noticed-by: Thomas Ferris Nicolaisen <tfnico@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/add.c  | 2 +-
 t/t3700-add.sh | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/builtin/add.c b/builtin/add.c
index 226f758..fbd3f3a 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -544,7 +544,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 
 		for (i = 0; i < pathspec.nr; i++) {
 			const char *path = pathspec.items[i].match;
-			if (!seen[i] &&
+			if (!seen[i] && pathspec.items[i].match[0] &&
 			    ((pathspec.items[i].magic &
 			      (PATHSPEC_GLOB | PATHSPEC_ICASE)) ||
 			     !file_exists(path))) {
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index aab86e8..1535d8f 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -307,4 +307,8 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out
 	test_i18ncmp expect.err actual.err
 '
 
+test_expect_success 'git add -A on empty repo does not error out' '
+	git init empty && ( cd empty && git add -A . )
+'
+
 test_done
-- 
1.8.5.2.240.g8478abd

  parent reply	other threads:[~2013-12-23  9:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-18  8:06 git add -A fails in empty repository since 1.8.5 Thomas Ferris Nicolaisen
2013-12-18  8:44 ` Antoine Pelisse
2013-12-18 11:59   ` Duy Nguyen
2013-12-18 18:54     ` Junio C Hamano
2013-12-18 19:24       ` Matthieu Moy
2013-12-18 19:56         ` Junio C Hamano
2013-12-18 20:57     ` Junio C Hamano
2013-12-19  0:49       ` Duy Nguyen
2013-12-23  9:02 ` Nguyễn Thái Ngọc Duy [this message]
2013-12-23 17:48   ` [PATCH] add: don't complain when adding empty project root Torsten Bögershausen
2013-12-23 23:46     ` Duy Nguyen
2013-12-24 21:48       ` Torsten Bögershausen
2013-12-24 23:49         ` Duy Nguyen
2014-01-30 11:39           ` Torsten Bögershausen
2014-01-31 18:10             ` Junio C Hamano
2013-12-26 17:25   ` Jonathan Nieder
2013-12-26 18:54     ` Junio C Hamano
2013-12-26 19:24       ` 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=1387789361-29036-1-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=tfnico@gmail.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).