Jeff King wrote:

        The seq command is GNU-ism, and is missing at least in older BSD
        releases and their derivatives, not to mention antique
        commercial Unixes.

        We already purged it in b3431bc (Don't use seq in tests, not
        everyone has it, 2007-05-02), but a few new instances have crept
        in. They went unnoticed because they are in scripts that are not
        run by default.

This commit replaces them with test_seq that is implemented with a Perl
snippet (proposed by Jeff).  This is better than inlining this snippet
everywhere it's needed because it's easier to read and it's easier to
change the implementation (e.g. to C) if we ever decide to remove Perl
from the test suite.

Note that test_seq is not a complete replacement for seq(1).  It just
has what we need now.

There are also many places that do `for i in 1 2 3 ...` but I'm not sure
if it's worth converting them to test_seq.  That would introduce running
more processes of Perl during the tests and might increase the total
time tests take.

Signed-off-by: Michał Kiedrowicz <>

> I don't have a strong preference, as there are only two callsites. Do
> you want to make a patch?

Sure. Here it is.

 t/perf/      |  2 +-
 t/   |  2 +-
 t/ | 14 ++++++++++++++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/t/perf/ b/t/perf/
index 5580c22..a1361e5 100644
--- a/t/perf/
+++ b/t/perf/
@@ -163,7 +163,7 @@ test_perf () {
                        echo "perf $test_count - $1:"
-               for i in $(seq 1 $GIT_PERF_REPEAT_COUNT); do
+               for i in $(test_seq 1 $GIT_PERF_REPEAT_COUNT); do
                        say >&3 "running: $2"
                        if test_run_perf_ "$2"
diff --git a/t/ b/t/
index fadf2f2..91eaf53 100755
--- a/t/
+++ b/t/
@@ -114,7 +114,7 @@ test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
 test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '
        cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
-       for i in `seq 50000`
+       for i in `test_seq 50000`
                echo "commit refs/heads/too-many-refs"
                echo "mark :$i"
diff --git a/t/ b/t/
index 80daaca..7d7424d 100644
--- a/t/
+++ b/t/
@@ -530,6 +530,20 @@ test_cmp() {
        $GIT_TEST_CMP "$@"
+# test_seq is a portable replacement for seq(1).
+# It may be used like:
+#      for i in `test_seq 100`; do
+#              echo $i
+#      done
+test_seq () {
+       test $# = 1 ||
+       error "bug in the test script: not 1 parameter to test_seq"
+       last=$1
+       "$PERL_PATH" -le "print for 1..$last"
 # This function can be used to schedule some commands to be run
 # unconditionally at the end of the test to restore sanity:

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to