brucemiller/LaTeXML — pull request #33 by dginev (2014-01-18 16:36:27+00:00)
Title:  making pre-commit aware of files with both staged and unstaged changes;...

... focus only on the staged file

When you first do a:
```
git add foo.pm
git commit -m 'foo'
```
and the commit gets aborted, the follow-up is to run:
```
tools/latexmllint foo.pm
```

Which will reformat and invite you to do local modifications. Once all is done you get a status report looking like:
```
$ git status
# On branch latexmllint_on_staged_content_only
# Changes to be committed:
# (use "git reset HEAD ..." to unstage)
#
#	modified: lib/LaTeXML.pm
#
# Changes not staged for commit:
# (use "git add ..." to update what will be committed)
# (use "git checkout -- ..." to discard changes in working directory)
#
#	modified: lib/LaTeXML.pm
```

and the porcelain status will tell you this is an ```MM lib/LaTeXML.pm``` state of that Perl class.

The master pre-commit always looked at the file on disk, which is *unstaged* in this circumstance (it is missing a ```git add``` to stage it alongside the rest of the changes for the commit). To this end, I have reworked the pre-commit hook to use ```git show``` in order to obtain only the file as it is *staged* for committing and lint that version.

The flaw is that since latexmllint doesn't support STDIN input, I need to write a temporary file (which I tentatively call ```foo.lint.ext``` for any file ```foo.ext``` which I then run latexmllint on and delete in the end).

That works perfectly and survives my example, never allowing to commit changes that don't comply with latexmllint. Once all changes are *staged*, it succeeds as expected.