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

[PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit

From
Alex Henrie <alexhenrie24@gmail.com>
Date
Mar 23, 2019, 04:13 UTC
Message-ID
<20190323041332.9743-1-alexhenrie24@gmail.com>

Having --pretty=medium as the default almost always makes the graph too difficult to follow.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
 builtin/log.c          |  5 +++++
 t/t4052-stat-output.sh | 14 +++++++-------
 t/t4202-log.sh         | 14 ++++++++++++++
 3 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/builtin/log.c b/builtin/log.c
index ab859f5904..4fca910fee 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -199,6 +199,11 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 	memset(&w, 0, sizeof(w));
 	userformat_find_requirements(NULL, &w);
 
+	if (rev->graph && !fmt_pretty && !rev->pretty_given && !rev->show_signature) {
+		rev->abbrev_commit = 1;
+		rev->commit_format = CMIT_FMT_ONELINE;
+	}
+
 	if (!rev->show_notes_given && (!rev->pretty_given || w.notes))
 		rev->show_notes = 1;
 	if (rev->show_notes)
diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
index 28c053849a..b44776efe3 100755
--- a/t/t4052-stat-output.sh
+++ b/t/t4052-stat-output.sh
@@ -144,7 +144,7 @@ done <<\EOF
 ignores expect72 format-patch -1 --stdout
 respects expect200 diff HEAD^ HEAD --stat
 respects expect200 show --stat
-respects expect200 log -1 --stat
+respects expect200 log -1 --pretty=medium --stat
 EOF
 
 cat >expect40 <<'EOF'
@@ -172,7 +172,7 @@ done <<\EOF
 ignores expect72 format-patch -1 --stdout
 respects expect40 diff HEAD^ HEAD --stat
 respects expect40 show --stat
-respects expect40 log -1 --stat
+respects expect40 log -1 --pretty=medium --stat
 EOF
 
 cat >expect40 <<'EOF'
@@ -200,7 +200,7 @@ done <<\EOF
 ignores expect72 format-patch -1 --stdout
 respects expect40 diff HEAD^ HEAD --stat
 respects expect40 show --stat
-respects expect40 log -1 --stat
+respects expect40 log -1 --pretty=medium --stat
 EOF
 
 
@@ -247,7 +247,7 @@ done <<\EOF
 format-patch -1 --stdout
 diff HEAD^ HEAD --stat
 show --stat
-log -1 --stat
+log -1 --pretty=medium --stat
 EOF
 
 test_expect_success 'preparation for long filename tests' '
@@ -281,7 +281,7 @@ done <<\EOF
 format-patch -1 --stdout
 diff HEAD^ HEAD --stat
 show --stat
-log -1 --stat
+log -1 --pretty=medium --stat
 EOF
 
 cat >expect72 <<'EOF'
@@ -315,7 +315,7 @@ done <<\EOF
 ignores expect72 format-patch -1 --stdout
 respects expect200 diff HEAD^ HEAD --stat
 respects expect200 show --stat
-respects expect200 log -1 --stat
+respects expect200 log -1 --pretty=medium --stat
 EOF
 
 cat >expect1 <<'EOF'
@@ -345,7 +345,7 @@ done <<\EOF
 ignores expect72 format-patch -1 --stdout
 respects expect1 diff HEAD^ HEAD --stat
 respects expect1 show --stat
-respects expect1 log -1 --stat
+respects expect1 log -1 --pretty=medium --stat
 EOF
 
 cat >expect <<'EOF'
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 819c24d10e..7cf9f15cec 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -39,6 +39,20 @@ test_expect_success setup '
 
 '
 
+test_expect_success 'default log format' '
+
+	git log --pretty=medium > expect &&
+	git log > actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'default log --graph format' '
+
+	git log --graph --pretty=oneline --abbrev-commit > expect &&
+	git log --graph > actual &&
+	test_cmp expect actual
+'
+
 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
 test_expect_success 'pretty' '
 
-- 
2.21.0
Next: Abhisek Ghosh
Message 1 of 10 in “In `git log --graph`, default to --pretty=oneline --abbrev-commit”
  1. In `git log --graph`, default to --pretty=oneline --abbrev-commitAlex Henrie, Mar 23, 2019
  2. Abhisek Ghosh, Mar 23, 2019
  3. Junio C HamanoMar 24, 2019
  4. Ævar Arnfjörð BjarmasonMar 24, 2019
  5. Alex HenrieMar 24, 2019
  6. Rafael AscensãoMar 25, 2019
  7. Alex HenrieMar 25, 2019
  8. Alex HenrieMar 25, 2019
  9. Junio C HamanoApr 1, 2019
  10. Alex HenrieMar 27, 2019

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.