From 1e337bc9052be40e7ad0da62761b3256542f15d0 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Thu, 1 Mar 2018 20:06:45 -0500 Subject: [PATCH] don't commit messages.po if only POT-Creation-Date changed (#114) --- git-hooks/pre-commit | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/git-hooks/pre-commit b/git-hooks/pre-commit index f01b516ea..99f59729e 100755 --- a/git-hooks/pre-commit +++ b/git-hooks/pre-commit @@ -1,4 +1,14 @@ #!/bin/bash -make messages.po | grep -v 'is up to date\.$' -git add messages.po +make messages.po > /dev/null 2>&1 + +# This monstrosity asks how many lines changed, but it ignores changes to the +# "POT-Creation-Date" line. In other words, if all that's changed is the +# "POT-Creation-Date", don't bother adding messages.po +lines_changed=$(git -c difftool.ignorepot.cmd='diff -u -I "POT-Creation-Date" "$LOCAL" "$REMOTE"' difftool -t ignorepot -y messages.po | wc -l) + +if [ "$lines_changed" = 0 ]; then + git checkout messages.po +else + git add messages.po +fi