9ecd5b8
From 2d1f19f2615f73eba8a95765a982492b385699b7 Mon Sep 17 00:00:00 2001
9ecd5b8
From: Wesley Dawson <whd@mozilla.com>
9ecd5b8
Date: Sun, 30 Nov 2014 23:27:00 -0800
9ecd5b8
Subject: [PATCH] journalctl: respect --after-cursor semantics with --follow in
9ecd5b8
 all cases
9ecd5b8
9ecd5b8
In the case where no entries have been added to the journal after the specified
9ecd5b8
cursor, set need_seek before the main loop to prevent display of the entry at
9ecd5b8
said cursor.
9ecd5b8
9ecd5b8
(cherry picked from commit 8ee8e53648bf45854d92b60e1e70c17a0cec3c3d)
9ecd5b8
---
9ecd5b8
 src/journal/journalctl.c | 8 ++++++--
9ecd5b8
 1 file changed, 6 insertions(+), 2 deletions(-)
9ecd5b8
9ecd5b8
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
9ecd5b8
index 03579fde09..03a3caec7c 100644
9ecd5b8
--- a/src/journal/journalctl.c
9ecd5b8
+++ b/src/journal/journalctl.c
9ecd5b8
@@ -1918,9 +1918,13 @@ int main(int argc, char *argv[]) {
9ecd5b8
                 else
9ecd5b8
                         r = sd_journal_previous_skip(j, 1 + !!arg_after_cursor);
9ecd5b8
 
9ecd5b8
-                if (arg_after_cursor && r < 2 && !arg_follow)
9ecd5b8
+                if (arg_after_cursor && r < 2) {
9ecd5b8
                         /* We couldn't find the next entry after the cursor. */
9ecd5b8
-                        arg_lines = 0;
9ecd5b8
+                        if (arg_follow)
9ecd5b8
+                                need_seek = true;
9ecd5b8
+                        else
9ecd5b8
+                                arg_lines = 0;
9ecd5b8
+                }
9ecd5b8
 
9ecd5b8
         } else if (arg_since_set && !arg_reverse) {
9ecd5b8
                 r = sd_journal_seek_realtime_usec(j, arg_since);