]> code.delx.au - gnu-emacs/commitdiff
Add command-line option-parsing to gitlog-to-emacslog.
authorGlenn Morris <rgm@gnu.org>
Sat, 9 May 2015 00:45:22 +0000 (20:45 -0400)
committerGlenn Morris <rgm@gnu.org>
Sat, 9 May 2015 00:45:22 +0000 (20:45 -0400)
* build-aux/gitlog-to-emacslog: Add command-line options.
By default, refuse to remove an existing output file.
* Makefile.in (CHANGELOG): Update default.
(ChangeLog): Do not test for existing file.
(change-history-nocommit): Ensure temp file does not exist.

Makefile.in
build-aux/gitlog-to-emacslog

index e8780c22d4ae5083b9043fed6cb6934604baf8cf..7ae81b0b21717fcd4f538e4406a83f19e50f4854 100644 (file)
@@ -1091,17 +1091,15 @@ bootstrap: bootstrap-clean
 .PHONY: ChangeLog change-history change-history-commit change-history-nocommit
 .PHONY: master-branch-is-current unchanged-history-files
 
-CHANGELOG =
+CHANGELOG = ChangeLog
 emacslog = $(srcdir)/build-aux/gitlog-to-emacslog
 
 # Convert git commit log to ChangeLog file.  make-dist uses this.
 # I guess this is PHONY because it generates in distprefix (which is
 # non-nil when called from make-dist)?
-# FIXME: test -f does not respect distprefix.
 ChangeLog:
-       @[ -n "${CHANGELOG}" ] || test ! -f ChangeLog
        $(AM_V_GEN)distprefix=$(distprefix) srcprefix=$(srcdir)/ \
-       $(emacslog) . $(CHANGELOG)
+       $(emacslog) -o $(CHANGELOG)
 
 # The ChangeLog history files are called ChangeLog.1, ChangeLog.2, ...,
 # ChangeLog.$(CHANGELOG_HISTORY_INDEX_MAX).  $(CHANGELOG_N) stands for
@@ -1119,6 +1117,7 @@ unchanged-history-files:
 # Copy newer commit messages to the start of the ChangeLog history file,
 # and consider them to be older.
 change-history-nocommit: master-branch-is-current unchanged-history-files
+       -rm -f ChangeLog.tmp
        $(MAKE) ChangeLog CHANGELOG=ChangeLog.tmp
        (sed '/^;; [L]ocal Variables:/,$$d' <ChangeLog.tmp && cat $(CHANGELOG_N)) \
          >$(CHANGELOG_N).tmp
index a657cce0b6133f68ead00c2da1853457fb35bee1..2e5741c16f6175d8770e7509b7231b0ee0ae3a8e 100755 (executable)
@@ -24,15 +24,26 @@ export LC_ALL
 
 # The newest revision that should not appear in the generated ChangeLog.
 gen_origin=2c1b8604946efbcd8ec5dd6c6dda7541ce4fc3c0
-test -n "$1" && test "$1" != "." && gen_origin=$1
-
-output=$2
-test -n "$output" || output=ChangeLog
+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}$output" || exit
   >"${distprefix}$output"
   exit
 }