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

Re: [PATCH v3 2/3] diff-highlight: add failing test for handling --graph output.

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 19, 2016, 18:25 UTC
Message-ID
<xmqqd1l439am.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160819170812.1676-3-henderson.bj@gmail.com>
Brian Henderson <henderson.bj@gmail.com> writes:
Show 15 quoted lines
> Signed-off-by: Brian Henderson <henderson.bj@gmail.com>
> ---
>  contrib/diff-highlight/t/t9400-diff-highlight.sh | 54 ++++++++++++++++++++++++
>  1 file changed, 54 insertions(+)
>
> diff --git a/contrib/diff-highlight/t/t9400-diff-highlight.sh b/contrib/diff-highlight/t/t9400-diff-highlight.sh
> index 6b8a461..3b3c831 100755
> --- a/contrib/diff-highlight/t/t9400-diff-highlight.sh
> +++ b/contrib/diff-highlight/t/t9400-diff-highlight.sh
> @@ -85,10 +85,50 @@ dh_commit_test () {
>  	test_cmp commit.exp commit.act
>  }
>  
> +# dh_test_setup_history takes a series (3) of changes and generates a contrived graph
> +# of commits and merges
The first line look a bit overlong.

If the graph is truly "contrived" as the comment at the beginning says (I haven't formed an opinion), it probably is a good idea to draw a picture upfront.

> +dh_test_setup_history () {
> +	a="$1" b="$2" c="$3"

Even though assignment would not fail, it probably is a good idea to &&-chain this line, too, for consistency. I.e.

	a=$1 b=$2 c=$3 &&

Note that RHS of an assignment do not need dq; it does not hurt to quote them, though.

> +	printf "$a" >file &&
> +	git add file &&
> +	git commit -m"Add a file" &&
Avoid sticking a short-option to its argument, i.e.
    git commit -m "Add a file"
> +	printf "$b" >file &&
> +	git commit -am"Update a file" &&
Likewise.
    git commit -a -m "Update a file".
Show 5 quoted lines
> +left_trim () {
> +	"$PERL_PATH" -pe 's/^\s+//'
> +}
> +
> +trim_graph_el () {
What does "el" stand for?  Not E-lisp ;-)

If you meant "elements" or something, probably that is unnecessary and "trim_graph" would be sufficient, but you may have meant something else.

Show 29 quoted lines
> +	# graphs start with * or |
> +	# followed by a space or / or \
> +	"$PERL_PATH" -pe 's@^((\*|\|)( |/|\\))+@@'
> +}
> +
>  test_expect_success 'diff-highlight highlights the beginning of a line' '
>  	dh_test \
>  		"aaa\nbbb\nccc\n" \
> @@ -145,6 +185,20 @@ test_expect_failure 'diff-highlight highlights mismatched hunk size' '
>  
>  # TODO add multi-byte test
>  
> +test_expect_failure 'diff-highlight works with the --graph option' '
> +	dh_test_setup_history \
> +		"aaa\nbbb\nccc\n" \
> +		"aaa\n0bb\nccc\n" \
> +		"aaa\nb0b\nccc\n" &&
> +
> +	# topo-order so that the order of the commits is the same as with --graph
> +	# trim graph elements so we can do a diff
> +	# trim leading space because our trim_graph_el is not perfect
> +	git log -p --topo-order | "$DIFF_HIGHLIGHT" | left_trim >graph.exp &&
> +	git log -p --graph | "$DIFF_HIGHLIGHT" | trim_graph_el | left_trim >graph.act &&
> +	test_cmp graph.exp graph.act
> +'
> +
>  test_done
>  
>  # vim: set noet
Previous: Brian HendersonNext: Brian Henderson
Message 3 of 30 in “diff-highlight: add support for git log --graph output.”
  1. 0/3 diff-highlight: add support for git log --graph output.Brian Henderson, Aug 19, 2016
  2. 2/3 diff-highlight: add failing test for handling --graph output.Brian Henderson, Aug 19, 2016
  3. Junio C HamanoAug 19, 2016
  4. 1/3 diff-highlight: add some tests.Brian Henderson, Aug 19, 2016
  5. Junio C HamanoAug 19, 2016
  6. Brian HendersonAug 19, 2016
  7. Eric WongAug 19, 2016
  8. diff-highlight: add some tests.Brian Henderson, Aug 19, 2016
  9. Junio C HamanoAug 19, 2016
  10. Jeff KingAug 19, 2016
  11. Junio C HamanoAug 19, 2016
  12. diff-highlight: add some tests.Brian Henderson, Aug 22, 2016
  13. Jeff KingAug 23, 2016
  14. 0/3 diff-highlight: add support for --graph optionBrian Henderson, Aug 29, 2016
  15. 2/3 diff-highlight: add failing test for handling --graph output.Brian Henderson, Aug 29, 2016
  16. 1/3 diff-highlight: add some tests.Brian Henderson, Aug 29, 2016
  17. 3/3 diff-highlight: add support for --graph output.Brian Henderson, Aug 29, 2016
  18. Junio C HamanoAug 29, 2016
  19. 0/3 diff-highlight: add support for --graph optionBrian Henderson, Aug 30, 2016
  20. 1/3 diff-highlight: add some testsBrian Henderson, Aug 30, 2016
  21. 3/3 diff-highlight: add support for --graph outputBrian Henderson, Aug 30, 2016
  22. 2/3 diff-highlight: add failing test for handling --graph outputBrian Henderson, Aug 30, 2016
  23. Jeff KingAug 31, 2016
  24. 1/3 diff-highlight: ignore test cruftJeff King, Aug 31, 2016
  25. 2/3 diff-highlight: add multi-byte testsJeff King, Aug 31, 2016
  26. 3/3 diff-highlight: avoid highlighting combined diffsJeff King, Aug 31, 2016
  27. Jeff KingAug 30, 2016
  28. Junio C HamanoAug 19, 2016
  29. 3/3 diff-highlight: add support for --graph output.Brian Henderson, Aug 19, 2016
  30. Junio C HamanoAug 19, 2016

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.