News for hackers. Stuff that matters.
Re:How to undo almost anything with Git by thyrsus on Monday June 08, 2015 @04:14PM (#9682066)
Something I'm still working out....

I have a directory tree full of test data. As the project goes along, the test data will evolve, and thus should go under revision control.

Testing needs to start with known files, so, hey!, git checkout test_data - except that means my latest code revisions need to go into the test_data branch even before they're tested :-(.

Then the tests make their changes to the data, which the tests check, and which I then want to throw away. So: "git checkout test_data -f; git clean -f" -- except that cleans out the source code area as well as the test data area.

I'm thinking the test data should be separate repository. Is that a mistake?

[Edit] I've tried looking at stackoverflow.com, but searching for "git testing" returned ~7000 articles, the first few hundred of which didn't look relevant.

Re:How to undo almost anything with Git by lmm on Monday June 08, 2015 @04:18PM (#9682087)
Keep the "pristine" version of the test data in src/ (checked into git), have the build process copy it into target/ (or build/ or whatever you want to call it; either way, ignored in git) before starting testing.
Re:How to undo almost anything with Git by phaemon on Monday June 08, 2015 @05:18PM (#9682506)
You can do:

git checkout test_data 'testdata/'

to only grab the 'testdata/' directory from that branch. You can do this with files with a pattern, like '*.c', as well.

Re:How to undo almost anything with Git by nothrabannosir on Monday June 08, 2015 @04:17PM (#9682082)
try putting test data templates in test_templates (under rev control), and doing rm -rf test_data, cp -r test_templates test_data at the start of your testing routine. Put test_data in .gitignore.

does that help?

Re:How to undo almost anything with Git by thyrsus on Monday June 08, 2015 @04:32PM (#9682168)
Thanks! On the one hand, git seems to restore the test data to its initial state faster than rm -r; cp -r, but I'm getting a strong hint from these answers that keeping the test data explicitly in sync with the code is worth the minor delay.
Re:How to undo almost anything with Git by pjc50 on Monday June 08, 2015 @05:41PM (#9682649)
Sounds like something that would be a lot easier to handle with "svn revert"..
Re:How to undo almost anything with Git by lmm on Tuesday June 09, 2015 @05:50AM (#9684878)
Only if you're looking for excuses to prefer svn. You can do the exact same thing you would with 'svn revert' with 'git checkout --'.