From: Greg Brockman <gdb@MIT.EDU>
To: avarab@gmail.com, Matthieu.Moy@grenoble-inp.fr,
git@vger.kernel.org, gitster@pobox.com, Jens.Lehmann@web.de,
jrnieder@gmail.com
Cc: Greg Brockman <gdb@mit.edu>
Subject: [RFC/PATCH] Add test case for dealing with a tracked file in an ignored directory
Date: Wed, 18 Aug 2010 04:29:48 -0500 [thread overview]
Message-ID: <1282123788-24055-1-git-send-email-gdb@mit.edu> (raw)
In-Reply-To: <AANLkTiky+azVAnXEBFWR1q9_8NH8TX2TfuonXCpA_-ms@mail.gmail.com>
This test case attempts to match the behavior of 'git add ignore-file'
with 'git add ignore-dir/file' when .gitignore contains entries for
ignore-file and ignore-dir.
---
t/t3700-add.sh | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
This patch is a follow-up to the thread '[RFC/PATCH] git-add: Don't
exclude explicitly-specified tracked files' at
http://thread.gmane.org/gmane.comp.version-control.git/153194
In this patch, I propose the desired behavior of 'git add' for files
contained in ignored directories. I have attempted to mirror the
behavior of 'git add' for ignored files, but I may have gotten that
wrong or that might not actually be what we want here. Comments on
whether this is the desired behavior and whether these test-cases
accurate capture that behavior would be appreciated.
Thank you,
Greg
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 7d7140d..97ba9e9 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -288,4 +288,34 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file' '
test_cmp expect.err actual.err
'
+cat >expect <<EOF
+The following paths are ignored by one of your .gitignore files:
+ignored-dir
+Use -f if you really want to add them.
+fatal: no files added
+EOF
+
+test_expect_success 'git add with file in ignored directory' '
+ mkdir ignored-dir &&
+ echo ignored-dir >> .gitignore &&
+ touch ignored-dir/file &&
+ test_must_fail git add ignored-dir/file >actual 2>&1 &&
+ test_cmp actual expect &&
+ git add -f ignored-dir/file &&
+ git add ignored-dir/file &&
+ echo change > ignored-dir/file &&
+ git add ignored-dir/file &&
+ ! ( git ls-files -m ignored-dir/file | grep ignored-dir/file )
+'
+
+test_expect_success 'git add with ignored directory using git globs' "
+ mkdir ignored-dir2 && echo ignored-dir2 >> .gitignore && touch ignored-dir2/file &&
+ git add 'ignored-dir2/*' >actual 2>&1 &&
+ echo \"fatal: pathspec 'ignored-dir2/*' did not match any files\" | test_cmp - actual
+ git add -f ignored-dir2/file && echo change > ignored-dir2/file &&
+ git add 'ignored-dir2/*' >actual 2>&1 &&
+ echo '' | test_cmp - actual &&
+ git ls-files -m ignored-dir2/file | grep ignored-dir2/file
+"
+
test_done
--
1.7.2.1.68.g1ba78
next prev parent reply other threads:[~2010-08-18 9:30 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
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 ` Greg Brockman [this message]
2010-08-18 9:43 ` [RFC/PATCH] Add test case for dealing with a tracked file in an ignored directory 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=1282123788-24055-1-git-send-email-gdb@mit.edu \
--to=gdb@mit.edu \
--cc=Jens.Lehmann@web.de \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@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).