4 ms·
How do you test the thing you're actually committing without everything else in your working tree contaminating your test? There are ways to do this using stas
by xenomachina 9y ago
How do you test the thing you're actually committing without everything else in your working tree contaminating your test?
There are ways to do this using stash but if you stash before you commit, you get merge conflicts when you pop the stash. The workaround I've seen is to commit before you stash, but that means you're also committing before you've actually tested that change, which seems pretty broken, IMHO.
- kazagistar 9y agoCommits are just a bit of local data. Until you push it out somewhere public, it's all just a big mushy pallette to do with as you will.
- imtringued 9y agoCreate a new branch for each issue where you create broken untested garbage commits with meaningless messages like "Fix". When you're done: git checkout master git merge --squash <branch_name> git commit -m "<Real commit message here>"
- sunny256 9y agoI've created a script for this, it applies the staged changes to a fresh clone and executes the command you specify. To quote from --help: If you have lots of unrelated uncommitted changes in the current repository and want to split up the commit, how can you easily check if the changes passes the test suite? With all the other unrelated changes it can be hard to make sure that only relevant changes becomes part of the commit, and that they don't result in regressions. This script clones the repository to the directory ".testadd.tmp" in the current directory and applies the staged changes there (unless -u/--unmodified or -p/--pristine is specified), chdirs to the same relative directory in the clone and executes the command specified on the command line there. It's available from https://github.com/sunny256/utils/blob/master/git-testadd https://github.com/sunny256/utils/blob/master/git-testadd and the test suite (place it in a subdirectory below the script) is at https://github.com/sunny256/utils/blob/master/tests/git-testadd.t https://github.com/sunny256/utils/blob/master/tests/git-test... It's stable, and I've been using it almost every day for 1.5 years. It also works with binary files.