From: "Torsten Bögershausen" <tboegi@web.de>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>, git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>, tfnico@gmail.com
Subject: Re: [PATCH] add: don't complain when adding empty project root
Date: Mon, 23 Dec 2013 18:48:09 +0100 [thread overview]
Message-ID: <52B87759.2090901@web.de> (raw)
In-Reply-To: <1387789361-29036-1-git-send-email-pclouds@gmail.com>
On 2013-12-23 10.02, Nguyễn Thái Ngọc Duy wrote:
> 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
>
I am (a little bit) confused.
This is what git does:
rm -rf test && mkdir test && cd test && git init && touch A && mkdir D && cd D && touch B && git add . && git status
Initialized empty Git repository in /Users/tb/test/test/.git/
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: B
Untracked files:
(use "git add <file>..." to include in what will be committed)
../A
----------------
And the behaviour is in line with
https://www.kernel.org/pub/software/scm/git/docs/git-add.html
"." stands for the current directory somewhere in the worktree,
not only the "project root".
-----------------
Could it make sense to mention that replace
[PATCH] add: don't complain when adding empty project root
with
[PATCH] add: don't complain when adding empty directory.
(and similar in the commit message)
/Torsten
next prev parent reply other threads:[~2013-12-23 17:49 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 ` [PATCH] add: don't complain when adding empty project root Nguyễn Thái Ngọc Duy
2013-12-23 17:48 ` Torsten Bögershausen [this message]
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=52B87759.2090901@web.de \
--to=tboegi@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.