.topdeps: tolerate missing \n on last line
commit22a5a5565b39a324625f10dc7433656bc9f4f16b
authorKyle J. McKay <mackyle@gmail.com>
Tue, 13 Jun 2017 03:52:27 +0000 (12 20:52 -0700)
committerKyle J. McKay <mackyle@gmail.com>
Tue, 13 Jun 2017 03:52:27 +0000 (12 20:52 -0700)
tree31a88050ce4a1ddca4356b3c37eeca94b93cf94e
parentaef6c4742598567b4d316dde5cd56f31b2fd629d
.topdeps: tolerate missing \n on last line

All of the tg commands themselves (`tg depend add` newly does
so now) are careful to make sure the .topdeps file has only
full, complete lines in it.  In other words, unless it's an
empty (i.e. zero length) .topdeps file, then every line ends
with a proper '\n'.

Unfortunately there are some poorly designed file editors out
there that make files appear as though they have an extra empty
line at the end when that line is properly terminated with a '\n'
even though there is actually no extra blank line.  Removing the
"phantom" blank line in such an editor and then saving the file
results in a last line that's missing its terminating '\n'
character.

When a .topdeps file is manually edited (naughty naughty) in such
a file editor it can end up missing its final terminating '\n'.

While it's certainly possible to add a check for this into the
pre-commit hook, that hook can easily be bypassed and furthermore
the ship has already sailed on all the newlineless .topdeps files
already checked in to existing repositories.

The recent awking acceleration affair magically caused most of the
issues dealing with such .topdeps files to just vanish (a combination
of using git cat-file --batch and awk to process them).

A previous commit already dealt with the problems such files produce
in diff output.

Alter the remaining places in the code that are sensitive to such
things to behave themselves when confronted with an unterminated
.topdeps file.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
hooks/pre-commit.sh
t/t2010-hook-checks.sh
tg-depend.sh
tg-info.sh
tg-log.sh
tg-revert.sh
tg-summary.sh
tg-update.sh