]> code.delx.au - gnu-emacs/blobdiff - build-aux/gitlog-to-emacslog
Add command-line option-parsing to gitlog-to-emacslog.
[gnu-emacs] / build-aux / gitlog-to-emacslog
index d994d140fe68fe2480edd771d92f4f251b3d782e..2e5741c16f6175d8770e7509b7231b0ee0ae3a8e 100755 (executable)
 LC_ALL=C
 export LC_ALL
 
-gen_origin=${1?}
+# The newest revision that should not appear in the generated ChangeLog.
+gen_origin=2c1b8604946efbcd8ec5dd6c6dda7541ce4fc3c0
+force=
+output=ChangeLog
+
+while [ $# -gt 0 ]; do
+  case "$1" in
+      -g|--gen-origin) gen_origin="$2" ; shift ;;
+      -f|--force) force=1 ;;
+      -o|--output) output="$2" ; shift ;;
+      *) echo "Unrecognized argument: $1" >&2; exit 1 ;;
+  esac
+  shift
+done
+
+if [ -f "${distprefix}$output" ]; then
+    [ ! "$force" ] && echo "${distprefix}$output exists" && exit 1
+    rm -f "${distprefix}$output" || exit 1
+fi
 
 # If this is not a Git repository, just generate an empty ChangeLog.
 test -d ${srcprefix}.git || {
-  # Remove any old ChangeLog, in case it is a vc-dwim symlink.
-  rm -f "${distprefix}ChangeLog" || exit
-  >"${distprefix}ChangeLog"
+  >"${distprefix}$output"
   exit
 }
 
 # Use Gnulib's packaged ChangeLog generator.
 ${srcprefix}build-aux/gitlog-to-changelog --ignore-matching='^; ' \
+  --format='%B' \
   "$gen_origin.." >"${distprefix}ChangeLog.tmp" || exit
 
 if test -s "${distprefix}ChangeLog.tmp"; then
@@ -77,4 +94,5 @@ if test -s "${distprefix}ChangeLog.tmp"; then
 fi
 
 # Install the generated ChangeLog.
-mv -i "${distprefix}ChangeLog.tmp" "${distprefix}ChangeLog"
+test "$output" = "ChangeLog.tmp" || \
+  mv -i "${distprefix}ChangeLog.tmp" "${distprefix}$output"