git add single file and git add list of files behave differentely for ignored files

2014-12-04 Thread Guilherme
Hello,

I reported this issue on the git-user mailing list and they redirected me here.

The problem I have observed is that with a ignored path `git add
single file` behaves differently then `git add list of files`.

I my git/info/excludes file i have

/COM/config
!COM/config/Project.gny

The file COM/config/Project.gny has already been added to the
repository via `git add -f`.

When doing

git add -- COM/config/Projec.gny

git will not complain but when doing

git add -- COM/config/Project.gny otherfiles.c

it will report:

The following paths are ignored by one of your .gitignore files:
COM/config
Use -f if you really want to add them.
fatal: no files added

This odd behaviour is also present in `git check-ignore`.

Before adding the file `git check-ignore` correctly reports the file
as ignored. After having added it via `git add -f` it won't report it
as ignored anymore.

Even if not a bug this behaviour is inconsistent and might want to be
addressed as it makes scripting a little bit harder.

Thank you.
--
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: git add single file and git add list of files behave differentely for ignored files

2014-12-04 Thread Konstantin Khomoutov
On Thu, 4 Dec 2014 10:06:23 +0100
Guilherme guibuf...@gmail.com wrote:

 I reported this issue on the git-user mailing list and they
 redirected me here.
 
 The problem I have observed is that with a ignored path `git add
 single file` behaves differently then `git add list of files`.
[...]

To those who's interested the original thread on git-users is
https://groups.google.com/d/topic/git-users/322tole9am8/discussion
--
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: git add single file and git add list of files behave differentely for ignored files

2014-12-04 Thread Guilherme
I forgot to mention:

Environment: Cygwin

Git version 2.1.1

On Thu, Dec 4, 2014 at 12:11 PM, Konstantin Khomoutov
flatw...@users.sourceforge.net wrote:
 On Thu, 4 Dec 2014 10:06:23 +0100
 Guilherme guibuf...@gmail.com wrote:

 I reported this issue on the git-user mailing list and they
 redirected me here.

 The problem I have observed is that with a ignored path `git add
 single file` behaves differently then `git add list of files`.
 [...]

 To those who's interested the original thread on git-users is
 https://groups.google.com/d/topic/git-users/322tole9am8/discussion
--
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: git add single file and git add list of files behave differentely for ignored files

2014-12-04 Thread Michael J Gruber
Guilherme schrieb am 04.12.2014 um 10:06:
 Hello,
 
 I reported this issue on the git-user mailing list and they redirected me 
 here.
 
 The problem I have observed is that with a ignored path `git add
 single file` behaves differently then `git add list of files`.
 
 I my git/info/excludes file i have
 
 /COM/config
 !COM/config/Project.gny
 
 The file COM/config/Project.gny has already been added to the
 repository via `git add -f`.
 
 When doing
 
 git add -- COM/config/Projec.gny
 
 git will not complain but when doing
 
 git add -- COM/config/Project.gny otherfiles.c
 
 it will report:
 
 The following paths are ignored by one of your .gitignore files:
 COM/config
 Use -f if you really want to add them.
 fatal: no files added

This is because git add assumes you specified on of the files in error,
and thus refuses to add the other one, too.

I found that behaviour surprising. There's already a patch which, in the
2nd case, would make git add only warn you about the ignored file but
add the other one anyways. It will probably make its way into the next
release.

For the case of a single file (or rather: ignored files only) I'm
wondering whether we should issue a warning, too.

 This odd behaviour is also present in `git check-ignore`.
 
 Before adding the file `git check-ignore` correctly reports the file
 as ignored. After having added it via `git add -f` it won't report it
 as ignored anymore.

This is different: Once a file is added, it is not ignored any more -
you explicitely told git to track that file (rather than ignoring it).
So, the output of git check-ignore is correct.

 Even if not a bug this behaviour is inconsistent and might want to be
 addressed as it makes scripting a little bit harder.
 
 Thank you.
 

I guess you want git check-ignore --no-index. That man page may be a
bit misleading - the description sounds as if only the patterns would
matter.

Michael

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