#514651 is about "this should be possible", I wrote the below about "this should be easy", before I found #514651. I'll sending it just in chance it's actually useful.
I want to be able to say, on a user-wide basis, 1. these things are whitespace errors; 2. NEVER let me introduce whitespace errors. core.whitespace meets (1), but apply.whitespace=error doesn't meet (2), and there's nothing like commit.whitespace=error. I commit bad whitespace, and don't find out until I try to rebase it. And the rebase doesn't tell me what's wrong, it just says "apply failed". I want things like commit and cherry-pick to say something like Aborted foo/bar.c:123: introduces trailing whitespace foo/quux.c: does not end in a newline If I need to commit something like a PNG or a symlink that would trigger an abort, I'd just comment it out temporarily. Apparently this can be done with hooks or smudge/clean filters, but it's a bit fiddly to arrange for it to always happen. Below is the #git conversation that lead to this ticket. twb> So I'm a bit sad because apply.whitespace=error doesn't trigger because I use "git add -p" then "git commit". twb> But it *does* trigger when I do "git rebase master" on symlinks, because git's fake symlink files have no trailing newline. twb> This is with git version 1.7.0.4 -- anybody know offhand if that's magically fixed by "FFS just use a current version!"? twb> Oh also if I can get "git commit" to abort when there are whitespace errors, that would also be fantastic. twb> PS: this is also with core.whitespace = space-before-tab, tab-in-indent, trailing-space, cr-at-eol cbreak-work> twb: apply is just apply, not commit and so on twb> cbreak-work: yeah I realize that twb> I only turn it on for apply because AFAIK that's the only place I can turn it on kadoban> twb: You can, with hooks. I use it in code all the time, goes right before running the test cases and bailing if they fail. kadoban> twb: actually I think the example hook is something about bailing on whitespace errors, iirc twb> hooks are a bit fiddly because then I have to turn them on for every repo separately (right?) cbreak-work> twb: just like configuration, hooks are repository local and not part of the history twb> cbreak-work: yeah what I want is an option that applies to everything my user does, like ~/.gitconfig cbreak-work> twb: put the hooks into your repository template cbreak-work> then they'll be in all new repositories you create twb> cbreak-work: even ones I clone? I haven't heard of repo templates before cbreak-work> clone is just a git init & other stuff kadoban> Yeah, that's what I do. Getting it to work well in a lot of cases is actually pretty hairy...think I found a guide at one point cbreak-work> ll /usr/local/share/git-core/templates/ twb> Mm, I really just want a thing that says "these things are whitespace errors. Don't let me introduce them EVER" cbreak-work> twb: use git diff --check somethingsomething in a pre-commit hook twb> cbreak-work: OK, can I edit those in $HOME? I don't have root on all my hosts. cbreak-work> I don't think so. Maybe. twb> Bleh. cbreak-work> they are in git's $PREFIX twb> May I quote you guys in a feature request? kadoban> Me? Uh sure if you want to. cbreak-work> if you want. twb> Thanks. kadoban> I think if I was going to request any features on it, I'd want a way to make the hook act on "what's about to be commited", IIRC it ws pretty annoying to wrap it in git resets and stashes to get that right. cbreak-work> kadoban: git diff --cached should give you the index, and unless some noob uses the per-file commit, that should be correct twb> I don't want it to "fix" it I just want it to dump core and say "whitespace was crap at foo.c:123" kadoban> cbreak-work: Yeah I think it wasn't too bad for something like whitespace, but IIRC like, running my test-cases required way more work cbreak-work> kadoban: hmm... I'd probably use git checkout with an external working dir overlay cbreak-work> twb: if you wanted to fix it, a clean/smudge filter pair with auto formating or whitespace cleaning would do that. cbreak-work> twb: that can also be configured in the settings twb> Hm. cbreak-work> (but needs a .gitattributes) twb> I think I'll just file a feature request and wait for someone else to make it turnkey
signature.asc
Description: Digital signature