summaryrefslogtreecommitdiff
path: root/set-serial.sh
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@gmail.com>2010-12-06 17:03:08 +0100
committerPeter Simons <simons@cryp.to>2010-12-18 17:31:42 +0100
commit8b51fe3fc2de9b233e1d86959e5c657d29c5b521 (patch)
treee5afd64e7cddee6185b269463df7726097a9d91b /set-serial.sh
parenta61505239398139eec7deb64b785bfc24e5e3e54 (diff)
downloadautoconf-archive-8b51fe3fc2de9b233e1d86959e5c657d29c5b521.tar.gz
set-serial.sh: make more portable, faster and safer.
POSIX sh disallows dashes in function names, so rename the function to set_serial_number. Check for staged changes as well as non-staged once to see if the revision has to be increased further. Call set_serial_number just once in all cases, rather than calling it twice if there are both new revisions and scheduled changes.
Diffstat (limited to 'set-serial.sh')
-rwxr-xr-xset-serial.sh10
1 files changed, 5 insertions, 5 deletions
diff --git a/set-serial.sh b/set-serial.sh
index e6aa016..93a9140 100755
--- a/set-serial.sh
+++ b/set-serial.sh
@@ -2,7 +2,7 @@
set -eu
-set-serial-number()
+set_serial_number()
{
sed >"$1.tmp" -e '/^$/q' "$1"
echo >>"$1.tmp" "#serial $2"
@@ -15,11 +15,11 @@ for n in "$@"; do
echo "$n ... "
# Determine the number of revisions that have occurred to the macro.
revision=$(git log --oneline -- "$n" | wc -l)
- # Update the serial number in the m4 file.
- set-serial-number "$n" "$revision"
# Check whether git regards the file as "modified" now. If it does,
# the serial number needs to be bumped one more time.
- if ! git diff --quiet --exit-code -- "$n"; then
- set-serial-number "$n" "$((revision + 1))"
+ if ! git diff --quiet --exit-code HEAD -- "$n"; then
+ revision="$((revision + 1))"
fi
+ # Update the serial number in the m4 file.
+ set_serial_number "$n" "$revision"
done