git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Brian Henderson <henderson.bj@gmail.com>
To: git@vger.kernel.org
Cc: peff@peff.net, e@80x24.org, Brian Henderson <henderson.bj@gmail.com>
Subject: [PATCH v2 0/3] diff-highlight: add support for git log --graph output.
Date: Wed, 17 Aug 2016 08:31:21 -0700	[thread overview]
Message-ID: <20160817153124.7770-1-henderson.bj@gmail.com> (raw)
In-Reply-To: <20160810085635.GA1672@starla>

Changes made per Eric.

On Wed, Aug 10, 2016 at 08:56:35AM +0000, Eric Wong wrote:
> Brian Henderson <henderson.bj@gmail.com> wrote:
> 
> Hi Brian,
> 
> A few minor portability/style nits below, but contrib/ probably
> (still?) has laxer rules than the rest of git...
> 
> I think we still require Signed-off-by lines in contrib,
> though...

added

> 
> > +++ b/contrib/diff-highlight/t/Makefile
> > @@ -0,0 +1,19 @@
> > +-include ../../../config.mak.autogen
> > +-include ../../../config.mak
> > +
> > +T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
> > +
> > +all: test
> > +test: $(T)
> > +
> > +.PHONY: help clean all test $(T)
> > +
> > +help:
> > +	@echo 'Run "$(MAKE) test" to launch test scripts'
> > +	@echo 'Run "$(MAKE) clean" to remove trash folders'
> > +
> > +$(T):
> > +	@echo "*** $@ ***"; sh $@ $(GIT_TEST_OPTS)
> 
> Probably:
> 
> 	@echo "*** $@ ***"; '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
> 
> like we do in t/Makefile in case we need to override 'sh'.
> 

done, although I basically had to copy the SHELL_PATH_SQ logic from t/Makefile

> > +
> > +clean:
> > +	$(RM) -r 'trash directory'.*
> > diff --git a/contrib/diff-highlight/t/t9400-diff-highlight.sh b/contrib/diff-highlight/t/t9400-diff-highlight.sh
> > new file mode 100644
> > index 0000000..ca7605f
> > --- /dev/null
> > +++ b/contrib/diff-highlight/t/t9400-diff-highlight.sh
> > @@ -0,0 +1,63 @@
> > +#!/bin/sh
> > +#
> > +# Copyright (C) 2016
> 
> IANAL, but I think your name (or who you represent) needs to be
> in the copyright.

diff-highlight doesn't have a copyright, so I just removed it. ok?

> 
> > +
> > +test_description='Test diff-highlight'
> > +
> > +. ./test-diff-highlight.sh
> > +. $TEST_DIRECTORY/test-lib.sh
> 
> TEST_DIRECTORY ought to be quoted since it could contain
> shell-unfriendly chars (we intentionally name 'trash directory'
> this way to trigger errors).

done

> 
> > +
> > +# PERL is required, but assumed to be present, although not necessarily modern
> > +# some tests require 5.8
> > +
> > +test_expect_success 'diff-highlight highlightes the beginning of a line' '
> 
> You can declare a prereq for PERL::
> 
> 	test_expect_success PERL 'name' 'true'

done

> 
> And spelling: "highlights" (there's other instances of this, too)

oops, thanks

> 
> > +  dh_test \
> > +    "aaa\nbbb\nccc\n" \
> > +    "aaa\n0bb\nccc\n" \
> > +"
> 
> We use tabs for shell indentation.

done

<snip>

> > +
> > +dh_diff_test() {
> > +  local a="$1" b="$2"
> 
> "local" is not a portable construct.  It's common for
> Debian/Ubuntu systems to use dash as /bin/sh instead of bash;
> (dash is faster, and mostly sticks to POSIX)
> 
> The "devscripts" package in Debian/Ubuntu-based systems has a
> handy "checkbashisms" tool for checking portability of shell
> scripts.

checkbashisms didn't output anything, and I found other instances of local in some tests. but I removed anyway.

> 
> > +
> > +  printf "$a" > file
> > +  git add file
> > +
> > +  printf "$b" > file
> > +
> > +  git diff file > diff.raw
> 
> Commands should be '&&'-chained here since any of them could fail
> ("git add"/printf/etc could run out of space or fail on disk errors)

I wasn't totally sure what to do here. I added some checks for empty files and
&& chained them with the last command to verify I wasn't diffing 2 empty files.
Hope that is sufficient.

> 
> Also, our redirect style is:	command >file
> without a space between '>' and destination.

done

> 
> See Documentation/CodingGuidelines for more details.
> Unfortunately, the reasoning is not explained for '>NOSPACE'
> and I'm not sure exactly why, either...
> 
> > +  if test "$#" = 3

done

> 
> Better to use -eq for numeric comparisons: test $# -eq 3
> Quoting $# doesn't seem necessary unless your shell is
> hopelessly buggy :)
> 
> > +  then
> > +    # remove last newline
> > +    head -n5 diff.raw | head -c -1 > diff.act
> 
> "head -c" isn't portable, fortunately Jeff hoisted it out for
> use as test_copy_bytes in commit 48860819e8026
> https://public-inbox.org/git/20160630090753.GA17463@sigill.intra.peff.net/

It didn't look like his version supported a negative number, so I rolled my own.

> 
> > +    printf "$3" >> diff.act
> > +  else
> > +    cat diff.raw > diff.act
> > +  fi
> > +
> > +  < diff.raw $CMD > diff.exp
> 
> $CMD probably needs to be quoted.  However, by the time I got
> here I had to ask myself:  What is $CMD again?
> A: Oh, look up at the top!
> 
> *shrug*  My attention span is tiny and my fonts are gigantic.
> 
> Perhaps using:
> 
> 	DIFF_HIGHLIGHT="$CURR_DIR"/../diff-highlight
> 
> Would be more-readable?

good, done.

> 
> > +
> > +  diff diff.exp diff.act
> 
> Maybe use test_cmp to avoid depending external diff.
> (or "git diff -b --no-index" in your later test)
> 
> Same comments for the rest of the series, I think.
> 
> Typically, we expect a reroll in a few days, and I guess there's
> no rush (so you can squash your comment patch in addressing
> Junio's concern into 3/3).
> 
> Thanks.

thanks for the feedback.

I've rebased my changes. Unfortunately, having 3 commits made this somewhat
tedious. I also find it weird that my new patch set makes it difficult to see
what changes I've made from my first set. What's the standard workflow here?

Brian Henderson (3):
  diff-highlight: add some tests.
  diff-highlight: add failing test for handling --graph output.
  diff-highlight: add support for --graph output.

 contrib/diff-highlight/Makefile                  |   5 +
 contrib/diff-highlight/diff-highlight            |  16 ++--
 contrib/diff-highlight/t/Makefile                |  22 +++++
 contrib/diff-highlight/t/t9400-diff-highlight.sh |  75 +++++++++++++++
 contrib/diff-highlight/t/test-diff-highlight.sh  | 112 +++++++++++++++++++++++
 5 files changed, 224 insertions(+), 6 deletions(-)
 create mode 100644 contrib/diff-highlight/Makefile
 create mode 100644 contrib/diff-highlight/t/Makefile
 create mode 100755 contrib/diff-highlight/t/t9400-diff-highlight.sh
 create mode 100644 contrib/diff-highlight/t/test-diff-highlight.sh

-- 
2.9.0


  parent reply	other threads:[~2016-08-17 15:32 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-30 15:11 [PATCH 0/3] diff-highlight: add support for git log --graph output Brian Henderson
2016-07-30 15:11 ` [PATCH 1/3] diff-highlight: add some tests Brian Henderson
2016-08-10  8:56   ` Eric Wong
2016-08-15 16:20     ` Brian Henderson
2016-08-15 16:25       ` Junio C Hamano
2016-08-17 15:31     ` Brian Henderson [this message]
2016-08-19 21:19       ` [PATCH v2 0/3] diff-highlight: add support for git log --graph output Eric Wong
2016-08-19 21:23         ` Jeff King
2016-08-17 15:31     ` [PATCH v2 1/3] diff-highlight: add some tests Brian Henderson
2016-08-17 19:09       ` Junio C Hamano
2016-08-19 14:42         ` Brian Henderson
2016-08-19 14:51           ` Jeff King
2016-08-19 15:13             ` Brian Henderson
2016-08-19 17:08             ` [PATCH v3 0/3] diff-highlight: add support for git log --graph output Brian Henderson
2016-08-19 17:08             ` [PATCH v3 1/3] diff-highlight: add some tests Brian Henderson
2016-08-19 18:10               ` Junio C Hamano
2016-08-19 19:30                 ` Brian Henderson
2016-08-19 20:56                   ` Eric Wong
2016-08-19 20:18                 ` [PATCH] " Brian Henderson
2016-08-19 20:44                   ` Junio C Hamano
2016-08-19 21:04                     ` Jeff King
2016-08-19 22:31                       ` Junio C Hamano
2016-08-22 15:55                         ` Brian Henderson
2016-08-23  4:12                           ` Jeff King
2016-08-29 17:33                             ` [PATCH v4 0/3] diff-highlight: add support for --graph option Brian Henderson
2016-08-29 17:33                               ` [PATCH v4 1/3] diff-highlight: add some tests Brian Henderson
2016-08-29 17:33                               ` [PATCH v4 2/3] diff-highlight: add failing test for handling --graph output Brian Henderson
2016-08-29 17:33                               ` [PATCH v4 3/3] diff-highlight: add support for " Brian Henderson
2016-08-29 21:37                               ` [PATCH v4 0/3] diff-highlight: add support for --graph option Junio C Hamano
2016-08-30 14:07                                 ` Brian Henderson
2016-08-30 14:07                                   ` [PATCH v4 1/3] diff-highlight: add some tests Brian Henderson
2016-08-30 14:07                                   ` [PATCH v4 2/3] diff-highlight: add failing test for handling --graph output Brian Henderson
2016-08-30 14:07                                   ` [PATCH v4 3/3] diff-highlight: add support for " Brian Henderson
2016-08-31  5:02                                   ` [PATCH v4 0/3] diff-highlight: add support for --graph option Jeff King
2016-08-31  5:02                                     ` [PATCH 1/3] diff-highlight: ignore test cruft Jeff King
2016-08-31  5:03                                     ` [PATCH 2/3] diff-highlight: add multi-byte tests Jeff King
2016-08-31  5:05                                     ` [PATCH 3/3] diff-highlight: avoid highlighting combined diffs Jeff King
2016-08-30  8:11                               ` [PATCH v4 0/3] diff-highlight: add support for --graph option Jeff King
2016-08-19 21:05                   ` [PATCH] diff-highlight: add some tests Junio C Hamano
2016-08-19 17:08             ` [PATCH v3 2/3] diff-highlight: add failing test for handling --graph output Brian Henderson
2016-08-19 18:25               ` Junio C Hamano
2016-08-19 17:08             ` [PATCH v3 3/3] diff-highlight: add support for " Brian Henderson
2016-08-19 18:27               ` Junio C Hamano
2016-08-17 15:31     ` [PATCH v2 2/3] diff-highlight: add failing test for handling " Brian Henderson
2016-08-17 19:18       ` Junio C Hamano
2016-08-17 15:31     ` [PATCH v2 3/3] diff-highlight: add support for " Brian Henderson
2016-08-19 14:37       ` Jeff King
2016-08-15 16:40   ` [PATCH 1/3] diff-highlight: add some tests Lars Schneider
2016-08-16 20:48     ` Junio C Hamano
2016-08-24  9:38       ` Lars Schneider
2016-07-30 15:11 ` [PATCH 2/3] diff-highlight: add failing test for handling --graph output Brian Henderson
2016-07-30 15:11 ` [PATCH 3/3] diff-highlight: add support for " Brian Henderson
2016-08-01 17:16   ` Junio C Hamano
2016-08-04 15:02     ` [PATCH] diff-highlight: Add comment for our assumption about " Brian Henderson

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=20160817153124.7770-1-henderson.bj@gmail.com \
    --to=henderson.bj@gmail.com \
    --cc=e@80x24.org \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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).