From a159d14c79c86c441e834a513e7b27ea735c26ff Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@fb.com>
Date: Mon, 28 Apr 2014 17:51:25 -0700
Subject: [PATCH] maint: make ChangeLog generation more robust

* Makefile.am (gen-ChangeLog): Sync changes from GNU coreutils,
to ensure exit status is propagated, and to support an optional
git-log-fix file.
---
 Makefile.am | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 2be7292..e618a00 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -45,9 +45,12 @@ gen_start_date = 2009-11-27
 .PHONY: gen-ChangeLog
 gen-ChangeLog:
 	$(AM_V_GEN)if test -d .git; then				\
+	  log_fix="$(srcdir)/build-aux/git-log-fix";			\
+	  test -e "$$log_fix"						\
+	    && amend_git_log="--amend=$$log_fix"			\
+	    || amend_git_log=;						\
 	  $(top_srcdir)/build-aux/gitlog-to-changelog			\
-	    --amend=$(srcdir)/build-aux/git-log-fix			\
-	    --since=$(gen_start_date) > $(distdir)/cl-t;		\
-	  rm -f $(distdir)/ChangeLog;					\
-	  mv $(distdir)/cl-t $(distdir)/ChangeLog;			\
+	    $$amend_git_log --since=$(gen_start_date) > $(distdir)/cl-t && \
+	    { rm -f $(distdir)/ChangeLog &&				\
+	      mv $(distdir)/cl-t $(distdir)/ChangeLog; }		\
 	fi
-- 
2.0.0.rc0.38.g1697bf3

