I forgot a then in one of my previous patch, so here is a corrected version.
From 128966da603326c7f9ae8444a45136b3ca19ed76 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?R=C3=A9mi=20Vanicat?= <[EMAIL PROTECTED]>
Date: Tue, 13 Nov 2007 20:08:32 +0100
Subject: [PATCH] Render option to git commit configurable

When etckeeper commit something it use a default message that can be
configured, but not easily edited on a case by case basis.

To make this possible, and to give other way to customize commit, I
add a configuration file that contain for now only one option:
GIT_COMMIT_OPTION that can contain option given to git commit when run
by etckeeper
---
 Makefile                        |    1 +
 etckeeper                       |    8 ++++++++
 etckeeper.conf                  |    5 +++++
 post-apt.d/50git-commit         |    2 +-
 pre-apt.d/50uncommitted-changes |    2 +-
 5 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 etckeeper.conf

diff --git a/Makefile b/Makefile
index 30a60b8..17b49b8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
 install:
 	mkdir -p $(PREFIX)/etc/etckeeper/
 	cp -a *.d $(PREFIX)/etc/etckeeper/
+	cp etckeeper.conf $(PREFIX)/etc/etckeeper/
 	install -D etckeeper $(PREFIX)/usr/bin/etckeeper
 	install -m 0644 -D apt.conf $(PREFIX)/etc/apt/apt.conf.d/05etckeeper
 	install -m 0644 -D etckeeper.1 $(PREFIX)/usr/share/man/man1/etckeeper.1
diff --git a/etckeeper b/etckeeper
index 363f706..a9cf577 100755
--- a/etckeeper
+++ b/etckeeper
@@ -1,6 +1,14 @@
 #!/bin/sh
 set -e
 
+if [ -e /etc/etckeeper/etckeeper.conf ]; then
+	. /etc/etckeeper/etckeeper.conf
+fi
+
+if [ ! -z "$GIT_COMMIT_OPTION" ]; then
+	export GIT_COMMIT_OPTION
+fi
+
 if [ -z "$1" ]; then
 	echo "usage: etckeeper command [directory]" >&2
 	exit 1
diff --git a/etckeeper.conf b/etckeeper.conf
new file mode 100644
index 0000000..6941e10
--- /dev/null
+++ b/etckeeper.conf
@@ -0,0 +1,5 @@
+# GIT_COMMIT_OPTION : option given to git commit when run by etckeeper 
+# you could for exemple use GIT_COMMIT_OPTION="-e" if you want to edit
+# all commit message before commiting
+
+# GIT_COMMIT_OPTION=""
diff --git a/post-apt.d/50git-commit b/post-apt.d/50git-commit
index 6eb3434..fe5eb95 100755
--- a/post-apt.d/50git-commit
+++ b/post-apt.d/50git-commit
@@ -8,5 +8,5 @@ if [ -d .git ]; then
 	message="committing changes after apt run"
 
 	# ignore exit code since it exits nonzero if there is nothing to do
-	git commit -m "$message" || true
+	git commit $GIT_COMMIT_OPTION -m "$message" || true
 fi
diff --git a/pre-apt.d/50uncommitted-changes b/pre-apt.d/50uncommitted-changes
index dd8db13..eb3a64d 100755
--- a/pre-apt.d/50uncommitted-changes
+++ b/pre-apt.d/50uncommitted-changes
@@ -12,7 +12,7 @@ if [ -d .git ] && ! LANG=C git-status 2>&1 | grep -q "working directory clean";
 	db_get etckeeper/unclean
 	if [ "$RET" = true ]; then
 		git add .
-		if ! git commit -m "saving uncommitted changes in /etc prior to apt run"; then
+		if ! git commit $GIT_COMMIT_OPTION -m "saving uncommitted changes in /etc prior to apt run"; then
 			db_input critical etckeeper/commit_failed || true
 			db_go || true
 			db_reset etckeeper/commit_failed || true
-- 
1.5.3.5

Reply via email to