From: Greg Brockman <gdb@MIT.EDU>
To: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Cc: git@vger.kernel.org, gitster@pobox.com, Jens.Lehmann@web.de
Subject: Re: [RFC/PATCH] git-add: Don't exclude explicitly-specified tracked files
Date: Thu, 12 Aug 2010 11:54:01 -0400 [thread overview]
Message-ID: <AANLkTimODL6j11D6QuUX4b47GwFOVOXdqkhqrRfRaxmq@mail.gmail.com> (raw)
In-Reply-To: <vpqsk2kjks7.fsf@bauges.imag.fr>
>> Currently, 'git add' will complain about excluded files, even if they
>> are already tracked:
>
> This is not exactly true:
>
> $ echo '*.pdf' > .gitignore; touch foo.pdf; git add -f foo.pdf
> $ echo content >> foo.pdf; git add foo.pdf
>
> Here, the second "git add" didn't need the -f flag.
>
> So, your problem is not about already-tracked exclude files, but it is
> about already-tracked files in an excluded directory.
Good catch. My commit message is definitely wrong.
>> This commit changes 'git add' to disregard excludes for tracked files
>> whose paths are explicitly specified on the command-line.
>
> I don't think you need this to solve the problem, and as Junio said,
> that would make "git add dir/*" add all the ignored files, which would
> make -f essentially useless.
I respectfully disagree with this assessment, however.
First of all, as you point out 'git add foo.pdf' works where foo.pdf
has been explicitly ignored, while in contrast 'git add dir/file'
fails when file has only been indirectly ignored because it is in an
ignored directory. In the former case, the user explicitly specified
a policy for that file. In the later case, the policy is only
indirectly expressed because that file happens to be in an ignored
directory; in my and Ævar's use cases what we mean is "I only care
about a few files in a big directory and don't feel like writing out a
.gitignore entry for each one". So it doesn't make sense to me to
allow the user to add the file in the first place (whether by a 'git
add foo.pdf' or a 'git add f*') but not the second. Perhaps the
answer is to swing in the opposite direction of this patch series and
make 'git add foo.pdf' fail as well, but I must ask what we'd be
defending against... it seems the only reason is to allow the user to
maintain local changes to a tracked file, but as I've stated many
other tools don't seem to similarly respect the .gitignore.
Secondly, I don't think this makes '-f' useless. '-f' would still be
used to initially add an untracked file to the index. So this would
maintain an invariant that no ignored files are tracked unless the
user has specified a '-f' for it in the past.
Incidentally, I noticed that 'git add dir/file' for ignored dir worked
fine in an older version of git. 'git bisect' reveals that the
behavior I would like to change was introduced in 29209cb. From the
commit message, I get the sense that this particular behavior was not
actually intentional (someone please correct me if I'm missing
something).
Thanks,
Greg
next prev parent reply other threads:[~2010-08-12 15:54 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-11 7:03 [RFC/PATCH] git-add: Don't exclude explicitly-specified tracked files Greg Brockman
2010-08-11 12:24 ` Ævar Arnfjörð Bjarmason
2010-08-11 20:50 ` Jens Lehmann
2010-08-12 2:11 ` Greg Brockman
2010-08-11 18:22 ` Junio C Hamano
2010-08-11 18:36 ` Greg Brockman
2010-08-12 2:59 ` Junio C Hamano
2010-08-12 3:19 ` Greg Brockman
2010-08-12 8:30 ` Matthieu Moy
2010-08-12 15:54 ` Greg Brockman [this message]
2010-08-12 16:31 ` Matthieu Moy
2010-08-12 20:00 ` Junio C Hamano
2010-08-12 20:19 ` Greg Brockman
2010-08-12 20:40 ` Jonathan Nieder
2010-08-12 20:26 ` Ævar Arnfjörð Bjarmason
2010-08-18 9:07 ` Greg Brockman
2010-08-18 9:29 ` [RFC/PATCH] Add test case for dealing with a tracked file in an ignored directory Greg Brockman
2010-08-18 9:43 ` Greg Brockman
2010-08-18 9:50 ` Matthieu Moy
2010-08-19 7:52 ` Greg Brockman
2010-08-19 8:50 ` Matthieu Moy
2010-08-18 13:43 ` Ævar Arnfjörð Bjarmason
2010-08-18 13:47 ` Matthieu Moy
2010-08-18 14:02 ` Ævar Arnfjörð Bjarmason
2010-08-19 0:00 ` Jonathan Nieder
2010-08-19 0:24 ` Ævar Arnfjörð Bjarmason
2010-08-25 3:13 ` Jonathan Nieder
2010-08-29 18:27 ` Ævar Arnfjörð Bjarmason
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=AANLkTimODL6j11D6QuUX4b47GwFOVOXdqkhqrRfRaxmq@mail.gmail.com \
--to=gdb@mit.edu \
--cc=Jens.Lehmann@web.de \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).