git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] log --oneline: put decoration at the end of the line

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Sep 19, 2012, 11:52 UTC
Message-ID
<1348055540-13774-1-git-send-email-pclouds@gmail.com>

I find it easier to read "git log --oneline" when the subject lines align, which they don't when the log is decorated because the decoration stands before the subject line.

I'm on colored output so moving decoration to the end of line does not make it harder to recognize refs. What about black-and-white people? We could right align the decoration if it makes it easier for the black-and-whites to read (but not to the right edge when the screen is too wide)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 log-tree.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/log-tree.c b/log-tree.c
index c894930..c51c942 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -616,11 +616,12 @@ void show_log(struct rev_info *opt)
 			printf(" (from %s)",
 			       find_unique_abbrev(parent->object.sha1,
 						  abbrev_commit));
-		show_decorations(opt, commit);
-		printf("%s", diff_get_color_opt(&opt->diffopt, DIFF_RESET));
 		if (opt->commit_format == CMIT_FMT_ONELINE) {
+			printf("%s", diff_get_color_opt(&opt->diffopt, DIFF_RESET));
 			putchar(' ');
 		} else {
+			show_decorations(opt, commit);
+			printf("%s", diff_get_color_opt(&opt->diffopt, DIFF_RESET));
 			putchar('\n');
 			graph_show_oneline(opt->graph);
 		}
@@ -682,6 +683,10 @@ void show_log(struct rev_info *opt)
 		graph_show_commit_msg(opt->graph, &msgbuf);
 	else
 		fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
+	if (opt->commit_format == CMIT_FMT_ONELINE) {
+		show_decorations(opt, commit);
+		printf("%s", diff_get_color_opt(&opt->diffopt, DIFF_RESET));
+	}
 	if (opt->use_terminator) {
 		if (!opt->missing_newline)
 			graph_show_padding(opt->graph);
-- 
1.7.12.403.gce5cf6f.dirty
Next: Jeff King
Message 1 of 21 in “log --oneline: put decoration at the end of the line”
  1. log --oneline: put decoration at the end of the lineNguyễn Thái Ngọc Duy, Sep 19, 2012
  2. Jeff KingSep 19, 2012
  3. Junio C HamanoSep 19, 2012
  4. Jeff KingSep 19, 2012
  5. Junio C HamanoSep 19, 2012
  6. Jeff KingSep 19, 2012
  7. Junio C HamanoSep 20, 2012
  8. Nguyen Thai Ngoc DuySep 20, 2012
  9. 0/2 New pretty format color specifiers %C+ and %C-Nguyễn Thái Ngọc Duy, Sep 20, 2012
  10. 1/2 pretty: share code between format_decoration and show_decorationsNguyễn Thái Ngọc Duy, Sep 20, 2012
  11. 2/2 pretty: support placeholders %C+ and %C-Nguyễn Thái Ngọc Duy, Sep 20, 2012
  12. Nguyen Thai Ngoc DuySep 20, 2012
  13. Junio C HamanoSep 20, 2012
  14. Nguyen Thai Ngoc DuySep 21, 2012
  15. Junio C HamanoSep 21, 2012
  16. Junio C HamanoSep 23, 2012
  17. Jeff KingSep 25, 2012
  18. Nguyen Thai Ngoc DuySep 21, 2012
  19. Junio C HamanoSep 20, 2012
  20. Junio C HamanoSep 20, 2012
  21. Nguyen Thai Ngoc DuySep 21, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.