Re: [PATCH 1/6] test-lib: introduce test_commit_bulk
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Jun 28, 2019, 21:32 UTC
- Message-ID
- <CAPig+cQAKVOqYH-CcqzViP_zuKwg5fWO2_i8=Z5t=BVf9uoAXQ@mail.gmail.com>
- In-Reply-To
- <20190628093911.GA27329@sigill.intra.peff.net>
On Fri, Jun 28, 2019 at 5:39 AM Jeff King <peff@peff.net> wrote:
Show 18 quoted lines
> [...]
> For bulk creation, we can do much better by using fast-import, but it's
> often a pain to generate the input. Let's provide a helper to do so.
> [...]
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> @@ -233,6 +233,137 @@ test_merge () {
> +# Similar to test_commit, but efficiently create <nr> commits, each with a
> +# unique number $n (from 1 to <nr> by default) in the commit message.
> +#
> +# Usage: test_commit_bulk [options] <nr>
> +# [...]
> +#
> +# The message, filename, and contents strings are evaluated by the shell inside
> +# double-quotes, with $n set to the current commit number. So you can do:
> +#
> +# test_commit_bulk --filename=file --contents='modification $n'Considering that test_commit_bulk() is intended to be used within a test body, and considering that test bodies are almost always encapsulated in single quotes, recommending single quoting the value of --contents= seems contraindicated. Double quotes likely would be better.
Show 7 quoted lines
> +# to have every commit touch the same file, but with unique content. Spaces are
> +# OK, but you must escape any metacharacters (like backslashes or
> +# double-quotes) you do not want expanded.
> +#
> +test_commit_bulk () {
> + [...]
> + in_dir=${indir:+-C "$indir"}Doesn't this suffer the problem in which some older/broken shells[1][2][3][4] incorrectly expand this to:
"-C <dir>"
rather than the expected:
-C "<dir>"
? Is this something we still care about?
Same comment applies to other instances of ${indir:+-C "$indir"} below.[1]: http://public-inbox.org/git/20160517215214.GA16905@sigill.intra.peff.net/ [2]: http://public-inbox.org/git/e3bfc53363b14826d828e1adffbbeea@74d39fa044aa309eaea14b9f57fe79c/ [3]: http://public-inbox.org/git/20160518010609.Horde.sM8QUFek6WMAAwho56DDob8@webmail.informatik.kit.edu/ [4]: http://public-inbox.org/git/1240044459-57227-1-git-send-email-ben@ben.com/