git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Abhishek Kumar <abhishekkumar8222@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [GSoC PATCH v2 1/2] lib-log-graph: consolidate test_cmp_graph logic
Date: Thu, 20 Feb 2020 09:49:17 -0800	[thread overview]
Message-ID: <xmqqsgj5b142.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20200220091528.28472-2-abhishekkumar8222@gmail.com> (Abhishek Kumar's message of "Thu, 20 Feb 2020 14:45:27 +0530")

Abhishek Kumar <abhishekkumar8222@gmail.com> writes:

> Logic for comparing log graphs is duplicated across test scripts.
>
> This patch consolidates such logic into lib-log-graph.

The proposed log message is a bit thin.  It does a bit more than
"conslidates", doesn't it?

> Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>
> ---
>  t/lib-log-graph.sh           | 22 +++++++++++++++
>  t/t3430-rebase-merges.sh     |  5 ++--
>  t/t4202-log.sh               | 53 ++++++++++--------------------------
>  t/t4214-log-graph-octopus.sh | 46 ++++++++++---------------------
>  t/t4215-log-skewed-merges.sh |  5 ++--
>  5 files changed, 54 insertions(+), 77 deletions(-)
>  create mode 100755 t/lib-log-graph.sh
>
> diff --git a/t/lib-log-graph.sh b/t/lib-log-graph.sh
> new file mode 100755
> index 0000000000..97cde44dc7
> --- /dev/null
> +++ b/t/lib-log-graph.sh
> @@ -0,0 +1,22 @@
> +# Helps shared by the test scripts for comparing log graphs.
> +
> +sanitize_log_output () {
> +	sed -e 's/ *$//' \
> +	    -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
> +	    -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
> +	    -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
> +	    -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
> +	    -e 's/index [0-9a-f]*\.\.[0-9a-f]*/index BEFORE..AFTER/'
> +}

For example, discarding the singular/plural compat stuff from the
t4202's version is OK, but we should record that is what we did in
the log message to allow readers to notice.

> +lib_test_cmp_graph () {

Nicely named.

> +	git log --graph "$@" >output &&
> +	sed 's/ *$//' >output.sanitized < output &&

Lose SP not just on the output redirection but also on the input
redirection.  I.e.

	sed 's/ *$//' >output.sanitized <output &&

Or you can lose the input redirection altogether as "sed" knows to
treat remaining command line arguments as names of its input files,
i.e.

	sed 's/ *$//' output >output.sanitized &&

People may find the latter easier to read.  I personally do not have
strong preference either way as long as it is consistent.

> +	test_i18ncmp expect output.sanitized
> +}
> +
> +lib_test_cmp_short_graph () {
> +	git log --graph --pretty=short "$@" >output &&
> +	sanitize_log_output >output.sanitized < output &&

	sanitize_log_output <output >output.sanitized &&

(I won't repeat)


>  check_graph () {
>  	cat >expect &&
> -	git log --graph --pretty=tformat:%s "$@" >actual.raw &&
> -	sed "s/ *$//" actual.raw >actual &&
> -	test_cmp expect actual
> +	lib_test_cmp_graph --format=%s "$@"
>  }

Hmm, is this correct?  The input goes to expect but the new helper
you wrote, lib_test_cmp_graph, won't see it.


  reply	other threads:[~2020-02-20 17:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-16 13:47 [GSoC Patch 1/5] lib-log-graph.sh: consolidate test_cmp_graph logic Abhishek Kumar
2020-02-16 13:47 ` [GSoC Patch 2/5] t3430: use lib-log-graph functions Abhishek Kumar
2020-02-19 17:23   ` Junio C Hamano
2020-02-16 13:47 ` [GSoC Patch 3/5] t4215: " Abhishek Kumar
2020-02-19 17:26   ` Junio C Hamano
2020-02-16 13:47 ` [GSoC Patch 4/5] t4214: " Abhishek Kumar
2020-02-19 17:29   ` Junio C Hamano
2020-02-16 13:47 ` [GSoC Patch 5/5] t4202: " Abhishek Kumar
2020-02-19 17:31   ` Junio C Hamano
2020-02-17  0:05 ` [GSoC Patch 1/5] lib-log-graph.sh: consolidate test_cmp_graph logic Junio C Hamano
2020-02-19 17:32   ` Junio C Hamano
2020-02-20  9:15 ` [GSoC PATCH v2 0/2] Consolidate " Abhishek Kumar
2020-02-20  9:15   ` [GSoC PATCH v2 1/2] lib-log-graph: consolidate " Abhishek Kumar
2020-02-20 17:49     ` Junio C Hamano [this message]
2020-02-20  9:15   ` [PATCH v2 2/2] lib-log-graph: consolidate colored graph cmp logic Abhishek Kumar
2020-02-24 13:38 ` [GSoC Patch v3 1/2] lib-log-graph: consolidate test_cmp_graph logic Abhishek Kumar
2020-02-24 13:38   ` [GSoC Patch v3 2/2] lib-log-graph: consolidate colored graph cmp logic Abhishek Kumar
2020-02-24 21:17   ` [GSoC Patch v3 1/2] lib-log-graph: consolidate test_cmp_graph logic 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqsgj5b142.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=abhishekkumar8222@gmail.com \
    --cc=git@vger.kernel.org \
    /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.
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).