Re: [RFC/PATCH] Add test case for dealing with a tracked file in an ignored directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greg Brockman <gdb@xxxxxxx> writes:

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

Good :-).

> +test_expect_success 'git add with file in ignored directory' '

In the final version, you can make the tests test_expect_failure in
the first patch, and turn them back into test_expect_success in the
second (which fixes the issue). This makes it clear what your change
to the code do, and makes sure the test suite passes for each commit.

> +	mkdir ignored-dir &&
> +	echo ignored-dir >> .gitignore &&
> +	touch ignored-dir/file &&

I think >ignored-dir/file is more portable than touch, and is
recommanded in the testsuite. But a quick grep shows that touch is
already used.

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

(so, this is the first thing you're fixing, shouldn't be
controversial)

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

Currently, "git add 'dir/*'" will add the files under dir/ if dir/
isn't ignored, and require -f if dir is ignored.

I don't think you want to complain with "did not match any files"
here.

> +	git add -f ignored-dir2/file && echo change > ignored-dir2/file &&
> +	git add 'ignored-dir2/*' >actual 2>&1 &&

Just making sure I'm reading correctly: this is the second thing that
should be fixed, and that your earlier patch didn't.

You're not testing the case

  git add ignored-dir/

which gives another case where Git tries to add files not explicitely
given on the command-line. But the correct behavior of this case may
be more controversial, so maybe it's indeed better to focus on the
other cases.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]