[PATCH v2 08/10] reflog-walk.c: move where the newline is added

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In a future commit, we want to possibly be able to continue the reflog message on
the same line without breaking the line. As a result, when
`oneline == 1`, strip any trailing new lines.

Add these missing newlines back in show_log().

While we're at it, cuddle the else with the closing brace of the if to
more closely match the existing style.

Signed-off-by: Denton Liu <liu.denton@xxxxxxxxx>
---
 log-tree.c    | 4 +++-
 reflog-walk.c | 8 +++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/log-tree.c b/log-tree.c
index 923a299e70..4a7d668af6 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -661,8 +661,10 @@ void show_log(struct rev_info *opt)
 					    opt->commit_format == CMIT_FMT_ONELINE,
 					    &opt->date_mode,
 					    opt->date_mode_explicit);
-			if (opt->commit_format == CMIT_FMT_ONELINE)
+			if (opt->commit_format == CMIT_FMT_ONELINE) {
+				putc('\n', opt->diffopt.file);
 				return;
+			}
 		}
 	}
 
diff --git a/reflog-walk.c b/reflog-walk.c
index 3a25b27d8f..6b6bd18e6c 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -285,9 +285,11 @@ void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,
 		info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
 		get_reflog_selector(&selector, reflog_info, dmode, force_date, 0);
 		if (oneline) {
-			printf("%s: %s", selector.buf, info->message);
-		}
-		else {
+			int len = strlen(info->message);
+			if (len > 0)
+				len--; /* strip away trailing newline */
+			printf("%s: %.*s", selector.buf, len, info->message);
+		} else {
 			printf("Reflog: %s (%s)\nReflog message: %s",
 			       selector.buf, info->email, info->message);
 		}
-- 
2.24.0.298.g3e88fbd976




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux