Blame SOURCES/0348-journalctl-properly-detect-empty-journal-files.patch

17b0f1
From 8290b73eeb8da4f8f0076f3bb7e23990af734de0 Mon Sep 17 00:00:00 2001
17b0f1
From: Lennart Poettering <lennart@poettering.net>
17b0f1
Date: Fri, 24 Jul 2015 02:10:32 +0200
17b0f1
Subject: [PATCH] journalctl: properly detect empty journal files
17b0f1
17b0f1
When we encounter a journal file with exactly zero entries, print a nice
17b0f1
message and exit, and don't print a weird error message.
17b0f1
17b0f1
Cherry-picked from: 02ab86c732576a71179ce12e97d44c289833236d
17b0f1
Related: #1350232
17b0f1
---
17b0f1
 src/journal/journalctl.c | 6 ++++++
17b0f1
 1 file changed, 6 insertions(+)
17b0f1
17b0f1
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
17b0f1
index 6948ed689d..904aae99ed 100644
17b0f1
--- a/src/journal/journalctl.c
17b0f1
+++ b/src/journal/journalctl.c
17b0f1
@@ -2141,6 +2141,12 @@ int main(int argc, char *argv[]) {
17b0f1
                 return EXIT_FAILURE;
17b0f1
         }
17b0f1
 
17b0f1
+        if (r == 0) {
17b0f1
+                printf("-- No entries --\n");
17b0f1
+                return EXIT_SUCCESS;
17b0f1
+        }
17b0f1
+
17b0f1
+
17b0f1
         if (!arg_follow)
17b0f1
                 pager_open_if_enabled();
17b0f1