* [PATCH] graph.c: log.showRootMark to indicate root commits
@ 2018-04-01 20:57 Lyubomyr Shaydariv
2018-04-02 17:57 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Lyubomyr Shaydariv @ 2018-04-01 20:57 UTC (permalink / raw)
To: git
When log.showRootMark is set, root commits are marked with
the at sign (@).
When log.showRootMark is not set, root commits are marked with
the asterisk sign (*). This is the default behavior.
Signed-off-by: Lyubomyr Shaydariv <lsh.dev@ukr.net>
---
Documentation/config.txt | 5 +++++
Documentation/git-log.txt | 5 +++++
graph.c | 20 ++++++++++++++++++++
t/t4202-log.sh | 16 ++++++++++++++++
4 files changed, 46 insertions(+)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 4e0cff87f62f5..0a32357e3c625 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2254,6 +2254,11 @@ log.showRoot::
Tools like linkgit:git-log[1] or linkgit:git-whatchanged[1], which
normally hide the root commit will now show it. True by default.
+log.showRootMark::
+ If true, the initial commit in `git log --graph` will be marked
+ with the at sign (`@`). Otherwise the initial commit will be
+ marked with the default asterisk sign (`*`). False by default.
+
log.showSignature::
If true, makes linkgit:git-log[1], linkgit:git-show[1], and
linkgit:git-whatchanged[1] assume `--show-signature`.
diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index 5437f8b0f0e66..7f5436231b6d7 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -205,6 +205,11 @@ log.showRoot::
`git log -p` output would be shown without a diff attached.
The default is `true`.
+log.showRootMark::
+ If true, the initial commit in `git log --graph` will be marked
+ with the at sign (`@`). Otherwise the initial commit will be
+ marked with the default asterisk sign (`*`). False by default.
+
log.showSignature::
If `true`, `git log` and related commands will act as if the
`--show-signature` option was passed to them.
diff --git a/graph.c b/graph.c
index e1f6d3bddb38a..d14ffec7a975c 100644
--- a/graph.c
+++ b/graph.c
@@ -80,6 +80,7 @@ static void graph_show_line_prefix(const struct diff_options *diffopt)
static const char **column_colors;
static unsigned short column_colors_max;
+static int show_root_mark;
static void parse_graph_colors_config(struct argv_array *colors, const char *string)
{
@@ -256,6 +257,16 @@ void graph_setup_line_prefix(struct diff_options *diffopt)
}
+static int git_graph_config(const char *var, const char *value, void *cb)
+{
+ if (!strcmp(var, "log.showrootmark")) {
+ show_root_mark = git_config_bool(var, value);
+ return 0;
+ }
+
+ return git_default_config(var, value, cb);
+}
+
struct git_graph *graph_init(struct rev_info *opt)
{
struct git_graph *graph = xmalloc(sizeof(struct git_graph));
@@ -276,6 +287,7 @@ struct git_graph *graph_init(struct rev_info *opt)
custom_colors.argc - 1);
}
}
+ git_config(git_graph_config, NULL);
graph->commit = NULL;
graph->revs = opt;
@@ -835,6 +847,14 @@ static void graph_output_commit_char(struct git_graph *graph, struct strbuf *sb)
return;
}
+ /*
+ * If the commit has no parents, it's a root commit
+ */
+ if (show_root_mark && !graph->num_parents) {
+ strbuf_addch(sb, '@');
+ return;
+ }
+
/*
* get_revision_mark() handles all other cases without assert()
*/
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 25b1f8cc73bc3..350e35264362f 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -455,6 +455,22 @@ test_expect_success 'simple log --graph' '
test_cmp expect actual
'
+cat > expect <<EOF
+* Second
+* sixth
+* fifth
+* fourth
+* third
+* second
+@ initial
+EOF
+
+test_expect_success 'simple log --graph' '
+ test_config log.showRootMark true &&
+ git log --graph --pretty=tformat:%s >actual &&
+ test_cmp expect actual
+'
+
cat > expect <<EOF
123 * Second
123 * sixth
--
https://github.com/git/git/pull/478
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] graph.c: log.showRootMark to indicate root commits
2018-04-01 20:57 [PATCH] graph.c: log.showRootMark to indicate root commits Lyubomyr Shaydariv
@ 2018-04-02 17:57 ` Junio C Hamano
2018-04-02 18:13 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2018-04-02 17:57 UTC (permalink / raw)
To: Lyubomyr Shaydariv; +Cc: git
Lyubomyr Shaydariv <lsh.dev@ukr.net> writes:
> When log.showRootMark is set, root commits are marked with
> the at sign (@).
>
> When log.showRootMark is not set, root commits are marked with
> the asterisk sign (*). This is the default behavior.
>
> Signed-off-by: Lyubomyr Shaydariv <lsh.dev@ukr.net>
> ---
So the idea is when you have a history like this:
R1--A---B
\
R2--C---D---M
to show "git log --oneline --graph D B" like
* B
* A
@ R1
* D
* C
@ R2
because you cannot tell that between R1 and D there is no
parent-child relationship otherwise?
One downside of that approach is that it is not clear how this
feature should interact with --left-right. I do not think there is
a clean way to do that, unless you come up with a pair of symbols,
not just a single '@'.
Another way to show that there is no parent-child relationship
between R1 and D is to show it like this instead:
* B
* A
\
* R1
* D
* C
* R2
and that would work well with --left-right automatically (as you
would just do the same thing as you would to a normal asterisk).
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] graph.c: log.showRootMark to indicate root commits
2018-04-02 17:57 ` Junio C Hamano
@ 2018-04-02 18:13 ` Junio C Hamano
0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2018-04-02 18:13 UTC (permalink / raw)
To: Lyubomyr Shaydariv; +Cc: git
Junio C Hamano <gitster@pobox.com> writes:
> Lyubomyr Shaydariv <lsh.dev@ukr.net> writes:
>
>> When log.showRootMark is set, root commits are marked with
>> the at sign (@).
>>
>> When log.showRootMark is not set, root commits are marked with
>> the asterisk sign (*). This is the default behavior.
>>
>> Signed-off-by: Lyubomyr Shaydariv <lsh.dev@ukr.net>
>> ---
>
> So the idea is when you have a history like this:
> ...
> and that would work well with --left-right automatically (as you
> would just do the same thing as you would to a normal asterisk).
There was some discussion a while back on making root commits more
apparent in the graph view, e.g.
https://public-inbox.org/git/1382717268-21884-1-git-send-email-milton.soares.filho@gmail.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-02 18:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-01 20:57 [PATCH] graph.c: log.showRootMark to indicate root commits Lyubomyr Shaydariv
2018-04-02 17:57 ` Junio C Hamano
2018-04-02 18:13 ` Junio C Hamano
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).