git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2] log: add --nonlinear-barrier to help see non-linear history
Date: Mon, 17 Mar 2014 13:32:56 -0700	[thread overview]
Message-ID: <xmqqob14d0qv.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1395060676-23144-1-git-send-email-pclouds@gmail.com> (=?utf-8?B?Ik5ndXnhu4VuCVRow6FpIE5n4buNYw==?= Duy"'s message of "Mon, 17 Mar 2014 19:51:16 +0700")

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  v2 renames the option name to --nonlinear-barrier and fixes using it
>  with --dense. Best used with --no-merges to see patch series.

I think that the earlier name "show linear-break" is more easily
understood than the new name, but maybe that is just me.  It's not
like you are blocking something from going forward with a barrier,
and internally it is called a "break-bar".

>  Documentation/rev-list-options.txt |  7 ++++++
>  log-tree.c                         |  4 +++
>  revision.c                         | 51 +++++++++++++++++++++++++++++++++++---
>  revision.h                         |  6 +++++
>  4 files changed, 65 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
> index 03533af..435aa2d 100644
> --- a/Documentation/rev-list-options.txt
> +++ b/Documentation/rev-list-options.txt
> @@ -750,6 +750,13 @@ This enables parent rewriting, see 'History Simplification' below.
>  This implies the `--topo-order` option by default, but the
>  `--date-order` option may also be specified.
>  
> +--nonlinear-barrier[=<barrier>]::
> +	When --graph is not used, all history branches are flatten and

s/flatten and/flattened and it/, perhaps?

> +	could be hard to see that the two consecutive commits do not
> +	belong to a linear branch. This option puts a barrier in
> +	between them in that case. If `<barrier>` is specified, it
> +	is the string that will be shown instead of the default one.
> +
>  ifdef::git-rev-list[]
>  --count::
>  	Print a number stating how many commits would have been
> diff --git a/log-tree.c b/log-tree.c
> index 08970bf..17862f6 100644
> --- a/log-tree.c
> +++ b/log-tree.c
> @@ -805,12 +805,16 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)
>  	if (opt->line_level_traverse)
>  		return line_log_print(opt, commit);
>  
> +	if (opt->track_linear && !opt->linear && !opt->reverse_output_stage)
> +		printf("\n%s\n", opt->break_bar);
>  	shown = log_tree_diff(opt, commit, &log);
>  	if (!shown && opt->loginfo && opt->always_show_header) {
>  		log.parent = NULL;
>  		show_log(opt);
>  		shown = 1;
>  	}
> +	if (opt->track_linear && !opt->linear && opt->reverse_output_stage)
> +		printf("\n%s\n", opt->break_bar);

Each time get_revision() returns a commit, it is inspected and
opt->linear is updated, this function is called and we show the
break in the single-strand-of-pearls if this is not a parent of the
commit we showed immediately before.  If we are showing the commit
in reverse, we have to go the other way around, showing the commit
and then the break.

OK.  It makes sense to me.

>  	opt->loginfo = NULL;
>  	maybe_flush_or_die(stdout, "stdout");
>  	return shown;

Does this new feature interact with -z format output in any way?
Should it, and if so how?

> diff --git a/revision.c b/revision.c
> index a68fde6..0a4849e 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -1832,6 +1832,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
>  		revs->notes_opt.use_default_notes = 1;
>  	} else if (!strcmp(arg, "--show-signature")) {
>  		revs->show_signature = 1;
> +	} else if (!strcmp(arg, "--nonlinear-barrier")) {
> +		revs->track_linear = 1;
> +		revs->break_bar = "                    ..........";
> +	} else if (starts_with(arg, "--nonlinear-barrier=")) {
> +		revs->track_linear = 1;
> +		revs->break_bar = xstrdup(arg + 20);
>  	} else if (starts_with(arg, "--show-notes=") ||
>  		   starts_with(arg, "--notes=")) {
>  		struct strbuf buf = STRBUF_INIT;
> @@ -2897,6 +2903,32 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
>  	return action;
>  }
>  
> +define_commit_slab(saved_linear, int);
> +
> +static void track_linear(struct rev_info *revs, struct commit *commit)
> +{
> +	struct commit_list *p = revs->previous_parents;
> +
> +	if (p) {
> +		int got_parent = 0;
> +		for (; p && !got_parent; p = p->next)
> +			got_parent = !hashcmp(p->item->object.sha1,
> +					      commit->object.sha1);
> +		revs->linear = got_parent;
> +		free_commit_list(revs->previous_parents);
> +	} else
> +		revs->linear = 1;
> +	if (revs->reverse) {
> +		if (!revs->saved_linear_slab) {
> +			revs->saved_linear_slab = xmalloc(sizeof(struct saved_linear));
> +			init_saved_linear(revs->saved_linear_slab);
> +		}
> +
> +		*saved_linear_at(revs->saved_linear_slab, commit) = revs->linear;
> +	}
> +	revs->previous_parents = copy_commit_list(commit->parents);

We are showing commit, and the parents (after history
simplification) of the commit we showed before this commit is kept
in previous-parents.  If we are one of them, we are showing
linearly, which makes sense.  While we are accumulating the output
in the forward direction in preparation for later emitting them in
reverse, we need to save away the linear-ness bit somewhere, and a
slab is a logical place to save that, which also makes sense.  But
why do you need a full int?  Doesn't an unsigned char wide enough?

I also wondered if the saved-parents slab we already have can be
easily reused for this, but it probably would not help.

I do not quite understand the "if we do not have previous parents"
bit, though.  Is it meant to trigger only at the very beginning?

Thanks.

  parent reply	other threads:[~2014-03-17 20:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-06 14:02 Confusing git log --- First time bug submission please advise on best practices Francis Stephens
2014-02-06 16:08 ` Vincent van Ravesteijn
2014-02-06 16:10   ` David Kastrup
2014-02-07  9:43     ` Francis Stephens
2014-02-07 10:26       ` Duy Nguyen
2014-02-07 11:37         ` demerphq
2014-02-08 13:50           ` [PATCH] log: add --show-linear-break to help see non-linear history Nguyễn Thái Ngọc Duy
2014-03-17 12:51             ` [PATCH v2] log: add --nonlinear-barrier " Nguyễn Thái Ngọc Duy
2014-03-17 19:09               ` Eric Sunshine
2014-03-17 20:32               ` Junio C Hamano [this message]
2014-03-18 11:46                 ` Duy Nguyen
2014-03-18 19:08                   ` Junio C Hamano
2014-03-20  5:44               ` [PATCH v3 1/2] object.h: centralize object flag allocation Nguyễn Thái Ngọc Duy
2014-03-20  5:44                 ` [PATCH v3 2/2] log: add --show-linear-break to help see non-linear history Nguyễn Thái Ngọc Duy
2014-03-20 19:15                   ` Junio C Hamano
2014-03-21  1:02                     ` Duy Nguyen
2014-03-25 13:23                 ` [PATCH v4 1/2] object.h: centralize object flag allocation Nguyễn Thái Ngọc Duy
2014-03-25 13:23                   ` [PATCH v4 2/2] log: add --show-linear-break to help see non-linear history Nguyễn Thái Ngọc Duy
2014-03-25 22:30                     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqob14d0qv.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).