aboutsummaryrefslogtreecommitdiffstats
path: root/testing/etckeeper/0001-30store-metadata-fix-bug-when-listfile-is-empty.patch
blob: 6b74f97e292768068ccbe0e6cbf7c7cb17f9156d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From 4ba839ff1898331f55947dcbee4b132a6bc96f18 Mon Sep 17 00:00:00 2001
From: Henrik Riomar <henrik.riomar@gmail.com>
Date: Wed, 15 Mar 2017 18:26:32 +0100
Subject: [PATCH] 30store-metadata: fix bug when $listfile is empty

(cherry picked from commit fad539b0ed762a7f6bc1bd94e64351ef56a25f2a)
---
 pre-commit.d/30store-metadata | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/pre-commit.d/30store-metadata b/pre-commit.d/30store-metadata
index 6d7d4b1..1e624dc 100755
--- a/pre-commit.d/30store-metadata
+++ b/pre-commit.d/30store-metadata
@@ -20,7 +20,11 @@ filter_ignore() {
 				;;
 			git)
 				(git ls-files -oi --exclude-standard; git ls-files -oi --exclude-standard --directory) | sort | uniq > "$listfile" || true
-				sed 's/^\.\///' | grep -xFvf "$listfile"
+				if [ -s "$listfile" ]; then
+					sed 's/^\.\///' | grep -xFvf "$listfile"
+				else
+					cat -
+				fi
 				;;
 		esac
 		rm -f "$listfile"
-- 
2.1.4