All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit
@ 2019-03-23  4:13 Alex Henrie
  2019-03-23  6:03 ` Abhisek Ghosh
  2019-03-24 13:03 ` [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit Junio C Hamano
  0 siblings, 2 replies; 10+ messages in thread
From: Alex Henrie @ 2019-03-23  4:13 UTC (permalink / raw)
  To: git, gitster; +Cc: Alex Henrie

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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* (no subject)
  2019-03-23  4:13 [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit Alex Henrie
@ 2019-03-23  6:03 ` Abhisek Ghosh
  2019-03-24 13:03 ` [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit Junio C Hamano
  1 sibling, 0 replies; 10+ messages in thread
From: Abhisek Ghosh @ 2019-03-23  6:03 UTC (permalink / raw)
  To: git

unsubscribe git

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit
  2019-03-23  4:13 [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit Alex Henrie
  2019-03-23  6:03 ` Abhisek Ghosh
@ 2019-03-24 13:03 ` Junio C Hamano
  2019-03-24 18:58   ` Ævar Arnfjörð Bjarmason
  2019-03-24 22:37   ` Alex Henrie
  1 sibling, 2 replies; 10+ messages in thread
From: Junio C Hamano @ 2019-03-24 13:03 UTC (permalink / raw)
  To: Alex Henrie; +Cc: git

Alex Henrie <alexhenrie24@gmail.com> writes:

> Having --pretty=medium as the default almost always makes the graph too
> difficult to follow.
>
> Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
> ---

I too thought that "--graph" should make "--oneline" the default
back when I originally accepted the patch series that introduced the
"--graph" feature, but with frequent use of "--graph" myself, I
stopped being sure that "--oneline" should be the default long time
ago.  I find that the default level of prettiness goes reasonably
well with the "--graph" option.

This would be something that needs a long transition period if
somebody really wants to force people to adapt to it.  I am not sure
if the complication is worth it.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit
  2019-03-24 13:03 ` [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit Junio C Hamano
@ 2019-03-24 18:58   ` Ævar Arnfjörð Bjarmason
  2019-03-24 22:37   ` Alex Henrie
  1 sibling, 0 replies; 10+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2019-03-24 18:58 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Alex Henrie, git


On Sun, Mar 24 2019, Junio C Hamano wrote:

> Alex Henrie <alexhenrie24@gmail.com> writes:
>
>> Having --pretty=medium as the default almost always makes the graph too
>> difficult to follow.
>>
>> Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
>> ---
>
> I too thought that "--graph" should make "--oneline" the default
> back when I originally accepted the patch series that introduced the
> "--graph" feature, but with frequent use of "--graph" myself, I
> stopped being sure that "--oneline" should be the default long time
> ago.  I find that the default level of prettiness goes reasonably
> well with the "--graph" option.
>
> This would be something that needs a long transition period if
> somebody really wants to force people to adapt to it.  I am not sure
> if the complication is worth it.

Aside from historical/backcompat concerns I think the current rendering
makes sense. One could also argue that e.g. --stat benefits from
--oneline.

We shouldn't have unrelated options implying one another, except stuff
like "--compact-summary" implying "--stat" (makes no sense
otherwise...).

I use --graph without --oneline more frequently than not. It gives you a
glance at how deep in a merge hierarchy some log range is, whereas with
--oneline you're most involved in the shape of that graph to the
exclusion of other things.

But maybe a built-in "git-graph" is in order? E.g. one can imagine that
once we have a dedicated command for that (similar to range-diff) you
could really focus on the UX of that, e.g. going further than --oneline
and truncating a N+ divergence as "...and N more.." or something.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit
  2019-03-24 13:03 ` [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit Junio C Hamano
  2019-03-24 18:58   ` Ævar Arnfjörð Bjarmason
@ 2019-03-24 22:37   ` Alex Henrie
  2019-03-25  1:17     ` Rafael Ascensão
  1 sibling, 1 reply; 10+ messages in thread
From: Alex Henrie @ 2019-03-24 22:37 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git mailing list

On Sun, Mar 24, 2019 at 7:03 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Alex Henrie <alexhenrie24@gmail.com> writes:
>
> > Having --pretty=medium as the default almost always makes the graph too
> > difficult to follow.
> >
> > Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
> > ---
>
> I too thought that "--graph" should make "--oneline" the default
> back when I originally accepted the patch series that introduced the
> "--graph" feature, but with frequent use of "--graph" myself, I
> stopped being sure that "--oneline" should be the default long time
> ago.  I find that the default level of prettiness goes reasonably
> well with the "--graph" option.
>
> This would be something that needs a long transition period if
> somebody really wants to force people to adapt to it.  I am not sure
> if the complication is worth it.

Can we compromise and make --pretty=short the default for --graph?

-Alex

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit
  2019-03-24 22:37   ` Alex Henrie
@ 2019-03-25  1:17     ` Rafael Ascensão
  2019-03-25  5:10       ` Alex Henrie
  2019-04-01 10:45       ` Junio C Hamano
  0 siblings, 2 replies; 10+ messages in thread
From: Rafael Ascensão @ 2019-03-25  1:17 UTC (permalink / raw)
  To: Alex Henrie; +Cc: Junio C Hamano, Git mailing list

Hi Alex,

On Sun, Mar 24, 2019 at 04:37:25PM -0600, Alex Henrie wrote:
> 
> Can we compromise and make --pretty=short the default for --graph?
> 

I agree that `pretty=medium` is sometimes hard to read and, as of now,
`pretty=oneline` can be very misleading:

    $ git log --graph --oneline todo~2..todo master~2..master

This will look like you have a sequence of commits when in fact they are
completely unrelated.

But If we make the default to 'short' (or anything else), what should be
done if the user has `format.pretty=` defined to something? Is `--graph`
special to be allowed to not follow said configuration?

It's inconsistent itself, and introduces inconsistencies on other things
like the configuration above.

In my opinion, a better alternative could be having a configuration like
log.graphFormat, similarly how we have log.graphColors for colors, to
determine which format should be used with --graph.

This would still require user configuration which may be what you were
trying to avoid by proposing the change in default behaviour.

Settling for a compromise feels like giving up on the strengths from both.

Cheers,
Rafael Ascensão

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit
  2019-03-25  1:17     ` Rafael Ascensão
@ 2019-03-25  5:10       ` Alex Henrie
  2019-03-25  5:16         ` Alex Henrie
  2019-04-01 10:45       ` Junio C Hamano
  1 sibling, 1 reply; 10+ messages in thread
From: Alex Henrie @ 2019-03-25  5:10 UTC (permalink / raw)
  To: Rafael Ascensão, Ævar Arnfjörð Bjarmason,
	Junio C Hamano
  Cc: Git mailing list

On Sun, Mar 24, 2019 at 7:18 PM Rafael Ascensão <rafa.almas@gmail.com> wrote:
>
> But If we make the default to 'short' (or anything else), what should be
> done if the user has `format.pretty=` defined to something? Is `--graph`
> special to be allowed to not follow said configuration?
>
> It's inconsistent itself, and introduces inconsistencies on other things
> like the configuration above.
>
> In my opinion, a better alternative could be having a configuration like
> log.graphFormat, similarly how we have log.graphColors for colors, to
> determine which format should be used with --graph.

The way that I wrote the patch, if format.pretty is not defined then
`git log` will default to one format and `git log --graph` will
default to another. I admit that it is a bit of a hack.

On Sun, Mar 24, 2019 at 12:58 PM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> But maybe a built-in "git-graph" is in order? E.g. one can imagine that
> once we have a dedicated command for that (similar to range-diff) you
> could really focus on the UX of that, e.g. going further than --oneline
> and truncating a N+ divergence as "...and N more.." or something.

I like the idea of a completely separate `git graph` command. This
command would simply be a builtin alias for `git log --abbrev-commit
--pretty=oneline`, like how `git reflog` is a builtin alias for `git
log -g --abbrev-commit --pretty=oneline`. Junio, would you be on board
with that?

-Alex

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit
  2019-03-25  5:10       ` Alex Henrie
@ 2019-03-25  5:16         ` Alex Henrie
       [not found]           ` <CACUQV59x-W+fCz_O5EnbZhjZ1CB2NhEQbkR8dAYMizAQGQ2SFA@mail.gmail.com>
  0 siblings, 1 reply; 10+ messages in thread
From: Alex Henrie @ 2019-03-25  5:16 UTC (permalink / raw)
  To: Rafael Ascensão, Ævar Arnfjörð Bjarmason,
	Junio C Hamano
  Cc: Git mailing list

On Sun, Mar 24, 2019 at 11:10 PM Alex Henrie <alexhenrie24@gmail.com> wrote:
>
> I like the idea of a completely separate `git graph` command. This
> command would simply be a builtin alias for `git log --abbrev-commit
> --pretty=oneline`, like how `git reflog` is a builtin alias for `git
> log -g --abbrev-commit --pretty=oneline`. Junio, would you be on board
> with that?

Sorry, I left off the --graph parameter. You can set up what I'm
proposing as a personal alias with the following command:

git config --global alias.graph 'log --graph --abbrev-commit --pretty=oneline'

-Alex

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit
       [not found]           ` <CACUQV59x-W+fCz_O5EnbZhjZ1CB2NhEQbkR8dAYMizAQGQ2SFA@mail.gmail.com>
@ 2019-03-27 17:49             ` Alex Henrie
  0 siblings, 0 replies; 10+ messages in thread
From: Alex Henrie @ 2019-03-27 17:49 UTC (permalink / raw)
  To: Rafael Ascensão
  Cc: Ævar Arnfjörð Bjarmason, Junio C Hamano, Git mailing list

On Sun, Mar 24, 2019 at 11:27 PM Rafael Ascensão <rafa.almas@gmail.com> wrote:
>
> Or just $git log --graph --oneline, since --oneline is a shortcut for the longer --pretty=oneline --abbrev-commit.

Thanks for the tip! I didn't know about the --oneline option, but now
that I do, I suppose I don't really need an alias.

-Alex

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit
  2019-03-25  1:17     ` Rafael Ascensão
  2019-03-25  5:10       ` Alex Henrie
@ 2019-04-01 10:45       ` Junio C Hamano
  1 sibling, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2019-04-01 10:45 UTC (permalink / raw)
  To: Rafael Ascensão; +Cc: Alex Henrie, Git mailing list

Rafael Ascensão <rafa.almas@gmail.com> writes:

> I agree that `pretty=medium` is sometimes hard to read and, as of now,
> `pretty=oneline` can be very misleading:
>
>     $ git log --graph --oneline todo~2..todo master~2..master
>
> This will look like you have a sequence of commits when in fact they are
> completely unrelated.

This is pretty much unrelated to which level of details should be
the default, isn't it?

I do agree that --graph should be more intelligent around the root
commits when showing two or more unrelated lines of histories.

Something like [*1*] from discussion in 2013 (not the patch that
started the thread, for reasons stated in the thread, but ideas
offered as alternative design in the discussion) would be the right
way to solve it and it would work with all the log formatting
options, whether --oneline, --pretty=medium, etc.

[Reference]


*1* http://public-inbox.org/git/1382717268-21884-1-git-send-email-milton.soares.filho@gmail.com/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-04-01 10:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-23  4:13 [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit Alex Henrie
2019-03-23  6:03 ` Abhisek Ghosh
2019-03-24 13:03 ` [PATCH] In `git log --graph`, default to --pretty=oneline --abbrev-commit Junio C Hamano
2019-03-24 18:58   ` Ævar Arnfjörð Bjarmason
2019-03-24 22:37   ` Alex Henrie
2019-03-25  1:17     ` Rafael Ascensão
2019-03-25  5:10       ` Alex Henrie
2019-03-25  5:16         ` Alex Henrie
     [not found]           ` <CACUQV59x-W+fCz_O5EnbZhjZ1CB2NhEQbkR8dAYMizAQGQ2SFA@mail.gmail.com>
2019-03-27 17:49             ` Alex Henrie
2019-04-01 10:45       ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.