Re: [PATCH] add: don't complain when adding empty project root

2014-01-31 Thread Junio C Hamano
Torsten Bögershausen  writes:

> But, look at
> https://www.kernel.org/pub/software/scm/git/docs/git-add.html
>
> This page seems to need an update too, and I wonder why:
> a) The makefile did'nt re-generate html even if it should have
> b) That page is not owned or updated by the git.git maintainer
> c) Any other reason?

Sorry, but if I understand correctly, k.org these days requires each
file to be GPG signed and uploaded individually (i.e. there is no
way as far as I can tell to say "here is a tarball, and I've even
signed it with my key to convince you that it is from me. Please
accept it and then unpack the contents there").  There is no way I'd
do that every time I update git-htmldocs repository for 500+ files.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] add: don't complain when adding empty project root

2014-01-30 Thread Torsten Bögershausen
[]
> filepattern is related to current directory too (e.g. "*.sh" from "t"
> won't cover git-rebase.sh, ":/*.sh" does). Yes a patch to update
> git-add.txt to use the term "pathspec" instead of "filepattern" would
> be nice. A pointer to pathspec glossary could help discover
> case-insensitive matching, negative matching..


To somewhat end this thread: 
I haven't been able to find a patch that really improves the documentation,
because "Documentation/git-add.txt" has already been updated:

commit 30784198b766b19a639c199e4365f2a805fc08c6
Author: Junio C Hamano 
Date:   Thu Feb 14 15:51:43 2013 -0800

Documentation/git-add: kill remaining 


And all changes are here:
http://git-htmldocs.googlecode.com/git/git-add.html

But, look at
https://www.kernel.org/pub/software/scm/git/docs/git-add.html

This page seems to need an update too, and I wonder why:
a) The makefile did'nt re-generate html even if it should have
b) That page is not owned or updated by the git.git maintainer
c) Any other reason?


Does anybody know how to trigger an update at kernel.org?

/Torsten
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] add: don't complain when adding empty project root

2013-12-26 Thread Junio C Hamano
Junio C Hamano  writes:

> Regarding "git add --refresh" (no other arguments), it would say
> "Nothing specified, nothing added.", and that is unrelated to the
> breakage reported and fixed in this thread, I think.  It is the same
> message "git add" (no other arguments) gives, which I think is a
> mistake.  "git add --refresh" is like "git add -u" in that the
> affected paths are determined by the index, and running these
> commands while your index is still empty can just be a silent no-op.

Something like this...

 builtin/add.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/builtin/add.c b/builtin/add.c
index d7e3e44..84e8a3e 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -483,8 +483,10 @@ int cmd_add(int argc, const char **argv, const char 
*prefix)
 (implicit_dot ? ADD_CACHE_IMPLICIT_DOT : 0);
 
if (require_pathspec && argc == 0) {
-   fprintf(stderr, _("Nothing specified, nothing added.\n"));
-   fprintf(stderr, _("Maybe you wanted to say 'git add .'?\n"));
+   if (!refresh_only) {
+   fprintf(stderr, _("Nothing specified, nothing 
added.\n"));
+   fprintf(stderr, _("Maybe you wanted to say 'git add 
.'?\n"));
+   }
return 0;
}
 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] add: don't complain when adding empty project root

2013-12-26 Thread Junio C Hamano
Jonathan Nieder  writes:

> How about something like the following, for squashing in?
>
> With or without the tweaks below,
> Reviewed-by: Jonathan Nieder 

Thanks, both.

Regarding "git add --refresh" (no other arguments), it would say
"Nothing specified, nothing added.", and that is unrelated to the
breakage reported and fixed in this thread, I think.  It is the same
message "git add" (no other arguments) gives, which I think is a
mistake.  "git add --refresh" is like "git add -u" in that the
affected paths are determined by the index, and running these
commands while your index is still empty can just be a silent no-op.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] add: don't complain when adding empty project root

2013-12-26 Thread Jonathan Nieder
Hi,

Nguyễn Thái Ngọc Duy wrote:

> Signed-off-by: Nguyễn Thái Ngọc Duy 

Thanks.

[...]
> --- 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))) {

Nit: in this loop there's already the synonym 'path' for item.match,
so perhaps

if (!seen[i] && path[0] && ...)

would be clearer.

Should "git add --refresh ." get the same treatment?

> --- 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 . )
> +'

Adding a test at the end like this means the tests come in chronological
order instead of logical order and simultaneous patches to the same
test script become more likely to conflict.

How about something like the following, for squashing in?

With or without the tweaks below,
Reviewed-by: Jonathan Nieder 

diff --git i/builtin/add.c w/builtin/add.c
index fbd3f3a..d7e3e44 100644
--- i/builtin/add.c
+++ w/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] && pathspec.items[i].match[0] &&
+   if (!seen[i] && path[0] &&
((pathspec.items[i].magic &
  (PATHSPEC_GLOB | PATHSPEC_ICASE)) ||
 !file_exists(path))) {
diff --git i/t/t3700-add.sh w/t/t3700-add.sh
index 1535d8f..fe274e2 100755
--- i/t/t3700-add.sh
+++ w/t/t3700-add.sh
@@ -272,6 +272,25 @@ test_expect_success '"add non-existent" should fail' '
! (git ls-files | grep "non-existent")
 '
 
+test_expect_success 'git add -A on empty repo does not error out' '
+   rm -fr empty &&
+   git init empty &&
+   (
+   cd empty &&
+   git add -A . &&
+   git add -A
+   )
+'
+
+test_expect_success '"git add ." in empty repo' '
+   rm -fr empty &&
+   git init empty &&
+   (
+   cd empty &&
+   git add .
+   )
+'
+
 test_expect_success 'git add --dry-run of existing changed file' "
echo new >>track-this &&
git add --dry-run track-this >actual 2>&1 &&
@@ -307,8 +326,4 @@ 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] add: don't complain when adding empty project root

2013-12-24 Thread Duy Nguyen
On Wed, Dec 25, 2013 at 4:48 AM, Torsten Bögershausen  wrote:
> On 2013-12-24 00.46, Duy Nguyen wrote:
>>
> [snip]
>> We don't complain about adding an empty directory before or after this patch.
> Ok, thanks for the explanation.
>
> I think that
> https://www.kernel.org/pub/software/scm/git/docs/git-add.html
> could deserve an update.
>
> My understanding is that  is related to $GIT_DIR,
> but "." is the current directory.
>
> I will be happy to write a patch,
> (or to review one, whatever comes first)
> /Torsten

filepattern is related to current directory too (e.g. "*.sh" from "t"
won't cover git-rebase.sh, ":/*.sh" does). Yes a patch to update
git-add.txt to use the term "pathspec" instead of "filepattern" would
be nice. A pointer to pathspec glossary could help discover
case-insensitive matching, negative matching..
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] add: don't complain when adding empty project root

2013-12-24 Thread Torsten Bögershausen
On 2013-12-24 00.46, Duy Nguyen wrote:
>
[snip]
> We don't complain about adding an empty directory before or after this patch.
Ok, thanks for the explanation.

I think that
https://www.kernel.org/pub/software/scm/git/docs/git-add.html
could deserve an update.

My understanding is that  is related to $GIT_DIR,
but "." is the current directory. 

I will be happy to write a patch,
(or to review one, whatever comes first)
/Torsten
 

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] add: don't complain when adding empty project root

2013-12-23 Thread Duy Nguyen
On Tue, Dec 24, 2013 at 12:48 AM, Torsten Bögershausen  wrote:
>> +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 ..." to unstage)
>
> new file:   B
>
> Untracked files:
>   (use "git add ..." 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".

Yes, except in this case "." is project root because current dir is. I
could have done "git add -A" (without the dot) like reported, but that
will be deprecated soon. Another way to make it clear about project
root is use "git add -A :/". I'll send an update if it makes it
clearer.

> -
>
> 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.

We don't complain about adding an empty directory before or after this patch.

>
> (and similar in the commit message)
> /Torsten
>



-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] add: don't complain when adding empty project root

2013-12-23 Thread Torsten Bögershausen
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 
> Signed-off-by: Nguyễn Thái Ngọc Duy 
> ---
>  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 ..." to unstage)

new file:   B

Untracked files:
  (use "git add ..." 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html