diff options
Diffstat (limited to 't')
170 files changed, 2867 insertions, 817 deletions
diff --git a/t/helper/test-chmtime.c b/t/helper/test-chmtime.c index e760256406..aa22af48c2 100644 --- a/t/helper/test-chmtime.c +++ b/t/helper/test-chmtime.c @@ -5,32 +5,43 @@ * * The mtime can be changed to an absolute value: * - * test-chmtime =<seconds> file... + * test-tool chmtime =<seconds> file... * * Relative to the current time as returned by time(3): * - * test-chmtime =+<seconds> (or =-<seconds>) file... + * test-tool chmtime =+<seconds> (or =-<seconds>) file... * * Or relative to the current mtime of the file: * - * test-chmtime <seconds> file... - * test-chmtime +<seconds> (or -<seconds>) file... + * test-tool chmtime <seconds> file... + * test-tool chmtime +<seconds> (or -<seconds>) file... * * Examples: * - * To just print the mtime use --verbose and set the file mtime offset to 0: + * To print the mtime and the file name use --verbose and set + * the file mtime offset to 0: * - * test-chmtime -v +0 file + * test-tool chmtime -v +0 file + * + * To print only the mtime use --get: + * + * test-tool chmtime --get file * * To set the mtime to current time: * - * test-chmtime =+0 file + * test-tool chmtime =+0 file + * + * To set the file mtime offset to +1 and print the new value: + * + * test-tool chmtime --get +1 file * */ +#include "test-tool.h" #include "git-compat-util.h" #include <utime.h> -static const char usage_str[] = "-v|--verbose (+|=|=+|=-|-)<seconds> <file>..."; +static const char usage_str[] = + "(-v|--verbose|-g|--get) (+|=|=+|=-|-)<seconds> <file>..."; static int timespec_arg(const char *arg, long int *set_time, int *set_eq) { @@ -46,7 +57,6 @@ static int timespec_arg(const char *arg, long int *set_time, int *set_eq) } *set_time = strtol(timespec, &test, 10); if (*test) { - fprintf(stderr, "Not a base-10 integer: %s\n", arg + 1); return 0; } if ((*set_eq && *set_time < 0) || *set_eq == 2) { @@ -56,9 +66,10 @@ static int timespec_arg(const char *arg, long int *set_time, int *set_eq) return 1; } -int cmd_main(int argc, const char **argv) +int cmd__chmtime(int argc, const char **argv) { static int verbose; + static int get; int i = 1; /* no mtime change by default */ @@ -68,18 +79,34 @@ int cmd_main(int argc, const char **argv) if (argc < 3) goto usage; - if (strcmp(argv[i], "--verbose") == 0 || strcmp(argv[i], "-v") == 0) { + if (strcmp(argv[i], "--get") == 0 || strcmp(argv[i], "-g") == 0) { + get = 1; + ++i; + } else if (strcmp(argv[i], "--verbose") == 0 || strcmp(argv[i], "-v") == 0) { verbose = 1; ++i; } - if (timespec_arg(argv[i], &set_time, &set_eq)) + + if (i == argc) { + goto usage; + } + + if (timespec_arg(argv[i], &set_time, &set_eq)) { ++i; - else + } else { + if (get == 0) { + fprintf(stderr, "Not a base-10 integer: %s\n", argv[i] + 1); + goto usage; + } + } + + if (i == argc) goto usage; for (; i < argc; i++) { struct stat sb; struct utimbuf utb; + uintmax_t mtime; if (stat(argv[i], &sb) < 0) { fprintf(stderr, "Failed to stat %s: %s\n", @@ -99,8 +126,10 @@ int cmd_main(int argc, const char **argv) utb.actime = sb.st_atime; utb.modtime = set_eq ? set_time : sb.st_mtime + set_time; - if (verbose) { - uintmax_t mtime = utb.modtime < 0 ? 0: utb.modtime; + mtime = utb.modtime < 0 ? 0: utb.modtime; + if (get) { + printf("%"PRIuMAX"\n", mtime); + } else if (verbose) { printf("%"PRIuMAX"\t%s\n", mtime, argv[i]); } diff --git a/t/helper/test-config.c b/t/helper/test-config.c index 1a7b8bd3d6..214003d5b2 100644 --- a/t/helper/test-config.c +++ b/t/helper/test-config.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "cache.h" #include "config.h" #include "string-list.h" @@ -32,7 +33,7 @@ * Examples: * * To print the value with highest priority for key "foo.bAr Baz.rock": - * test-config get_value "foo.bAr Baz.rock" + * test-tool config get_value "foo.bAr Baz.rock" * */ @@ -77,7 +78,7 @@ static int early_config_cb(const char *var, const char *value, void *vdata) return 0; } -int cmd_main(int argc, const char **argv) +int cmd__config(int argc, const char **argv) { int i, val; const char *v; diff --git a/t/helper/test-ctype.c b/t/helper/test-ctype.c index bb72c47df5..92c4c2313e 100644 --- a/t/helper/test-ctype.c +++ b/t/helper/test-ctype.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "cache.h" static int rc; @@ -28,7 +29,7 @@ static int is_in(const char *s, int ch) #define LOWER "abcdefghijklmnopqrstuvwxyz" #define UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ" -int cmd_main(int argc, const char **argv) +int cmd__ctype(int argc, const char **argv) { TEST_CLASS(isdigit, DIGIT); TEST_CLASS(isspace, " \n\r\t"); diff --git a/t/helper/test-date.c b/t/helper/test-date.c index ac83687970..a0837371ab 100644 --- a/t/helper/test-date.c +++ b/t/helper/test-date.c @@ -1,13 +1,14 @@ +#include "test-tool.h" #include "cache.h" static const char *usage_msg = "\n" -" test-date relative [time_t]...\n" -" test-date show:<format> [time_t]...\n" -" test-date parse [date]...\n" -" test-date approxidate [date]...\n" -" test-date timestamp [date]...\n" -" test-date is64bit\n" -" test-date time_t-is64bit\n"; +" test-tool date relative [time_t]...\n" +" test-tool date show:<format> [time_t]...\n" +" test-tool date parse [date]...\n" +" test-tool date approxidate [date]...\n" +" test-tool date timestamp [date]...\n" +" test-tool date is64bit\n" +" test-tool date time_t-is64bit\n"; static void show_relative_dates(const char **argv, struct timeval *now) { @@ -81,7 +82,7 @@ static void parse_approx_timestamp(const char **argv, struct timeval *now) } } -int cmd_main(int argc, const char **argv) +int cmd__date(int argc, const char **argv) { struct timeval now; const char *x; diff --git a/t/helper/test-delta.c b/t/helper/test-delta.c index 591730adc4..34c7259248 100644 --- a/t/helper/test-delta.c +++ b/t/helper/test-delta.c @@ -8,14 +8,15 @@ * published by the Free Software Foundation. */ +#include "test-tool.h" #include "git-compat-util.h" #include "delta.h" #include "cache.h" static const char usage_str[] = - "test-delta (-d|-p) <from_file> <data_file> <out_file>"; + "test-tool delta (-d|-p) <from_file> <data_file> <out_file>"; -int cmd_main(int argc, const char **argv) +int cmd__delta(int argc, const char **argv) { int fd; struct stat st; diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c index bd1a857d52..838760898b 100644 --- a/t/helper/test-drop-caches.c +++ b/t/helper/test-drop-caches.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "git-compat-util.h" #if defined(GIT_WINDOWS_NATIVE) @@ -157,7 +158,7 @@ static int cmd_dropcaches(void) #endif -int cmd_main(int argc, const char **argv) +int cmd__drop_caches(int argc, const char **argv) { cmd_sync(); return cmd_dropcaches(); diff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c index ebf3aab22d..98a4891f1d 100644 --- a/t/helper/test-dump-cache-tree.c +++ b/t/helper/test-dump-cache-tree.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "cache.h" #include "tree.h" #include "cache-tree.h" @@ -54,7 +55,7 @@ static int dump_cache_tree(struct cache_tree *it, return errs; } -int cmd_main(int ac, const char **av) +int cmd__dump_cache_tree(int ac, const char **av) { struct index_state istate; struct cache_tree *another = cache_tree(); diff --git a/t/helper/test-dump-split-index.c b/t/helper/test-dump-split-index.c index e44430b699..4e2fdb5e30 100644 --- a/t/helper/test-dump-split-index.c +++ b/t/helper/test-dump-split-index.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "cache.h" #include "split-index.h" #include "ewah/ewok.h" @@ -7,7 +8,7 @@ static void show_bit(size_t pos, void *data) printf(" %d", (int)pos); } -int cmd_main(int ac, const char **av) +int cmd__dump_split_index(int ac, const char **av) { struct split_index *si; int i; diff --git a/t/helper/test-example-decorate.c b/t/helper/test-example-decorate.c index 90dc97a9d0..081115bf8e 100644 --- a/t/helper/test-example-decorate.c +++ b/t/helper/test-example-decorate.c @@ -1,8 +1,9 @@ +#include "test-tool.h" #include "cache.h" #include "object.h" #include "decorate.h" -int cmd_main(int argc, const char **argv) +int cmd__example_decorate(int argc, const char **argv) { struct decoration n; struct object_id one_oid = { {1} }; diff --git a/t/helper/test-genrandom.c b/t/helper/test-genrandom.c index 8d11d22d98..99b8dc1e2d 100644 --- a/t/helper/test-genrandom.c +++ b/t/helper/test-genrandom.c @@ -4,9 +4,10 @@ * Copyright (C) 2007 by Nicolas Pitre, licensed under the GPL version 2. */ +#include "test-tool.h" #include "git-compat-util.h" -int cmd_main(int argc, const char **argv) +int cmd__genrandom(int argc, const char **argv) { unsigned long count, next = 0; unsigned char *c; diff --git a/t/helper/test-hashmap.c b/t/helper/test-hashmap.c index 9ae9281c07..23d2b172fe 100644 --- a/t/helper/test-hashmap.c +++ b/t/helper/test-hashmap.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "git-compat-util.h" #include "hashmap.h" #include "strbuf.h" @@ -77,7 +78,7 @@ static unsigned int hash(unsigned int method, unsigned int i, const char *key) /* * Test performance of hashmap.[ch] - * Usage: time echo "perfhashmap method rounds" | test-hashmap + * Usage: time echo "perfhashmap method rounds" | test-tool hashmap */ static void perf_hashmap(unsigned int method, unsigned int rounds) { @@ -144,7 +145,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds) * * perfhashmap method rounds -> test hashmap.[ch] performance */ -int cmd_main(int argc, const char **argv) +int cmd__hashmap(int argc, const char **argv) { struct strbuf line = STRBUF_INIT; struct hashmap map; diff --git a/t/helper/test-index-version.c b/t/helper/test-index-version.c index f569f6b7ef..fcd10968cc 100644 --- a/t/helper/test-index-version.c +++ b/t/helper/test-index-version.c @@ -1,6 +1,7 @@ +#include "test-tool.h" #include "cache.h" -int cmd_main(int argc, const char **argv) +int cmd__index_version(int argc, const char **argv) { struct cache_header hdr; int version; diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c index 297fb01d61..b99a37080d 100644 --- a/t/helper/test-lazy-init-name-hash.c +++ b/t/helper/test-lazy-init-name-hash.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "cache.h" #include "parse-options.h" @@ -184,14 +185,14 @@ static void analyze_run(void) } } -int cmd_main(int argc, const char **argv) +int cmd__lazy_init_name_hash(int argc, const char **argv) { const char *usage[] = { - "test-lazy-init-name-hash -d (-s | -m)", - "test-lazy-init-name-hash -p [-c c]", - "test-lazy-init-name-hash -a a [--step s] [-c c]", - "test-lazy-init-name-hash (-s | -m) [-c c]", - "test-lazy-init-name-hash -s -m [-c c]", + "test-tool lazy-init-name-hash -d (-s | -m)", + "test-tool lazy-init-name-hash -p [-c c]", + "test-tool lazy-init-name-hash -a a [--step s] [-c c]", + "test-tool lazy-init-name-hash (-s | -m) [-c c]", + "test-tool lazy-init-name-hash -s -m [-c c]", NULL }; struct option options[] = { diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c index 356d8edef1..96857f26ac 100644 --- a/t/helper/test-match-trees.c +++ b/t/helper/test-match-trees.c @@ -1,7 +1,8 @@ +#include "test-tool.h" #include "cache.h" #include "tree.h" -int cmd_main(int ac, const char **av) +int cmd__match_trees(int ac, const char **av) { struct object_id hash1, hash2, shifted; struct tree *one, *two; diff --git a/t/helper/test-mergesort.c b/t/helper/test-mergesort.c index 335cf6b626..c5cffaa4b7 100644 --- a/t/helper/test-mergesort.c +++ b/t/helper/test-mergesort.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "cache.h" #include "mergesort.h" @@ -22,7 +23,7 @@ static int compare_strings(const void *a, const void *b) return strcmp(x->text, y->text); } -int cmd_main(int argc, const char **argv) +int cmd__mergesort(int argc, const char **argv) { struct line *line, *p = NULL, *lines = NULL; struct strbuf sb = STRBUF_INIT; diff --git a/t/helper/test-mktemp.c b/t/helper/test-mktemp.c index 89d9b2f7be..2290688940 100644 --- a/t/helper/test-mktemp.c +++ b/t/helper/test-mktemp.c @@ -1,9 +1,10 @@ /* * test-mktemp.c: code to exercise the creation of temporary files */ +#include "test-tool.h" #include "git-compat-util.h" -int cmd_main(int argc, const char **argv) +int cmd__mktemp(int argc, const char **argv) { if (argc != 2) usage("Expected 1 parameter defining the temporary file template"); diff --git a/t/helper/test-online-cpus.c b/t/helper/test-online-cpus.c index 06c09c6b88..8cb0d53840 100644 --- a/t/helper/test-online-cpus.c +++ b/t/helper/test-online-cpus.c @@ -1,7 +1,8 @@ +#include "test-tool.h" #include "git-compat-util.h" #include "thread-utils.h" -int cmd_main(int argc, const char **argv) +int cmd__online_cpus(int argc, const char **argv) { printf("%d\n", online_cpus()); return 0; diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c index 2b3c5092a1..e115d44ac2 100644 --- a/t/helper/test-path-utils.c +++ b/t/helper/test-path-utils.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "cache.h" #include "string-list.h" @@ -170,7 +171,7 @@ static struct test_data dirname_data[] = { { NULL, NULL } }; -int cmd_main(int argc, const char **argv) +int cmd__path_utils(int argc, const char **argv) { if (argc == 3 && !strcmp(argv[1], "normalize_path_copy")) { char *buf = xmallocz(strlen(argv[2])); diff --git a/t/helper/test-pkt-line.c b/t/helper/test-pkt-line.c new file mode 100644 index 0000000000..0f19e53c75 --- /dev/null +++ b/t/helper/test-pkt-line.c @@ -0,0 +1,64 @@ +#include "pkt-line.h" + +static void pack_line(const char *line) +{ + if (!strcmp(line, "0000") || !strcmp(line, "0000\n")) + packet_flush(1); + else if (!strcmp(line, "0001") || !strcmp(line, "0001\n")) + packet_delim(1); + else + packet_write_fmt(1, "%s", line); +} + +static void pack(int argc, const char **argv) +{ + if (argc) { /* read from argv */ + int i; + for (i = 0; i < argc; i++) + pack_line(argv[i]); + } else { /* read from stdin */ + char line[LARGE_PACKET_MAX]; + while (fgets(line, sizeof(line), stdin)) { + pack_line(line); + } + } +} + +static void unpack(void) +{ + struct packet_reader reader; + packet_reader_init(&reader, 0, NULL, 0, + PACKET_READ_GENTLE_ON_EOF | + PACKET_READ_CHOMP_NEWLINE); + + while (packet_reader_read(&reader) != PACKET_READ_EOF) { + switch (reader.status) { + case PACKET_READ_EOF: + break; + case PACKET_READ_NORMAL: + printf("%s\n", reader.line); + break; + case PACKET_READ_FLUSH: + printf("0000\n"); + break; + case PACKET_READ_DELIM: + printf("0001\n"); + break; + } + } +} + +int cmd_main(int argc, const char **argv) +{ + if (argc < 2) + die("too few arguments"); + + if (!strcmp(argv[1], "pack")) + pack(argc - 2, argv + 2); + else if (!strcmp(argv[1], "unpack")) + unpack(); + else + die("invalid argument '%s'", argv[1]); + + return 0; +} diff --git a/t/helper/test-prio-queue.c b/t/helper/test-prio-queue.c index ae58fff359..9807b649b1 100644 --- a/t/helper/test-prio-queue.c +++ b/t/helper/test-prio-queue.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "cache.h" #include "prio-queue.h" @@ -16,7 +17,7 @@ static void show(int *v) free(v); } -int cmd_main(int argc, const char **argv) +int cmd__prio_queue(int argc, const char **argv) { struct prio_queue pq = { intcmp }; diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c index 48255eef31..d674c88ba0 100644 --- a/t/helper/test-read-cache.c +++ b/t/helper/test-read-cache.c @@ -1,6 +1,7 @@ +#include "test-tool.h" #include "cache.h" -int cmd_main(int argc, const char **argv) +int cmd__read_cache(int argc, const char **argv) { int i, cnt = 1; if (argc == 2) diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index 7120634b04..e9e0541276 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -1,6 +1,9 @@ +#include "test-tool.h" #include "cache.h" #include "refs.h" #include "worktree.h" +#include "object-store.h" +#include "repository.h" static const char *notnull(const char *arg, const char *name) { @@ -21,7 +24,7 @@ static const char **get_store(const char **argv, struct ref_store **refs) if (!argv[0]) { die("ref store required"); } else if (!strcmp(argv[0], "main")) { - *refs = get_main_ref_store(); + *refs = get_main_ref_store(the_repository); } else if (skip_prefix(argv[0], "submodule:", &gitdir)) { struct strbuf sb = STRBUF_INIT; int ret; @@ -274,7 +277,7 @@ static struct command commands[] = { { NULL, NULL } }; -int cmd_main(int argc, const char **argv) +int cmd__ref_store(int argc, const char **argv) { struct ref_store *refs; const char *func; diff --git a/t/helper/test-regex.c b/t/helper/test-regex.c index b5ea8a97c5..10284cc56f 100644 --- a/t/helper/test-regex.c +++ b/t/helper/test-regex.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "git-compat-util.h" #include "gettext.h" @@ -36,7 +37,7 @@ static int test_regex_bug(void) return 0; } -int cmd_main(int argc, const char **argv) +int cmd__regex(int argc, const char **argv) { const char *pat; const char *str; @@ -47,8 +48,8 @@ int cmd_main(int argc, const char **argv) if (argc == 2 && !strcmp(argv[1], "--bug")) return test_regex_bug(); else if (argc < 3) - usage("test-regex --bug\n" - "test-regex <pattern> <string> [<options>]"); + usage("test-tool regex --bug\n" + "test-tool regex <pattern> <string> [<options>]"); argv++; pat = *argv++; diff --git a/t/helper/test-revision-walking.c b/t/helper/test-revision-walking.c index b8e6fe1d00..4f8bc75821 100644 --- a/t/helper/test-revision-walking.c +++ b/t/helper/test-revision-walking.c @@ -8,6 +8,7 @@ * published by the Free Software Foundation. */ +#include "test-tool.h" #include "cache.h" #include "commit.h" #include "diff.h" @@ -45,7 +46,7 @@ static int run_revision_walk(void) return got_revision; } -int cmd_main(int argc, const char **argv) +int cmd__revision_walking(int argc, const char **argv) { if (argc < 2) return 1; diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c index 153342e44d..2cc93bb69c 100644 --- a/t/helper/test-run-command.c +++ b/t/helper/test-run-command.c @@ -8,6 +8,7 @@ * published by the Free Software Foundation. */ +#include "test-tool.h" #include "git-compat-util.h" #include "run-command.h" #include "argv-array.h" @@ -49,7 +50,7 @@ static int task_finished(int result, return 1; } -int cmd_main(int argc, const char **argv) +int cmd__run_command(int argc, const char **argv) { struct child_process proc = CHILD_PROCESS_INIT; int jobs; diff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c index d2a63bea43..d26d3e7c8b 100644 --- a/t/helper/test-scrap-cache-tree.c +++ b/t/helper/test-scrap-cache-tree.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "cache.h" #include "lockfile.h" #include "tree.h" @@ -5,7 +6,7 @@ static struct lock_file index_lock; -int cmd_main(int ac, const char **av) +int cmd__scrap_cache_tree(int ac, const char **av) { setup_git_directory(); hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR); diff --git a/t/helper/test-sha1-array.c b/t/helper/test-sha1-array.c index edfd52d82a..ad5e69f9d3 100644 --- a/t/helper/test-sha1-array.c +++ b/t/helper/test-sha1-array.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "cache.h" #include "sha1-array.h" @@ -7,7 +8,7 @@ static int print_oid(const struct object_id *oid, void *data) return 0; } -int cmd_main(int argc, const char **argv) +int cmd__sha1_array(int argc, const char **argv) { struct oid_array array = OID_ARRAY_INIT; struct strbuf line = STRBUF_INIT; diff --git a/t/helper/test-sha1.c b/t/helper/test-sha1.c index a1c13f54ec..1ba0675c75 100644 --- a/t/helper/test-sha1.c +++ b/t/helper/test-sha1.c @@ -1,6 +1,7 @@ +#include "test-tool.h" #include "cache.h" -int cmd_main(int ac, const char **av) +int cmd__sha1(int ac, const char **av) { git_SHA_CTX ctx; unsigned char sha1[20]; diff --git a/t/helper/test-sha1.sh b/t/helper/test-sha1.sh index 750b95a0a1..84594885c7 100755 --- a/t/helper/test-sha1.sh +++ b/t/helper/test-sha1.sh @@ -1,7 +1,7 @@ #!/bin/sh dd if=/dev/zero bs=1048576 count=100 2>/dev/null | -/usr/bin/time t/helper/test-sha1 >/dev/null +/usr/bin/time t/helper/test-tool sha1 >/dev/null while read expect cnt pfx do @@ -11,7 +11,7 @@ do test -z "$pfx" || echo "$pfx" dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null | perl -pe 'y/\000/g/' - } | ./t/helper/test-sha1 $cnt + } | ./t/helper/test-tool sha1 $cnt ) if test "$expect" = "$actual" then diff --git a/t/helper/test-sigchain.c b/t/helper/test-sigchain.c index b71edbd442..77ac5bc33f 100644 --- a/t/helper/test-sigchain.c +++ b/t/helper/test-sigchain.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "cache.h" #include "sigchain.h" @@ -13,7 +14,7 @@ X(two) X(three) #undef X -int cmd_main(int argc, const char **argv) { +int cmd__sigchain(int argc, const char **argv) { sigchain_push(SIGTERM, one); sigchain_push(SIGTERM, two); sigchain_push(SIGTERM, three); diff --git a/t/helper/test-strcmp-offset.c b/t/helper/test-strcmp-offset.c index e159c9a127..44e4a6d143 100644 --- a/t/helper/test-strcmp-offset.c +++ b/t/helper/test-strcmp-offset.c @@ -1,6 +1,7 @@ +#include "test-tool.h" #include "cache.h" -int cmd_main(int argc, const char **argv) +int cmd__strcmp_offset(int argc, const char **argv) { int result; size_t offset; diff --git a/t/helper/test-string-list.c b/t/helper/test-string-list.c index 829ec3d7d2..2123dda85b 100644 --- a/t/helper/test-string-list.c +++ b/t/helper/test-string-list.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "cache.h" #include "string-list.h" @@ -41,7 +42,7 @@ static int prefix_cb(struct string_list_item *item, void *cb_data) return starts_with(item->string, prefix); } -int cmd_main(int argc, const char **argv) +int cmd__string_list(int argc, const char **argv) { if (argc == 5 && !strcmp(argv[1], "split")) { struct string_list list = STRING_LIST_INIT_DUP; diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c index f23db3b19a..e2692746df 100644 --- a/t/helper/test-submodule-config.c +++ b/t/helper/test-submodule-config.c @@ -1,3 +1,4 @@ +#include "test-tool.h" #include "cache.h" #include "config.h" #include "submodule-config.h" @@ -10,7 +11,7 @@ static void die_usage(int argc, const char **argv, const char *msg) exit(1); } -int cmd_main(int argc, const char **argv) +int cmd__submodule_config(int argc, const char **argv) { const char **arg = argv; int my_argc = argc; @@ -48,9 +49,11 @@ int cmd_main(int argc, const char **argv) die_usage(argc, argv, "Commit not found."); if (lookup_name) { - submodule = submodule_from_name(&commit_oid, path_or_name); + submodule = submodule_from_name(the_repository, + &commit_oid, path_or_name); } else - submodule = submodule_from_path(&commit_oid, path_or_name); + submodule = submodule_from_path(the_repository, + &commit_oid, path_or_name); if (!submodule) die_usage(argc, argv, "Submodule not found."); @@ -64,7 +67,7 @@ int cmd_main(int argc, const char **argv) arg += 2; } - submodule_free(); + submodule_free(the_repository); return 0; } diff --git a/t/helper/test-subprocess.c b/t/helper/test-subprocess.c index 30c5765bfc..92b69de635 100644 --- a/t/helper/test-subprocess.c +++ b/t/helper/test-subprocess.c @@ -1,7 +1,8 @@ +#include "test-tool.h" #include "cache.h" #include "run-command.h" -int cmd_main(int argc, const char **argv) +int cmd__subprocess(int argc, const char **argv) { struct child_process cp = CHILD_PROCESS_INIT; int nogit = 0; diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c new file mode 100644 index 0000000000..87066ced62 --- /dev/null +++ b/t/helper/test-tool.c @@ -0,0 +1,62 @@ +#include "git-compat-util.h" +#include "test-tool.h" + +struct test_cmd { + const char *name; + int (*fn)(int argc, const char **argv); +}; + +static struct test_cmd cmds[] = { + { "chmtime", cmd__chmtime }, + { "config", cmd__config }, + { "ctype", cmd__ctype }, + { "date", cmd__date }, + { "delta", cmd__delta }, + { "drop-caches", cmd__drop_caches }, + { "dump-cache-tree", cmd__dump_cache_tree }, + { "dump-split-index", cmd__dump_split_index }, + { "example-decorate", cmd__example_decorate }, + { "genrandom", cmd__genrandom }, + { "hashmap", cmd__hashmap }, + { "index-version", cmd__index_version }, + { "lazy-init-name-hash", cmd__lazy_init_name_hash }, + { "match-trees", cmd__match_trees }, + { "mergesort", cmd__mergesort }, + { "mktemp", cmd__mktemp }, + { "online-cpus", cmd__online_cpus }, + { "path-utils", cmd__path_utils }, + { "prio-queue", cmd__prio_queue }, + { "read-cache", cmd__read_cache }, + { "ref-store", cmd__ref_store }, + { "regex", cmd__regex }, + { "revision-walking", cmd__revision_walking }, + { "run-command", cmd__run_command }, + { "scrap-cache-tree", cmd__scrap_cache_tree }, + { "sha1-array", cmd__sha1_array }, + { "sha1", cmd__sha1 }, + { "sigchain", cmd__sigchain }, + { "strcmp-offset", cmd__strcmp_offset }, + { "string-list", cmd__string_list }, + { "submodule-config", cmd__submodule_config }, + { "subprocess", cmd__subprocess }, + { "urlmatch-normalization", cmd__urlmatch_normalization }, + { "wildmatch", cmd__wildmatch }, + { "write-cache", cmd__write_cache }, +}; + +int cmd_main(int argc, const char **argv) +{ + int i; + + if (argc < 2) + die("I need a test name!"); + + for (i = 0; i < ARRAY_SIZE(cmds); i++) { + if (!strcmp(cmds[i].name, argv[1])) { + argv++; + argc--; + return cmds[i].fn(argc, argv); + } + } + die("There is no test named '%s'", argv[1]); +} diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h new file mode 100644 index 0000000000..7116ddfb94 --- /dev/null +++ b/t/helper/test-tool.h @@ -0,0 +1,40 @@ +#ifndef __TEST_TOOL_H__ +#define __TEST_TOOL_H__ + +int cmd__chmtime(int argc, const char **argv); +int cmd__config(int argc, const char **argv); +int cmd__ctype(int argc, const char **argv); +int cmd__date(int argc, const char **argv); +int cmd__delta(int argc, const char **argv); +int cmd__drop_caches(int argc, const char **argv); +int cmd__dump_cache_tree(int argc, const char **argv); +int cmd__dump_split_index(int argc, const char **argv); +int cmd__example_decorate(int argc, const char **argv); +int cmd__genrandom(int argc, const char **argv); +int cmd__hashmap(int argc, const char **argv); +int cmd__index_version(int argc, const char **argv); +int cmd__lazy_init_name_hash(int argc, const char **argv); +int cmd__match_trees(int argc, const char **argv); +int cmd__mergesort(int argc, const char **argv); +int cmd__mktemp(int argc, const char **argv); +int cmd__online_cpus(int argc, const char **argv); +int cmd__path_utils(int argc, const char **argv); +int cmd__prio_queue(int argc, const char **argv); +int cmd__read_cache(int argc, const char **argv); +int cmd__ref_store(int argc, const char **argv); +int cmd__regex(int argc, const char **argv); +int cmd__revision_walking(int argc, const char **argv); +int cmd__run_command(int argc, const char **argv); +int cmd__scrap_cache_tree(int argc, const char **argv); +int cmd__sha1_array(int argc, const char **argv); +int cmd__sha1(int argc, const char **argv); +int cmd__sigchain(int argc, const char **argv); +int cmd__strcmp_offset(int argc, const char **argv); +int cmd__string_list(int argc, const char **argv); +int cmd__submodule_config(int argc, const char **argv); +int cmd__subprocess(int argc, const char **argv); +int cmd__urlmatch_normalization(int argc, const char **argv); +int cmd__wildmatch(int argc, const char **argv); +int cmd__write_cache(int argc, const char **argv); + +#endif diff --git a/t/helper/test-urlmatch-normalization.c b/t/helper/test-urlmatch-normalization.c index 49b6e836be..8f4d67e646 100644 --- a/t/helper/test-urlmatch-normalization.c +++ b/t/helper/test-urlmatch-normalization.c @@ -1,9 +1,10 @@ +#include "test-tool.h" #include "git-compat-util.h" #include "urlmatch.h" -int cmd_main(int argc, const char **argv) +int cmd__urlmatch_normalization(int argc, const char **argv) { - const char usage[] = "test-urlmatch-normalization [-p | -l] <url1> | <url1> <url2>"; + const char usage[] = "test-tool urlmatch-normalization [-p | -l] <url1> | <url1> <url2>"; char *url1, *url2; int opt_p = 0, opt_l = 0; diff --git a/t/helper/test-wildmatch.c b/t/helper/test-wildmatch.c index 66d33dfcfd..2c103d1824 100644 --- a/t/helper/test-wildmatch.c +++ b/t/helper/test-wildmatch.c @@ -1,6 +1,7 @@ +#include "test-tool.h" #include "cache.h" -int cmd_main(int argc, const char **argv) +int cmd__wildmatch(int argc, const char **argv) { int i; for (i = 2; i < argc; i++) { diff --git a/t/helper/test-write-cache.c b/t/helper/test-write-cache.c index b7ee039669..017dc30380 100644 --- a/t/helper/test-write-cache.c +++ b/t/helper/test-write-cache.c @@ -1,9 +1,10 @@ +#include "test-tool.h" #include "cache.h" #include "lockfile.h" static struct lock_file index_lock; -int cmd_main(int argc, const char **argv) +int cmd__write_cache(int argc, const char **argv) { int i, cnt = 1, lockfd; if (argc == 2) diff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh index 54fd5a6ca0..c27599474c 100644 --- a/t/lib-git-p4.sh +++ b/t/lib-git-p4.sh @@ -39,7 +39,7 @@ native_path () { then path=$(cygpath --windows "$path") else - path=$(test-path-utils real_path "$path") + path=$(test-tool path-utils real_path "$path") fi && echo "$path" } diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh index 4c1f81f167..a8130f9119 100644 --- a/t/lib-git-svn.sh +++ b/t/lib-git-svn.sh @@ -49,7 +49,7 @@ rawsvnrepo="$svnrepo" svnrepo="file://$svnrepo" poke() { - test-chmtime +1 "$1" + test-tool chmtime +1 "$1" } # We need this, because we should pass empty configuration directory to diff --git a/t/lib-pack.sh b/t/lib-pack.sh index 7509846571..501078249d 100644 --- a/t/lib-pack.sh +++ b/t/lib-pack.sh @@ -85,7 +85,7 @@ pack_obj () { # Compute and append pack trailer to "$1" pack_trailer () { - test-sha1 -b <"$1" >trailer.tmp && + test-tool sha1 -b <"$1" >trailer.tmp && cat trailer.tmp >>"$1" && rm -f trailer.tmp } diff --git a/t/perf/aggregate.perl b/t/perf/aggregate.perl index 821cf1498b..48637ef64b 100755 --- a/t/perf/aggregate.perl +++ b/t/perf/aggregate.perl @@ -37,7 +37,7 @@ sub format_times { } my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests, - $codespeed, $subsection, $reponame); + $codespeed, $sortby, $subsection, $reponame); while (scalar @ARGV) { my $arg = $ARGV[0]; my $dir; @@ -46,6 +46,18 @@ while (scalar @ARGV) { shift @ARGV; next; } + if ($arg =~ /--sort-by(?:=(.*))?/) { + shift @ARGV; + if (defined $1) { + $sortby = $1; + } else { + $sortby = shift @ARGV; + if (! defined $sortby) { + die "'--sort-by' requires an argument"; + } + } + next; + } if ($arg eq "--subsection") { shift @ARGV; $subsection = $ARGV[0]; @@ -147,6 +159,11 @@ sub have_slash { return 0; } +sub display_dir { + my ($d) = @_; + return exists $dirabbrevs{$d} ? $dirabbrevs{$d} : $dirnames{$d}; +} + sub print_default_results { my %descrs; my $descrlen = 4; # "Test" @@ -168,8 +185,7 @@ sub print_default_results { my %times; my @colwidth = ((0)x@dirs); for my $i (0..$#dirs) { - my $d = $dirs[$i]; - my $w = length (exists $dirabbrevs{$d} ? $dirabbrevs{$d} : $dirnames{$d}); + my $w = length display_dir($dirs[$i]); $colwidth[$i] = $w if $w > $colwidth[$i]; } for my $t (@subtests) { @@ -188,8 +204,7 @@ sub print_default_results { printf "%-${descrlen}s", "Test"; for my $i (0..$#dirs) { - my $d = $dirs[$i]; - printf " %-$colwidth[$i]s", (exists $dirabbrevs{$d} ? $dirabbrevs{$d} : $dirnames{$d}); + printf " %-$colwidth[$i]s", display_dir($dirs[$i]); } print "\n"; print "-"x$totalwidth, "\n"; @@ -206,6 +221,49 @@ sub print_default_results { } } +sub print_sorted_results { + my ($sortby) = @_; + + if ($sortby ne "regression") { + die "only 'regression' is supported as '--sort-by' argument"; + } + + my @evolutions; + for my $t (@subtests) { + my ($prevr, $prevu, $prevs, $prevrev); + for my $i (0..$#dirs) { + my $d = $dirs[$i]; + my ($r, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times"); + if ($i > 0 and defined $r and defined $prevr and $prevr > 0) { + my $percent = 100.0 * ($r - $prevr) / $prevr; + push @evolutions, { "percent" => $percent, + "test" => $t, + "prevrev" => $prevrev, + "rev" => $d, + "prevr" => $prevr, + "r" => $r, + "prevu" => $prevu, + "u" => $u, + "prevs" => $prevs, + "s" => $s}; + } + ($prevr, $prevu, $prevs, $prevrev) = ($r, $u, $s, $d); + } + } + + my @sorted_evolutions = sort { $b->{percent} <=> $a->{percent} } @evolutions; + + for my $e (@sorted_evolutions) { + printf "%+.1f%%", $e->{percent}; + print " " . $e->{test}; + print " " . format_times($e->{prevr}, $e->{prevu}, $e->{prevs}); + print " " . format_times($e->{r}, $e->{u}, $e->{s}); + print " " . display_dir($e->{prevrev}); + print " " . display_dir($e->{rev}); + print "\n"; + } +} + sub print_codespeed_results { my ($subsection) = @_; @@ -260,6 +318,8 @@ binmode STDOUT, ":utf8" or die "PANIC on binmode: $!"; if ($codespeed) { print_codespeed_results($subsection); +} elsif (defined $sortby) { + print_sorted_results($sortby); } else { print_default_results(); } diff --git a/t/perf/bisect_regression b/t/perf/bisect_regression new file mode 100755 index 0000000000..a94d9955d0 --- /dev/null +++ b/t/perf/bisect_regression @@ -0,0 +1,73 @@ +#!/bin/sh + +# Read a line coming from `./aggregate.perl --sort-by regression ...` +# and automatically bisect to find the commit responsible for the +# performance regression. +# +# Lines from `./aggregate.perl --sort-by regression ...` look like: +# +# +100.0% p7821-grep-engines-fixed.1 0.04(0.10+0.03) 0.08(0.11+0.08) v2.14.3 v2.15.1 +# +33.3% p7820-grep-engines.1 0.03(0.08+0.02) 0.04(0.08+0.02) v2.14.3 v2.15.1 +# + +die () { + echo >&2 "error: $*" + exit 1 +} + +while [ $# -gt 0 ]; do + arg="$1" + case "$arg" in + --help) + echo "usage: $0 [--config file] [--subsection subsection]" + exit 0 + ;; + --config) + shift + GIT_PERF_CONFIG_FILE=$(cd "$(dirname "$1")"; pwd)/$(basename "$1") + export GIT_PERF_CONFIG_FILE + shift ;; + --subsection) + shift + GIT_PERF_SUBSECTION="$1" + export GIT_PERF_SUBSECTION + shift ;; + --*) + die "unrecognised option: '$arg'" ;; + *) + die "unknown argument '$arg'" + ;; + esac +done + +read -r regression subtest oldtime newtime oldrev newrev + +test_script=$(echo "$subtest" | sed -e 's/\(.*\)\.[0-9]*$/\1.sh/') +test_number=$(echo "$subtest" | sed -e 's/.*\.\([0-9]*\)$/\1/') + +# oldtime and newtime are decimal number, not integers + +oldtime=$(echo "$oldtime" | sed -e 's/^\([0-9]\+\.[0-9]\+\).*$/\1/') +newtime=$(echo "$newtime" | sed -e 's/^\([0-9]\+\.[0-9]\+\).*$/\1/') + +test $(echo "$newtime" "$oldtime" | awk '{ print ($1 > $2) }') = 1 || + die "New time '$newtime' shoud be greater than old time '$oldtime'" + +tmpdir=$(mktemp -d -t bisect_regression_XXXXXX) || die "Failed to create temp directory" +echo "$oldtime" >"$tmpdir/oldtime" || die "Failed to write to '$tmpdir/oldtime'" +echo "$newtime" >"$tmpdir/newtime" || die "Failed to write to '$tmpdir/newtime'" + +# Bisecting must be performed from the top level directory (even with --no-checkout) +( + toplevel_dir=$(git rev-parse --show-toplevel) || die "Failed to find top level directory" + cd "$toplevel_dir" || die "Failed to cd into top level directory '$toplevel_dir'" + + git bisect start --no-checkout "$newrev" "$oldrev" || die "Failed to start bisecting" + + git bisect run t/perf/bisect_run_script "$test_script" "$test_number" "$tmpdir" + res="$?" + + git bisect reset + + exit "$res" +) diff --git a/t/perf/bisect_run_script b/t/perf/bisect_run_script new file mode 100755 index 0000000000..038255df4b --- /dev/null +++ b/t/perf/bisect_run_script @@ -0,0 +1,47 @@ +#!/bin/sh + +script="$1" +test_number="$2" +info_dir="$3" + +# This aborts the bisection immediately +die () { + echo >&2 "error: $*" + exit 255 +} + +bisect_head=$(git rev-parse --verify BISECT_HEAD) || die "Failed to find BISECT_HEAD ref" + +script_number=$(echo "$script" | sed -e "s/^p\([0-9]*\).*\$/\1/") || die "Failed to get script number for '$script'" + +oldtime=$(cat "$info_dir/oldtime") || die "Failed to access '$info_dir/oldtime'" +newtime=$(cat "$info_dir/newtime") || die "Failed to access '$info_dir/newtime'" + +cd t/perf || die "Failed to cd into 't/perf'" + +result_file="$info_dir/perf_${script_number}_${bisect_head}_results.txt" + +GIT_PERF_DIRS_OR_REVS="$bisect_head" +export GIT_PERF_DIRS_OR_REVS + +./run "$script" >"$result_file" 2>&1 || die "Failed to run perf test '$script'" + +rtime=$(sed -n "s/^$script_number\.$test_number:.*\([0-9]\+\.[0-9]\+\)(.*).*\$/\1/p" "$result_file") + +echo "newtime: $newtime" +echo "rtime: $rtime" +echo "oldtime: $oldtime" + +# Compare ($newtime - $rtime) with ($rtime - $oldtime) +# Times are decimal number, not integers + +if test $(echo "$newtime" "$rtime" "$oldtime" | awk '{ print ($1 - $2 > $2 - $3) }') = 1 +then + # Current commit is considered "good/old" + echo "$rtime" >"$info_dir/oldtime" + exit 0 +else + # Current commit is considered "bad/new" + echo "$rtime" >"$info_dir/newtime" + exit 1 +fi diff --git a/t/perf/p0002-read-cache.sh b/t/perf/p0002-read-cache.sh index 9180ae9343..cdd105a594 100755 --- a/t/perf/p0002-read-cache.sh +++ b/t/perf/p0002-read-cache.sh @@ -8,7 +8,7 @@ test_perf_default_repo count=1000 test_perf "read_cache/discard_cache $count times" " - test-read-cache $count + test-tool read-cache $count " test_done diff --git a/t/perf/p0004-lazy-init-name-hash.sh b/t/perf/p0004-lazy-init-name-hash.sh index 8de5a98cfc..1afc08fe7f 100755 --- a/t/perf/p0004-lazy-init-name-hash.sh +++ b/t/perf/p0004-lazy-init-name-hash.sh @@ -7,8 +7,8 @@ test_perf_large_repo test_checkout_worktree test_expect_success 'verify both methods build the same hashmaps' ' - test-lazy-init-name-hash --dump --single >out.single && - if test-lazy-init-name-hash --dump --multi >out.multi + test-tool lazy-init-name-hash --dump --single >out.single && + if test-tool lazy-init-name-hash --dump --multi >out.multi then test_set_prereq REPO_BIG_ENOUGH_FOR_MULTI && sort <out.single >sorted.single && @@ -46,11 +46,11 @@ test_expect_success 'calibrate' ' ' test_perf "single-threaded, $desc" " - test-lazy-init-name-hash --single --count=$count + test-tool lazy-init-name-hash --single --count=$count " test_perf REPO_BIG_ENOUGH_FOR_MULTI "multi-threaded, $desc" " - test-lazy-init-name-hash --multi --count=$count + test-tool lazy-init-name-hash --multi --count=$count " test_done diff --git a/t/perf/p0007-write-cache.sh b/t/perf/p0007-write-cache.sh index 261fe92fd9..09595264f0 100755 --- a/t/perf/p0007-write-cache.sh +++ b/t/perf/p0007-write-cache.sh @@ -23,7 +23,7 @@ test_expect_success "setup repo" ' count=3 test_perf "write_locked_index $count times ($nr_files files)" " - test-write-cache $count + test-tool write-cache $count " test_done diff --git a/t/perf/p0071-sort.sh b/t/perf/p0071-sort.sh index 7c9a35a646..6e924f5fa3 100755 --- a/t/perf/p0071-sort.sh +++ b/t/perf/p0071-sort.sh @@ -16,7 +16,7 @@ test_perf 'sort(1)' ' ' test_perf 'string_list_sort()' ' - test-string-list sort <unsorted >actual + test-tool string-list sort <unsorted >actual ' test_expect_success 'string_list_sort() sorts like sort(1)' ' diff --git a/t/perf/p7519-fsmonitor.sh b/t/perf/p7519-fsmonitor.sh index 65e145c02d..def7ecdbc7 100755 --- a/t/perf/p7519-fsmonitor.sh +++ b/t/perf/p7519-fsmonitor.sh @@ -118,7 +118,7 @@ test_expect_success "setup for fsmonitor" ' ' if test -n "$GIT_PERF_7519_DROP_CACHE"; then - test-drop-caches + test-tool drop-caches fi test_perf "status (fsmonitor=$INTEGRATION_SCRIPT)" ' @@ -126,7 +126,7 @@ test_perf "status (fsmonitor=$INTEGRATION_SCRIPT)" ' ' if test -n "$GIT_PERF_7519_DROP_CACHE"; then - test-drop-caches + test-tool drop-caches fi test_perf "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" ' @@ -134,7 +134,7 @@ test_perf "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" ' ' if test -n "$GIT_PERF_7519_DROP_CACHE"; then - test-drop-caches + test-tool drop-caches fi test_perf "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" ' @@ -148,7 +148,7 @@ test_expect_success "setup without fsmonitor" ' ' if test -n "$GIT_PERF_7519_DROP_CACHE"; then - test-drop-caches + test-tool drop-caches fi test_perf "status (fsmonitor=$INTEGRATION_SCRIPT)" ' @@ -156,7 +156,7 @@ test_perf "status (fsmonitor=$INTEGRATION_SCRIPT)" ' ' if test -n "$GIT_PERF_7519_DROP_CACHE"; then - test-drop-caches + test-tool drop-caches fi test_perf "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" ' @@ -164,7 +164,7 @@ test_perf "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" ' ' if test -n "$GIT_PERF_7519_DROP_CACHE"; then - test-drop-caches + test-tool drop-caches fi test_perf "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" ' diff --git a/t/perf/run b/t/perf/run index 213da5d6b9..9aaa733c77 100755 --- a/t/perf/run +++ b/t/perf/run @@ -1,21 +1,34 @@ #!/bin/sh -case "$1" in +die () { + echo >&2 "error: $*" + exit 1 +} + +while [ $# -gt 0 ]; do + arg="$1" + case "$arg" in + --) + break ;; --help) - echo "usage: $0 [--config file] [other_git_tree...] [--] [test_scripts]" - exit 0 - ;; + echo "usage: $0 [--config file] [--subsection subsec] [other_git_tree...] [--] [test_scripts]" + exit 0 ;; --config) shift GIT_PERF_CONFIG_FILE=$(cd "$(dirname "$1")"; pwd)/$(basename "$1") export GIT_PERF_CONFIG_FILE shift ;; -esac - -die () { - echo >&2 "error: $*" - exit 1 -} + --subsection) + shift + GIT_PERF_SUBSECTION="$1" + export GIT_PERF_SUBSECTION + shift ;; + --*) + die "unrecognised option: '$arg'" ;; + *) + break ;; + esac +done run_one_dir () { if test $# -eq 0; then @@ -172,9 +185,32 @@ get_subsections "perf" >test-results/run_subsections.names if test $(wc -l <test-results/run_subsections.names) -eq 0 then + if test -n "$GIT_PERF_SUBSECTION" + then + if test -n "$GIT_PERF_CONFIG_FILE" + then + die "no subsections are defined in config file '$GIT_PERF_CONFIG_FILE'" + else + die "subsection '$GIT_PERF_SUBSECTION' defined without a config file" + fi + fi ( run_subsection "$@" ) +elif test -n "$GIT_PERF_SUBSECTION" +then + egrep "^$GIT_PERF_SUBSECTION\$" test-results/run_subsections.names >/dev/null || + die "subsection '$GIT_PERF_SUBSECTION' not found in '$GIT_PERF_CONFIG_FILE'" + + egrep "^$GIT_PERF_SUBSECTION\$" test-results/run_subsections.names | while read -r subsec + do + ( + GIT_PERF_SUBSECTION="$subsec" + export GIT_PERF_SUBSECTION + echo "======== Run for subsection '$GIT_PERF_SUBSECTION' ========" + run_subsection "$@" + ) + done else while read -r subsec do diff --git a/t/t0005-signals.sh b/t/t0005-signals.sh index 46042f1f13..4c214bd11c 100755 --- a/t/t0005-signals.sh +++ b/t/t0005-signals.sh @@ -10,7 +10,7 @@ one EOF test_expect_success 'sigchain works' ' - { test-sigchain >actual; ret=$?; } && + { test-tool sigchain >actual; ret=$?; } && { # Signal death by raise() on Windows acts like exit(3), # regardless of the signal number. So we must allow that @@ -24,7 +24,7 @@ test_expect_success 'sigchain works' ' test_expect_success !MINGW 'signals are propagated using shell convention' ' # we use exec here to avoid any sub-shell interpretation # of the exit code - git config alias.sigterm "!exec test-sigchain" && + git config alias.sigterm "!exec test-tool sigchain" && test_expect_code 143 git sigterm ' @@ -36,7 +36,7 @@ large_git () { } test_expect_success 'create blob' ' - test-genrandom foo 16384 >file && + test-tool genrandom foo 16384 >file && git add file ' diff --git a/t/t0006-date.sh b/t/t0006-date.sh index 7ac9466d50..64ff86df8e 100755 --- a/t/t0006-date.sh +++ b/t/t0006-date.sh @@ -10,7 +10,7 @@ check_relative() { t=$(($TEST_DATE_NOW - $1)) echo "$t -> $2" >expect test_expect_${3:-success} "relative date ($2)" " - test-date relative $t >actual && + test-tool date relative $t >actual && test_i18ncmp expect actual " } @@ -35,7 +35,7 @@ check_show () { zone=$5 test_expect_success $prereqs "show date ($format:$time)" ' echo "$time -> $expect" >expect && - TZ=${zone:-$TZ} test-date show:"$format" "$time" >actual && + TZ=${zone:-$TZ} test-tool date show:"$format" "$time" >actual && test_cmp expect actual ' } @@ -71,7 +71,7 @@ check_show iso-local "$FUTURE" "2152-06-19 22:24:56 +0000" TIME_IS_64BIT,TIME_T_ check_parse() { echo "$1 -> $2" >expect test_expect_${4:-success} "parse date ($1${3:+ TZ=$3})" " - TZ=${3:-$TZ} test-date parse '$1' >actual && + TZ=${3:-$TZ} test-tool date parse '$1' >actual && test_cmp expect actual " } @@ -92,7 +92,7 @@ check_parse '2008-02-14 20:30:45' '2008-02-14 20:30:45 -0500' EST5 check_approxidate() { echo "$1 -> $2 +0000" >expect test_expect_${3:-success} "parse approxidate ($1)" " - test-date approxidate '$1' >actual && + test-tool date approxidate '$1' >actual && test_cmp expect actual " } diff --git a/t/t0009-prio-queue.sh b/t/t0009-prio-queue.sh index 94045c3fad..e56dfce668 100755 --- a/t/t0009-prio-queue.sh +++ b/t/t0009-prio-queue.sh @@ -17,7 +17,7 @@ cat >expect <<'EOF' 10 EOF test_expect_success 'basic ordering' ' - test-prio-queue 2 6 3 10 9 5 7 4 5 8 1 dump >actual && + test-tool prio-queue 2 6 3 10 9 5 7 4 5 8 1 dump >actual && test_cmp expect actual ' @@ -30,7 +30,7 @@ cat >expect <<'EOF' 6 EOF test_expect_success 'mixed put and get' ' - test-prio-queue 6 2 4 get 5 3 get get 1 dump >actual && + test-tool prio-queue 6 2 4 get 5 3 get get 1 dump >actual && test_cmp expect actual ' @@ -43,7 +43,7 @@ NULL NULL EOF test_expect_success 'notice empty queue' ' - test-prio-queue 1 2 get get get 1 2 get get get >actual && + test-tool prio-queue 1 2 get get get 1 2 get get get >actual && test_cmp expect actual ' diff --git a/t/t0011-hashmap.sh b/t/t0011-hashmap.sh index 9c217d948c..3f1f505e89 100755 --- a/t/t0011-hashmap.sh +++ b/t/t0011-hashmap.sh @@ -4,7 +4,7 @@ test_description='test hashmap and string hash functions' . ./test-lib.sh test_hashmap() { - echo "$1" | test-hashmap $3 > actual && + echo "$1" | test-tool hashmap $3 > actual && echo "$2" > expect && test_cmp expect actual } @@ -232,7 +232,7 @@ test_expect_success 'grow / shrink' ' echo value40 >> expect && echo size >> in && echo 64 39 >> expect && - cat in | test-hashmap > out && + cat in | test-tool hashmap > out && test_cmp expect out ' diff --git a/t/t0013-sha1dc.sh b/t/t0013-sha1dc.sh index 6d655cb161..419f31a8f7 100755 --- a/t/t0013-sha1dc.sh +++ b/t/t0013-sha1dc.sh @@ -11,7 +11,7 @@ then fi test_expect_success 'test-sha1 detects shattered pdf' ' - test_must_fail test-sha1 <"$TEST_DATA/shattered-1.pdf" 2>err && + test_must_fail test-tool sha1 <"$TEST_DATA/shattered-1.pdf" 2>err && test_i18ngrep collision err && grep 38762cf7f55934b34d179ae6a4c80cadccbb7f0a err ' diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh index 46f8e583c3..9479a4aaab 100755 --- a/t/t0021-conversion.sh +++ b/t/t0021-conversion.sh @@ -19,7 +19,7 @@ write_script rot13-filter.pl "$PERL_PATH" \ generate_random_characters () { LEN=$1 NAME=$2 - test-genrandom some-seed $LEN | + test-tool genrandom some-seed $LEN | perl -pe "s/./chr((ord($&) % 26) + ord('a'))/sge" >"$TEST_ROOT/$NAME" } @@ -267,7 +267,7 @@ test_expect_success 'filtering large input to small output should use little mem ' test_expect_success 'filter that does not read is fine' ' - test-genrandom foo $((128 * 1024 + 1)) >big && + test-tool genrandom foo $((128 * 1024 + 1)) >big && echo "big filter=epipe" >.gitattributes && test_config filter.epipe.clean "echo xyzzy" && git add big && diff --git a/t/t0028-working-tree-encoding.sh b/t/t0028-working-tree-encoding.sh new file mode 100755 index 0000000000..12b8eb963a --- /dev/null +++ b/t/t0028-working-tree-encoding.sh @@ -0,0 +1,245 @@ +#!/bin/sh + +test_description='working-tree-encoding conversion via gitattributes' + +. ./test-lib.sh + +GIT_TRACE_WORKING_TREE_ENCODING=1 && export GIT_TRACE_WORKING_TREE_ENCODING + +test_expect_success 'setup test files' ' + git config core.eol lf && + + text="hallo there!\ncan you read me?" && + echo "*.utf16 text working-tree-encoding=utf-16" >.gitattributes && + printf "$text" >test.utf8.raw && + printf "$text" | iconv -f UTF-8 -t UTF-16 >test.utf16.raw && + printf "$text" | iconv -f UTF-8 -t UTF-32 >test.utf32.raw && + + # Line ending tests + printf "one\ntwo\nthree\n" >lf.utf8.raw && + printf "one\r\ntwo\r\nthree\r\n" >crlf.utf8.raw && + + # BOM tests + printf "\0a\0b\0c" >nobom.utf16be.raw && + printf "a\0b\0c\0" >nobom.utf16le.raw && + printf "\376\777\0a\0b\0c" >bebom.utf16be.raw && + printf "\777\376a\0b\0c\0" >lebom.utf16le.raw && + printf "\0\0\0a\0\0\0b\0\0\0c" >nobom.utf32be.raw && + printf "a\0\0\0b\0\0\0c\0\0\0" >nobom.utf32le.raw && + printf "\0\0\376\777\0\0\0a\0\0\0b\0\0\0c" >bebom.utf32be.raw && + printf "\777\376\0\0a\0\0\0b\0\0\0c\0\0\0" >lebom.utf32le.raw && + + # Add only UTF-16 file, we will add the UTF-32 file later + cp test.utf16.raw test.utf16 && + cp test.utf32.raw test.utf32 && + git add .gitattributes test.utf16 && + git commit -m initial +' + +test_expect_success 'ensure UTF-8 is stored in Git' ' + test_when_finished "rm -f test.utf16.git" && + + git cat-file -p :test.utf16 >test.utf16.git && + test_cmp_bin test.utf8.raw test.utf16.git +' + +test_expect_success 're-encode to UTF-16 on checkout' ' + test_when_finished "rm -f test.utf16.raw" && + + rm test.utf16 && + git checkout test.utf16 && + test_cmp_bin test.utf16.raw test.utf16 +' + +test_expect_success 'check $GIT_DIR/info/attributes support' ' + test_when_finished "rm -f test.utf32.git" && + test_when_finished "git reset --hard HEAD" && + + echo "*.utf32 text working-tree-encoding=utf-32" >.git/info/attributes && + git add test.utf32 && + + git cat-file -p :test.utf32 >test.utf32.git && + test_cmp_bin test.utf8.raw test.utf32.git +' + +for i in 16 32 +do + test_expect_success "check prohibited UTF-${i} BOM" ' + test_when_finished "git reset --hard HEAD" && + + echo "*.utf${i}be text working-tree-encoding=utf-${i}be" >>.gitattributes && + echo "*.utf${i}le text working-tree-encoding=utf-${i}LE" >>.gitattributes && + + # Here we add a UTF-16 (resp. UTF-32) files with BOM (big/little-endian) + # but we tell Git to treat it as UTF-16BE/UTF-16LE (resp. UTF-32). + # In these cases the BOM is prohibited. + cp bebom.utf${i}be.raw bebom.utf${i}be && + test_must_fail git add bebom.utf${i}be 2>err.out && + test_i18ngrep "fatal: BOM is prohibited .* utf-${i}be" err.out && + test_i18ngrep "use UTF-${i} as working-tree-encoding" err.out && + + cp lebom.utf${i}le.raw lebom.utf${i}be && + test_must_fail git add lebom.utf${i}be 2>err.out && + test_i18ngrep "fatal: BOM is prohibited .* utf-${i}be" err.out && + test_i18ngrep "use UTF-${i} as working-tree-encoding" err.out && + + cp bebom.utf${i}be.raw bebom.utf${i}le && + test_must_fail git add bebom.utf${i}le 2>err.out && + test_i18ngrep "fatal: BOM is prohibited .* utf-${i}LE" err.out && + test_i18ngrep "use UTF-${i} as working-tree-encoding" err.out && + + cp lebom.utf${i}le.raw lebom.utf${i}le && + test_must_fail git add lebom.utf${i}le 2>err.out && + test_i18ngrep "fatal: BOM is prohibited .* utf-${i}LE" err.out && + test_i18ngrep "use UTF-${i} as working-tree-encoding" err.out + ' + + test_expect_success "check required UTF-${i} BOM" ' + test_when_finished "git reset --hard HEAD" && + + echo "*.utf${i} text working-tree-encoding=utf-${i}" >>.gitattributes && + + cp nobom.utf${i}be.raw nobom.utf${i} && + test_must_fail git add nobom.utf${i} 2>err.out && + test_i18ngrep "fatal: BOM is required .* utf-${i}" err.out && + test_i18ngrep "use UTF-${i}BE or UTF-${i}LE" err.out && + + cp nobom.utf${i}le.raw nobom.utf${i} && + test_must_fail git add nobom.utf${i} 2>err.out && + test_i18ngrep "fatal: BOM is required .* utf-${i}" err.out && + test_i18ngrep "use UTF-${i}BE or UTF-${i}LE" err.out + ' + + test_expect_success "eol conversion for UTF-${i} encoded files on checkout" ' + test_when_finished "rm -f crlf.utf${i}.raw lf.utf${i}.raw" && + test_when_finished "git reset --hard HEAD^" && + + cat lf.utf8.raw | iconv -f UTF-8 -t UTF-${i} >lf.utf${i}.raw && + cat crlf.utf8.raw | iconv -f UTF-8 -t UTF-${i} >crlf.utf${i}.raw && + cp crlf.utf${i}.raw eol.utf${i} && + + cat >expectIndexLF <<-EOF && + i/lf w/-text attr/text eol.utf${i} + EOF + + git add eol.utf${i} && + git commit -m eol && + + # UTF-${i} with CRLF (Windows line endings) + rm eol.utf${i} && + git -c core.eol=crlf checkout eol.utf${i} && + test_cmp_bin crlf.utf${i}.raw eol.utf${i} && + + # Although the file has CRLF in the working tree, + # ensure LF in the index + git ls-files --eol eol.utf${i} >actual && + test_cmp expectIndexLF actual && + + # UTF-${i} with LF (Unix line endings) + rm eol.utf${i} && + git -c core.eol=lf checkout eol.utf${i} && + test_cmp_bin lf.utf${i}.raw eol.utf${i} && + + # The file LF in the working tree, ensure LF in the index + git ls-files --eol eol.utf${i} >actual && + test_cmp expectIndexLF actual + ' +done + +test_expect_success 'check unsupported encodings' ' + test_when_finished "git reset --hard HEAD" && + + echo "*.set text working-tree-encoding" >.gitattributes && + printf "set" >t.set && + test_must_fail git add t.set 2>err.out && + test_i18ngrep "true/false are no valid working-tree-encodings" err.out && + + echo "*.unset text -working-tree-encoding" >.gitattributes && + printf "unset" >t.unset && + git add t.unset && + + echo "*.empty text working-tree-encoding=" >.gitattributes && + printf "empty" >t.empty && + git add t.empty && + + echo "*.garbage text working-tree-encoding=garbage" >.gitattributes && + printf "garbage" >t.garbage && + test_must_fail git add t.garbage 2>err.out && + test_i18ngrep "failed to encode" err.out +' + +test_expect_success 'error if encoding round trip is not the same during refresh' ' + BEFORE_STATE=$(git rev-parse HEAD) && + test_when_finished "git reset --hard $BEFORE_STATE" && + + # Add and commit a UTF-16 file but skip the "working-tree-encoding" + # filter. Consequently, the in-repo representation is UTF-16 and not + # UTF-8. This simulates a Git version that has no working tree encoding + # support. + echo "*.utf16le text working-tree-encoding=utf-16le" >.gitattributes && + echo "hallo" >nonsense.utf16le && + TEST_HASH=$(git hash-object --no-filters -w nonsense.utf16le) && + git update-index --add --cacheinfo 100644 $TEST_HASH nonsense.utf16le && + COMMIT=$(git commit-tree -p $(git rev-parse HEAD) -m "plain commit" $(git write-tree)) && + git update-ref refs/heads/master $COMMIT && + + test_must_fail git checkout HEAD^ 2>err.out && + test_i18ngrep "error: .* overwritten by checkout:" err.out +' + +test_expect_success 'error if encoding garbage is already in Git' ' + BEFORE_STATE=$(git rev-parse HEAD) && + test_when_finished "git reset --hard $BEFORE_STATE" && + + # Skip the UTF-16 filter for the added file + # This simulates a Git version that has no checkoutEncoding support + cp nobom.utf16be.raw nonsense.utf16 && + TEST_HASH=$(git hash-object --no-filters -w nonsense.utf16) && + git update-index --add --cacheinfo 100644 $TEST_HASH nonsense.utf16 && + COMMIT=$(git commit-tree -p $(git rev-parse HEAD) -m "plain commit" $(git write-tree)) && + git update-ref refs/heads/master $COMMIT && + + git diff 2>err.out && + test_i18ngrep "error: BOM is required" err.out +' + +test_expect_success 'check roundtrip encoding' ' + test_when_finished "rm -f roundtrip.shift roundtrip.utf16" && + test_when_finished "git reset --hard HEAD" && + + text="hallo there!\nroundtrip test here!" && + printf "$text" | iconv -f UTF-8 -t SHIFT-JIS >roundtrip.shift && + printf "$text" | iconv -f UTF-8 -t UTF-16 >roundtrip.utf16 && + echo "*.shift text working-tree-encoding=SHIFT-JIS" >>.gitattributes && + + # SHIFT-JIS encoded files are round-trip checked by default... + GIT_TRACE=1 git add .gitattributes roundtrip.shift 2>&1 | + grep "Checking roundtrip encoding for SHIFT-JIS" && + git reset && + + # ... unless we overwrite the Git config! + ! GIT_TRACE=1 git -c core.checkRoundtripEncoding=garbage \ + add .gitattributes roundtrip.shift 2>&1 | + grep "Checking roundtrip encoding for SHIFT-JIS" && + git reset && + + # UTF-16 encoded files should not be round-trip checked by default... + ! GIT_TRACE=1 git add roundtrip.utf16 2>&1 | + grep "Checking roundtrip encoding for UTF-16" && + git reset && + + # ... unless we tell Git to check it! + GIT_TRACE=1 git -c core.checkRoundtripEncoding="UTF-16, UTF-32" \ + add roundtrip.utf16 2>&1 | + grep "Checking roundtrip encoding for utf-16" && + git reset && + + # ... unless we tell Git to check it! + # (here we also check that the casing of the encoding is irrelevant) + GIT_TRACE=1 git -c core.checkRoundtripEncoding="UTF-32, utf-16" \ + add roundtrip.utf16 2>&1 | + grep "Checking roundtrip encoding for utf-16" && + git reset +' + +test_done diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh index 0c2fc81d7b..04d474c84f 100755 --- a/t/t0040-parse-options.sh +++ b/t/t0040-parse-options.sh @@ -291,7 +291,7 @@ test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' ' test_expect_success 'OPT_CALLBACK() and callback errors work' ' test_must_fail test-parse-options --no-length >output 2>output.err && test_i18ncmp expect output && - test_i18ncmp expect.err output.err + test_must_be_empty output.err ' cat >expect <<\EOF diff --git a/t/t0041-usage.sh b/t/t0041-usage.sh new file mode 100755 index 0000000000..5b927b76fe --- /dev/null +++ b/t/t0041-usage.sh @@ -0,0 +1,107 @@ +#!/bin/sh + +test_description='Test commands behavior when given invalid argument value' + +. ./test-lib.sh + +test_expect_success 'setup ' ' + test_commit "v1.0" +' + +test_expect_success 'tag --contains <existent_tag>' ' + git tag --contains "v1.0" >actual 2>actual.err && + grep "v1.0" actual && + test_line_count = 0 actual.err +' + +test_expect_success 'tag --contains <inexistent_tag>' ' + test_must_fail git tag --contains "notag" >actual 2>actual.err && + test_line_count = 0 actual && + test_i18ngrep "error" actual.err && + test_i18ngrep ! "usage" actual.err +' + +test_expect_success 'tag --no-contains <existent_tag>' ' + git tag --no-contains "v1.0" >actual 2>actual.err && + test_line_count = 0 actual && + test_line_count = 0 actual.err +' + +test_expect_success 'tag --no-contains <inexistent_tag>' ' + test_must_fail git tag --no-contains "notag" >actual 2>actual.err && + test_line_count = 0 actual && + test_i18ngrep "error" actual.err && + test_i18ngrep ! "usage" actual.err +' + +test_expect_success 'tag usage error' ' + test_must_fail git tag --noopt >actual 2>actual.err && + test_line_count = 0 actual && + test_i18ngrep "usage" actual.err +' + +test_expect_success 'branch --contains <existent_commit>' ' + git branch --contains "master" >actual 2>actual.err && + test_i18ngrep "master" actual && + test_line_count = 0 actual.err +' + +test_expect_success 'branch --contains <inexistent_commit>' ' + test_must_fail git branch --no-contains "nocommit" >actual 2>actual.err && + test_line_count = 0 actual && + test_i18ngrep "error" actual.err && + test_i18ngrep ! "usage" actual.err +' + +test_expect_success 'branch --no-contains <existent_commit>' ' + git branch --no-contains "master" >actual 2>actual.err && + test_line_count = 0 actual && + test_line_count = 0 actual.err +' + +test_expect_success 'branch --no-contains <inexistent_commit>' ' + test_must_fail git branch --no-contains "nocommit" >actual 2>actual.err && + test_line_count = 0 actual && + test_i18ngrep "error" actual.err && + test_i18ngrep ! "usage" actual.err +' + +test_expect_success 'branch usage error' ' + test_must_fail git branch --noopt >actual 2>actual.err && + test_line_count = 0 actual && + test_i18ngrep "usage" actual.err +' + +test_expect_success 'for-each-ref --contains <existent_object>' ' + git for-each-ref --contains "master" >actual 2>actual.err && + test_line_count = 2 actual && + test_line_count = 0 actual.err +' + +test_expect_success 'for-each-ref --contains <inexistent_object>' ' + test_must_fail git for-each-ref --no-contains "noobject" >actual 2>actual.err && + test_line_count = 0 actual && + test_i18ngrep "error" actual.err && + test_i18ngrep ! "usage" actual.err +' + +test_expect_success 'for-each-ref --no-contains <existent_object>' ' + git for-each-ref --no-contains "master" >actual 2>actual.err && + test_line_count = 0 actual && + test_line_count = 0 actual.err +' + +test_expect_success 'for-each-ref --no-contains <inexistent_object>' ' + test_must_fail git for-each-ref --no-contains "noobject" >actual 2>actual.err && + test_line_count = 0 actual && + test_i18ngrep "error" actual.err && + test_i18ngrep ! "usage" actual.err +' + +test_expect_success 'for-each-ref usage error' ' + test_must_fail git for-each-ref --noopt >actual 2>actual.err && + test_line_count = 0 actual && + test_i18ngrep "usage" actual.err +' + +test_done diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index 7ea2bb515b..f46e3c4995 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -8,15 +8,15 @@ test_description='Test various path utilities' . ./test-lib.sh norm_path() { - expected=$(test-path-utils print_path "$2") + expected=$(test-tool path-utils print_path "$2") test_expect_success $3 "normalize path: $1 => $2" \ - "test \"\$(test-path-utils normalize_path_copy '$1')\" = '$expected'" + "test \"\$(test-tool path-utils normalize_path_copy '$1')\" = '$expected'" } relative_path() { - expected=$(test-path-utils print_path "$3") + expected=$(test-tool path-utils print_path "$3") test_expect_success $4 "relative path: $1 $2 => $3" \ - "test \"\$(test-path-utils relative_path '$1' '$2')\" = '$expected'" + "test \"\$(test-tool path-utils relative_path '$1' '$2')\" = '$expected'" } test_submodule_relative_url() { @@ -37,7 +37,7 @@ test_git_path() { # On Windows, we are using MSYS's bash, which mangles the paths. # Absolute paths are anchored at the MSYS installation directory, # which means that the path / accounts for this many characters: -rootoff=$(test-path-utils normalize_path_copy / | wc -c) +rootoff=$(test-tool path-utils normalize_path_copy / | wc -c) # Account for the trailing LF: if test $rootoff = 2; then rootoff= # we are on Unix @@ -46,7 +46,7 @@ else # In MSYS2, the root directory "/" is translated into a Windows # directory *with* trailing slash. Let's test for that and adjust # our expected longest ancestor length accordingly. - case "$(test-path-utils print_path /)" in + case "$(test-tool path-utils print_path /)" in */) rootslash=1;; *) rootslash=0;; esac @@ -61,7 +61,7 @@ ancestor() { expected=$(($expected+$rootoff)) fi test_expect_success "longest ancestor: $1 $2 => $expected" \ - "actual=\$(test-path-utils longest_ancestor_length '$1' '$2') && + "actual=\$(test-tool path-utils longest_ancestor_length '$1' '$2') && test \"\$actual\" = '$expected'" } @@ -77,8 +77,8 @@ case $(uname -s) in ;; esac -test_expect_success basename 'test-path-utils basename' -test_expect_success dirname 'test-path-utils dirname' +test_expect_success basename 'test-tool path-utils basename' +test_expect_success dirname 'test-tool path-utils dirname' norm_path "" "" norm_path . "" @@ -157,48 +157,48 @@ ancestor /foo/bar /foo:/bar 4 ancestor /foo/bar /bar -1 test_expect_success 'strip_path_suffix' ' - test c:/msysgit = $(test-path-utils strip_path_suffix \ + test c:/msysgit = $(test-tool path-utils strip_path_suffix \ c:/msysgit/libexec//git-core libexec/git-core) ' test_expect_success 'absolute path rejects the empty string' ' - test_must_fail test-path-utils absolute_path "" + test_must_fail test-tool path-utils absolute_path "" ' test_expect_success 'real path rejects the empty string' ' - test_must_fail test-path-utils real_path "" + test_must_fail test-tool path-utils real_path "" ' test_expect_success POSIX 'real path works on absolute paths 1' ' nopath="hopefully-absent-path" && - test "/" = "$(test-path-utils real_path "/")" && - test "/$nopath" = "$(test-path-utils real_path "/$nopath")" + test "/" = "$(test-tool path-utils real_path "/")" && + test "/$nopath" = "$(test-tool path-utils real_path "/$nopath")" ' test_expect_success 'real path works on absolute paths 2' ' nopath="hopefully-absent-path" && # Find an existing top-level directory for the remaining tests: d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") && - test "$d" = "$(test-path-utils real_path "$d")" && - test "$d/$nopath" = "$(test-path-utils real_path "$d/$nopath")" + test "$d" = "$(test-tool path-utils real_path "$d")" && + test "$d/$nopath" = "$(test-tool path-utils real_path "$d/$nopath")" ' test_expect_success POSIX 'real path removes extra leading slashes' ' nopath="hopefully-absent-path" && - test "/" = "$(test-path-utils real_path "///")" && - test "/$nopath" = "$(test-path-utils real_path "///$nopath")" && + test "/" = "$(test-tool path-utils real_path "///")" && + test "/$nopath" = "$(test-tool path-utils real_path "///$nopath")" && # Find an existing top-level directory for the remaining tests: d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") && - test "$d" = "$(test-path-utils real_path "//$d")" && - test "$d/$nopath" = "$(test-path-utils real_path "//$d/$nopath")" + test "$d" = "$(test-tool path-utils real_path "//$d")" && + test "$d/$nopath" = "$(test-tool path-utils real_path "//$d/$nopath")" ' test_expect_success 'real path removes other extra slashes' ' nopath="hopefully-absent-path" && # Find an existing top-level directory for the remaining tests: d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") && - test "$d" = "$(test-path-utils real_path "$d///")" && - test "$d/$nopath" = "$(test-path-utils real_path "$d///$nopath")" + test "$d" = "$(test-tool path-utils real_path "$d///")" && + test "$d/$nopath" = "$(test-tool path-utils real_path "$d///$nopath")" ' test_expect_success SYMLINKS 'real path works on symlinks' ' @@ -209,35 +209,35 @@ test_expect_success SYMLINKS 'real path works on symlinks' ' mkdir third && dir="$(cd .git; pwd -P)" && dir2=third/../second/other/.git && - test "$dir" = "$(test-path-utils real_path $dir2)" && + test "$dir" = "$(test-tool path-utils real_path $dir2)" && file="$dir"/index && - test "$file" = "$(test-path-utils real_path $dir2/index)" && + test "$file" = "$(test-tool path-utils real_path $dir2/index)" && basename=blub && - test "$dir/$basename" = "$(cd .git && test-path-utils real_path "$basename")" && + test "$dir/$basename" = "$(cd .git && test-tool path-utils real_path "$basename")" && ln -s ../first/file .git/syml && sym="$(cd first; pwd -P)"/file && - test "$sym" = "$(test-path-utils real_path "$dir2/syml")" + test "$sym" = "$(test-tool path-utils real_path "$dir2/syml")" ' test_expect_success SYMLINKS 'prefix_path works with absolute paths to work tree symlinks' ' ln -s target symlink && - test "$(test-path-utils prefix_path prefix "$(pwd)/symlink")" = "symlink" + test "$(test-tool path-utils prefix_path prefix "$(pwd)/symlink")" = "symlink" ' test_expect_success 'prefix_path works with only absolute path to work tree' ' echo "" >expected && - test-path-utils prefix_path prefix "$(pwd)" >actual && + test-tool path-utils prefix_path prefix "$(pwd)" >actual && test_cmp expected actual ' test_expect_success 'prefix_path rejects absolute path to dir with same beginning as work tree' ' - test_must_fail test-path-utils prefix_path prefix "$(pwd)a" + test_must_fail test-tool path-utils prefix_path prefix "$(pwd)a" ' test_expect_success SYMLINKS 'prefix_path works with absolute path to a symlink to work tree having same beginning as work tree' ' git init repo && ln -s repo repolink && - test "a" = "$(cd repo && test-path-utils prefix_path prefix "$(pwd)/../repolink/a")" + test "a" = "$(cd repo && test-tool path-utils prefix_path prefix "$(pwd)/../repolink/a")" ' relative_path /foo/a/b/c/ /foo/a/b/ c/ diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh index 24c92b6cd7..c887ed5b45 100755 --- a/t/t0061-run-command.sh +++ b/t/t0061-run-command.sh @@ -14,13 +14,13 @@ EOF >empty test_expect_success 'start_command reports ENOENT' ' - test-run-command start-command-ENOENT ./does-not-exist + test-tool run-command start-command-ENOENT ./does-not-exist ' test_expect_success 'run_command can run a command' ' cat hello-script >hello.sh && chmod +x hello.sh && - test-run-command run-command ./hello.sh >actual 2>err && + test-tool run-command run-command ./hello.sh >actual 2>err && test_cmp hello-script actual && test_cmp empty err @@ -31,7 +31,7 @@ test_expect_success !MINGW 'run_command can run a script without a #! line' ' cat hello-script EOF chmod +x hello && - test-run-command run-command ./hello >actual 2>err && + test-tool run-command run-command ./hello >actual 2>err && test_cmp hello-script actual && test_cmp empty err @@ -45,7 +45,7 @@ test_expect_success 'run_command does not try to execute a directory' ' EOF PATH=$PWD/bin1:$PWD/bin2:$PATH \ - test-run-command run-command greet >actual 2>err && + test-tool run-command run-command greet >actual 2>err && test_cmp bin2/greet actual && test_cmp empty err ' @@ -62,7 +62,7 @@ test_expect_success POSIXPERM 'run_command passes over non-executable file' ' EOF PATH=$PWD/bin1:$PWD/bin2:$PATH \ - test-run-command run-command greet >actual 2>err && + test-tool run-command run-command greet >actual 2>err && test_cmp bin2/greet actual && test_cmp empty err ' @@ -70,7 +70,7 @@ test_expect_success POSIXPERM 'run_command passes over non-executable file' ' test_expect_success POSIXPERM 'run_command reports EACCES' ' cat hello-script >hello.sh && chmod -x hello.sh && - test_must_fail test-run-command run-command ./hello.sh 2>err && + test_must_fail test-tool run-command run-command ./hello.sh 2>err && grep "fatal: cannot exec.*hello.sh" err ' @@ -104,17 +104,17 @@ World EOF test_expect_success 'run_command runs in parallel with more jobs available than tasks' ' - test-run-command run-command-parallel 5 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && + test-tool run-command run-command-parallel 5 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && test_cmp expect actual ' test_expect_success 'run_command runs in parallel with as many jobs as tasks' ' - test-run-command run-command-parallel 4 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && + test-tool run-command run-command-parallel 4 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && test_cmp expect actual ' test_expect_success 'run_command runs in parallel with more tasks than jobs available' ' - test-run-command run-command-parallel 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && + test-tool run-command run-command-parallel 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && test_cmp expect actual ' @@ -128,7 +128,7 @@ asking for a quick stop EOF test_expect_success 'run_command is asked to abort gracefully' ' - test-run-command run-command-abort 3 false 2>actual && + test-tool run-command run-command-abort 3 false 2>actual && test_cmp expect actual ' @@ -137,15 +137,15 @@ no further jobs available EOF test_expect_success 'run_command outputs ' ' - test-run-command run-command-no-jobs 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && + test-tool run-command run-command-no-jobs 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && test_cmp expect actual ' test_trace () { expect="$1" shift - GIT_TRACE=1 test-run-command "$@" run-command true 2>&1 >/dev/null | \ - sed 's/.* run_command: //' >actual && + GIT_TRACE=1 test-tool run-command "$@" run-command true 2>&1 >/dev/null | \ + sed -e 's/.* run_command: //' -e '/trace: .*/d' >actual && echo "$expect true" >expect && test_cmp expect actual } diff --git a/t/t0062-revision-walking.sh b/t/t0062-revision-walking.sh index 113c728e67..8e215867b8 100755 --- a/t/t0062-revision-walking.sh +++ b/t/t0062-revision-walking.sh @@ -26,7 +26,7 @@ test_expect_success 'setup' ' ' test_expect_success 'revision walking can be done twice' ' - test-revision-walking run-twice >run_twice_actual && + test-tool revision-walking run-twice >run_twice_actual && test_cmp run_twice_expected run_twice_actual ' diff --git a/t/t0063-string-list.sh b/t/t0063-string-list.sh index dbfc05ebdc..c6ee9f66b1 100755 --- a/t/t0063-string-list.sh +++ b/t/t0063-string-list.sh @@ -10,9 +10,9 @@ test_description='Test string list functionality' test_split () { cat >expected && test_expect_success "split $1 at $2, max $3" " - test-string-list split '$1' '$2' '$3' >actual && + test-tool string-list split '$1' '$2' '$3' >actual && test_cmp expected actual && - test-string-list split_in_place '$1' '$2' '$3' >actual && + test-tool string-list split_in_place '$1' '$2' '$3' >actual && test_cmp expected actual " } @@ -61,31 +61,31 @@ test_split ":" ":" "-1" <<EOF EOF test_expect_success "test filter_string_list" ' - test "x-" = "x$(test-string-list filter - y)" && - test "x-" = "x$(test-string-list filter no y)" && - test yes = "$(test-string-list filter yes y)" && - test yes = "$(test-string-list filter no:yes y)" && - test yes = "$(test-string-list filter yes:no y)" && - test y1:y2 = "$(test-string-list filter y1:y2 y)" && - test y2:y1 = "$(test-string-list filter y2:y1 y)" && - test "x-" = "x$(test-string-list filter x1:x2 y)" + test "x-" = "x$(test-tool string-list filter - y)" && + test "x-" = "x$(test-tool string-list filter no y)" && + test yes = "$(test-tool string-list filter yes y)" && + test yes = "$(test-tool string-list filter no:yes y)" && + test yes = "$(test-tool string-list filter yes:no y)" && + test y1:y2 = "$(test-tool string-list filter y1:y2 y)" && + test y2:y1 = "$(test-tool string-list filter y2:y1 y)" && + test "x-" = "x$(test-tool string-list filter x1:x2 y)" ' test_expect_success "test remove_duplicates" ' - test "x-" = "x$(test-string-list remove_duplicates -)" && - test "x" = "x$(test-string-list remove_duplicates "")" && - test a = "$(test-string-list remove_duplicates a)" && - test a = "$(test-string-list remove_duplicates a:a)" && - test a = "$(test-string-list remove_duplicates a:a:a:a:a)" && - test a:b = "$(test-string-list remove_duplicates a:b)" && - test a:b = "$(test-string-list remove_duplicates a:a:b)" && - test a:b = "$(test-string-list remove_duplicates a:b:b)" && - test a:b:c = "$(test-string-list remove_duplicates a:b:c)" && - test a:b:c = "$(test-string-list remove_duplicates a:a:b:c)" && - test a:b:c = "$(test-string-list remove_duplicates a:b:b:c)" && - test a:b:c = "$(test-string-list remove_duplicates a:b:c:c)" && - test a:b:c = "$(test-string-list remove_duplicates a:a:b:b:c:c)" && - test a:b:c = "$(test-string-list remove_duplicates a:a:a:b:b:b:c:c:c)" + test "x-" = "x$(test-tool string-list remove_duplicates -)" && + test "x" = "x$(test-tool string-list remove_duplicates "")" && + test a = "$(test-tool string-list remove_duplicates a)" && + test a = "$(test-tool string-list remove_duplicates a:a)" && + test a = "$(test-tool string-list remove_duplicates a:a:a:a:a)" && + test a:b = "$(test-tool string-list remove_duplicates a:b)" && + test a:b = "$(test-tool string-list remove_duplicates a:a:b)" && + test a:b = "$(test-tool string-list remove_duplicates a:b:b)" && + test a:b:c = "$(test-tool string-list remove_duplicates a:b:c)" && + test a:b:c = "$(test-tool string-list remove_duplicates a:a:b:c)" && + test a:b:c = "$(test-tool string-list remove_duplicates a:b:b:c)" && + test a:b:c = "$(test-tool string-list remove_duplicates a:b:c:c)" && + test a:b:c = "$(test-tool string-list remove_duplicates a:a:b:b:c:c)" && + test a:b:c = "$(test-tool string-list remove_duplicates a:a:a:b:b:b:c:c:c)" ' test_done diff --git a/t/t0064-sha1-array.sh b/t/t0064-sha1-array.sh index 50b31ffe75..67484502a0 100755 --- a/t/t0064-sha1-array.sh +++ b/t/t0064-sha1-array.sh @@ -18,7 +18,7 @@ test_expect_success 'ordered enumeration' ' { echo20 append 88 44 aa 55 && echo for_each_unique - } | test-sha1-array >actual && + } | test-tool sha1-array >actual && test_cmp expect actual ' @@ -28,7 +28,7 @@ test_expect_success 'ordered enumeration with duplicate suppression' ' echo20 append 88 44 aa 55 && echo20 append 88 44 aa 55 && echo for_each_unique - } | test-sha1-array >actual && + } | test-tool sha1-array >actual && test_cmp expect actual ' @@ -36,7 +36,7 @@ test_expect_success 'lookup' ' { echo20 append 88 44 aa 55 && echo20 lookup 55 - } | test-sha1-array >actual && + } | test-tool sha1-array >actual && n=$(cat actual) && test "$n" -eq 1 ' @@ -45,7 +45,7 @@ test_expect_success 'lookup non-existing entry' ' { echo20 append 88 44 aa 55 && echo20 lookup 33 - } | test-sha1-array >actual && + } | test-tool sha1-array >actual && n=$(cat actual) && test "$n" -lt 0 ' @@ -55,7 +55,7 @@ test_expect_success 'lookup with duplicates' ' echo20 append 88 44 aa 55 && echo20 append 88 44 aa 55 && echo20 lookup 55 - } | test-sha1-array >actual && + } | test-tool sha1-array >actual && n=$(cat actual) && test "$n" -ge 2 && test "$n" -le 3 @@ -66,7 +66,7 @@ test_expect_success 'lookup non-existing entry with duplicates' ' echo20 append 88 44 aa 55 && echo20 append 88 44 aa 55 && echo20 lookup 66 - } | test-sha1-array >actual && + } | test-tool sha1-array >actual && n=$(cat actual) && test "$n" -lt 0 ' @@ -76,7 +76,7 @@ test_expect_success 'lookup with almost duplicate values' ' echo "append 5555555555555555555555555555555555555555" && echo "append 555555555555555555555555555555555555555f" && echo20 lookup 55 - } | test-sha1-array >actual && + } | test-tool sha1-array >actual && n=$(cat actual) && test "$n" -eq 0 ' @@ -85,7 +85,7 @@ test_expect_success 'lookup with single duplicate value' ' { echo20 append 55 55 && echo20 lookup 55 - } | test-sha1-array >actual && + } | test-tool sha1-array >actual && n=$(cat actual) && test "$n" -ge 0 && test "$n" -le 1 diff --git a/t/t0065-strcmp-offset.sh b/t/t0065-strcmp-offset.sh index 7d6d21425f..91fa639c4a 100755 --- a/t/t0065-strcmp-offset.sh +++ b/t/t0065-strcmp-offset.sh @@ -8,7 +8,7 @@ while read s1 s2 expect do test_expect_success "strcmp_offset($s1, $s2)" ' echo "$expect" >expect && - test-strcmp-offset "$s1" "$s2" >actual && + test-tool strcmp-offset "$s1" "$s2" >actual && test_cmp expect actual ' done <<-EOF diff --git a/t/t0070-fundamental.sh b/t/t0070-fundamental.sh index 991ed2a48d..23fbe6434a 100755 --- a/t/t0070-fundamental.sh +++ b/t/t0070-fundamental.sh @@ -9,11 +9,11 @@ Verify wrappers and compatibility functions. . ./test-lib.sh test_expect_success 'character classes (isspace, isalpha etc.)' ' - test-ctype + test-tool ctype ' test_expect_success 'mktemp to nonexistent directory prints filename' ' - test_must_fail test-mktemp doesnotexist/testXXXXXX 2>err && + test_must_fail test-tool mktemp doesnotexist/testXXXXXX 2>err && grep "doesnotexist/test" err ' @@ -21,7 +21,7 @@ test_expect_success POSIXPERM,SANITY 'mktemp to unwritable directory prints file mkdir cannotwrite && chmod -w cannotwrite && test_when_finished "chmod +w cannotwrite" && - test_must_fail test-mktemp cannotwrite/testXXXXXX 2>err && + test_must_fail test-tool mktemp cannotwrite/testXXXXXX 2>err && grep "cannotwrite/test" err ' @@ -31,7 +31,7 @@ test_expect_success 'git_mkstemps_mode does not fail if fd 0 is not open' ' test_expect_success 'check for a bug in the regex routines' ' # if this test fails, re-build git with NO_REGEX=1 - test-regex --bug + test-tool regex --bug ' test_done diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh index adfd4f0b5e..4ae0995cd9 100755 --- a/t/t0090-cache-tree.sh +++ b/t/t0090-cache-tree.sh @@ -8,13 +8,13 @@ cache-tree extension. . ./test-lib.sh cmp_cache_tree () { - test-dump-cache-tree | sed -e '/#(ref)/d' >actual && + test-tool dump-cache-tree | sed -e '/#(ref)/d' >actual && sed "s/$_x40/SHA/" <actual >filtered && test_cmp "$1" filtered } # We don't bother with actually checking the SHA1: -# test-dump-cache-tree already verifies that all existing data is +# test-tool dump-cache-tree already verifies that all existing data is # correct. generate_expected_cache_tree_rec () { dir="$1${1:+/}" && @@ -47,7 +47,7 @@ test_cache_tree () { test_invalid_cache_tree () { printf "invalid %s ()\n" "" "$@" >expect && - test-dump-cache-tree | + test-tool dump-cache-tree | sed -n -e "s/[0-9]* subtrees//" -e '/#(ref)/d' -e '/^invalid /p' >actual && test_cmp expect actual } @@ -115,14 +115,14 @@ test_expect_success 'update-index invalidates cache-tree' ' ' test_expect_success 'write-tree establishes cache-tree' ' - test-scrap-cache-tree && + test-tool scrap-cache-tree && git write-tree && test_cache_tree ' -test_expect_success 'test-scrap-cache-tree works' ' +test_expect_success 'test-tool scrap-cache-tree works' ' git read-tree HEAD && - test-scrap-cache-tree && + test-tool scrap-cache-tree && test_no_cache_tree ' @@ -170,7 +170,7 @@ test_expect_success 'commit in child dir has cache-tree' ' ' test_expect_success 'reset --hard gives cache-tree' ' - test-scrap-cache-tree && + test-tool scrap-cache-tree && git reset --hard && test_cache_tree ' @@ -246,9 +246,9 @@ test_expect_success 'switching trees does not invalidate shared index' ' git update-index --split-index && >split && git add split && - test-dump-split-index .git/index | grep -v ^own >before && + test-tool dump-split-index .git/index | grep -v ^own >before && git commit -m "as-is" && - test-dump-split-index .git/index | grep -v ^own >after && + test-tool dump-split-index .git/index | grep -v ^own >after && test_cmp before after ' diff --git a/t/t0110-urlmatch-normalization.sh b/t/t0110-urlmatch-normalization.sh index 410d5768ca..f99529d838 100755 --- a/t/t0110-urlmatch-normalization.sh +++ b/t/t0110-urlmatch-normalization.sh @@ -9,172 +9,172 @@ tu="$TEST_DIRECTORY/t0110/url" # Note that only file: URLs should be allowed without a host test_expect_success 'url scheme' ' - ! test-urlmatch-normalization "" && - ! test-urlmatch-normalization "_" && - ! test-urlmatch-normalization "scheme" && - ! test-urlmatch-normalization "scheme:" && - ! test-urlmatch-normalization "scheme:/" && - ! test-urlmatch-normalization "scheme://" && - ! test-urlmatch-normalization "file" && - ! test-urlmatch-normalization "file:" && - ! test-urlmatch-normalization "file:/" && - test-urlmatch-normalization "file://" && - ! test-urlmatch-normalization "://acme.co" && - ! test-urlmatch-normalization "x_test://acme.co" && - ! test-urlmatch-normalization "-test://acme.co" && - ! test-urlmatch-normalization "0test://acme.co" && - ! test-urlmatch-normalization "+test://acme.co" && - ! test-urlmatch-normalization ".test://acme.co" && - ! test-urlmatch-normalization "schem%6e://" && - test-urlmatch-normalization "x-Test+v1.0://acme.co" && - test "$(test-urlmatch-normalization -p "AbCdeF://x.Y")" = "abcdef://x.y/" + ! test-tool urlmatch-normalization "" && + ! test-tool urlmatch-normalization "_" && + ! test-tool urlmatch-normalization "scheme" && + ! test-tool urlmatch-normalization "scheme:" && + ! test-tool urlmatch-normalization "scheme:/" && + ! test-tool urlmatch-normalization "scheme://" && + ! test-tool urlmatch-normalization "file" && + ! test-tool urlmatch-normalization "file:" && + ! test-tool urlmatch-normalization "file:/" && + test-tool urlmatch-normalization "file://" && + ! test-tool urlmatch-normalization "://acme.co" && + ! test-tool urlmatch-normalization "x_test://acme.co" && + ! test-tool urlmatch-normalization "-test://acme.co" && + ! test-tool urlmatch-normalization "0test://acme.co" && + ! test-tool urlmatch-normalization "+test://acme.co" && + ! test-tool urlmatch-normalization ".test://acme.co" && + ! test-tool urlmatch-normalization "schem%6e://" && + test-tool urlmatch-normalization "x-Test+v1.0://acme.co" && + test "$(test-tool urlmatch-normalization -p "AbCdeF://x.Y")" = "abcdef://x.y/" ' test_expect_success 'url authority' ' - ! test-urlmatch-normalization "scheme://user:pass@" && - ! test-urlmatch-normalization "scheme://?" && - ! test-urlmatch-normalization "scheme://#" && - ! test-urlmatch-normalization "scheme:///" && - ! test-urlmatch-normalization "scheme://:" && - ! test-urlmatch-normalization "scheme://:555" && - test-urlmatch-normalization "file://user:pass@" && - test-urlmatch-normalization "file://?" && - test-urlmatch-normalization "file://#" && - test-urlmatch-normalization "file:///" && - test-urlmatch-normalization "file://:" && - ! test-urlmatch-normalization "file://:555" && - test-urlmatch-normalization "scheme://user:pass@host" && - test-urlmatch-normalization "scheme://@host" && - test-urlmatch-normalization "scheme://%00@host" && - ! test-urlmatch-normalization "scheme://%%@host" && - ! test-urlmatch-normalization "scheme://host_" && - test-urlmatch-normalization "scheme://user:pass@host/" && - test-urlmatch-normalization "scheme://@host/" && - test-urlmatch-normalization "scheme://host/" && - test-urlmatch-normalization "scheme://host?x" && - test-urlmatch-normalization "scheme://host#x" && - test-urlmatch-normalization "scheme://host/@" && - test-urlmatch-normalization "scheme://host?@x" && - test-urlmatch-normalization "scheme://host#@x" && - test-urlmatch-normalization "scheme://[::1]" && - test-urlmatch-normalization "scheme://[::1]/" && - ! test-urlmatch-normalization "scheme://hos%41/" && - test-urlmatch-normalization "scheme://[invalid....:/" && - test-urlmatch-normalization "scheme://invalid....:]/" && - ! test-urlmatch-normalization "scheme://invalid....:[/" && - ! test-urlmatch-normalization "scheme://invalid....:[" + ! test-tool urlmatch-normalization "scheme://user:pass@" && + ! test-tool urlmatch-normalization "scheme://?" && + ! test-tool urlmatch-normalization "scheme://#" && + ! test-tool urlmatch-normalization "scheme:///" && + ! test-tool urlmatch-normalization "scheme://:" && + ! test-tool urlmatch-normalization "scheme://:555" && + test-tool urlmatch-normalization "file://user:pass@" && + test-tool urlmatch-normalization "file://?" && + test-tool urlmatch-normalization "file://#" && + test-tool urlmatch-normalization "file:///" && + test-tool urlmatch-normalization "file://:" && + ! test-tool urlmatch-normalization "file://:555" && + test-tool urlmatch-normalization "scheme://user:pass@host" && + test-tool urlmatch-normalization "scheme://@host" && + test-tool urlmatch-normalization "scheme://%00@host" && + ! test-tool urlmatch-normalization "scheme://%%@host" && + ! test-tool urlmatch-normalization "scheme://host_" && + test-tool urlmatch-normalization "scheme://user:pass@host/" && + test-tool urlmatch-normalization "scheme://@host/" && + test-tool urlmatch-normalization "scheme://host/" && + test-tool urlmatch-normalization "scheme://host?x" && + test-tool urlmatch-normalization "scheme://host#x" && + test-tool urlmatch-normalization "scheme://host/@" && + test-tool urlmatch-normalization "scheme://host?@x" && + test-tool urlmatch-normalization "scheme://host#@x" && + test-tool urlmatch-normalization "scheme://[::1]" && + test-tool urlmatch-normalization "scheme://[::1]/" && + ! test-tool urlmatch-normalization "scheme://hos%41/" && + test-tool urlmatch-normalization "scheme://[invalid....:/" && + test-tool urlmatch-normalization "scheme://invalid....:]/" && + ! test-tool urlmatch-normalization "scheme://invalid....:[/" && + ! test-tool urlmatch-normalization "scheme://invalid....:[" ' test_expect_success 'url port checks' ' - test-urlmatch-normalization "xyz://q@some.host:" && - test-urlmatch-normalization "xyz://q@some.host:456/" && - ! test-urlmatch-normalization "xyz://q@some.host:0" && - ! test-urlmatch-normalization "xyz://q@some.host:0000000" && - test-urlmatch-normalization "xyz://q@some.host:0000001?" && - test-urlmatch-normalization "xyz://q@some.host:065535#" && - test-urlmatch-normalization "xyz://q@some.host:65535" && - ! test-urlmatch-normalization "xyz://q@some.host:65536" && - ! test-urlmatch-normalization "xyz://q@some.host:99999" && - ! test-urlmatch-normalization "xyz://q@some.host:100000" && - ! test-urlmatch-normalization "xyz://q@some.host:100001" && - test-urlmatch-normalization "http://q@some.host:80" && - test-urlmatch-normalization "https://q@some.host:443" && - test-urlmatch-normalization "http://q@some.host:80/" && - test-urlmatch-normalization "https://q@some.host:443?" && - ! test-urlmatch-normalization "http://q@:8008" && - ! test-urlmatch-normalization "http://:8080" && - ! test-urlmatch-normalization "http://:" && - test-urlmatch-normalization "xyz://q@some.host:456/" && - test-urlmatch-normalization "xyz://[::1]:456/" && - test-urlmatch-normalization "xyz://[::1]:/" && - ! test-urlmatch-normalization "xyz://[::1]:000/" && - ! test-urlmatch-normalization "xyz://[::1]:0%300/" && - ! test-urlmatch-normalization "xyz://[::1]:0x80/" && - ! test-urlmatch-normalization "xyz://[::1]:4294967297/" && - ! test-urlmatch-normalization "xyz://[::1]:030f/" + test-tool urlmatch-normalization "xyz://q@some.host:" && + test-tool urlmatch-normalization "xyz://q@some.host:456/" && + ! test-tool urlmatch-normalization "xyz://q@some.host:0" && + ! test-tool urlmatch-normalization "xyz://q@some.host:0000000" && + test-tool urlmatch-normalization "xyz://q@some.host:0000001?" && + test-tool urlmatch-normalization "xyz://q@some.host:065535#" && + test-tool urlmatch-normalization "xyz://q@some.host:65535" && + ! test-tool urlmatch-normalization "xyz://q@some.host:65536" && + ! test-tool urlmatch-normalization "xyz://q@some.host:99999" && + ! test-tool urlmatch-normalization "xyz://q@some.host:100000" && + ! test-tool urlmatch-normalization "xyz://q@some.host:100001" && + test-tool urlmatch-normalization "http://q@some.host:80" && + test-tool urlmatch-normalization "https://q@some.host:443" && + test-tool urlmatch-normalization "http://q@some.host:80/" && + test-tool urlmatch-normalization "https://q@some.host:443?" && + ! test-tool urlmatch-normalization "http://q@:8008" && + ! test-tool urlmatch-normalization "http://:8080" && + ! test-tool urlmatch-normalization "http://:" && + test-tool urlmatch-normalization "xyz://q@some.host:456/" && + test-tool urlmatch-normalization "xyz://[::1]:456/" && + test-tool urlmatch-normalization "xyz://[::1]:/" && + ! test-tool urlmatch-normalization "xyz://[::1]:000/" && + ! test-tool urlmatch-normalization "xyz://[::1]:0%300/" && + ! test-tool urlmatch-normalization "xyz://[::1]:0x80/" && + ! test-tool urlmatch-normalization "xyz://[::1]:4294967297/" && + ! test-tool urlmatch-normalization "xyz://[::1]:030f/" ' test_expect_success 'url port normalization' ' - test "$(test-urlmatch-normalization -p "http://x:800")" = "http://x:800/" && - test "$(test-urlmatch-normalization -p "http://x:0800")" = "http://x:800/" && - test "$(test-urlmatch-normalization -p "http://x:00000800")" = "http://x:800/" && - test "$(test-urlmatch-normalization -p "http://x:065535")" = "http://x:65535/" && - test "$(test-urlmatch-normalization -p "http://x:1")" = "http://x:1/" && - test "$(test-urlmatch-normalization -p "http://x:80")" = "http://x/" && - test "$(test-urlmatch-normalization -p "http://x:080")" = "http://x/" && - test "$(test-urlmatch-normalization -p "http://x:000000080")" = "http://x/" && - test "$(test-urlmatch-normalization -p "https://x:443")" = "https://x/" && - test "$(test-urlmatch-normalization -p "https://x:0443")" = "https://x/" && - test "$(test-urlmatch-normalization -p "https://x:000000443")" = "https://x/" + test "$(test-tool urlmatch-normalization -p "http://x:800")" = "http://x:800/" && + test "$(test-tool urlmatch-normalization -p "http://x:0800")" = "http://x:800/" && + test "$(test-tool urlmatch-normalization -p "http://x:00000800")" = "http://x:800/" && + test "$(test-tool urlmatch-normalization -p "http://x:065535")" = "http://x:65535/" && + test "$(test-tool urlmatch-normalization -p "http://x:1")" = "http://x:1/" && + test "$(test-tool urlmatch-normalization -p "http://x:80")" = "http://x/" && + test "$(test-tool urlmatch-normalization -p "http://x:080")" = "http://x/" && + test "$(test-tool urlmatch-normalization -p "http://x:000000080")" = "http://x/" && + test "$(test-tool urlmatch-normalization -p "https://x:443")" = "https://x/" && + test "$(test-tool urlmatch-normalization -p "https://x:0443")" = "https://x/" && + test "$(test-tool urlmatch-normalization -p "https://x:000000443")" = "https://x/" ' test_expect_success 'url general escapes' ' - ! test-urlmatch-normalization "http://x.y?%fg" && - test "$(test-urlmatch-normalization -p "X://W/%7e%41^%3a")" = "x://w/~A%5E%3A" && - test "$(test-urlmatch-normalization -p "X://W/:/?#[]@")" = "x://w/:/?#[]@" && - test "$(test-urlmatch-normalization -p "X://W/$&()*+,;=")" = "x://w/$&()*+,;=" && - test "$(test-urlmatch-normalization -p "X://W/'\''")" = "x://w/'\''" && - test "$(test-urlmatch-normalization -p "X://W?'\!'")" = "x://w/?'\!'" + ! test-tool urlmatch-normalization "http://x.y?%fg" && + test "$(test-tool urlmatch-normalization -p "X://W/%7e%41^%3a")" = "x://w/~A%5E%3A" && + test "$(test-tool urlmatch-normalization -p "X://W/:/?#[]@")" = "x://w/:/?#[]@" && + test "$(test-tool urlmatch-normalization -p "X://W/$&()*+,;=")" = "x://w/$&()*+,;=" && + test "$(test-tool urlmatch-normalization -p "X://W/'\''")" = "x://w/'\''" && + test "$(test-tool urlmatch-normalization -p "X://W?'\!'")" = "x://w/?'\!'" ' test_expect_success !MINGW 'url high-bit escapes' ' - test "$(test-urlmatch-normalization -p "$(cat "$tu-1")")" = "x://q/%01%02%03%04%05%06%07%08%0E%0F%10%11%12" && - test "$(test-urlmatch-normalization -p "$(cat "$tu-2")")" = "x://q/%13%14%15%16%17%18%19%1B%1C%1D%1E%1F%7F" && - test "$(test-urlmatch-normalization -p "$(cat "$tu-3")")" = "x://q/%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F" && - test "$(test-urlmatch-normalization -p "$(cat "$tu-4")")" = "x://q/%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F" && - test "$(test-urlmatch-normalization -p "$(cat "$tu-5")")" = "x://q/%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF" && - test "$(test-urlmatch-normalization -p "$(cat "$tu-6")")" = "x://q/%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF" && - test "$(test-urlmatch-normalization -p "$(cat "$tu-7")")" = "x://q/%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF" && - test "$(test-urlmatch-normalization -p "$(cat "$tu-8")")" = "x://q/%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF" && - test "$(test-urlmatch-normalization -p "$(cat "$tu-9")")" = "x://q/%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF" && - test "$(test-urlmatch-normalization -p "$(cat "$tu-10")")" = "x://q/%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" + test "$(test-tool urlmatch-normalization -p "$(cat "$tu-1")")" = "x://q/%01%02%03%04%05%06%07%08%0E%0F%10%11%12" && + test "$(test-tool urlmatch-normalization -p "$(cat "$tu-2")")" = "x://q/%13%14%15%16%17%18%19%1B%1C%1D%1E%1F%7F" && + test "$(test-tool urlmatch-normalization -p "$(cat "$tu-3")")" = "x://q/%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F" && + test "$(test-tool urlmatch-normalization -p "$(cat "$tu-4")")" = "x://q/%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F" && + test "$(test-tool urlmatch-normalization -p "$(cat "$tu-5")")" = "x://q/%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF" && + test "$(test-tool urlmatch-normalization -p "$(cat "$tu-6")")" = "x://q/%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF" && + test "$(test-tool urlmatch-normalization -p "$(cat "$tu-7")")" = "x://q/%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF" && + test "$(test-tool urlmatch-normalization -p "$(cat "$tu-8")")" = "x://q/%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF" && + test "$(test-tool urlmatch-normalization -p "$(cat "$tu-9")")" = "x://q/%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF" && + test "$(test-tool urlmatch-normalization -p "$(cat "$tu-10")")" = "x://q/%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" ' test_expect_success 'url utf-8 escapes' ' - test "$(test-urlmatch-normalization -p "$(cat "$tu-11")")" = "x://q/%C2%80%DF%BF%E0%A0%80%EF%BF%BD%F0%90%80%80%F0%AF%BF%BD" + test "$(test-tool urlmatch-normalization -p "$(cat "$tu-11")")" = "x://q/%C2%80%DF%BF%E0%A0%80%EF%BF%BD%F0%90%80%80%F0%AF%BF%BD" ' test_expect_success 'url username/password escapes' ' - test "$(test-urlmatch-normalization -p "x://%41%62(^):%70+d@foo")" = "x://Ab(%5E):p+d@foo/" + test "$(test-tool urlmatch-normalization -p "x://%41%62(^):%70+d@foo")" = "x://Ab(%5E):p+d@foo/" ' test_expect_success 'url normalized lengths' ' - test "$(test-urlmatch-normalization -l "Http://%4d%65:%4d^%70@The.Host")" = 25 && - test "$(test-urlmatch-normalization -l "http://%41:%42@x.y/%61/")" = 17 && - test "$(test-urlmatch-normalization -l "http://@x.y/^")" = 15 + test "$(test-tool urlmatch-normalization -l "Http://%4d%65:%4d^%70@The.Host")" = 25 && + test "$(test-tool urlmatch-normalization -l "http://%41:%42@x.y/%61/")" = 17 && + test "$(test-tool urlmatch-normalization -l "http://@x.y/^")" = 15 ' test_expect_success 'url . and .. segments' ' - test "$(test-urlmatch-normalization -p "x://y/.")" = "x://y/" && - test "$(test-urlmatch-normalization -p "x://y/./")" = "x://y/" && - test "$(test-urlmatch-normalization -p "x://y/a/.")" = "x://y/a" && - test "$(test-urlmatch-normalization -p "x://y/a/./")" = "x://y/a/" && - test "$(test-urlmatch-normalization -p "x://y/.?")" = "x://y/?" && - test "$(test-urlmatch-normalization -p "x://y/./?")" = "x://y/?" && - test "$(test-urlmatch-normalization -p "x://y/a/.?")" = "x://y/a?" && - test "$(test-urlmatch-normalization -p "x://y/a/./?")" = "x://y/a/?" && - test "$(test-urlmatch-normalization -p "x://y/a/./b/.././../c")" = "x://y/c" && - test "$(test-urlmatch-normalization -p "x://y/a/./b/../.././c/")" = "x://y/c/" && - test "$(test-urlmatch-normalization -p "x://y/a/./b/.././../c/././.././.")" = "x://y/" && - ! test-urlmatch-normalization "x://y/a/./b/.././../c/././.././.." && - test "$(test-urlmatch-normalization -p "x://y/a/./?/././..")" = "x://y/a/?/././.." && - test "$(test-urlmatch-normalization -p "x://y/%2e/")" = "x://y/" && - test "$(test-urlmatch-normalization -p "x://y/%2E/")" = "x://y/" && - test "$(test-urlmatch-normalization -p "x://y/a/%2e./")" = "x://y/" && - test "$(test-urlmatch-normalization -p "x://y/b/.%2E/")" = "x://y/" && - test "$(test-urlmatch-normalization -p "x://y/c/%2e%2E/")" = "x://y/" + test "$(test-tool urlmatch-normalization -p "x://y/.")" = "x://y/" && + test "$(test-tool urlmatch-normalization -p "x://y/./")" = "x://y/" && + test "$(test-tool urlmatch-normalization -p "x://y/a/.")" = "x://y/a" && + test "$(test-tool urlmatch-normalization -p "x://y/a/./")" = "x://y/a/" && + test "$(test-tool urlmatch-normalization -p "x://y/.?")" = "x://y/?" && + test "$(test-tool urlmatch-normalization -p "x://y/./?")" = "x://y/?" && + test "$(test-tool urlmatch-normalization -p "x://y/a/.?")" = "x://y/a?" && + test "$(test-tool urlmatch-normalization -p "x://y/a/./?")" = "x://y/a/?" && + test "$(test-tool urlmatch-normalization -p "x://y/a/./b/.././../c")" = "x://y/c" && + test "$(test-tool urlmatch-normalization -p "x://y/a/./b/../.././c/")" = "x://y/c/" && + test "$(test-tool urlmatch-normalization -p "x://y/a/./b/.././../c/././.././.")" = "x://y/" && + ! test-tool urlmatch-normalization "x://y/a/./b/.././../c/././.././.." && + test "$(test-tool urlmatch-normalization -p "x://y/a/./?/././..")" = "x://y/a/?/././.." && + test "$(test-tool urlmatch-normalization -p "x://y/%2e/")" = "x://y/" && + test "$(test-tool urlmatch-normalization -p "x://y/%2E/")" = "x://y/" && + test "$(test-tool urlmatch-normalization -p "x://y/a/%2e./")" = "x://y/" && + test "$(test-tool urlmatch-normalization -p "x://y/b/.%2E/")" = "x://y/" && + test "$(test-tool urlmatch-normalization -p "x://y/c/%2e%2E/")" = "x://y/" ' # http://@foo specifies an empty user name but does not specify a password # http://foo specifies neither a user name nor a password # So they should not be equivalent test_expect_success 'url equivalents' ' - test-urlmatch-normalization "httP://x" "Http://X/" && - test-urlmatch-normalization "Http://%4d%65:%4d^%70@The.Host" "hTTP://Me:%4D^p@the.HOST:80/" && - ! test-urlmatch-normalization "https://@x.y/^" "httpS://x.y:443/^" && - test-urlmatch-normalization "https://@x.y/^" "httpS://@x.y:0443/^" && - test-urlmatch-normalization "https://@x.y/^/../abc" "httpS://@x.y:0443/abc" && - test-urlmatch-normalization "https://@x.y/^/.." "httpS://@x.y:0443/" + test-tool urlmatch-normalization "httP://x" "Http://X/" && + test-tool urlmatch-normalization "Http://%4d%65:%4d^%70@The.Host" "hTTP://Me:%4D^p@the.HOST:80/" && + ! test-tool urlmatch-normalization "https://@x.y/^" "httpS://x.y:443/^" && + test-tool urlmatch-normalization "https://@x.y/^" "httpS://@x.y:0443/^" && + test-tool urlmatch-normalization "https://@x.y/^/../abc" "httpS://@x.y:0443/abc" && + test-tool urlmatch-normalization "https://@x.y/^/.." "httpS://@x.y:0443/" ' test_done diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index b19f332694..2ac3b940c6 100755 --- a/t/t1006-cat-file.sh +++ b/t/t1006-cat-file.sh @@ -282,7 +282,7 @@ test_expect_success "--batch-check with multiple sha1s gives correct format" ' ' test_expect_success 'setup blobs which are likely to delta' ' - test-genrandom foo 10240 >foo && + test-tool genrandom foo 10240 >foo && { cat foo; echo plus; } >foo-plus && git add foo foo-plus && git commit -m foo && diff --git a/t/t1011-read-tree-sparse-checkout.sh b/t/t1011-read-tree-sparse-checkout.sh index c167f606ca..0c6f48f302 100755 --- a/t/t1011-read-tree-sparse-checkout.sh +++ b/t/t1011-read-tree-sparse-checkout.sh @@ -15,8 +15,11 @@ test_description='sparse checkout tests . "$TEST_DIRECTORY"/lib-read-tree.sh test_expect_success 'setup' ' + test_commit init && + echo modified >>init.t && + cat >expected <<-EOF && - 100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t + 100644 $(git hash-object init.t) 0 init.t 100644 $EMPTY_BLOB 0 sub/added 100644 $EMPTY_BLOB 0 sub/addedtoo 100644 $EMPTY_BLOB 0 subsub/added @@ -28,8 +31,6 @@ test_expect_success 'setup' ' H subsub/added EOF - test_commit init && - echo modified >>init.t && mkdir sub subsub && touch sub/added sub/addedtoo subsub/added && git add init.t sub/added sub/addedtoo subsub/added && diff --git a/t/t1050-large.sh b/t/t1050-large.sh index 6fd264cff0..f9eb143f43 100755 --- a/t/t1050-large.sh +++ b/t/t1050-large.sh @@ -103,9 +103,9 @@ test_expect_success 'packsize limit' ' # mid1 and mid2 will fit within 256k limit but # appending mid3 will bust the limit and will # result in a separate packfile. - test-genrandom "a" $(( 66 * 1024 )) >mid1 && - test-genrandom "b" $(( 80 * 1024 )) >mid2 && - test-genrandom "c" $(( 128 * 1024 )) >mid3 && + test-tool genrandom "a" $(( 66 * 1024 )) >mid1 && + test-tool genrandom "b" $(( 80 * 1024 )) >mid2 && + test-tool genrandom "c" $(( 128 * 1024 )) >mid3 && git add mid1 mid2 mid3 && count=0 diff --git a/t/t1300-repo-config.sh b/t/t1300-config.sh index 4f8e6f5fde..03c223708e 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-config.sh @@ -108,6 +108,7 @@ bar = foo [beta] baz = multiple \ lines +foo = bar EOF test_expect_success 'unset with cont. lines' ' @@ -118,6 +119,7 @@ cat > expect <<\EOF [alpha] bar = foo [beta] +foo = bar EOF test_expect_success 'unset with cont. lines is correct' 'test_cmp expect .git/config' @@ -740,7 +742,7 @@ test_expect_success bool ' do git config --bool --get bool.true$i >>result git config --bool --get bool.false$i >>result - done && + done && test_cmp expect result' test_expect_success 'invalid bool (--get)' ' @@ -914,7 +916,7 @@ test_expect_success 'get --expiry-date' ' invalid1 = "abc" EOF cat >expect <<-EOF && - $(test-date timestamp $rel) + $(test-tool date timestamp $rel) 1275666415 1510441871 1510348087 @@ -931,6 +933,36 @@ test_expect_success 'get --expiry-date' ' test_must_fail git config --expiry-date date.invalid1 ' +test_expect_success 'get --type=color' ' + rm .git/config && + git config foo.color "red" && + git config --get --type=color foo.color >actual.raw && + test_decode_color <actual.raw >actual && + echo "<RED>" >expect && + test_cmp expect actual +' + +cat >expect << EOF +[foo] + color = red +EOF + +test_expect_success 'set --type=color' ' + rm .git/config && + git config --type=color foo.color "red" && + test_cmp expect .git/config +' + +test_expect_success 'get --type=color barfs on non-color' ' + echo "[foo]bar=not-a-color" >.git/config && + test_must_fail git config --get --type=color foo.bar +' + +test_expect_success 'set --type=color barfs on non-color' ' + test_must_fail git config --type=color foo.color "not-a-color" 2>error && + test_i18ngrep "cannot parse color" error +' + cat > expect << EOF [quote] leading = " test" @@ -1411,7 +1443,7 @@ test_expect_success 'urlmatch with wildcard' ' ' # good section hygiene -test_expect_failure 'unsetting the last key in a section removes header' ' +test_expect_success '--unset last key removes section (except if commented)' ' cat >.git/config <<-\EOF && # some generic comment on the configuration file itself # a comment specific to this "section" section. @@ -1425,13 +1457,86 @@ test_expect_failure 'unsetting the last key in a section removes header' ' cat >expect <<-\EOF && # some generic comment on the configuration file itself + # a comment specific to this "section" section. + [section] + # some intervening lines + # that should also be dropped + + # please be careful when you update the above variable EOF git config --unset section.key && - test_cmp expect .git/config + test_cmp expect .git/config && + + cat >.git/config <<-\EOF && + [section] + key = value + [next-section] + EOF + + cat >expect <<-\EOF && + [next-section] + EOF + + git config --unset section.key && + test_cmp expect .git/config && + + q_to_tab >.git/config <<-\EOF && + [one] + Qkey = "multiline \ + QQ# with comment" + [two] + key = true + EOF + git config --unset two.key && + ! grep two .git/config && + + q_to_tab >.git/config <<-\EOF && + [one] + Qkey = "multiline \ + QQ# with comment" + [one] + key = true + EOF + git config --unset-all one.key && + test_line_count = 0 .git/config && + + q_to_tab >.git/config <<-\EOF && + [one] + Qkey = true + Q# a comment not at the start + [two] + Qkey = true + EOF + git config --unset two.key && + grep two .git/config && + + q_to_tab >.git/config <<-\EOF && + [one] + Qkey = not [two "subsection"] + [two "subsection"] + [two "subsection"] + Qkey = true + [TWO "subsection"] + [one] + EOF + git config --unset two.subsection.key && + test "not [two subsection]" = "$(git config one.key)" && + test_line_count = 3 .git/config +' + +test_expect_success '--unset-all removes section if empty & uncommented' ' + cat >.git/config <<-\EOF && + [section] + key = value1 + key = value2 + EOF + + git config --unset-all section.key && + test_line_count = 0 .git/config ' -test_expect_failure 'adding a key into an empty section reuses header' ' +test_expect_success 'adding a key into an empty section reuses header' ' cat >.git/config <<-\EOF && [section] EOF @@ -1587,10 +1692,10 @@ test_expect_success '--show-origin stdin with file include' ' ' test_expect_success !MINGW '--show-origin blob' ' - cat >expect <<-\EOF && - blob:a9d9f9e555b5c6f07cbe09d3f06fe3df11e09c08 user.custom=true - EOF blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") && + cat >expect <<-EOF && + blob:$blob user.custom=true + EOF git config --blob=$blob --show-origin --list >output && test_cmp expect output ' @@ -1611,4 +1716,88 @@ test_expect_success '--local requires a repo' ' test_expect_code 128 nongit git config --local foo.bar ' +cat >.git/config <<-\EOF && +[core] +foo = true +number = 10 +big = 1M +EOF + +test_expect_success 'identical modern --type specifiers are allowed' ' + git config --type=int --type=int core.big >actual && + echo 1048576 >expect && + test_cmp expect actual +' + +test_expect_success 'identical legacy --type specifiers are allowed' ' + git config --int --int core.big >actual && + echo 1048576 >expect && + test_cmp expect actual +' + +test_expect_success 'identical mixed --type specifiers are allowed' ' + git config --int --type=int core.big >actual && + echo 1048576 >expect && + test_cmp expect actual +' + +test_expect_success 'non-identical modern --type specifiers are not allowed' ' + test_must_fail git config --type=int --type=bool core.big 2>error && + test_i18ngrep "only one type at a time" error +' + +test_expect_success 'non-identical legacy --type specifiers are not allowed' ' + test_must_fail git config --int --bool core.big 2>error && + test_i18ngrep "only one type at a time" error +' + +test_expect_success 'non-identical mixed --type specifiers are not allowed' ' + test_must_fail git config --type=int --bool core.big 2>error && + test_i18ngrep "only one type at a time" error +' + +test_expect_success '--type allows valid type specifiers' ' + echo "true" >expect && + git config --type=bool core.foo >actual && + test_cmp expect actual +' + +test_expect_success '--no-type unsets type specifiers' ' + echo "10" >expect && + git config --type=bool --no-type core.number >actual && + test_cmp expect actual +' + +test_expect_success 'unset type specifiers may be reset to conflicting ones' ' + echo 1048576 >expect && + git config --type=bool --no-type --type=int core.big >actual && + test_cmp expect actual +' + +test_expect_success '--type rejects unknown specifiers' ' + test_must_fail git config --type=nonsense core.foo 2>error && + test_i18ngrep "unrecognized --type argument" error +' + +test_expect_success '--replace-all does not invent newlines' ' + q_to_tab >.git/config <<-\EOF && + [abc]key + QkeepSection + [xyz] + Qkey = 1 + [abc] + Qkey = a + EOF + q_to_tab >expect <<-\EOF && + [abc] + QkeepSection + [xyz] + Qkey = 1 + [abc] + Qkey = b + EOF + git config --replace-all abc.key b && + test_cmp .git/config expect +' + test_done diff --git a/t/t1304-default-acl.sh b/t/t1304-default-acl.sh index f5422f1d33..335d3f3211 100755 --- a/t/t1304-default-acl.sh +++ b/t/t1304-default-acl.sh @@ -54,7 +54,7 @@ test_expect_success SETFACL 'Setup test repo' ' test_expect_success SETFACL 'Objects creation does not break ACLs with restrictive umask' ' # SHA1 for empty blob - check_perms_and_acl .git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 + check_perms_and_acl .git/objects/$(echo $EMPTY_BLOB | sed -e "s,^\(..\),\1/,") ' test_expect_success SETFACL 'git gc does not break ACLs with restrictive umask' ' diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh index d9d2f545a4..f035ee40a3 100755 --- a/t/t1305-config-include.sh +++ b/t/t1305-config-include.sh @@ -224,7 +224,7 @@ test_expect_success 'conditional include, early config reading' ' echo "[includeIf \"gitdir:foo/\"]path=bar6" >>.git/config && echo "[test]six=6" >.git/bar6 && echo 6 >expect && - test-config read_early_config test.six >actual && + test-tool config read_early_config test.six >actual && test_cmp expect actual ) ' diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh index bafed5c9b8..3e00d1af01 100755 --- a/t/t1308-config-set.sh +++ b/t/t1308-config-set.sh @@ -18,7 +18,7 @@ check_config () { then printf "%s\n" "$@" fi >expect && - test_expect_code $expect_code test-config "$op" "$key" >actual && + test_expect_code $expect_code test-tool config "$op" "$key" >actual && test_cmp expect actual } @@ -125,7 +125,7 @@ test_expect_success 'find string value for a key' ' ' test_expect_success 'check line error when NULL string is queried' ' - test_expect_code 128 test-config get_string case.foo 2>result && + test_expect_code 128 test-tool config get_string case.foo 2>result && test_i18ngrep "fatal: .*case\.foo.*\.git/config.*line 7" result ' @@ -155,13 +155,13 @@ test_expect_success 'find value from a configset' ' baz = ball EOF echo silk >expect && - test-config configset_get_value my.new config2 .git/config >actual && + test-tool config configset_get_value my.new config2 .git/config >actual && test_cmp expect actual ' test_expect_success 'find value with highest priority from a configset' ' echo hask >expect && - test-config configset_get_value case.baz config2 .git/config >actual && + test-tool config configset_get_value case.baz config2 .git/config >actual && test_cmp expect actual ' @@ -173,20 +173,20 @@ test_expect_success 'find value_list for a key from a configset' ' lama ball EOF - test-config configset_get_value case.baz config2 .git/config >actual && + test-tool config configset_get_value case.baz config2 .git/config >actual && test_cmp expect actual ' test_expect_success 'proper error on non-existent files' ' echo "Error (-1) reading configuration file non-existent-file." >expect && - test_expect_code 2 test-config configset_get_value foo.bar non-existent-file 2>actual && + test_expect_code 2 test-tool config configset_get_value foo.bar non-existent-file 2>actual && test_cmp expect actual ' test_expect_success 'proper error on directory "files"' ' echo "Error (-1) reading configuration file a-directory." >expect && mkdir a-directory && - test_expect_code 2 test-config configset_get_value foo.bar a-directory 2>output && + test_expect_code 2 test-tool config configset_get_value foo.bar a-directory 2>output && grep "^warning:" output && grep "^Error" output >actual && test_cmp expect actual @@ -196,7 +196,7 @@ test_expect_success POSIXPERM,SANITY 'proper error on non-accessible files' ' chmod -r .git/config && test_when_finished "chmod +r .git/config" && echo "Error (-1) reading configuration file .git/config." >expect && - test_expect_code 2 test-config configset_get_value foo.bar .git/config 2>output && + test_expect_code 2 test-tool config configset_get_value foo.bar .git/config 2>output && grep "^warning:" output && grep "^Error" output >actual && test_cmp expect actual @@ -207,14 +207,14 @@ test_expect_success 'proper error on error in default config files' ' test_when_finished "mv .git/config.old .git/config" && echo "[" >>.git/config && echo "fatal: bad config line 34 in file .git/config" >expect && - test_expect_code 128 test-config get_value foo.bar 2>actual && + test_expect_code 128 test-tool config get_value foo.bar 2>actual && test_i18ncmp expect actual ' test_expect_success 'proper error on error in custom config files' ' echo "[" >>syntax-error && echo "fatal: bad config line 1 in file syntax-error" >expect && - test_expect_code 128 test-config configset_get_value foo.bar syntax-error 2>actual && + test_expect_code 128 test-tool config configset_get_value foo.bar syntax-error 2>actual && test_i18ncmp expect actual ' @@ -267,7 +267,7 @@ test_expect_success 'iteration shows correct origins' ' name= scope=cmdline EOF - GIT_CONFIG_PARAMETERS=$cmdline_config test-config iterate >actual && + GIT_CONFIG_PARAMETERS=$cmdline_config test-tool config iterate >actual && test_cmp expect actual ' diff --git a/t/t1309-early-config.sh b/t/t1309-early-config.sh index 3dda215e8e..413642aa56 100755 --- a/t/t1309-early-config.sh +++ b/t/t1309-early-config.sh @@ -6,7 +6,7 @@ test_description='Test read_early_config()' test_expect_success 'read early config' ' test_config early.config correct && - test-config read_early_config early.config >output && + test-tool config read_early_config early.config >output && test correct = "$(cat output)" ' @@ -15,7 +15,7 @@ test_expect_success 'in a sub-directory' ' mkdir -p sub && ( cd sub && - test-config read_early_config early.config + test-tool config read_early_config early.config ) >output && test sub = "$(cat output)" ' @@ -27,7 +27,7 @@ test_expect_success 'ceiling' ' GIT_CEILING_DIRECTORIES="$PWD" && export GIT_CEILING_DIRECTORIES && cd sub && - test-config read_early_config early.config + test-tool config read_early_config early.config ) >output && test -z "$(cat output)" ' @@ -42,7 +42,7 @@ test_expect_success 'ceiling #2' ' GIT_CEILING_DIRECTORIES="$PWD" && export GIT_CEILING_DIRECTORIES XDG_CONFIG_HOME && cd sub && - test-config read_early_config early.config + test-tool config read_early_config early.config ) >output && test xdg = "$(cat output)" ' @@ -54,7 +54,7 @@ test_expect_success 'read config file in right order' ' ( cd foo && echo "[test]source = repo" >>.git/config && - GIT_CONFIG_PARAMETERS=$cmdline_config test-config \ + GIT_CONFIG_PARAMETERS=$cmdline_config test-tool config \ read_early_config test.source >actual && cat >expected <<-\EOF && home @@ -71,7 +71,7 @@ test_with_config () { ( cd throwaway && echo "$*" >.git/config && - test-config read_early_config early.config + test-tool config read_early_config early.config ) } diff --git a/t/t1310-config-default.sh b/t/t1310-config-default.sh new file mode 100755 index 0000000000..6049d91708 --- /dev/null +++ b/t/t1310-config-default.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +test_description='Test git config in different settings (with --default)' + +. ./test-lib.sh + +test_expect_success 'uses --default when entry missing' ' + echo quux >expect && + git config -f config --default=quux core.foo >actual && + test_cmp expect actual +' + +test_expect_success 'does not use --default when entry present' ' + echo bar >expect && + git -c core.foo=bar config --default=baz core.foo >actual && + test_cmp expect actual +' + +test_expect_success 'canonicalizes --default with appropriate type' ' + echo true >expect && + git config -f config --default=yes --bool core.foo >actual && + test_cmp expect actual +' + +test_expect_success 'dies when --default cannot be parsed' ' + test_must_fail git config -f config --type=expiry-date --default=x --get \ + not.a.section 2>error && + test_i18ngrep "failed to format default config value" error +' + +test_expect_success 'does not allow --default without --get' ' + test_must_fail git config --default=quux --unset a.section >output 2>&1 && + test_i18ngrep "\-\-default is only applicable to" output +' + +test_done diff --git a/t/t1405-main-ref-store.sh b/t/t1405-main-ref-store.sh index e8115df5ba..a74c38b5fb 100755 --- a/t/t1405-main-ref-store.sh +++ b/t/t1405-main-ref-store.sh @@ -4,7 +4,7 @@ test_description='test main ref store api' . ./test-lib.sh -RUN="test-ref-store main" +RUN="test-tool ref-store main" test_expect_success 'pack_refs(PACK_REFS_ALL | PACK_REFS_PRUNE)' ' test_commit one && @@ -45,7 +45,7 @@ test_expect_success 'rename_refs(master, new-master)' ' ' test_expect_success 'for_each_ref(refs/heads/)' ' - $RUN for-each-ref refs/heads/ | cut -c 42- >actual && + $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual && cat >expected <<-\EOF && master 0x0 new-master 0x0 @@ -71,7 +71,7 @@ test_expect_success 'verify_ref(new-master)' ' ' test_expect_success 'for_each_reflog()' ' - $RUN for-each-reflog | sort | cut -c 42- >actual && + $RUN for-each-reflog | sort -k2 | cut -c 42- >actual && cat >expected <<-\EOF && HEAD 0x1 refs/heads/master 0x0 diff --git a/t/t1406-submodule-ref-store.sh b/t/t1406-submodule-ref-store.sh index c32d4cc465..e093782cc3 100755 --- a/t/t1406-submodule-ref-store.sh +++ b/t/t1406-submodule-ref-store.sh @@ -4,7 +4,7 @@ test_description='test submodule ref store api' . ./test-lib.sh -RUN="test-ref-store submodule:sub" +RUN="test-tool ref-store submodule:sub" test_expect_success 'setup' ' git init sub && diff --git a/t/t1407-worktree-ref-store.sh b/t/t1407-worktree-ref-store.sh index 8842d0329f..2211f9831f 100755 --- a/t/t1407-worktree-ref-store.sh +++ b/t/t1407-worktree-ref-store.sh @@ -4,8 +4,8 @@ test_description='test worktree ref store api' . ./test-lib.sh -RWT="test-ref-store worktree:wt" -RMAIN="test-ref-store worktree:main" +RWT="test-tool ref-store worktree:wt" +RMAIN="test-tool ref-store worktree:main" test_expect_success 'setup' ' test_commit first && diff --git a/t/t1411-reflog-show.sh b/t/t1411-reflog-show.sh index 6ac7734d79..596907758d 100755 --- a/t/t1411-reflog-show.sh +++ b/t/t1411-reflog-show.sh @@ -10,6 +10,7 @@ test_expect_success 'setup' ' git commit -m one ' +commit=$(git rev-parse --short HEAD) cat >expect <<'EOF' Reflog: HEAD@{0} (C O Mitter <committer@example.com>) Reflog message: commit (initial): one @@ -20,8 +21,8 @@ test_expect_success 'log -g shows reflog headers' ' test_cmp expect actual ' -cat >expect <<'EOF' -e46513e HEAD@{0}: commit (initial): one +cat >expect <<EOF +$commit HEAD@{0}: commit (initial): one EOF test_expect_success 'oneline reflog format' ' git log -g -1 --oneline >actual && @@ -33,8 +34,8 @@ test_expect_success 'reflog default format' ' test_cmp expect actual ' -cat >expect <<'EOF' -commit e46513e +cat >expect <<EOF +commit $commit Reflog: HEAD@{0} (C O Mitter <committer@example.com>) Reflog message: commit (initial): one Author: A U Thor <author@example.com> @@ -56,8 +57,8 @@ test_expect_success 'using @{now} syntax shows reflog date (multiline)' ' test_cmp expect actual ' -cat >expect <<'EOF' -e46513e HEAD@{Thu Apr 7 15:13:13 2005 -0700}: commit (initial): one +cat >expect <<EOF +$commit HEAD@{Thu Apr 7 15:13:13 2005 -0700}: commit (initial): one EOF test_expect_success 'using @{now} syntax shows reflog date (oneline)' ' git log -g -1 --oneline HEAD@{now} >actual && @@ -82,8 +83,8 @@ test_expect_success 'using --date= shows reflog date (multiline)' ' test_cmp expect actual ' -cat >expect <<'EOF' -e46513e HEAD@{Thu Apr 7 15:13:13 2005 -0700}: commit (initial): one +cat >expect <<EOF +$commit HEAD@{Thu Apr 7 15:13:13 2005 -0700}: commit (initial): one EOF test_expect_success 'using --date= shows reflog date (oneline)' ' git log -g -1 --oneline --date=default >actual && @@ -109,8 +110,8 @@ test_expect_success 'log.date does not invoke "--date" magic (multiline)' ' test_cmp expect actual ' -cat >expect <<'EOF' -e46513e HEAD@{0}: commit (initial): one +cat >expect <<EOF +$commit HEAD@{0}: commit (initial): one EOF test_expect_success 'log.date does not invoke "--date" magic (oneline)' ' test_config log.date raw && diff --git a/t/t1501-work-tree.sh b/t/t1501-work-tree.sh index b06210ec5e..9c0bc65250 100755 --- a/t/t1501-work-tree.sh +++ b/t/t1501-work-tree.sh @@ -341,7 +341,7 @@ test_expect_success 'make_relative_path handles double slashes in GIT_DIR' ' test_expect_success 'relative $GIT_WORK_TREE and git subprocesses' ' GIT_DIR=repo.git GIT_WORK_TREE=repo.git/work \ - test-subprocess --setup-work-tree rev-parse --show-toplevel >actual && + test-tool subprocess --setup-work-tree rev-parse --show-toplevel >actual && echo "$(pwd)/repo.git/work" >expected && test_cmp expected actual ' @@ -360,7 +360,7 @@ test_expect_success 'GIT_DIR set (1)' ' ( cd work && GIT_DIR=../gitfile git rev-parse --git-common-dir >actual && - test-path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect && + test-tool path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect && test_cmp expect actual ) ' @@ -371,7 +371,7 @@ test_expect_success 'GIT_DIR set (2)' ' ( cd work && GIT_DIR=../gitfile git rev-parse --git-common-dir >actual && - test-path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect && + test-tool path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect && test_cmp expect actual ) ' @@ -382,7 +382,7 @@ test_expect_success 'Auto discovery' ' ( cd work && git rev-parse --git-common-dir >actual && - test-path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect && + test-tool path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect && test_cmp expect actual && echo haha >data1 && git add data1 && @@ -400,7 +400,7 @@ test_expect_success '$GIT_DIR/common overrides core.worktree' ' ( cd work && git rev-parse --git-common-dir >actual && - test-path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect && + test-tool path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect && test_cmp expect actual && echo haha >data2 && git add data2 && @@ -431,4 +431,16 @@ test_expect_success 'error out gracefully on invalid $GIT_WORK_TREE' ' ) ' +test_expect_success 'refs work with relative gitdir and work tree' ' + git init relative && + git -C relative commit --allow-empty -m one && + git -C relative commit --allow-empty -m two && + + GIT_DIR=relative/.git GIT_WORK_TREE=relative git reset HEAD^ && + + git -C relative log -1 --format=%s >actual && + echo one >expect && + test_cmp expect actual +' + test_done diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh index 2ce68cc277..93c77eac45 100755 --- a/t/t1507-rev-parse-upstream.sh +++ b/t/t1507-rev-parse-upstream.sh @@ -209,8 +209,9 @@ test_expect_success '@{u} works when tracking a local branch' ' test refs/heads/master = "$(full_name @{u})" ' +commit=$(git rev-parse HEAD) cat >expect <<EOF -commit 8f489d01d0cc65c3b0f09504ec50b5ed02a70bd5 +commit $commit Reflog: master@{0} (C O Mitter <committer@example.com>) Reflog message: branch: Created from HEAD Author: A U Thor <author@example.com> @@ -224,7 +225,7 @@ test_expect_success 'log -g other@{u}' ' ' cat >expect <<EOF -commit 8f489d01d0cc65c3b0f09504ec50b5ed02a70bd5 +commit $commit Reflog: master@{Thu Apr 7 15:17:13 2005 -0700} (C O Mitter <committer@example.com>) Reflog message: branch: Created from HEAD Author: A U Thor <author@example.com> diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh index e6854b828e..972bd9c785 100755 --- a/t/t1510-repo-setup.sh +++ b/t/t1510-repo-setup.sh @@ -238,7 +238,6 @@ test_expect_success '#0: nonbare repo, no explicit configuration' ' ' test_expect_success '#1: GIT_WORK_TREE without explicit GIT_DIR is accepted' ' - mkdir -p wt && try_repo 1 "$here" unset unset "" unset \ "$here/1/.git" "$here" "$here" 1/ \ "$here/1/.git" "$here" "$here" 1/sub/ 2>message && diff --git a/t/t1600-index.sh b/t/t1600-index.sh index 079d241145..c4422312f4 100755 --- a/t/t1600-index.sh +++ b/t/t1600-index.sh @@ -68,7 +68,7 @@ test_expect_success 'GIT_INDEX_VERSION takes precedence over config' ' git config --add index.version 2 && git add a 2>&1 && echo 4 >expect && - test-index-version <.git/index >actual && + test-tool index-version <.git/index >actual && test_cmp expect actual ) ' diff --git a/t/t1700-split-index.sh b/t/t1700-split-index.sh index a66936fe9b..e4f4c4df4e 100755 --- a/t/t1700-split-index.sh +++ b/t/t1700-split-index.sh @@ -11,8 +11,8 @@ sane_unset GIT_FSMONITOR_TEST test_expect_success 'enable split index' ' git config splitIndex.maxPercentChange 100 && git update-index --split-index && - test-dump-split-index .git/index >actual && - indexversion=$(test-index-version <.git/index) && + test-tool dump-split-index .git/index >actual && + indexversion=$(test-tool index-version <.git/index) && if test "$indexversion" = "4" then own=432ef4b63f32193984f339431fd50ca796493569 @@ -39,7 +39,7 @@ test_expect_success 'add one file' ' EOF test_cmp ls-files.expect ls-files.actual && - test-dump-split-index .git/index | sed "/^own/d" >actual && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && base $base 100644 $EMPTY_BLOB 0 one @@ -57,8 +57,8 @@ test_expect_success 'disable split index' ' EOF test_cmp ls-files.expect ls-files.actual && - BASE=$(test-dump-split-index .git/index | grep "^own" | sed "s/own/base/") && - test-dump-split-index .git/index | sed "/^own/d" >actual && + BASE=$(test-tool dump-split-index .git/index | grep "^own" | sed "s/own/base/") && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && not a split index EOF @@ -73,7 +73,7 @@ test_expect_success 'enable split index again, "one" now belongs to base index"' EOF test_cmp ls-files.expect ls-files.actual && - test-dump-split-index .git/index | sed "/^own/d" >actual && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && $BASE replacements: @@ -91,7 +91,7 @@ test_expect_success 'modify original file, base index untouched' ' EOF test_cmp ls-files.expect ls-files.actual && - test-dump-split-index .git/index | sed "/^own/d" >actual && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && q_to_tab >expect <<-EOF && $BASE 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q @@ -111,7 +111,7 @@ test_expect_success 'add another file, which stays index' ' EOF test_cmp ls-files.expect ls-files.actual && - test-dump-split-index .git/index | sed "/^own/d" >actual && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && q_to_tab >expect <<-EOF && $BASE 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q @@ -130,7 +130,7 @@ test_expect_success 'remove file not in base index' ' EOF test_cmp ls-files.expect ls-files.actual && - test-dump-split-index .git/index | sed "/^own/d" >actual && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && q_to_tab >expect <<-EOF && $BASE 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q @@ -147,7 +147,7 @@ test_expect_success 'remove file in base index' ' EOF test_cmp ls-files.expect ls-files.actual && - test-dump-split-index .git/index | sed "/^own/d" >actual && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && $BASE replacements: @@ -165,7 +165,7 @@ test_expect_success 'add original file back' ' EOF test_cmp ls-files.expect ls-files.actual && - test-dump-split-index .git/index | sed "/^own/d" >actual && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && $BASE 100644 $EMPTY_BLOB 0 one @@ -195,7 +195,7 @@ test_expect_success 'unify index, two files remain' ' EOF test_cmp ls-files.expect ls-files.actual && - test-dump-split-index .git/index | sed "/^own/d" >actual && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && not a split index EOF @@ -229,8 +229,8 @@ test_expect_success 'set core.splitIndex config variable to true' ' 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two EOF test_cmp ls-files.expect ls-files.actual && - BASE=$(test-dump-split-index .git/index | grep "^base") && - test-dump-split-index .git/index | sed "/^own/d" >actual && + BASE=$(test-tool dump-split-index .git/index | grep "^base") && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && $BASE replacements: @@ -248,7 +248,7 @@ test_expect_success 'set core.splitIndex config variable to false' ' 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two EOF test_cmp ls-files.expect ls-files.actual && - test-dump-split-index .git/index | sed "/^own/d" >actual && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && not a split index EOF @@ -259,8 +259,8 @@ test_expect_success 'set core.splitIndex config variable to true' ' git config core.splitIndex true && : >three && git update-index --add three && - BASE=$(test-dump-split-index .git/index | grep "^base") && - test-dump-split-index .git/index | sed "/^own/d" >actual && + BASE=$(test-tool dump-split-index .git/index | grep "^base") && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && $BASE replacements: @@ -269,7 +269,7 @@ test_expect_success 'set core.splitIndex config variable to true' ' test_cmp expect actual && : >four && git update-index --add four && - test-dump-split-index .git/index | sed "/^own/d" >actual && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && $BASE 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 four @@ -283,8 +283,8 @@ test_expect_success 'check behavior with splitIndex.maxPercentChange unset' ' git config --unset splitIndex.maxPercentChange && : >five && git update-index --add five && - BASE=$(test-dump-split-index .git/index | grep "^base") && - test-dump-split-index .git/index | sed "/^own/d" >actual && + BASE=$(test-tool dump-split-index .git/index | grep "^base") && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && $BASE replacements: @@ -293,7 +293,7 @@ test_expect_success 'check behavior with splitIndex.maxPercentChange unset' ' test_cmp expect actual && : >six && git update-index --add six && - test-dump-split-index .git/index | sed "/^own/d" >actual && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && $BASE 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 six @@ -307,8 +307,8 @@ test_expect_success 'check splitIndex.maxPercentChange set to 0' ' git config splitIndex.maxPercentChange 0 && : >seven && git update-index --add seven && - BASE=$(test-dump-split-index .git/index | grep "^base") && - test-dump-split-index .git/index | sed "/^own/d" >actual && + BASE=$(test-tool dump-split-index .git/index | grep "^base") && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && $BASE replacements: @@ -317,8 +317,8 @@ test_expect_success 'check splitIndex.maxPercentChange set to 0' ' test_cmp expect actual && : >eight && git update-index --add eight && - BASE=$(test-dump-split-index .git/index | grep "^base") && - test-dump-split-index .git/index | sed "/^own/d" >actual && + BASE=$(test-tool dump-split-index .git/index | grep "^base") && + test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && $BASE replacements: @@ -332,12 +332,12 @@ test_expect_success 'shared index files expire after 2 weeks by default' ' git update-index --add ten && test $(ls .git/sharedindex.* | wc -l) -gt 2 && just_under_2_weeks_ago=$((5-14*86400)) && - test-chmtime =$just_under_2_weeks_ago .git/sharedindex.* && + test-tool chmtime =$just_under_2_weeks_ago .git/sharedindex.* && : >eleven && git update-index --add eleven && test $(ls .git/sharedindex.* | wc -l) -gt 2 && just_over_2_weeks_ago=$((-1-14*86400)) && - test-chmtime =$just_over_2_weeks_ago .git/sharedindex.* && + test-tool chmtime =$just_over_2_weeks_ago .git/sharedindex.* && : >twelve && git update-index --add twelve && test $(ls .git/sharedindex.* | wc -l) -le 2 @@ -345,12 +345,12 @@ test_expect_success 'shared index files expire after 2 weeks by default' ' test_expect_success 'check splitIndex.sharedIndexExpire set to 16 days' ' git config splitIndex.sharedIndexExpire "16.days.ago" && - test-chmtime =$just_over_2_weeks_ago .git/sharedindex.* && + test-tool chmtime =$just_over_2_weeks_ago .git/sharedindex.* && : >thirteen && git update-index --add thirteen && test $(ls .git/sharedindex.* | wc -l) -gt 2 && just_over_16_days_ago=$((-1-16*86400)) && - test-chmtime =$just_over_16_days_ago .git/sharedindex.* && + test-tool chmtime =$just_over_16_days_ago .git/sharedindex.* && : >fourteen && git update-index --add fourteen && test $(ls .git/sharedindex.* | wc -l) -le 2 @@ -359,13 +359,13 @@ test_expect_success 'check splitIndex.sharedIndexExpire set to 16 days' ' test_expect_success 'check splitIndex.sharedIndexExpire set to "never" and "now"' ' git config splitIndex.sharedIndexExpire never && just_10_years_ago=$((-365*10*86400)) && - test-chmtime =$just_10_years_ago .git/sharedindex.* && + test-tool chmtime =$just_10_years_ago .git/sharedindex.* && : >fifteen && git update-index --add fifteen && test $(ls .git/sharedindex.* | wc -l) -gt 2 && git config splitIndex.sharedIndexExpire now && just_1_second_ago=-1 && - test-chmtime =$just_1_second_ago .git/sharedindex.* && + test-tool chmtime =$just_1_second_ago .git/sharedindex.* && : >sixteen && git update-index --add sixteen && test $(ls .git/sharedindex.* | wc -l) -le 2 @@ -435,7 +435,7 @@ test_expect_success 'writing split index with null sha1 does not write cache tre commit=$(git commit-tree $tree -p HEAD <msg) && git update-ref HEAD "$commit" && GIT_ALLOW_NULL_SHA1=1 git reset --hard && - (test-dump-cache-tree >cache-tree.out || true) && + (test-tool dump-cache-tree >cache-tree.out || true) && test_line_count = 0 cache-tree.out ' diff --git a/t/t2020-checkout-detach.sh b/t/t2020-checkout-detach.sh index bb4f2e0c63..1fa670625c 100755 --- a/t/t2020-checkout-detach.sh +++ b/t/t2020-checkout-detach.sh @@ -189,8 +189,12 @@ test_expect_success 'no advice given for explicit detached head state' ' # Detached HEAD tests for GIT_PRINT_SHA1_ELLIPSIS (new format) test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not asked to' " + commit=$(git rev-parse --short=12 master^) && + commit2=$(git rev-parse --short=12 master~2) && + commit3=$(git rev-parse --short=12 master~3) && + # The first detach operation is more chatty than the following ones. - cat >1st_detach <<-'EOF' && + cat >1st_detach <<-EOF && Note: checking out 'HEAD^'. You are in 'detached HEAD' state. You can look around, make experimental @@ -202,18 +206,18 @@ test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not as git checkout -b <new-branch-name> - HEAD is now at 7c7cd714e262 three + HEAD is now at \$commit three EOF # The remaining ones just show info about previous and current HEADs. - cat >2nd_detach <<-'EOF' && - Previous HEAD position was 7c7cd714e262 three - HEAD is now at 139b20d8e6c5 two + cat >2nd_detach <<-EOF && + Previous HEAD position was \$commit three + HEAD is now at \$commit2 two EOF - cat >3rd_detach <<-'EOF' && - Previous HEAD position was 139b20d8e6c5 two - HEAD is now at d79ce1670bdc one + cat >3rd_detach <<-EOF && + Previous HEAD position was \$commit2 two + HEAD is now at \$commit3 one EOF reset && @@ -261,8 +265,12 @@ test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not as # Detached HEAD tests for GIT_PRINT_SHA1_ELLIPSIS (old format) test_expect_success 'describe_detached_head does print SHA-1 ellipsis when asked to' " + commit=$(git rev-parse --short=12 master^) && + commit2=$(git rev-parse --short=12 master~2) && + commit3=$(git rev-parse --short=12 master~3) && + # The first detach operation is more chatty than the following ones. - cat >1st_detach <<-'EOF' && + cat >1st_detach <<-EOF && Note: checking out 'HEAD^'. You are in 'detached HEAD' state. You can look around, make experimental @@ -274,18 +282,18 @@ test_expect_success 'describe_detached_head does print SHA-1 ellipsis when asked git checkout -b <new-branch-name> - HEAD is now at 7c7cd714e262... three + HEAD is now at \$commit... three EOF # The remaining ones just show info about previous and current HEADs. - cat >2nd_detach <<-'EOF' && - Previous HEAD position was 7c7cd714e262... three - HEAD is now at 139b20d8e6c5... two + cat >2nd_detach <<-EOF && + Previous HEAD position was \$commit... three + HEAD is now at \$commit2... two EOF - cat >3rd_detach <<-'EOF' && - Previous HEAD position was 139b20d8e6c5... two - HEAD is now at d79ce1670bdc... one + cat >3rd_detach <<-EOF && + Previous HEAD position was \$commit2... two + HEAD is now at \$commit3... one EOF reset && diff --git a/t/t2022-checkout-paths.sh b/t/t2022-checkout-paths.sh index f46d0499bc..fc3eb43b89 100755 --- a/t/t2022-checkout-paths.sh +++ b/t/t2022-checkout-paths.sh @@ -68,13 +68,13 @@ test_expect_success 'do not touch files that are already up-to-date' ' git add file1 file2 && git commit -m base && echo modified >file1 && - test-chmtime =1000000000 file2 && + test-tool chmtime =1000000000 file2 && git update-index -q --refresh && git checkout HEAD -- file1 file2 && echo one >expect && test_cmp expect file1 && - echo "1000000000 file2" >expect && - test-chmtime -v +0 file2 >actual && + echo "1000000000" >expect && + test-tool chmtime --get file2 >actual && test_cmp expect actual ' diff --git a/t/t2026-worktree-prune.sh b/t/t2026-worktree-prune.sh index a0f1e3bb80..b7d6d5d45a 100755 --- a/t/t2026-worktree-prune.sh +++ b/t/t2026-worktree-prune.sh @@ -78,10 +78,9 @@ test_expect_success 'not prune locked checkout' ' test_expect_success 'not prune recent checkouts' ' test_when_finished rm -r .git/worktrees && - mkdir zz && - mkdir -p .git/worktrees/jlm && - echo "$(pwd)"/zz >.git/worktrees/jlm/gitdir && - rmdir zz && + git worktree add jlm HEAD && + test -d .git/worktrees/jlm && + rm -rf jlm && git worktree prune --verbose --expire=2.days.ago && test -d .git/worktrees/jlm ' diff --git a/t/t2028-worktree-move.sh b/t/t2028-worktree-move.sh index 5d5b3632ba..5f7d45b7b7 100755 --- a/t/t2028-worktree-move.sh +++ b/t/t2028-worktree-move.sh @@ -72,12 +72,11 @@ test_expect_success 'move locked worktree' ' ' test_expect_success 'move worktree' ' - toplevel="$(pwd)" && git worktree move source destination && test_path_is_missing source && git worktree list --porcelain >out && - grep "^worktree.*/destination" out && - ! grep "^worktree.*/source" out && + grep "^worktree.*/destination$" out && + ! grep "^worktree.*/source$" out && git -C destination log --format=%s >actual2 && echo init >expected2 && test_cmp expected2 actual2 @@ -93,7 +92,7 @@ test_expect_success 'move worktree to another dir' ' test_when_finished "git worktree move some-dir/destination destination" && test_path_is_missing destination && git worktree list --porcelain >out && - grep "^worktree.*/some-dir/destination" out && + grep "^worktree.*/some-dir/destination$" out && git -C some-dir/destination log --format=%s >actual2 && echo init >expected2 && test_cmp expected2 actual2 diff --git a/t/t2101-update-index-reupdate.sh b/t/t2101-update-index-reupdate.sh index c8bce8c2e4..685ec45639 100755 --- a/t/t2101-update-index-reupdate.sh +++ b/t/t2101-update-index-reupdate.sh @@ -8,19 +8,20 @@ test_description='git update-index --again test. . ./test-lib.sh -cat > expected <<\EOF -100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0 file1 -100644 9db8893856a8a02eaa73470054b7c1c5a7c82e47 0 file2 -EOF -test_expect_success 'update-index --add' \ - 'echo hello world >file1 && - echo goodbye people >file2 && - git update-index --add file1 file2 && - git ls-files -s >current && - cmp current expected' +test_expect_success 'update-index --add' ' + echo hello world >file1 && + echo goodbye people >file2 && + git update-index --add file1 file2 && + git ls-files -s >current && + cat >expected <<-EOF && + 100644 $(git hash-object file1) 0 file1 + 100644 $(git hash-object file2) 0 file2 + EOF + cmp current expected +' -test_expect_success 'update-index --again' \ - 'rm -f file1 && +test_expect_success 'update-index --again' ' + rm -f file1 && echo hello everybody >file2 && if git update-index --again then @@ -29,25 +30,23 @@ test_expect_success 'update-index --again' \ else echo happy - failed as expected fi && - git ls-files -s >current && - cmp current expected' + git ls-files -s >current && + cmp current expected +' -cat > expected <<\EOF -100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2 -EOF -test_expect_success 'update-index --remove --again' \ - 'git update-index --remove --again && - git ls-files -s >current && - cmp current expected' +test_expect_success 'update-index --remove --again' ' + git update-index --remove --again && + git ls-files -s >current && + cat >expected <<-EOF && + 100644 $(git hash-object file2) 0 file2 + EOF + cmp current expected +' test_expect_success 'first commit' 'git commit -m initial' -cat > expected <<\EOF -100644 53ab446c3f4e42ce9bb728a0ccb283a101be4979 0 dir1/file3 -100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2 -EOF -test_expect_success 'update-index again' \ - 'mkdir -p dir1 && +test_expect_success 'update-index again' ' + mkdir -p dir1 && echo hello world >dir1/file3 && echo goodbye people >file2 && git update-index --add file2 dir1/file3 && @@ -55,30 +54,38 @@ test_expect_success 'update-index again' \ echo happy >dir1/file3 && git update-index --again && git ls-files -s >current && - cmp current expected' + cat >expected <<-EOF && + 100644 $(git hash-object dir1/file3) 0 dir1/file3 + 100644 $(git hash-object file2) 0 file2 + EOF + cmp current expected +' -cat > expected <<\EOF -100644 d7fb3f695f06c759dbf3ab00046e7cc2da22d10f 0 dir1/file3 -100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2 -EOF -test_expect_success 'update-index --update from subdir' \ - 'echo not so happy >file2 && +file2=$(git hash-object file2) +test_expect_success 'update-index --update from subdir' ' + echo not so happy >file2 && (cd dir1 && cat ../file2 >file3 && git update-index --again ) && git ls-files -s >current && - cmp current expected' + cat >expected <<-EOF && + 100644 $(git hash-object dir1/file3) 0 dir1/file3 + 100644 $file2 0 file2 + EOF + test_cmp current expected +' -cat > expected <<\EOF -100644 594fb5bb1759d90998e2bf2a38261ae8e243c760 0 dir1/file3 -100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2 -EOF -test_expect_success 'update-index --update with pathspec' \ - 'echo very happy >file2 && +test_expect_success 'update-index --update with pathspec' ' + echo very happy >file2 && cat file2 >dir1/file3 && git update-index --again dir1/ && git ls-files -s >current && - cmp current expected' + cat >expected <<-EOF && + 100644 $(git hash-object dir1/file3) 0 dir1/file3 + 100644 $file2 0 file2 + EOF + cmp current expected +' test_done diff --git a/t/t2104-update-index-skip-worktree.sh b/t/t2104-update-index-skip-worktree.sh index cc830da58d..7e2e7dd4ae 100755 --- a/t/t2104-update-index-skip-worktree.sh +++ b/t/t2104-update-index-skip-worktree.sh @@ -33,7 +33,7 @@ test_expect_success 'setup' ' ' test_expect_success 'index is at version 2' ' - test "$(test-index-version < .git/index)" = 2 + test "$(test-tool index-version < .git/index)" = 2 ' test_expect_success 'update-index --skip-worktree' ' @@ -42,7 +42,7 @@ test_expect_success 'update-index --skip-worktree' ' ' test_expect_success 'index is at version 3 after having some skip-worktree entries' ' - test "$(test-index-version < .git/index)" = 3 + test "$(test-tool index-version < .git/index)" = 3 ' test_expect_success 'ls-files -t' ' @@ -55,7 +55,7 @@ test_expect_success 'update-index --no-skip-worktree' ' ' test_expect_success 'index version is back to 2 when there is no skip-worktree entry' ' - test "$(test-index-version < .git/index)" = 2 + test "$(test-tool index-version < .git/index)" = 2 ' test_done diff --git a/t/t2107-update-index-basic.sh b/t/t2107-update-index-basic.sh index 32ac6e09bd..1db7e6a1ab 100755 --- a/t/t2107-update-index-basic.sh +++ b/t/t2107-update-index-basic.sh @@ -85,9 +85,9 @@ test_expect_success '--chmod=+x and chmod=-x in the same argument list' ' >B && git add A B && git update-index --chmod=+x A --chmod=-x B && - cat >expect <<-\EOF && - 100755 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 A - 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 B + cat >expect <<-EOF && + 100755 $EMPTY_BLOB 0 A + 100644 $EMPTY_BLOB 0 B EOF git ls-files --stage A B >actual && test_cmp expect actual diff --git a/t/t3008-ls-files-lazy-init-name-hash.sh b/t/t3008-ls-files-lazy-init-name-hash.sh index bdf5198b7e..08af596ba6 100755 --- a/t/t3008-ls-files-lazy-init-name-hash.sh +++ b/t/t3008-ls-files-lazy-init-name-hash.sh @@ -4,7 +4,7 @@ test_description='Test the lazy init name hash with various folder structures' . ./test-lib.sh -if test 1 -eq $($GIT_BUILD_DIR/t/helper/test-online-cpus) +if test 1 -eq $($GIT_BUILD_DIR/t/helper/test-tool online-cpus) then skip_all='skipping lazy-init tests, single cpu' test_done @@ -21,7 +21,7 @@ test_expect_success 'no buffer overflow in lazy_init_name_hash' ' ) | sed "s/^/100644 $EMPTY_BLOB /" | git update-index --index-info && - test-lazy-init-name-hash -m + test-tool lazy-init-name-hash -m ' test_done diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh index c1fc6ca730..dce102130f 100755 --- a/t/t3070-wildmatch.sh +++ b/t/t3070-wildmatch.sh @@ -79,12 +79,12 @@ match_with_function() { if test "$match_expect" = 1 then test_expect_success "$match_function: match '$text' '$pattern'" " - test-wildmatch $match_function '$text' '$pattern' + test-tool wildmatch $match_function '$text' '$pattern' " elif test "$match_expect" = 0 then test_expect_success "$match_function: no match '$text' '$pattern'" " - test_must_fail test-wildmatch $match_function '$text' '$pattern' + test_must_fail test-tool wildmatch $match_function '$text' '$pattern' " else test_expect_success "PANIC: Test framework error. Unknown matches value $match_expect" 'false' @@ -148,7 +148,7 @@ match_with_ls_files() { match() { if test "$#" = 6 then - # When test-wildmatch and git ls-files produce the same + # When test-tool wildmatch and git ls-files produce the same # result. match_glob=$1 match_file_glob=$match_glob @@ -204,19 +204,19 @@ match() { fi ' - # $1: Case sensitive glob match: test-wildmatch & ls-files + # $1: Case sensitive glob match: test-tool wildmatch & ls-files match_with_function "$text" "$pattern" $match_glob "wildmatch" match_with_ls_files "$text" "$pattern" $match_file_glob "wildmatch" " --glob-pathspecs" - # $2: Case insensitive glob match: test-wildmatch & ls-files + # $2: Case insensitive glob match: test-tool wildmatch & ls-files match_with_function "$text" "$pattern" $match_iglob "iwildmatch" match_with_ls_files "$text" "$pattern" $match_file_iglob "iwildmatch" " --glob-pathspecs --icase-pathspecs" - # $3: Case sensitive path match: test-wildmatch & ls-files + # $3: Case sensitive path match: test-tool wildmatch & ls-files match_with_function "$text" "$pattern" $match_pathmatch "pathmatch" match_with_ls_files "$text" "$pattern" $match_file_pathmatch "pathmatch" "" - # $4: Case insensitive path match: test-wildmatch & ls-files + # $4: Case insensitive path match: test-tool wildmatch & ls-files match_with_function "$text" "$pattern" $match_pathmatchi "ipathmatch" match_with_ls_files "$text" "$pattern" $match_file_pathmatchi "ipathmatch" " --icase-pathspecs" } diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 6c0b7ea4ad..c0ef946811 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -6,6 +6,7 @@ test_description='git branch assorted tests' . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-rebase.sh test_expect_success 'prepare a trivial repository' ' echo Hello >A && @@ -1246,6 +1247,29 @@ test_expect_success '--merged is incompatible with --no-merged' ' test_must_fail git branch --merged HEAD --no-merged HEAD ' +test_expect_success '--list during rebase' ' + test_when_finished "reset_rebase" && + git checkout master && + FAKE_LINES="1 edit 2" && + export FAKE_LINES && + set_fake_editor && + git rebase -i HEAD~2 && + git branch --list >actual && + test_i18ngrep "rebasing master" actual +' + +test_expect_success '--list during rebase from detached HEAD' ' + test_when_finished "reset_rebase && git checkout master" && + git checkout master^0 && + oid=$(git rev-parse --short HEAD) && + FAKE_LINES="1 edit 2" && + export FAKE_LINES && + set_fake_editor && + git rebase -i HEAD~2 && + git branch --list >actual && + test_i18ngrep "rebasing detached HEAD $oid" actual +' + test_expect_success 'tracking with unexpected .fetch refspec' ' rm -rf a b c d && git init a && diff --git a/t/t3306-notes-prune.sh b/t/t3306-notes-prune.sh index 86bf909ee3..61748088eb 100755 --- a/t/t3306-notes-prune.sh +++ b/t/t3306-notes-prune.sh @@ -22,7 +22,7 @@ test_expect_success 'setup: create a few commits with notes' ' git commit -m 3rd && COMMIT_FILE=.git/objects/5e/e1c35e83ea47cd3cc4f8cbee0568915fbbbd29 && test -f $COMMIT_FILE && - test-chmtime =+0 $COMMIT_FILE && + test-tool chmtime =+0 $COMMIT_FILE && git notes add -m "Note #3" ' diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 3b905406df..59c766540e 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -711,13 +711,13 @@ test_expect_success 'rebase -i continue with unstaged submodule' ' test_expect_success 'avoid unnecessary reset' ' git checkout master && git reset --hard && - test-chmtime =123456789 file3 && + test-tool chmtime =123456789 file3 && git update-index --refresh && HEAD=$(git rev-parse HEAD) && set_fake_editor && git rebase -i HEAD~4 && test $HEAD = $(git rev-parse HEAD) && - MTIME=$(test-chmtime -v +0 file3 | sed 's/[^0-9].*$//') && + MTIME=$(test-tool chmtime --get file3) && test 123456789 = $MTIME ' @@ -927,10 +927,8 @@ test_expect_success 'rebase --exec works without -i ' ' test_expect_success 'rebase -i --exec without <CMD>' ' git reset --hard execute && set_fake_editor && - test_must_fail git rebase -i --exec 2>tmp && - sed -e "1d" tmp >actual && - test_must_fail git rebase -h >expected && - test_cmp expected actual && + test_must_fail git rebase -i --exec 2>actual && + test_i18ngrep "requires a value" actual && git checkout master ' diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index 7c91a85f43..9214d0bb51 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -24,7 +24,7 @@ test_expect_success 'interactive rebase --continue works with touched file' ' git checkout master && FAKE_LINES="edit 1" git rebase -i HEAD^ && - test-chmtime =-60 F1 && + test-tool chmtime =-60 F1 && git rebase --continue ' @@ -36,7 +36,7 @@ test_expect_success 'non-interactive rebase --continue works with touched file' test_must_fail git rebase --onto master master topic && echo "Resolved" >F2 && git add F2 && - test-chmtime =-60 F1 && + test-tool chmtime =-60 F1 && git rebase --continue ' diff --git a/t/t3421-rebase-topology-linear.sh b/t/t3421-rebase-topology-linear.sh index 68fe2003ef..b078f93046 100755 --- a/t/t3421-rebase-topology-linear.sh +++ b/t/t3421-rebase-topology-linear.sh @@ -199,7 +199,7 @@ test_run_rebase () { " } test_run_rebase success '' -test_run_rebase failure -m +test_run_rebase success -m test_run_rebase success -i test_run_rebase failure -p @@ -214,8 +214,8 @@ test_run_rebase () { " } test_run_rebase success '' -test_run_rebase failure -m -test_run_rebase failure -i +test_run_rebase success -m +test_run_rebase success -i test_run_rebase failure -p # m diff --git a/t/t3428-rebase-signoff.sh b/t/t3428-rebase-signoff.sh index 2afb564701..f6993b7e14 100755 --- a/t/t3428-rebase-signoff.sh +++ b/t/t3428-rebase-signoff.sh @@ -12,6 +12,13 @@ cat >file <<EOF a EOF +# Expected commit message for initial commit after rebase --signoff +cat >expected-initial-signed <<EOF +Initial empty commit + +Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/") +EOF + # Expected commit message after rebase --signoff cat >expected-signed <<EOF first @@ -43,4 +50,35 @@ test_expect_success 'rebase --no-signoff does not add a sign-off line' ' test_cmp expected-unsigned actual ' +test_expect_success 'rebase --exec --signoff adds a sign-off line' ' + test_when_finished "rm exec" && + git commit --amend -m "first" && + git rebase --exec "touch exec" --signoff HEAD^ && + test_path_is_file exec && + git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && + test_cmp expected-signed actual +' + +test_expect_success 'rebase --root --signoff adds a sign-off line' ' + git commit --amend -m "first" && + git rebase --root --keep-empty --signoff && + git cat-file commit HEAD^ | sed -e "1,/^\$/d" >actual && + test_cmp expected-initial-signed actual && + git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && + test_cmp expected-signed actual +' + +test_expect_success 'rebase -i --signoff fails' ' + git commit --amend -m "first" && + git rebase -i --signoff HEAD^ && + git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && + test_cmp expected-signed actual +' + +test_expect_success 'rebase -m --signoff fails' ' + git commit --amend -m "first" && + git rebase -m --signoff HEAD^ && + git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && + test_cmp expected-signed actual +' test_done diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh index 783bdbf59d..ccbc118514 100755 --- a/t/t3501-revert-cherry-pick.sh +++ b/t/t3501-revert-cherry-pick.sh @@ -86,7 +86,7 @@ test_expect_success 'cherry-pick on stat-dirty working tree' ' ( cd copy && git checkout initial && - test-chmtime +40 oops && + test-tool chmtime +40 oops && git cherry-pick added ) ' diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh index 0acf4b1461..21b4f194a2 100755 --- a/t/t3510-cherry-pick-sequence.sh +++ b/t/t3510-cherry-pick-sequence.sh @@ -247,9 +247,9 @@ test_expect_success '--abort after last commit in sequence' ' test_expect_success 'cherry-pick does not implicitly stomp an existing operation' ' pristine_detach initial && test_expect_code 1 git cherry-pick base..anotherpick && - test-chmtime -v +0 .git/sequencer >expect && + test-tool chmtime --get .git/sequencer >expect && test_expect_code 128 git cherry-pick unrelatedpick && - test-chmtime -v +0 .git/sequencer >actual && + test-tool chmtime --get .git/sequencer >actual && test_cmp expect actual ' diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 46f15169f5..b8fbdefcdc 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -232,7 +232,7 @@ test_expect_success 'Call "rm" from outside the work tree' ' test_expect_success 'refresh index before checking if it is up-to-date' ' git reset --hard && - test-chmtime -86400 frotz/nitfol && + test-tool chmtime -86400 frotz/nitfol && git rm frotz/nitfol && test ! -f frotz/nitfol diff --git a/t/t3700-add.sh b/t/t3700-add.sh index 2748805642..07af05d7ae 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -187,7 +187,7 @@ test_expect_success 'git add --refresh with pathspec' ' echo >foo && echo >bar && echo >baz && git add foo bar baz && H=$(git rev-parse :foo) && git rm -f foo && echo "100644 $H 3 foo" | git update-index --index-info && - test-chmtime -60 bar baz && + test-tool chmtime -60 bar baz && >expect && git add --refresh bar >actual && test_cmp expect actual && diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh index bfde4057ad..3ea5b9bb3f 100755 --- a/t/t3905-stash-include-untracked.sh +++ b/t/t3905-stash-include-untracked.sh @@ -228,4 +228,56 @@ test_expect_success 'stash previously ignored file' ' test_path_is_file ignored.d/foo ' +test_expect_success 'stash -u -- <untracked> doesnt print error' ' + >untracked && + git stash push -u -- untracked 2>actual && + test_path_is_missing untracked && + test_line_count = 0 actual +' + +test_expect_success 'stash -u -- <untracked> leaves rest of working tree in place' ' + >tracked && + git add tracked && + >untracked && + git stash push -u -- untracked && + test_path_is_missing untracked && + test_path_is_file tracked +' + +test_expect_success 'stash -u -- <tracked> <untracked> clears changes in both' ' + >tracked && + git add tracked && + >untracked && + git stash push -u -- tracked untracked && + test_path_is_missing tracked && + test_path_is_missing untracked +' + +test_expect_success 'stash --all -- <ignored> stashes ignored file' ' + >ignored.d/bar && + git stash push --all -- ignored.d/bar && + test_path_is_missing ignored.d/bar +' + +test_expect_success 'stash --all -- <tracked> <ignored> clears changes in both' ' + >tracked && + git add tracked && + >ignored.d/bar && + git stash push --all -- tracked ignored.d/bar && + test_path_is_missing tracked && + test_path_is_missing ignored.d/bar +' + +test_expect_success 'stash -u -- <ignored> leaves ignored file alone' ' + >ignored.d/bar && + git stash push -u -- ignored.d/bar && + test_path_is_file ignored.d/bar +' + +test_expect_success 'stash -u -- <non-existant> shows no changes when there are none' ' + git stash push -u -- non-existant >actual && + echo "No local changes to save" >expect && + test_i18ncmp expect actual +' + test_done diff --git a/t/t4011-diff-symlink.sh b/t/t4011-diff-symlink.sh index 13e7f621ab..cf0f3a1ee7 100755 --- a/t/t4011-diff-symlink.sh +++ b/t/t4011-diff-symlink.sh @@ -73,7 +73,7 @@ test_expect_success 'diff identical, but newly created symlink and file' ' >expected && rm -f frotz nitfol && echo xyzzy >nitfol && - test-chmtime +10 nitfol && + test-tool chmtime +10 nitfol && if test_have_prereq SYMLINKS then ln -s xyzzy frotz diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 3f9a24fd56..f8d853595b 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -76,7 +76,7 @@ test_expect_success setup ' mkdir dir3 && cp dir/sub dir3/sub && - test-chmtime +1 dir3/sub && + test-tool chmtime +1 dir3/sub && git config log.showroot false && git commit --amend && diff --git a/t/t4035-diff-quiet.sh b/t/t4035-diff-quiet.sh index 2f1737fcef..0352bf81a9 100755 --- a/t/t4035-diff-quiet.sh +++ b/t/t4035-diff-quiet.sh @@ -147,7 +147,7 @@ test_expect_success 'git diff --ignore-all-space, both files outside repo' ' ' test_expect_success 'git diff --quiet ignores stat-change only entries' ' - test-chmtime +10 a && + test-tool chmtime +10 a && echo modified >>b && test_expect_code 1 git diff --quiet ' diff --git a/t/t4151-am-abort.sh b/t/t4151-am-abort.sh index 16432781d2..9d8d3c72e7 100755 --- a/t/t4151-am-abort.sh +++ b/t/t4151-am-abort.sh @@ -171,7 +171,7 @@ test_expect_success 'am --skip leaves index stat info alone' ' git checkout -f --orphan skip-stat-info && git reset && test_commit skip-should-be-untouched && - test-chmtime =0 skip-should-be-untouched.t && + test-tool chmtime =0 skip-should-be-untouched.t && git update-index --refresh && git diff-files --exit-code --quiet && test_must_fail git am 0001-*.patch && @@ -183,7 +183,7 @@ test_expect_success 'am --abort leaves index stat info alone' ' git checkout -f --orphan abort-stat-info && git reset && test_commit abort-should-be-untouched && - test-chmtime =0 abort-should-be-untouched.t && + test-tool chmtime =0 abort-should-be-untouched.t && git update-index --refresh && git diff-files --exit-code --quiet && test_must_fail git am 0001-*.patch && diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index d97d2bebc9..eaf18c81cb 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -166,7 +166,7 @@ test_expect_success 'first postimage wins' ' git commit -q -a -m "prefer first over second" && test -f $rr/postimage && - oldmtimepost=$(test-chmtime -v -60 $rr/postimage | cut -f 1) && + oldmtimepost=$(test-tool chmtime --get -60 $rr/postimage) && git checkout -b third master && git show second^:a1 | sed "s/To die: t/To die! T/" >a1 && @@ -179,7 +179,7 @@ test_expect_success 'first postimage wins' ' ' test_expect_success 'rerere updates postimage timestamp' ' - newmtimepost=$(test-chmtime -v +0 $rr/postimage | cut -f 1) && + newmtimepost=$(test-tool chmtime --get $rr/postimage) && test $oldmtimepost -lt $newmtimepost ' @@ -220,9 +220,9 @@ test_expect_success 'set up for garbage collection tests' ' almost_60_days_ago=$((60-60*86400)) && just_over_60_days_ago=$((-1-60*86400)) && - test-chmtime =$just_over_60_days_ago $rr/preimage && - test-chmtime =$almost_60_days_ago $rr/postimage && - test-chmtime =$almost_15_days_ago $rr2/preimage + test-tool chmtime =$just_over_60_days_ago $rr/preimage && + test-tool chmtime =$almost_60_days_ago $rr/postimage && + test-tool chmtime =$almost_15_days_ago $rr2/preimage ' test_expect_success 'gc preserves young or recently used records' ' @@ -232,8 +232,8 @@ test_expect_success 'gc preserves young or recently used records' ' ' test_expect_success 'old records rest in peace' ' - test-chmtime =$just_over_60_days_ago $rr/postimage && - test-chmtime =$just_over_15_days_ago $rr2/preimage && + test-tool chmtime =$just_over_60_days_ago $rr/postimage && + test-tool chmtime =$just_over_15_days_ago $rr2/preimage && git rerere gc && ! test -f $rr/preimage && ! test -f $rr2/preimage @@ -249,8 +249,8 @@ rerere_gc_custom_expiry_test () { >"$rr/postimage" && two_days_ago=$((-2*86400)) && - test-chmtime =$two_days_ago "$rr/preimage" && - test-chmtime =$two_days_ago "$rr/postimage" && + test-tool chmtime =$two_days_ago "$rr/preimage" && + test-tool chmtime =$two_days_ago "$rr/postimage" && find .git/rr-cache -type f | sort >original && @@ -512,7 +512,7 @@ test_expect_success 'multiple identical conflicts' ' count_pre_post 2 0 && # Pretend that the conflicts were made quite some time ago - find .git/rr-cache/ -type f | xargs test-chmtime -172800 && + test-tool chmtime -172800 $(find .git/rr-cache/ -type f) && # Unresolved entries have not expired yet git -c gc.rerereresolved=5 -c gc.rerereunresolved=5 rerere gc && @@ -568,7 +568,7 @@ test_expect_success 'multiple identical conflicts' ' git rerere && # Pretend that the resolutions are old again - find .git/rr-cache/ -type f | xargs test-chmtime -172800 && + test-tool chmtime -172800 $(find .git/rr-cache/ -type f) && # Resolved entries have not expired yet git -c gc.rerereresolved=5 -c gc.rerereunresolved=5 rerere gc && diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh index da10478f59..ff6649ed9a 100755 --- a/t/t4201-shortlog.sh +++ b/t/t4201-shortlog.sh @@ -127,6 +127,11 @@ test_expect_success !MINGW 'shortlog can read --format=raw output' ' test_cmp expect out ' +test_expect_success 'shortlog from non-git directory refuses extra arguments' ' + test_must_fail env GIT_DIR=non-existing git shortlog foo 2>out && + test_i18ngrep "too many arguments" out +' + test_expect_success 'shortlog should add newline when input line matches wraplen' ' cat >expect <<\EOF && A U Thor (2): diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index fe2d4f15a7..2a97b27b0a 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -101,7 +101,7 @@ test_expect_success \ ten=0123456789 && hundred=$ten$ten$ten$ten$ten$ten$ten$ten$ten$ten && echo long filename >a/four$hundred && mkdir a/bin && - test-genrandom "frotz" 500000 >a/bin/sh && + test-tool genrandom "frotz" 500000 >a/bin/sh && printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 && printf "A not substituted O" >a/substfile2 && if test_have_prereq SYMLINKS; then @@ -192,7 +192,7 @@ test_expect_success \ 'validate file modification time' \ 'mkdir extract && "$TAR" xf b.tar -C extract a/a && - test-chmtime -v +0 extract/a/a |cut -f 1 >b.mtime && + test-tool chmtime --get extract/a/a >b.mtime && echo "1117231200" >expected.mtime && test_cmp expected.mtime b.mtime' diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index 9c68b99251..65ff60f2ee 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -16,8 +16,8 @@ test_expect_success \ perl -e "print \"a\" x 4096;" > a && perl -e "print \"b\" x 4096;" > b && perl -e "print \"c\" x 4096;" > c && - test-genrandom "seed a" 2097152 > a_big && - test-genrandom "seed b" 2097152 > b_big && + test-tool genrandom "seed a" 2097152 > a_big && + test-tool genrandom "seed b" 2097152 > b_big && git update-index --add a a_big b b_big c && cat c >d && echo foo >>d && git update-index --add d && tree=$(git write-tree) && @@ -311,8 +311,8 @@ test_expect_success 'unpacking with --strict' ' rm -f .git/index && tail -n 10 LIST | git update-index --index-info && ST=$(git write-tree) && - PACK5=$( git rev-list --objects "$LIST" "$LI" "$ST" | \ - git pack-objects test-5 ) && + git rev-list --objects "$LIST" "$LI" "$ST" >actual && + PACK5=$( git pack-objects test-5 <actual ) && PACK6=$( ( echo "$LIST" echo "$LI" @@ -358,8 +358,8 @@ test_expect_success 'index-pack with --strict' ' rm -f .git/index && tail -n 10 LIST | git update-index --index-info && ST=$(git write-tree) && - PACK5=$( git rev-list --objects "$LIST" "$LI" "$ST" | \ - git pack-objects test-5 ) && + git rev-list --objects "$LIST" "$LI" "$ST" >actual && + PACK5=$( git pack-objects test-5 <actual ) && PACK6=$( ( echo "$LIST" echo "$LI" diff --git a/t/t5301-sliding-window.sh b/t/t5301-sliding-window.sh index cae8c2e882..76f9798ab9 100755 --- a/t/t5301-sliding-window.sh +++ b/t/t5301-sliding-window.sh @@ -12,7 +12,7 @@ test_expect_success \ for i in a b c do echo $i >$i && - test-genrandom "$i" 32768 >>$i && + test-tool genrandom "$i" 32768 >>$i && git update-index --add $i || return 1 done && echo d >d && cat c >>d && git update-index --add d && diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh index d695a6082e..bb9b8bb309 100755 --- a/t/t5302-pack-index.sh +++ b/t/t5302-pack-index.sh @@ -15,17 +15,17 @@ test_expect_success \ while test $i -le 100 do iii=$(printf '%03i' $i) - test-genrandom "bar" 200 > wide_delta_$iii && - test-genrandom "baz $iii" 50 >> wide_delta_$iii && - test-genrandom "foo"$i 100 > deep_delta_$iii && - test-genrandom "foo"$(expr $i + 1) 100 >> deep_delta_$iii && - test-genrandom "foo"$(expr $i + 2) 100 >> deep_delta_$iii && + test-tool genrandom "bar" 200 > wide_delta_$iii && + test-tool genrandom "baz $iii" 50 >> wide_delta_$iii && + test-tool genrandom "foo"$i 100 > deep_delta_$iii && + test-tool genrandom "foo"$(expr $i + 1) 100 >> deep_delta_$iii && + test-tool genrandom "foo"$(expr $i + 2) 100 >> deep_delta_$iii && echo $iii >file_$iii && - test-genrandom "$iii" 8192 >>file_$iii && + test-tool genrandom "$iii" 8192 >>file_$iii && git update-index --add file_$iii deep_delta_$iii wide_delta_$iii && i=$(expr $i + 1) || return 1 done && - { echo 101 && test-genrandom 100 8192; } >file_101 && + { echo 101 && test-tool genrandom 100 8192; } >file_101 && git update-index --add file_101 && tree=$(git write-tree) && commit=$(git commit-tree $tree </dev/null) && { diff --git a/t/t5303-pack-corruption-resilience.sh b/t/t5303-pack-corruption-resilience.sh index 5940ce2084..3634e258f8 100755 --- a/t/t5303-pack-corruption-resilience.sh +++ b/t/t5303-pack-corruption-resilience.sh @@ -19,14 +19,14 @@ test_description='resilience to pack corruptions with redundant objects' # 3) object header is always 2 bytes. create_test_files() { - test-genrandom "foo" 2000 > file_1 && - test-genrandom "foo" 1800 > file_2 && - test-genrandom "foo" 1800 > file_3 && + test-tool genrandom "foo" 2000 > file_1 && + test-tool genrandom "foo" 1800 > file_2 && + test-tool genrandom "foo" 1800 > file_3 && echo " base " >> file_1 && echo " delta1 " >> file_2 && echo " delta delta2 " >> file_3 && - test-genrandom "bar" 150 >> file_2 && - test-genrandom "baz" 100 >> file_3 + test-tool genrandom "bar" 150 >> file_2 && + test-tool genrandom "baz" 100 >> file_3 } create_new_pack() { diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh index 6694c19a1e..f20f03c103 100755 --- a/t/t5304-prune.sh +++ b/t/t5304-prune.sh @@ -15,7 +15,7 @@ add_blob() { BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") && verbose test $((1 + $before)) = $(git count-objects | sed "s/ .*//") && test_path_is_file $BLOB_FILE && - test-chmtime =+0 $BLOB_FILE + test-tool chmtime =+0 $BLOB_FILE } test_expect_success setup ' @@ -33,7 +33,7 @@ test_expect_success 'prune stale packs' ' orig_pack=$(echo .git/objects/pack/*.pack) && : > .git/objects/tmp_1.pack && : > .git/objects/tmp_2.pack && - test-chmtime =-86501 .git/objects/tmp_1.pack && + test-tool chmtime =-86501 .git/objects/tmp_1.pack && git prune --expire 1.day && test_path_is_file $orig_pack && test_path_is_file .git/objects/tmp_2.pack && @@ -47,7 +47,7 @@ test_expect_success 'prune --expire' ' git prune --expire=1.hour.ago && verbose test $((1 + $before)) = $(git count-objects | sed "s/ .*//") && test_path_is_file $BLOB_FILE && - test-chmtime =-86500 $BLOB_FILE && + test-tool chmtime =-86500 $BLOB_FILE && git prune --expire 1.day && verbose test $before = $(git count-objects | sed "s/ .*//") && test_path_is_missing $BLOB_FILE @@ -57,11 +57,11 @@ test_expect_success 'prune --expire' ' test_expect_success 'gc: implicit prune --expire' ' add_blob && - test-chmtime =-$((2*$week-30)) $BLOB_FILE && + test-tool chmtime =-$((2*$week-30)) $BLOB_FILE && git gc && verbose test $((1 + $before)) = $(git count-objects | sed "s/ .*//") && test_path_is_file $BLOB_FILE && - test-chmtime =-$((2*$week+1)) $BLOB_FILE && + test-tool chmtime =-$((2*$week+1)) $BLOB_FILE && git gc && verbose test $before = $(git count-objects | sed "s/ .*//") && test_path_is_missing $BLOB_FILE @@ -141,7 +141,7 @@ test_expect_success 'prune: do not prune heads listed as an argument' ' test_expect_success 'gc --no-prune' ' add_blob && - test-chmtime =-$((5001*$day)) $BLOB_FILE && + test-tool chmtime =-$((5001*$day)) $BLOB_FILE && git config gc.pruneExpire 2.days.ago && git gc --no-prune && verbose test 1 = $(git count-objects | sed "s/ .*//") && @@ -163,7 +163,7 @@ test_expect_success 'gc respects gc.pruneExpire' ' test_expect_success 'gc --prune=<date>' ' add_blob && - test-chmtime =-$((5001*$day)) $BLOB_FILE && + test-tool chmtime =-$((5001*$day)) $BLOB_FILE && git gc --prune=5002.days.ago && test_path_is_file $BLOB_FILE && git gc --prune=5000.days.ago && @@ -205,7 +205,7 @@ test_expect_success 'prune --expire=never' ' test_expect_success 'gc: prune old objects after local clone' ' add_blob && - test-chmtime =-$((2*$week+1)) $BLOB_FILE && + test-tool chmtime =-$((2*$week+1)) $BLOB_FILE && git clone --no-hardlinks . aclone && ( cd aclone && @@ -320,4 +320,14 @@ test_expect_success 'prune: handle HEAD reflog in multiple worktrees' ' test_cmp expected actual ' +test_expect_success 'prune: handle expire option correctly' ' + test_must_fail git prune --expire 2>error && + test_i18ngrep "requires a value" error && + + test_must_fail git prune --expire=nyah 2>error && + test_i18ngrep "malformed expiration" error && + + git prune --no-expire +' + test_done diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh index 20e2473a03..f6d600fd82 100755 --- a/t/t5310-pack-bitmaps.sh +++ b/t/t5310-pack-bitmaps.sh @@ -284,7 +284,7 @@ test_expect_success JGIT 'jgit can read our bitmaps' ' ' test_expect_success 'splitting packs does not generate bogus bitmaps' ' - test-genrandom foo $((1024 * 1024)) >rand && + test-tool genrandom foo $((1024 * 1024)) >rand && git add rand && git commit -m "commit with big file" && git -c pack.packSizeLimit=500k repack -adb && diff --git a/t/t5313-pack-bounds-checks.sh b/t/t5313-pack-bounds-checks.sh index 9372508c99..4fe4ad9d61 100755 --- a/t/t5313-pack-bounds-checks.sh +++ b/t/t5313-pack-bounds-checks.sh @@ -163,8 +163,8 @@ test_expect_success 'bogus offset inside v2 extended table' ' test_expect_success 'bogus OFS_DELTA in packfile' ' # Generate a pack with a delta in it. - base=$(test-genrandom foo 3000 | git hash-object --stdin -w) && - delta=$(test-genrandom foo 2000 | git hash-object --stdin -w) && + base=$(test-tool genrandom foo 3000 | git hash-object --stdin -w) && + delta=$(test-tool genrandom foo 2000 | git hash-object --stdin -w) && do_pack "$base $delta" --delta-base-offset && rm -f .git/objects/??/* && diff --git a/t/t5314-pack-cycle-detection.sh b/t/t5314-pack-cycle-detection.sh index f7dbdfb412..f31995d3d2 100755 --- a/t/t5314-pack-cycle-detection.sh +++ b/t/t5314-pack-cycle-detection.sh @@ -73,7 +73,7 @@ make_pack () { } test_expect_success 'setup' ' - test-genrandom base 4096 >base && + test-tool genrandom base 4096 >base && for i in one two do # we want shared content here to encourage deltas... diff --git a/t/t5316-pack-delta-depth.sh b/t/t5316-pack-delta-depth.sh index 2ed479b712..0f06c40eb1 100755 --- a/t/t5316-pack-delta-depth.sh +++ b/t/t5316-pack-delta-depth.sh @@ -47,7 +47,7 @@ test_description='pack-objects breaks long cross-pack delta chains' # repeatedly-modified file to generate the delta chain). test_expect_success 'create series of packs' ' - test-genrandom foo 4096 >content && + test-tool genrandom foo 4096 >content && prev= && for i in $(test_seq 1 10) do diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh new file mode 100755 index 0000000000..a380419b65 --- /dev/null +++ b/t/t5318-commit-graph.sh @@ -0,0 +1,224 @@ +#!/bin/sh + +test_description='commit graph' +. ./test-lib.sh + +test_expect_success 'setup full repo' ' + mkdir full && + cd "$TRASH_DIRECTORY/full" && + git init && + git config core.commitGraph true && + objdir=".git/objects" +' + +test_expect_success 'write graph with no packs' ' + cd "$TRASH_DIRECTORY/full" && + git commit-graph write --object-dir . && + test_path_is_file info/commit-graph +' + +test_expect_success 'create commits and repack' ' + cd "$TRASH_DIRECTORY/full" && + for i in $(test_seq 3) + do + test_commit $i && + git branch commits/$i + done && + git repack +' + +graph_git_two_modes() { + git -c core.graph=true $1 >output + git -c core.graph=false $1 >expect + test_cmp output expect +} + +graph_git_behavior() { + MSG=$1 + DIR=$2 + BRANCH=$3 + COMPARE=$4 + test_expect_success "check normal git operations: $MSG" ' + cd "$TRASH_DIRECTORY/$DIR" && + graph_git_two_modes "log --oneline $BRANCH" && + graph_git_two_modes "log --topo-order $BRANCH" && + graph_git_two_modes "log --graph $COMPARE..$BRANCH" && + graph_git_two_modes "branch -vv" && + graph_git_two_modes "merge-base -a $BRANCH $COMPARE" + ' +} + +graph_git_behavior 'no graph' full commits/3 commits/1 + +graph_read_expect() { + OPTIONAL="" + NUM_CHUNKS=3 + if test ! -z $2 + then + OPTIONAL=" $2" + NUM_CHUNKS=$((3 + $(echo "$2" | wc -w))) + fi + cat >expect <<- EOF + header: 43475048 1 1 $NUM_CHUNKS 0 + num_commits: $1 + chunks: oid_fanout oid_lookup commit_metadata$OPTIONAL + EOF + git commit-graph read >output && + test_cmp expect output +} + +test_expect_success 'write graph' ' + cd "$TRASH_DIRECTORY/full" && + graph1=$(git commit-graph write) && + test_path_is_file $objdir/info/commit-graph && + graph_read_expect "3" +' + +graph_git_behavior 'graph exists' full commits/3 commits/1 + +test_expect_success 'Add more commits' ' + cd "$TRASH_DIRECTORY/full" && + git reset --hard commits/1 && + for i in $(test_seq 4 5) + do + test_commit $i && + git branch commits/$i + done && + git reset --hard commits/2 && + for i in $(test_seq 6 7) + do + test_commit $i && + git branch commits/$i + done && + git reset --hard commits/2 && + git merge commits/4 && + git branch merge/1 && + git reset --hard commits/4 && + git merge commits/6 && + git branch merge/2 && + git reset --hard commits/3 && + git merge commits/5 commits/7 && + git branch merge/3 && + git repack +' + +# Current graph structure: +# +# __M3___ +# / | \ +# 3 M1 5 M2 7 +# |/ \|/ \| +# 2 4 6 +# |___/____/ +# 1 + +test_expect_success 'write graph with merges' ' + cd "$TRASH_DIRECTORY/full" && + git commit-graph write && + test_path_is_file $objdir/info/commit-graph && + graph_read_expect "10" "large_edges" +' + +graph_git_behavior 'merge 1 vs 2' full merge/1 merge/2 +graph_git_behavior 'merge 1 vs 3' full merge/1 merge/3 +graph_git_behavior 'merge 2 vs 3' full merge/2 merge/3 + +test_expect_success 'Add one more commit' ' + cd "$TRASH_DIRECTORY/full" && + test_commit 8 && + git branch commits/8 && + ls $objdir/pack | grep idx >existing-idx && + git repack && + ls $objdir/pack| grep idx | grep -v --file=existing-idx >new-idx +' + +# Current graph structure: +# +# 8 +# | +# __M3___ +# / | \ +# 3 M1 5 M2 7 +# |/ \|/ \| +# 2 4 6 +# |___/____/ +# 1 + +graph_git_behavior 'mixed mode, commit 8 vs merge 1' full commits/8 merge/1 +graph_git_behavior 'mixed mode, commit 8 vs merge 2' full commits/8 merge/2 + +test_expect_success 'write graph with new commit' ' + cd "$TRASH_DIRECTORY/full" && + git commit-graph write && + test_path_is_file $objdir/info/commit-graph && + graph_read_expect "11" "large_edges" +' + +graph_git_behavior 'full graph, commit 8 vs merge 1' full commits/8 merge/1 +graph_git_behavior 'full graph, commit 8 vs merge 2' full commits/8 merge/2 + +test_expect_success 'write graph with nothing new' ' + cd "$TRASH_DIRECTORY/full" && + git commit-graph write && + test_path_is_file $objdir/info/commit-graph && + graph_read_expect "11" "large_edges" +' + +graph_git_behavior 'cleared graph, commit 8 vs merge 1' full commits/8 merge/1 +graph_git_behavior 'cleared graph, commit 8 vs merge 2' full commits/8 merge/2 + +test_expect_success 'build graph from latest pack with closure' ' + cd "$TRASH_DIRECTORY/full" && + cat new-idx | git commit-graph write --stdin-packs && + test_path_is_file $objdir/info/commit-graph && + graph_read_expect "9" "large_edges" +' + +graph_git_behavior 'graph from pack, commit 8 vs merge 1' full commits/8 merge/1 +graph_git_behavior 'graph from pack, commit 8 vs merge 2' full commits/8 merge/2 + +test_expect_success 'build graph from commits with closure' ' + cd "$TRASH_DIRECTORY/full" && + git tag -a -m "merge" tag/merge merge/2 && + git rev-parse tag/merge >commits-in && + git rev-parse merge/1 >>commits-in && + cat commits-in | git commit-graph write --stdin-commits && + test_path_is_file $objdir/info/commit-graph && + graph_read_expect "6" +' + +graph_git_behavior 'graph from commits, commit 8 vs merge 1' full commits/8 merge/1 +graph_git_behavior 'graph from commits, commit 8 vs merge 2' full commits/8 merge/2 + +test_expect_success 'build graph from commits with append' ' + cd "$TRASH_DIRECTORY/full" && + git rev-parse merge/3 | git commit-graph write --stdin-commits --append && + test_path_is_file $objdir/info/commit-graph && + graph_read_expect "10" "large_edges" +' + +graph_git_behavior 'append graph, commit 8 vs merge 1' full commits/8 merge/1 +graph_git_behavior 'append graph, commit 8 vs merge 2' full commits/8 merge/2 + +test_expect_success 'setup bare repo' ' + cd "$TRASH_DIRECTORY" && + git clone --bare --no-local full bare && + cd bare && + git config core.commitGraph true && + baredir="./objects" +' + +graph_git_behavior 'bare repo, commit 8 vs merge 1' bare commits/8 merge/1 +graph_git_behavior 'bare repo, commit 8 vs merge 2' bare commits/8 merge/2 + +test_expect_success 'write graph in bare repo' ' + cd "$TRASH_DIRECTORY/bare" && + git commit-graph write && + test_path_is_file $baredir/info/commit-graph && + graph_read_expect "11" "large_edges" +' + +graph_git_behavior 'bare repo with graph, commit 8 vs merge 1' bare commits/8 merge/1 +graph_git_behavior 'bare repo with graph, commit 8 vs merge 2' bare commits/8 merge/2 + +test_done diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index d375d7110d..911eae1bf7 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -180,7 +180,7 @@ test_expect_success 'receive-pack runs auto-gc in remote repo' ' # And create a file that follows the temporary object naming # convention for the auto-gc to remove : >.git/objects/tmp_test_object && - test-chmtime =-1209601 .git/objects/tmp_test_object + test-tool chmtime =-1209601 .git/objects/tmp_test_object ) && ( cd parent && diff --git a/t/t5404-tracking-branches.sh b/t/t5404-tracking-branches.sh index 2b8c0bac7d..2762f420bc 100755 --- a/t/t5404-tracking-branches.sh +++ b/t/t5404-tracking-branches.sh @@ -56,7 +56,7 @@ test_expect_success 'deleted branches have their tracking branches removed' ' test_expect_success 'already deleted tracking branches ignored' ' git branch -d -r origin/b3 && git push origin :b3 >output 2>&1 && - ! grep error output + ! grep "^error: " output ' test_done diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index da9ac00557..ae5a530a2d 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -840,8 +840,8 @@ test_expect_success C_LOCALE_OUTPUT 'fetch aligned output' ' test_commit looooooooooooong-tag && ( cd full-output && - git -c fetch.output=full fetch origin 2>&1 | \ - grep -e "->" | cut -c 22- >../actual + git -c fetch.output=full fetch origin >actual 2>&1 && + grep -e "->" actual | cut -c 22- >../actual ) && cat >expect <<-\EOF && master -> origin/master @@ -855,8 +855,8 @@ test_expect_success C_LOCALE_OUTPUT 'fetch compact output' ' test_commit extraaa && ( cd compact && - git -c fetch.output=compact fetch origin 2>&1 | \ - grep -e "->" | cut -c 22- >../actual + git -c fetch.output=compact fetch origin >actual 2>&1 && + grep -e "->" actual | cut -c 22- >../actual ) && cat >expect <<-\EOF && master -> origin/* diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh index 02106c9226..6a949484d0 100755 --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@ -10,6 +10,9 @@ test_expect_success setup ' test_tick && git commit -m initial && git tag mark && + git tag mark1.1 && + git tag mark1.2 && + git tag mark1.10 && git show-ref --tags -d | sed -e "s/ / /" >expected.tag && ( echo "$(git rev-parse HEAD) HEAD" @@ -39,6 +42,39 @@ test_expect_success 'ls-remote self' ' test_cmp expected.all actual ' +test_expect_success 'ls-remote --sort="version:refname" --tags self' ' + cat >expect <<-EOF && + $(git rev-parse mark) refs/tags/mark + $(git rev-parse mark1.1) refs/tags/mark1.1 + $(git rev-parse mark1.2) refs/tags/mark1.2 + $(git rev-parse mark1.10) refs/tags/mark1.10 + EOF + git ls-remote --sort="version:refname" --tags self >actual && + test_cmp expect actual +' + +test_expect_success 'ls-remote --sort="-version:refname" --tags self' ' + cat >expect <<-EOF && + $(git rev-parse mark1.10) refs/tags/mark1.10 + $(git rev-parse mark1.2) refs/tags/mark1.2 + $(git rev-parse mark1.1) refs/tags/mark1.1 + $(git rev-parse mark) refs/tags/mark + EOF + git ls-remote --sort="-version:refname" --tags self >actual && + test_cmp expect actual +' + +test_expect_success 'ls-remote --sort="-refname" --tags self' ' + cat >expect <<-EOF && + $(git rev-parse mark1.2) refs/tags/mark1.2 + $(git rev-parse mark1.10) refs/tags/mark1.10 + $(git rev-parse mark1.1) refs/tags/mark1.1 + $(git rev-parse mark) refs/tags/mark + EOF + git ls-remote --sort="-refname" --tags self >actual && + test_cmp expect actual +' + test_expect_success 'dies when no remote specified and no default remotes found' ' test_must_fail git ls-remote ' @@ -131,7 +167,7 @@ test_expect_success 'Report no-match with --exit-code' ' test_expect_success 'Report match with --exit-code' ' git ls-remote --exit-code other.git "refs/tags/*" >actual && - git ls-remote . tags/mark >expect && + git ls-remote . tags/mark* >expect && test_cmp expect actual ' @@ -171,13 +207,17 @@ test_expect_success 'overrides work between mixed transfer/upload-pack hideRefs' ' test_expect_success 'ls-remote --symref' ' - cat >expect <<-\EOF && + git fetch origin && + cat >expect <<-EOF && ref: refs/heads/master HEAD - 1bd44cb9d13204b0fe1958db0082f5028a16eb3a HEAD - 1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/heads/master - 1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/remotes/origin/HEAD - 1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/remotes/origin/master - 1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/tags/mark + $(git rev-parse HEAD) HEAD + $(git rev-parse refs/heads/master) refs/heads/master + $(git rev-parse HEAD) refs/remotes/origin/HEAD + $(git rev-parse refs/remotes/origin/master) refs/remotes/origin/master + $(git rev-parse refs/tags/mark) refs/tags/mark + $(git rev-parse refs/tags/mark1.1) refs/tags/mark1.1 + $(git rev-parse refs/tags/mark1.10) refs/tags/mark1.10 + $(git rev-parse refs/tags/mark1.2) refs/tags/mark1.2 EOF git ls-remote --symref >actual && test_cmp expect actual diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index 177897ea0b..82239138d5 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -1418,7 +1418,7 @@ test_expect_success 'receive.denyCurrentBranch = updateInstead' ' cd testrepo && git reset --hard HEAD^ && test $(git -C .. rev-parse HEAD^) = $(git rev-parse HEAD) && - test-chmtime +100 path1 + test-tool chmtime +100 path1 ) && git push testrepo master && ( diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh index 21340e89c9..a2af693068 100755 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@ -377,5 +377,17 @@ test_expect_success 'push status output scrubs password' ' grep "^To $HTTPD_URL/smart/test_repo.git" status ' +test_expect_success 'colorize errors/hints' ' + cd "$ROOT_PATH"/test_repo_clone && + test_must_fail git -c color.transport=always -c color.advice=always \ + -c color.push=always \ + push origin origin/master^:master 2>act && + test_decode_color <act >decoded && + test_i18ngrep "<RED>.*rejected.*<RESET>" decoded && + test_i18ngrep "<RED>error: failed to push some refs" decoded && + test_i18ngrep "<YELLOW>hint: " decoded && + test_i18ngrep ! "^hint: " decoded +' + stop_httpd test_done diff --git a/t/t5546-receive-limits.sh b/t/t5546-receive-limits.sh index 10cb0be2b7..0b0e987fdb 100755 --- a/t/t5546-receive-limits.sh +++ b/t/t5546-receive-limits.sh @@ -44,7 +44,7 @@ test_pack_input_limit () { } test_expect_success "create known-size (1024 bytes) commit" ' - test-genrandom foo 1024 >one-k && + test-tool genrandom foo 1024 >one-k && git add one-k && test_commit one-k ' diff --git a/t/t5547-push-quarantine.sh b/t/t5547-push-quarantine.sh index 113c87007f..faaa51ccc5 100755 --- a/t/t5547-push-quarantine.sh +++ b/t/t5547-push-quarantine.sh @@ -39,7 +39,7 @@ test_expect_success 'push to repo path with path separator (colon)' ' # so make it likely for us to generate a delta by having # a non-trivial file with multiple versions. - test-genrandom foo 4096 >file.bin && + test-tool genrandom foo 4096 >file.bin && git add file.bin && git commit -m bin && diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh index 8552184e74..6d7d88ccc9 100755 --- a/t/t5550-http-fetch-dumb.sh +++ b/t/t5550-http-fetch-dumb.sh @@ -169,6 +169,17 @@ test_expect_success 'fetch changes via manual http-fetch' ' test_cmp file clone2/file ' +test_expect_success 'manual http-fetch without -a works just as well' ' + cp -R clone-tmpl clone3 && + + HEAD=$(git rev-parse --verify HEAD) && + (cd clone3 && + git http-fetch -w heads/master-new $HEAD $(git config remote.origin.url) && + git checkout master-new && + test $HEAD = $(git rev-parse --verify HEAD)) && + test_cmp file clone3/file +' + test_expect_success 'http remote detects correct HEAD' ' git push public master:other && (cd clone && diff --git a/t/t5561-http-backend.sh b/t/t5561-http-backend.sh index 90e0d6f0fe..84a955770a 100755 --- a/t/t5561-http-backend.sh +++ b/t/t5561-http-backend.sh @@ -3,10 +3,16 @@ test_description='test git-http-backend' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-httpd.sh + +if ! test_have_prereq CURL; then + skip_all='skipping raw http-backend tests, curl not available' + test_done +fi + start_httpd GET() { - curl --include "$HTTPD_URL/$SMART/repo.git/$1" >out 2>/dev/null && + curl --include "$HTTPD_URL/$SMART/repo.git/$1" >out && tr '\015' Q <out | sed ' s/Q$// @@ -19,7 +25,7 @@ GET() { POST() { curl --include --data "$2" \ --header "Content-Type: application/x-$1-request" \ - "$HTTPD_URL/smart/repo.git/$1" >out 2>/dev/null && + "$HTTPD_URL/smart/repo.git/$1" >out && tr '\015' Q <out | sed ' s/Q$// diff --git a/t/t5608-clone-2gb.sh b/t/t5608-clone-2gb.sh index 191d6d3a78..df822d9a3e 100755 --- a/t/t5608-clone-2gb.sh +++ b/t/t5608-clone-2gb.sh @@ -21,7 +21,7 @@ test_expect_success CLONE_2GB 'setup' ' do printf "Generating blob $i/$blobcount\r" >&2 && printf "blob\nmark :$i\ndata $blobsize\n" && - #test-genrandom $i $blobsize && + #test-tool genrandom $i $blobsize && printf "%-${blobsize}s" $i && echo "M 100644 :$i $i" >> commit i=$(($i+1)) || diff --git a/t/t5701-git-serve.sh b/t/t5701-git-serve.sh new file mode 100755 index 0000000000..72d7bc5628 --- /dev/null +++ b/t/t5701-git-serve.sh @@ -0,0 +1,176 @@ +#!/bin/sh + +test_description='test git-serve and server commands' + +. ./test-lib.sh + +test_expect_success 'test capability advertisement' ' + cat >expect <<-EOF && + version 2 + agent=git/$(git version | cut -d" " -f3) + ls-refs + fetch=shallow + 0000 + EOF + + git serve --advertise-capabilities >out && + test-pkt-line unpack <out >actual && + test_cmp actual expect +' + +test_expect_success 'stateless-rpc flag does not list capabilities' ' + # Empty request + test-pkt-line pack >in <<-EOF && + 0000 + EOF + git serve --stateless-rpc >out <in && + test_must_be_empty out && + + # EOF + git serve --stateless-rpc >out && + test_must_be_empty out +' + +test_expect_success 'request invalid capability' ' + test-pkt-line pack >in <<-EOF && + foobar + 0000 + EOF + test_must_fail git serve --stateless-rpc 2>err <in && + test_i18ngrep "unknown capability" err +' + +test_expect_success 'request with no command' ' + test-pkt-line pack >in <<-EOF && + agent=git/test + 0000 + EOF + test_must_fail git serve --stateless-rpc 2>err <in && + test_i18ngrep "no command requested" err +' + +test_expect_success 'request invalid command' ' + test-pkt-line pack >in <<-EOF && + command=foo + agent=git/test + 0000 + EOF + test_must_fail git serve --stateless-rpc 2>err <in && + test_i18ngrep "invalid command" err +' + +# Test the basics of ls-refs +# +test_expect_success 'setup some refs and tags' ' + test_commit one && + git branch dev master && + test_commit two && + git symbolic-ref refs/heads/release refs/heads/master && + git tag -a -m "annotated tag" annotated-tag +' + +test_expect_success 'basics of ls-refs' ' + test-pkt-line pack >in <<-EOF && + command=ls-refs + 0000 + EOF + + cat >expect <<-EOF && + $(git rev-parse HEAD) HEAD + $(git rev-parse refs/heads/dev) refs/heads/dev + $(git rev-parse refs/heads/master) refs/heads/master + $(git rev-parse refs/heads/release) refs/heads/release + $(git rev-parse refs/tags/annotated-tag) refs/tags/annotated-tag + $(git rev-parse refs/tags/one) refs/tags/one + $(git rev-parse refs/tags/two) refs/tags/two + 0000 + EOF + + git serve --stateless-rpc <in >out && + test-pkt-line unpack <out >actual && + test_cmp actual expect +' + +test_expect_success 'basic ref-prefixes' ' + test-pkt-line pack >in <<-EOF && + command=ls-refs + 0001 + ref-prefix refs/heads/master + ref-prefix refs/tags/one + 0000 + EOF + + cat >expect <<-EOF && + $(git rev-parse refs/heads/master) refs/heads/master + $(git rev-parse refs/tags/one) refs/tags/one + 0000 + EOF + + git serve --stateless-rpc <in >out && + test-pkt-line unpack <out >actual && + test_cmp actual expect +' + +test_expect_success 'refs/heads prefix' ' + test-pkt-line pack >in <<-EOF && + command=ls-refs + 0001 + ref-prefix refs/heads/ + 0000 + EOF + + cat >expect <<-EOF && + $(git rev-parse refs/heads/dev) refs/heads/dev + $(git rev-parse refs/heads/master) refs/heads/master + $(git rev-parse refs/heads/release) refs/heads/release + 0000 + EOF + + git serve --stateless-rpc <in >out && + test-pkt-line unpack <out >actual && + test_cmp actual expect +' + +test_expect_success 'peel parameter' ' + test-pkt-line pack >in <<-EOF && + command=ls-refs + 0001 + peel + ref-prefix refs/tags/ + 0000 + EOF + + cat >expect <<-EOF && + $(git rev-parse refs/tags/annotated-tag) refs/tags/annotated-tag peeled:$(git rev-parse refs/tags/annotated-tag^{}) + $(git rev-parse refs/tags/one) refs/tags/one + $(git rev-parse refs/tags/two) refs/tags/two + 0000 + EOF + + git serve --stateless-rpc <in >out && + test-pkt-line unpack <out >actual && + test_cmp actual expect +' + +test_expect_success 'symrefs parameter' ' + test-pkt-line pack >in <<-EOF && + command=ls-refs + 0001 + symrefs + ref-prefix refs/heads/ + 0000 + EOF + + cat >expect <<-EOF && + $(git rev-parse refs/heads/dev) refs/heads/dev + $(git rev-parse refs/heads/master) refs/heads/master + $(git rev-parse refs/heads/release) refs/heads/release symref-target:refs/heads/master + 0000 + EOF + + git serve --stateless-rpc <in >out && + test-pkt-line unpack <out >actual && + test_cmp actual expect +' + +test_done diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh new file mode 100755 index 0000000000..56f7c3c326 --- /dev/null +++ b/t/t5702-protocol-v2.sh @@ -0,0 +1,273 @@ +#!/bin/sh + +test_description='test git wire-protocol version 2' + +TEST_NO_CREATE_REPO=1 + +. ./test-lib.sh + +# Test protocol v2 with 'git://' transport +# +. "$TEST_DIRECTORY"/lib-git-daemon.sh +start_git_daemon --export-all --enable=receive-pack +daemon_parent=$GIT_DAEMON_DOCUMENT_ROOT_PATH/parent + +test_expect_success 'create repo to be served by git-daemon' ' + git init "$daemon_parent" && + test_commit -C "$daemon_parent" one +' + +test_expect_success 'list refs with git:// using protocol v2' ' + test_when_finished "rm -f log" && + + GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \ + ls-remote --symref "$GIT_DAEMON_URL/parent" >actual && + + # Client requested to use protocol v2 + grep "git> .*\\\0\\\0version=2\\\0$" log && + # Server responded using protocol v2 + grep "git< version 2" log && + + git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect && + test_cmp actual expect +' + +test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' ' + test_when_finished "rm -f log" && + + GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \ + ls-remote "$GIT_DAEMON_URL/parent" master >actual && + + cat >expect <<-EOF && + $(git -C "$daemon_parent" rev-parse refs/heads/master)$(printf "\t")refs/heads/master + EOF + + test_cmp actual expect +' + +test_expect_success 'clone with git:// using protocol v2' ' + test_when_finished "rm -f log" && + + GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \ + clone "$GIT_DAEMON_URL/parent" daemon_child && + + git -C daemon_child log -1 --format=%s >actual && + git -C "$daemon_parent" log -1 --format=%s >expect && + test_cmp expect actual && + + # Client requested to use protocol v2 + grep "clone> .*\\\0\\\0version=2\\\0$" log && + # Server responded using protocol v2 + grep "clone< version 2" log +' + +test_expect_success 'fetch with git:// using protocol v2' ' + test_when_finished "rm -f log" && + + test_commit -C "$daemon_parent" two && + + GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \ + fetch && + + git -C daemon_child log -1 --format=%s origin/master >actual && + git -C "$daemon_parent" log -1 --format=%s >expect && + test_cmp expect actual && + + # Client requested to use protocol v2 + grep "fetch> .*\\\0\\\0version=2\\\0$" log && + # Server responded using protocol v2 + grep "fetch< version 2" log +' + +test_expect_success 'pull with git:// using protocol v2' ' + test_when_finished "rm -f log" && + + GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \ + pull && + + git -C daemon_child log -1 --format=%s >actual && + git -C "$daemon_parent" log -1 --format=%s >expect && + test_cmp expect actual && + + # Client requested to use protocol v2 + grep "fetch> .*\\\0\\\0version=2\\\0$" log && + # Server responded using protocol v2 + grep "fetch< version 2" log +' + +test_expect_success 'push with git:// and a config of v2 does not request v2' ' + test_when_finished "rm -f log" && + + # Till v2 for push is designed, make sure that if a client has + # protocol.version configured to use v2, that the client instead falls + # back and uses v0. + + test_commit -C daemon_child three && + + # Push to another branch, as the target repository has the + # master branch checked out and we cannot push into it. + GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \ + push origin HEAD:client_branch && + + git -C daemon_child log -1 --format=%s >actual && + git -C "$daemon_parent" log -1 --format=%s client_branch >expect && + test_cmp expect actual && + + # Client requested to use protocol v2 + ! grep "push> .*\\\0\\\0version=2\\\0$" log && + # Server responded using protocol v2 + ! grep "push< version 2" log +' + +stop_git_daemon + +# Test protocol v2 with 'file://' transport +# +test_expect_success 'create repo to be served by file:// transport' ' + git init file_parent && + test_commit -C file_parent one +' + +test_expect_success 'list refs with file:// using protocol v2' ' + test_when_finished "rm -f log" && + + GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \ + ls-remote --symref "file://$(pwd)/file_parent" >actual && + + # Server responded using protocol v2 + grep "git< version 2" log && + + git ls-remote --symref "file://$(pwd)/file_parent" >expect && + test_cmp actual expect +' + +test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' ' + test_when_finished "rm -f log" && + + GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \ + ls-remote "file://$(pwd)/file_parent" master >actual && + + cat >expect <<-EOF && + $(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master + EOF + + test_cmp actual expect +' + +test_expect_success 'clone with file:// using protocol v2' ' + test_when_finished "rm -f log" && + + GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \ + clone "file://$(pwd)/file_parent" file_child && + + git -C file_child log -1 --format=%s >actual && + git -C file_parent log -1 --format=%s >expect && + test_cmp expect actual && + + # Server responded using protocol v2 + grep "clone< version 2" log +' + +test_expect_success 'fetch with file:// using protocol v2' ' + test_when_finished "rm -f log" && + + test_commit -C file_parent two && + + GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \ + fetch origin && + + git -C file_child log -1 --format=%s origin/master >actual && + git -C file_parent log -1 --format=%s >expect && + test_cmp expect actual && + + # Server responded using protocol v2 + grep "fetch< version 2" log +' + +test_expect_success 'ref advertisment is filtered during fetch using protocol v2' ' + test_when_finished "rm -f log" && + + test_commit -C file_parent three && + + GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \ + fetch origin master && + + git -C file_child log -1 --format=%s origin/master >actual && + git -C file_parent log -1 --format=%s >expect && + test_cmp expect actual && + + ! grep "refs/tags/one" log && + ! grep "refs/tags/two" log && + ! grep "refs/tags/three" log +' + +# Test protocol v2 with 'http://' transport +# +. "$TEST_DIRECTORY"/lib-httpd.sh +start_httpd + +test_expect_success 'create repo to be served by http:// transport' ' + git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && + git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" config http.receivepack true && + test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one +' + +test_expect_success 'clone with http:// using protocol v2' ' + test_when_finished "rm -f log" && + + GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \ + clone "$HTTPD_URL/smart/http_parent" http_child && + + git -C http_child log -1 --format=%s >actual && + git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect && + test_cmp expect actual && + + # Client requested to use protocol v2 + grep "Git-Protocol: version=2" log && + # Server responded using protocol v2 + grep "git< version 2" log +' + +test_expect_success 'fetch with http:// using protocol v2' ' + test_when_finished "rm -f log" && + + test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two && + + GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \ + fetch && + + git -C http_child log -1 --format=%s origin/master >actual && + git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect && + test_cmp expect actual && + + # Server responded using protocol v2 + grep "git< version 2" log +' + +test_expect_success 'push with http:// and a config of v2 does not request v2' ' + test_when_finished "rm -f log" && + # Till v2 for push is designed, make sure that if a client has + # protocol.version configured to use v2, that the client instead falls + # back and uses v0. + + test_commit -C http_child three && + + # Push to another branch, as the target repository has the + # master branch checked out and we cannot push into it. + GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \ + push origin HEAD:client_branch && + + git -C http_child log -1 --format=%s >actual && + git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s client_branch >expect && + test_cmp expect actual && + + # Client didnt request to use protocol v2 + ! grep "Git-Protocol: version=2" log && + # Server didnt respond using protocol v2 + ! grep "git< version 2" log +' + + +stop_httpd + +test_done diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index c01f721f13..48747e71df 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -635,10 +635,9 @@ test_expect_success 'setup avoid unnecessary update, normal rename' ' test_expect_success 'avoid unnecessary update, normal rename' ' git checkout -q avoid-unnecessary-update-1^0 && - test-chmtime =1000000000 rename && - test-chmtime -v +0 rename >expect && + test-tool chmtime --get =1000000000 rename >expect && git merge merge-branch-1 && - test-chmtime -v +0 rename >actual && + test-tool chmtime --get rename >actual && test_cmp expect actual # "rename" should have stayed intact ' @@ -668,10 +667,9 @@ test_expect_success 'setup to test avoiding unnecessary update, with D/F conflic test_expect_success 'avoid unnecessary update, with D/F conflict' ' git checkout -q avoid-unnecessary-update-2^0 && - test-chmtime =1000000000 df && - test-chmtime -v +0 df >expect && + test-tool chmtime --get =1000000000 df >expect && git merge merge-branch-2 && - test-chmtime -v +0 df >actual && + test-tool chmtime --get df >actual && test_cmp expect actual # "df" should have stayed intact ' @@ -700,10 +698,9 @@ test_expect_success 'setup avoid unnecessary update, dir->(file,nothing)' ' test_expect_success 'avoid unnecessary update, dir->(file,nothing)' ' git checkout -q master^0 && - test-chmtime =1000000000 df && - test-chmtime -v +0 df >expect && + test-tool chmtime --get =1000000000 df >expect && git merge side && - test-chmtime -v +0 df >actual && + test-tool chmtime --get df >actual && test_cmp expect actual # "df" should have stayed intact ' @@ -730,10 +727,9 @@ test_expect_success 'setup avoid unnecessary update, modify/delete' ' test_expect_success 'avoid unnecessary update, modify/delete' ' git checkout -q master^0 && - test-chmtime =1000000000 file && - test-chmtime -v +0 file >expect && + test-tool chmtime --get =1000000000 file >expect && test_must_fail git merge side && - test-chmtime -v +0 file >actual && + test-tool chmtime --get file >actual && test_cmp expect actual # "file" should have stayed intact ' @@ -759,10 +755,9 @@ test_expect_success 'setup avoid unnecessary update, rename/add-dest' ' test_expect_success 'avoid unnecessary update, rename/add-dest' ' git checkout -q master^0 && - test-chmtime =1000000000 newfile && - test-chmtime -v +0 newfile >expect && + test-tool chmtime --get =1000000000 newfile >expect && git merge side && - test-chmtime -v +0 newfile >actual && + test-tool chmtime --get newfile >actual && test_cmp expect actual # "file" should have stayed intact ' diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh index 41b0be575d..d5255dd576 100755 --- a/t/t6500-gc.sh +++ b/t/t6500-gc.sh @@ -87,7 +87,7 @@ test_expect_success 'background auto gc does not run if gc.log is present and re test_must_fail git gc --auto 2>err && test_i18ngrep "^error:" err && test_config gc.logexpiry 5.days && - test-chmtime =-345600 .git/gc.log && + test-tool chmtime =-345600 .git/gc.log && test_must_fail git gc --auto && test_config gc.logexpiry 2.days && run_and_wait_for_auto_gc && diff --git a/t/t6501-freshen-objects.sh b/t/t6501-freshen-objects.sh index 394b169ead..033871ee5f 100755 --- a/t/t6501-freshen-objects.sh +++ b/t/t6501-freshen-objects.sh @@ -72,8 +72,7 @@ for repack in '' true; do ' test_expect_success "simulate time passing ($title)" ' - find .git/objects -type f | - xargs test-chmtime -v -86400 + test-tool chmtime --get -86400 $(find .git/objects -type f) ' test_expect_success "start writing new commit with old blob ($title)" ' @@ -103,8 +102,7 @@ for repack in '' true; do test_expect_success "abandon objects again ($title)" ' git reset --hard HEAD^ && - find .git/objects -type f | - xargs test-chmtime -v -86400 + test-tool chmtime --get -86400 $(find .git/objects -type f) ' test_expect_success "start writing new commit with same tree ($title)" ' diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh index d4e6485a26..cc3fd2baf2 100755 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@ -21,8 +21,8 @@ test_expect_success \ test_expect_success \ 'checking the commit' \ - 'git diff-tree -r -M --name-status HEAD^ HEAD | \ - grep "^R100..*path0/COPYING..*path1/COPYING"' + 'git diff-tree -r -M --name-status HEAD^ HEAD >actual && + grep "^R100..*path0/COPYING..*path1/COPYING" actual' test_expect_success \ 'moving the file back into subdirectory' \ @@ -35,8 +35,8 @@ test_expect_success \ test_expect_success \ 'checking the commit' \ - 'git diff-tree -r -M --name-status HEAD^ HEAD | \ - grep "^R100..*path1/COPYING..*path0/COPYING"' + 'git diff-tree -r -M --name-status HEAD^ HEAD >actual && + grep "^R100..*path1/COPYING..*path0/COPYING" actual' test_expect_success \ 'mv --dry-run does not move file' \ @@ -122,10 +122,9 @@ test_expect_success \ test_expect_success \ 'checking the commit' \ - 'git diff-tree -r -M --name-status HEAD^ HEAD | \ - grep "^R100..*path0/COPYING..*path2/COPYING" && - git diff-tree -r -M --name-status HEAD^ HEAD | \ - grep "^R100..*path0/README..*path2/README"' + 'git diff-tree -r -M --name-status HEAD^ HEAD >actual && + grep "^R100..*path0/COPYING..*path2/COPYING" actual && + grep "^R100..*path0/README..*path2/README" actual' test_expect_success \ 'succeed when source is a prefix of destination' \ @@ -141,10 +140,9 @@ test_expect_success \ test_expect_success \ 'checking the commit' \ - 'git diff-tree -r -M --name-status HEAD^ HEAD | \ - grep "^R100..*path2/COPYING..*path1/path2/COPYING" && - git diff-tree -r -M --name-status HEAD^ HEAD | \ - grep "^R100..*path2/README..*path1/path2/README"' + 'git diff-tree -r -M --name-status HEAD^ HEAD >actual && + grep "^R100..*path2/COPYING..*path1/path2/COPYING" actual && + grep "^R100..*path2/README..*path1/path2/README" actual' test_expect_success \ 'do not move directory over existing directory' \ @@ -497,7 +495,7 @@ test_expect_success 'moving a submodule in nested directories' ' test_cmp expect actual ' -test_expect_failure 'moving nested submodules' ' +test_expect_success 'moving nested submodules' ' git commit -am "cleanup commit" && mkdir sub_nested_nested && (cd sub_nested_nested && diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh index 7cb60799be..ec4b160ddb 100755 --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@ -187,7 +187,8 @@ test_expect_success 'author information is preserved' ' test \$GIT_COMMIT != $(git rev-parse master) || \ echo Hallo" \ preserved-author) && - test 1 = $(git rev-list --author="B V Uips" preserved-author | wc -l) + git rev-list --author="B V Uips" preserved-author >actual && + test_line_count = 1 actual ' test_expect_success "remove a certain author's commits" ' @@ -205,7 +206,8 @@ test_expect_success "remove a certain author's commits" ' cnt1=$(git rev-list master | wc -l) && cnt2=$(git rev-list removed-author | wc -l) && test $cnt1 -eq $(($cnt2 + 1)) && - test 0 = $(git rev-list --author="B V Uips" removed-author | wc -l) + git rev-list --author="B V Uips" removed-author >actual && + test_line_count = 0 actual ' test_expect_success 'barf on invalid name' ' @@ -258,7 +260,8 @@ test_expect_success 'Subdirectory filter with disappearing trees' ' git commit -m "Re-adding foo" && git filter-branch -f --subdirectory-filter foo && - test $(git rev-list master | wc -l) = 3 + git rev-list master >actual && + test_line_count = 3 actual ' test_expect_success 'Tag name filtering retains tag message' ' @@ -470,4 +473,18 @@ test_expect_success 'tree-filter deals with object name vs pathname ambiguity' ' git show HEAD:$ambiguous ' +test_expect_success 'rewrite repository including refs that point at non-commit object' ' + test_when_finished "git reset --hard original" && + tree=$(git rev-parse HEAD^{tree}) && + test_when_finished "git replace -d $tree" && + echo A >new && + git add new && + new_tree=$(git write-tree) && + git replace $tree $new_tree && + git tag -a -m "tag to a tree" treetag $new_tree && + git reset --hard HEAD && + git filter-branch -f -- --all >filter-output 2>&1 && + ! fgrep fatal filter-output +' + test_done diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index 2aac77af70..e3f1e014aa 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -1056,7 +1056,18 @@ test_expect_success GPG \ git tag -s -F sigblanknonlfile blanknonlfile-signed-tag && get_tag_msg blanknonlfile-signed-tag >actual && test_cmp expect actual && - git tag -v signed-tag + git tag -v blanknonlfile-signed-tag +' + +test_expect_success GPG 'signed tag with embedded PGP message' ' + cat >msg <<-\EOF && + -----BEGIN PGP MESSAGE----- + + this is not a real PGP message + -----END PGP MESSAGE----- + EOF + git tag -s -F msg confusing-pgp-message && + git tag -v confusing-pgp-message ' # messages with commented lines for signed tags: diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index a39e69a3eb..152104412f 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -821,6 +821,21 @@ test_expect_success 'moving the superproject does not break submodules' ' ) ' +test_expect_success 'moving the submodule does not break the superproject' ' + ( + cd addtest2 && + git submodule status + ) >actual && + sed -e "s/^ \([^ ]* repo\) .*/-\1/" <actual >expect && + mv addtest2/repo addtest2/repo.bak && + test_when_finished "mv addtest2/repo.bak addtest2/repo" && + ( + cd addtest2 && + git submodule status + ) >actual && + test_cmp expect actual +' + test_expect_success 'submodule add --name allows to replace a submodule with another at the same path' ' ( cd addtest2 && diff --git a/t/t7411-submodule-config.sh b/t/t7411-submodule-config.sh index 46c09c7765..0bde5850ac 100755 --- a/t/t7411-submodule-config.sh +++ b/t/t7411-submodule-config.sh @@ -41,7 +41,7 @@ test_expect_success 'configuration parsing with error' ' EOF ( cd repo && - test_must_fail test-submodule-config "" s 2>actual && + test_must_fail test-tool submodule-config "" s 2>actual && test_i18ngrep "bad config" actual ) ' @@ -55,7 +55,7 @@ EOF test_expect_success 'test parsing and lookup of submodule config by path' ' (cd super && - test-submodule-config \ + test-tool submodule-config \ HEAD^ a \ HEAD b \ HEAD^ submodule \ @@ -67,7 +67,7 @@ test_expect_success 'test parsing and lookup of submodule config by path' ' test_expect_success 'test parsing and lookup of submodule config by name' ' (cd super && - test-submodule-config --name \ + test-tool submodule-config --name \ HEAD^ a \ HEAD a \ HEAD^ submodule \ @@ -89,7 +89,7 @@ test_expect_success 'error in one submodule config lets continue' ' git add .gitmodules && mv .gitmodules.bak .gitmodules && git commit -m "add error" && - test-submodule-config \ + test-tool submodule-config \ HEAD b \ HEAD submodule \ >actual && @@ -100,7 +100,7 @@ test_expect_success 'error in one submodule config lets continue' ' test_expect_success 'error message contains blob reference' ' (cd super && sha1=$(git rev-parse HEAD) && - test-submodule-config \ + test-tool submodule-config \ HEAD b \ HEAD submodule \ 2>actual_err && @@ -114,9 +114,9 @@ test_expect_success 'using different treeishs works' ' git tag new_tag && tree=$(git rev-parse HEAD^{tree}) && commit=$(git rev-parse HEAD^{commit}) && - test-submodule-config $commit b >expect && - test-submodule-config $tree b >actual.1 && - test-submodule-config new_tag b >actual.2 && + test-tool submodule-config $commit b >expect && + test-tool submodule-config $tree b >actual.1 && + test-tool submodule-config new_tag b >actual.2 && test_cmp expect actual.1 && test_cmp expect actual.2 ) @@ -130,7 +130,7 @@ test_expect_success 'error in history in fetchrecursesubmodule lets continue' ' git config --unset -f .gitmodules \ submodule.submodule.fetchrecursesubmodules && git commit -m "add error in fetchrecursesubmodules" && - test-submodule-config \ + test-tool submodule-config \ HEAD b \ HEAD submodule \ >actual && diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh index fa61b1a4ee..9dbbd01fc0 100755 --- a/t/t7501-commit.sh +++ b/t/t7501-commit.sh @@ -52,6 +52,18 @@ test_expect_success PERL 'can use paths with --interactive' ' git reset --hard HEAD^ ' +test_expect_success 'removed files and relative paths' ' + test_when_finished "rm -rf foo" && + git init foo && + >foo/foo.txt && + git -C foo add foo.txt && + git -C foo commit -m first && + git -C foo rm foo.txt && + + mkdir -p foo/bar && + git -C foo/bar commit -m second ../foo.txt +' + test_expect_success 'using invalid commit with -C' ' test_must_fail git commit --allow-empty -C bogus ' diff --git a/t/t7508-status.sh b/t/t7508-status.sh index 50052e2872..18a40257fb 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -1672,12 +1672,12 @@ test_expect_success '"Initial commit" should not be noted in commit template' ' ' test_expect_success '--no-optional-locks prevents index update' ' - test-chmtime =1234567890 .git/index && + test-tool chmtime =1234567890 .git/index && git --no-optional-locks status && - test-chmtime -v +0 .git/index >out && + test-tool chmtime --get .git/index >out && grep ^1234567890 out && git status && - test-chmtime -v +0 .git/index >out && + test-tool chmtime --get .git/index >out && ! grep ^1234567890 out ' diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh index 987573c41f..48261ba080 100755 --- a/t/t7701-repack-unpack-unreachable.sh +++ b/t/t7701-repack-unpack-unreachable.sh @@ -55,8 +55,8 @@ test_expect_success '-A with -d option leaves unreachable objects unpacked' ' compare_mtimes () { - read tref rest && - while read t rest; do + read tref && + while read t; do test "$tref" = "$t" || return 1 done } @@ -90,7 +90,7 @@ test_expect_success 'unpacked objects receive timestamp of pack file' ' tmppack=".git/objects/pack/tmp_pack" && ln "$packfile" "$tmppack" && git repack -A -l -d && - test-chmtime -v +0 "$tmppack" "$fsha1path" "$csha1path" "$tsha1path" \ + test-tool chmtime --get "$tmppack" "$fsha1path" "$csha1path" "$tsha1path" \ > mtimes && compare_mtimes < mtimes ' @@ -103,7 +103,7 @@ test_expect_success 'do not bother loosening old objects' ' git prune-packed && git cat-file -p $obj1 && git cat-file -p $obj2 && - test-chmtime =-86400 .git/objects/pack/pack-$pack2.pack && + test-tool chmtime =-86400 .git/objects/pack/pack-$pack2.pack && git repack -A -d --unpack-unreachable=1.hour.ago && git cat-file -p $obj1 && test_must_fail git cat-file -p $obj2 @@ -117,7 +117,7 @@ test_expect_success 'keep packed objects found only in index' ' git reset HEAD^ && git reflog expire --expire=now --all && git add file && - test-chmtime =-86400 .git/objects/pack/* && + test-tool chmtime =-86400 .git/objects/pack/* && git gc --prune=1.hour.ago && git cat-file blob :file ' diff --git a/t/t7812-grep-icase-non-ascii.sh b/t/t7812-grep-icase-non-ascii.sh index 0059a1f837..0c685d3598 100755 --- a/t/t7812-grep-icase-non-ascii.sh +++ b/t/t7812-grep-icase-non-ascii.sh @@ -12,7 +12,7 @@ test_expect_success GETTEXT_LOCALE 'setup' ' ' test_have_prereq GETTEXT_LOCALE && -test-regex "HALLÓ" "Halló" ICASE && +test-tool regex "HALLÓ" "Halló" ICASE && test_set_prereq REGEX_LOCALE test_expect_success REGEX_LOCALE 'grep literal string, no -F' ' diff --git a/t/t9004-example.sh b/t/t9004-example.sh index b28a028f55..7e8894a4a7 100755 --- a/t/t9004-example.sh +++ b/t/t9004-example.sh @@ -4,7 +4,7 @@ test_description='check that example code compiles and runs' . ./test-lib.sh test_expect_success 'decorate' ' - test-example-decorate + test-tool example-decorate ' test_done diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh index 8a8ba65a2a..c937330a5f 100755 --- a/t/t9100-git-svn-basic.sh +++ b/t/t9100-git-svn-basic.sh @@ -288,12 +288,12 @@ test_expect_success 'able to dcommit to a subdirectory' ' test_expect_success 'dcommit should not fail with a touched file' ' test_commit "commit-new-file-foo2" foo2 && - test-chmtime =-60 foo && + test-tool chmtime =-60 foo && git svn dcommit ' test_expect_success 'rebase should not fail with a touched file' ' - test-chmtime =-60 foo && + test-tool chmtime =-60 foo && git svn rebase ' diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh index cd480edf16..a735fa3717 100755 --- a/t/t9104-git-svn-follow-parent.sh +++ b/t/t9104-git-svn-follow-parent.sh @@ -33,8 +33,8 @@ test_expect_success 'init and fetch a moved directory' ' git svn fetch -i thunk && test "$(git rev-parse --verify refs/remotes/thunk@2)" \ = "$(git rev-parse --verify refs/remotes/thunk~1)" && - test "$(git cat-file blob refs/remotes/thunk:readme |\ - sed -n -e "3p")" = goodbye && + git cat-file blob refs/remotes/thunk:readme >actual && + test "$(sed -n -e "3p" actual)" = goodbye && test -z "$(git config --get svn-remote.svn.fetch \ "^trunk:refs/remotes/thunk@2$")" ' @@ -48,8 +48,8 @@ test_expect_success 'init and fetch from one svn-remote' ' git svn fetch -i svn/thunk && test "$(git rev-parse --verify refs/remotes/svn/trunk)" \ = "$(git rev-parse --verify refs/remotes/svn/thunk~1)" && - test "$(git cat-file blob refs/remotes/svn/thunk:readme |\ - sed -n -e "3p")" = goodbye + git cat-file blob refs/remotes/svn/thunk:readme >actual && + test "$(sed -n -e "3p" actual)" = goodbye ' test_expect_success 'follow deleted parent' ' @@ -107,7 +107,8 @@ test_expect_success 'follow deleted directory' ' git svn init --minimize-url -i glob "$svnrepo"/glob && git svn fetch -i glob && test "$(git cat-file blob refs/remotes/glob:blob/bye)" = hi && - test "$(git ls-tree refs/remotes/glob | wc -l )" -eq 1 + git ls-tree refs/remotes/glob >actual && + test_line_count = 1 actual ' # ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn) @@ -204,8 +205,9 @@ test_expect_success "follow-parent is atomic" ' test_expect_success "track multi-parent paths" ' svn_cmd cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob && git svn multi-fetch && - test $(git cat-file commit refs/remotes/glob | \ - grep "^parent " | wc -l) -eq 2 + git cat-file commit refs/remotes/glob >actual && + grep "^parent " actual >actual2 && + test_line_count = 2 actual2 ' test_expect_success "multi-fetch continues to work" " diff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh index a94286c8ec..6990f64364 100755 --- a/t/t9108-git-svn-glob.sh +++ b/t/t9108-git-svn-glob.sh @@ -47,8 +47,8 @@ test_expect_success 'test refspec globbing' ' git config --add svn-remote.svn.tags\ "tags/*/src/a:refs/remotes/tags/*" && git svn multi-fetch && - git log --pretty=oneline refs/remotes/tags/end | \ - sed -e "s/^.\{41\}//" > output.end && + git log --pretty=oneline refs/remotes/tags/end >actual && + sed -e "s/^.\{41\}//" actual >output.end && test_cmp expect.end output.end && test "$(git rev-parse refs/remotes/tags/end~1)" = \ "$(git rev-parse refs/remotes/branches/start)" && @@ -75,14 +75,16 @@ test_expect_success 'test left-hand-side only globbing' ' svn_cmd commit -m "try to try" ) && git svn fetch two && - test $(git rev-list refs/remotes/two/tags/end | wc -l) -eq 6 && - test $(git rev-list refs/remotes/two/branches/start | wc -l) -eq 3 && + git rev-list refs/remotes/two/tags/end >actual && + test_line_count = 6 actual && + git rev-list refs/remotes/two/branches/start >actual && + test_line_count = 3 actual && test $(git rev-parse refs/remotes/two/branches/start~2) = \ $(git rev-parse refs/remotes/two/trunk) && test $(git rev-parse refs/remotes/two/tags/end~3) = \ $(git rev-parse refs/remotes/two/branches/start) && - git log --pretty=oneline refs/remotes/two/tags/end | \ - sed -e "s/^.\{41\}//" > output.two && + git log --pretty=oneline refs/remotes/two/tags/end >actual && + sed -e "s/^.\{41\}//" actual >output.two && test_cmp expect.two output.two ' diff --git a/t/t9109-git-svn-multi-glob.sh b/t/t9109-git-svn-multi-glob.sh index 8d99e848d4..c1e7542a37 100755 --- a/t/t9109-git-svn-multi-glob.sh +++ b/t/t9109-git-svn-multi-glob.sh @@ -47,8 +47,8 @@ test_expect_success 'test refspec globbing' ' git config --add svn-remote.svn.tags\ "tags/*/src/a:refs/remotes/tags/*" && git svn multi-fetch && - git log --pretty=oneline refs/remotes/tags/end | \ - sed -e "s/^.\{41\}//" > output.end && + git log --pretty=oneline refs/remotes/tags/end >actual && + sed -e "s/^.\{41\}//" actual >output.end && test_cmp expect.end output.end && test "$(git rev-parse refs/remotes/tags/end~1)" = \ "$(git rev-parse refs/remotes/branches/v1/start)" && @@ -75,14 +75,16 @@ test_expect_success 'test left-hand-side only globbing' ' svn_cmd commit -m "try to try" ) && git svn fetch two && - test $(git rev-list refs/remotes/two/tags/end | wc -l) -eq 6 && - test $(git rev-list refs/remotes/two/branches/v1/start | wc -l) -eq 3 && + git rev-list refs/remotes/two/tags/end >actual && + test_line_count = 6 actual && + git rev-list refs/remotes/two/branches/v1/start >actual && + test_line_count = 3 actual && test $(git rev-parse refs/remotes/two/branches/v1/start~2) = \ $(git rev-parse refs/remotes/two/trunk) && test $(git rev-parse refs/remotes/two/tags/end~3) = \ $(git rev-parse refs/remotes/two/branches/v1/start) && - git log --pretty=oneline refs/remotes/two/tags/end | \ - sed -e "s/^.\{41\}//" > output.two && + git log --pretty=oneline refs/remotes/two/tags/end >actual && + sed -e "s/^.\{41\}//" actual >output.two && test_cmp expect.two output.two ' cat > expect.four <<EOF @@ -124,14 +126,16 @@ test_expect_success 'test another branch' ' git config --add svn-remote.four.tags \ "tags/*:refs/remotes/four/tags/*" && git svn fetch four && - test $(git rev-list refs/remotes/four/tags/next | wc -l) -eq 5 && - test $(git rev-list refs/remotes/four/branches/v2/start | wc -l) -eq 3 && + git rev-list refs/remotes/four/tags/next >actual && + test_line_count = 5 actual && + git rev-list refs/remotes/four/branches/v2/start >actual && + test_line_count = 3 actual && test $(git rev-parse refs/remotes/four/branches/v2/start~2) = \ $(git rev-parse refs/remotes/four/trunk) && test $(git rev-parse refs/remotes/four/tags/next~2) = \ $(git rev-parse refs/remotes/four/branches/v2/start) && - git log --pretty=oneline refs/remotes/four/tags/next | \ - sed -e "s/^.\{41\}//" > output.four && + git log --pretty=oneline refs/remotes/four/tags/next >actual && + sed -e "s/^.\{41\}//" actual >output.four && test_cmp expect.four output.four ' diff --git a/t/t9110-git-svn-use-svm-props.sh b/t/t9110-git-svn-use-svm-props.sh index dde0a3c222..ad37d980c9 100755 --- a/t/t9110-git-svn-use-svm-props.sh +++ b/t/t9110-git-svn-use-svm-props.sh @@ -21,37 +21,37 @@ uuid=161ce429-a9dd-4828-af4a-52023f968c89 bar_url=http://mayonaise/svnrepo/bar test_expect_success 'verify metadata for /bar' " - git cat-file commit refs/remotes/bar | \ - grep '^git-svn-id: $bar_url@12 $uuid$' && - git cat-file commit refs/remotes/bar~1 | \ - grep '^git-svn-id: $bar_url@11 $uuid$' && - git cat-file commit refs/remotes/bar~2 | \ - grep '^git-svn-id: $bar_url@10 $uuid$' && - git cat-file commit refs/remotes/bar~3 | \ - grep '^git-svn-id: $bar_url@9 $uuid$' && - git cat-file commit refs/remotes/bar~4 | \ - grep '^git-svn-id: $bar_url@6 $uuid$' && - git cat-file commit refs/remotes/bar~5 | \ - grep '^git-svn-id: $bar_url@1 $uuid$' + git cat-file commit refs/remotes/bar >actual && + grep '^git-svn-id: $bar_url@12 $uuid$' actual && + git cat-file commit refs/remotes/bar~1 >actual && + grep '^git-svn-id: $bar_url@11 $uuid$' actual && + git cat-file commit refs/remotes/bar~2 >actual && + grep '^git-svn-id: $bar_url@10 $uuid$' actual && + git cat-file commit refs/remotes/bar~3 >actual && + grep '^git-svn-id: $bar_url@9 $uuid$' actual && + git cat-file commit refs/remotes/bar~4 >actual && + grep '^git-svn-id: $bar_url@6 $uuid$' actual && + git cat-file commit refs/remotes/bar~5 >actual && + grep '^git-svn-id: $bar_url@1 $uuid$' actual " e_url=http://mayonaise/svnrepo/dir/a/b/c/d/e test_expect_success 'verify metadata for /dir/a/b/c/d/e' " - git cat-file commit refs/remotes/e | \ - grep '^git-svn-id: $e_url@1 $uuid$' + git cat-file commit refs/remotes/e >actual && + grep '^git-svn-id: $e_url@1 $uuid$' actual " dir_url=http://mayonaise/svnrepo/dir test_expect_success 'verify metadata for /dir' " - git cat-file commit refs/remotes/dir | \ - grep '^git-svn-id: $dir_url@2 $uuid$' && - git cat-file commit refs/remotes/dir~1 | \ - grep '^git-svn-id: $dir_url@1 $uuid$' + git cat-file commit refs/remotes/dir >actual && + grep '^git-svn-id: $dir_url@2 $uuid$' actual && + git cat-file commit refs/remotes/dir~1 >actual && + grep '^git-svn-id: $dir_url@1 $uuid$' actual " test_expect_success 'find commit based on SVN revision number' " - git svn find-rev r12 | - grep $(git rev-parse HEAD) + git svn find-rev r12 >actual && + grep $(git rev-parse HEAD) actual " test_expect_success 'empty rebase' " diff --git a/t/t9111-git-svn-use-svnsync-props.sh b/t/t9111-git-svn-use-svnsync-props.sh index 22b6e5ee7d..6c93073551 100755 --- a/t/t9111-git-svn-use-svnsync-props.sh +++ b/t/t9111-git-svn-use-svnsync-props.sh @@ -20,32 +20,32 @@ uuid=161ce429-a9dd-4828-af4a-52023f968c89 bar_url=http://mayonaise/svnrepo/bar test_expect_success 'verify metadata for /bar' " - git cat-file commit refs/remotes/bar | \ - grep '^git-svn-id: $bar_url@12 $uuid$' && - git cat-file commit refs/remotes/bar~1 | \ - grep '^git-svn-id: $bar_url@11 $uuid$' && - git cat-file commit refs/remotes/bar~2 | \ - grep '^git-svn-id: $bar_url@10 $uuid$' && - git cat-file commit refs/remotes/bar~3 | \ - grep '^git-svn-id: $bar_url@9 $uuid$' && - git cat-file commit refs/remotes/bar~4 | \ - grep '^git-svn-id: $bar_url@6 $uuid$' && - git cat-file commit refs/remotes/bar~5 | \ - grep '^git-svn-id: $bar_url@1 $uuid$' + git cat-file commit refs/remotes/bar >actual && + grep '^git-svn-id: $bar_url@12 $uuid$' actual && + git cat-file commit refs/remotes/bar~1 >actual && + grep '^git-svn-id: $bar_url@11 $uuid$' actual && + git cat-file commit refs/remotes/bar~2 >actual && + grep '^git-svn-id: $bar_url@10 $uuid$' actual && + git cat-file commit refs/remotes/bar~3 >actual && + grep '^git-svn-id: $bar_url@9 $uuid$' actual && + git cat-file commit refs/remotes/bar~4 >actual && + grep '^git-svn-id: $bar_url@6 $uuid$' actual && + git cat-file commit refs/remotes/bar~5 >actual && + grep '^git-svn-id: $bar_url@1 $uuid$' actual " e_url=http://mayonaise/svnrepo/dir/a/b/c/d/e test_expect_success 'verify metadata for /dir/a/b/c/d/e' " - git cat-file commit refs/remotes/e | \ - grep '^git-svn-id: $e_url@1 $uuid$' + git cat-file commit refs/remotes/e >actual && + grep '^git-svn-id: $e_url@1 $uuid$' actual " dir_url=http://mayonaise/svnrepo/dir test_expect_success 'verify metadata for /dir' " - git cat-file commit refs/remotes/dir | \ - grep '^git-svn-id: $dir_url@2 $uuid$' && - git cat-file commit refs/remotes/dir~1 | \ - grep '^git-svn-id: $dir_url@1 $uuid$' + git cat-file commit refs/remotes/dir >actual && + grep '^git-svn-id: $dir_url@2 $uuid$' actual && + git cat-file commit refs/remotes/dir~1 >actual && + grep '^git-svn-id: $dir_url@1 $uuid$' actual " test_done diff --git a/t/t9114-git-svn-dcommit-merge.sh b/t/t9114-git-svn-dcommit-merge.sh index 50bca62def..32317d6bca 100755 --- a/t/t9114-git-svn-dcommit-merge.sh +++ b/t/t9114-git-svn-dcommit-merge.sh @@ -68,7 +68,8 @@ test_debug 'gitk --all & sleep 1' test_expect_success 'verify pre-merge ancestry' " test x\$(git rev-parse --verify refs/heads/svn^2) = \ x\$(git rev-parse --verify refs/heads/merge) && - git cat-file commit refs/heads/svn^ | grep '^friend$' + git cat-file commit refs/heads/svn^ >actual && + grep '^friend$' actual " test_expect_success 'git svn dcommit merges' " @@ -82,12 +83,13 @@ test_expect_success 'verify post-merge ancestry' " x\$(git rev-parse --verify refs/remotes/origin/trunk) && test x\$(git rev-parse --verify refs/heads/svn^2) = \ x\$(git rev-parse --verify refs/heads/merge) && - git cat-file commit refs/heads/svn^ | grep '^friend$' + git cat-file commit refs/heads/svn^ >actual && + grep '^friend$' actual " test_expect_success 'verify merge commit message' " - git rev-list --pretty=raw -1 refs/heads/svn | \ - grep \" Merge branch 'merge' into svn\" + git rev-list --pretty=raw -1 refs/heads/svn >actual && + grep \" Merge branch 'merge' into svn\" actual " test_done diff --git a/t/t9130-git-svn-authors-file.sh b/t/t9130-git-svn-authors-file.sh index 41264818cc..d8262854bb 100755 --- a/t/t9130-git-svn-authors-file.sh +++ b/t/t9130-git-svn-authors-file.sh @@ -26,11 +26,12 @@ test_expect_success 'start import with incomplete authors file' ' test_expect_success 'imported 2 revisions successfully' ' ( cd x - test "$(git rev-list refs/remotes/git-svn | wc -l)" -eq 2 && - git rev-list -1 --pretty=raw refs/remotes/git-svn | \ - grep "^author BBBBBBB BBBBBBB <bb@example\.com> " && - git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \ - grep "^author AAAAAAA AAAAAAA <aa@example\.com> " + git rev-list refs/remotes/git-svn >actual && + test_line_count = 2 actual && + git rev-list -1 --pretty=raw refs/remotes/git-svn >actual && + grep "^author BBBBBBB BBBBBBB <bb@example\.com> " actual && + git rev-list -1 --pretty=raw refs/remotes/git-svn~1 >actual && + grep "^author AAAAAAA AAAAAAA <aa@example\.com> " actual ) ' @@ -43,11 +44,12 @@ test_expect_success 'continues to import once authors have been added' ' ( cd x git svn fetch --authors-file=../svn-authors && - test "$(git rev-list refs/remotes/git-svn | wc -l)" -eq 4 && - git rev-list -1 --pretty=raw refs/remotes/git-svn | \ - grep "^author DDDDDDD DDDDDDD <dd@example\.com> " && - git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \ - grep "^author CCCCCCC CCCCCCC <cc@example\.com> " + git rev-list refs/remotes/git-svn >actual && + test_line_count = 4 actual && + git rev-list -1 --pretty=raw refs/remotes/git-svn >actual && + grep "^author DDDDDDD DDDDDDD <dd@example\.com> " actual && + git rev-list -1 --pretty=raw refs/remotes/git-svn~1 >actual && + grep "^author CCCCCCC CCCCCCC <cc@example\.com> " actual ) ' @@ -102,12 +104,28 @@ test_expect_success !MINGW 'fresh clone with svn.authors-file in config' ' test x"$HOME"/svn-authors = x"$(git config svn.authorsfile)" && git svn clone "$svnrepo" gitconfig.clone && cd gitconfig.clone && - nr_ex=$(git log | grep "^Author:.*example.com" | wc -l) && - nr_rev=$(git rev-list HEAD | wc -l) && + git log >actual && + nr_ex=$(grep "^Author:.*example.com" actual | wc -l) && + git rev-list HEAD >actual && + nr_rev=$(wc -l <actual) && test $nr_rev -eq $nr_ex ) ' +cat >> svn-authors <<EOF +ff = FFFFFFF FFFFFFF <> +EOF + +test_expect_success 'authors-file imported user without email' ' + svn_cmd mkdir -m aa/branches/ff --username ff "$svnrepo/aa/branches/ff" && + ( + cd aa-work && + git svn fetch --authors-file=../svn-authors && + git rev-list -1 --pretty=raw refs/remotes/origin/ff | \ + grep "^author FFFFFFF FFFFFFF <> " + ) + ' + test_debug 'GIT_DIR=gitconfig.clone/.git git log' test_done diff --git a/t/t9138-git-svn-authors-prog.sh b/t/t9138-git-svn-authors-prog.sh index 7d7e9d46bc..93ef44fae8 100755 --- a/t/t9138-git-svn-authors-prog.sh +++ b/t/t9138-git-svn-authors-prog.sh @@ -9,7 +9,9 @@ test_description='git svn authors prog tests' write_script svn-authors-prog "$PERL_PATH" <<-\EOF $_ = shift; - if (s/-sub$//) { + if (s/-hermit//) { + print "$_ <>\n"; + } elsif (s/-sub$//) { print "$_ <$_\@sub.example.com>\n"; } else { print "$_ <$_\@example.com>\n"; @@ -37,44 +39,67 @@ test_expect_success 'import authors with prog and file' ' test_expect_success 'imported 6 revisions successfully' ' ( cd x - test "$(git rev-list refs/remotes/git-svn | wc -l)" -eq 6 + git rev-list refs/remotes/git-svn >actual && + test_line_count = 6 actual ) ' test_expect_success 'authors-prog ran correctly' ' ( cd x - git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \ - grep "^author ee-foo <ee-foo@example\.com> " && - git rev-list -1 --pretty=raw refs/remotes/git-svn~2 | \ - grep "^author dd <dd@sub\.example\.com> " && - git rev-list -1 --pretty=raw refs/remotes/git-svn~3 | \ - grep "^author cc <cc@sub\.example\.com> " && - git rev-list -1 --pretty=raw refs/remotes/git-svn~4 | \ - grep "^author bb <bb@example\.com> " && - git rev-list -1 --pretty=raw refs/remotes/git-svn~5 | \ - grep "^author aa <aa@example\.com> " + git rev-list -1 --pretty=raw refs/remotes/git-svn~1 >actual && + grep "^author ee-foo <ee-foo@example\.com> " actual && + git rev-list -1 --pretty=raw refs/remotes/git-svn~2 >actual && + grep "^author dd <dd@sub\.example\.com> " actual && + git rev-list -1 --pretty=raw refs/remotes/git-svn~3 >actual && + grep "^author cc <cc@sub\.example\.com> " actual && + git rev-list -1 --pretty=raw refs/remotes/git-svn~4 >actual && + grep "^author bb <bb@example\.com> " actual && + git rev-list -1 --pretty=raw refs/remotes/git-svn~5 >actual && + grep "^author aa <aa@example\.com> " actual ) ' test_expect_success 'authors-file overrode authors-prog' ' ( cd x - git rev-list -1 --pretty=raw refs/remotes/git-svn | \ - grep "^author FFFFFFF FFFFFFF <fFf@other\.example\.com> " + git rev-list -1 --pretty=raw refs/remotes/git-svn >actual && + grep "^author FFFFFFF FFFFFFF <fFf@other\.example\.com> " actual ) ' git --git-dir=x/.git config --unset svn.authorsfile git --git-dir=x/.git config --unset svn.authorsprog +test_expect_success 'authors-prog imported user without email' ' + svn mkdir -m gg --username gg-hermit "$svnrepo"/gg && + ( + cd x && + git svn fetch --authors-prog=../svn-authors-prog && + git rev-list -1 --pretty=raw refs/remotes/git-svn | \ + grep "^author gg <> " + ) +' + +test_expect_success 'imported without authors-prog and authors-file' ' + svn mkdir -m hh --username hh "$svnrepo"/hh && + ( + uuid=$(svn info "$svnrepo" | + sed -n "s/^Repository UUID: //p") && + cd x && + git svn fetch && + git rev-list -1 --pretty=raw refs/remotes/git-svn | \ + grep "^author hh <hh@$uuid> " + ) +' + test_expect_success 'authors-prog handled special characters in username' ' svn mkdir -m bad --username "xyz; touch evil" "$svnrepo"/bad && ( cd x && git svn --authors-prog=../svn-authors-prog fetch && - git rev-list -1 --pretty=raw refs/remotes/git-svn | - grep "^author xyz; touch evil <xyz; touch evil@example\.com> " && + git rev-list -1 --pretty=raw refs/remotes/git-svn >actual && + grep "^author xyz; touch evil <xyz; touch evil@example\.com> " actual && ! test -f evil ) ' diff --git a/t/t9153-git-svn-rewrite-uuid.sh b/t/t9153-git-svn-rewrite-uuid.sh index 372ef15685..8cb2b5c69c 100755 --- a/t/t9153-git-svn-rewrite-uuid.sh +++ b/t/t9153-git-svn-rewrite-uuid.sh @@ -16,10 +16,10 @@ test_expect_success 'load svn repo' " " test_expect_success 'verify uuid' " - git cat-file commit refs/remotes/git-svn~0 | \ - grep '^git-svn-id: .*@2 $uuid$' && - git cat-file commit refs/remotes/git-svn~1 | \ - grep '^git-svn-id: .*@1 $uuid$' + git cat-file commit refs/remotes/git-svn~0 >actual && + grep '^git-svn-id: .*@2 $uuid$' actual && + git cat-file commit refs/remotes/git-svn~1 >actual && + grep '^git-svn-id: .*@1 $uuid$' actual " test_done diff --git a/t/t9168-git-svn-partially-globbed-names.sh b/t/t9168-git-svn-partially-globbed-names.sh index 8b22f2272c..bdf6e84999 100755 --- a/t/t9168-git-svn-partially-globbed-names.sh +++ b/t/t9168-git-svn-partially-globbed-names.sh @@ -48,8 +48,8 @@ test_expect_success 'test refspec prefixed globbing' ' git config --add svn-remote.svn.tags\ "tags/t_*/src/a:refs/remotes/tags/t_*" && git svn multi-fetch && - git log --pretty=oneline refs/remotes/tags/t_end | \ - sed -e "s/^.\{41\}//" >output.end && + git log --pretty=oneline refs/remotes/tags/t_end >actual && + sed -e "s/^.\{41\}//" actual >output.end && test_cmp expect.end output.end && test "$(git rev-parse refs/remotes/tags/t_end~1)" = \ "$(git rev-parse refs/remotes/branches/b_start)" && @@ -78,14 +78,16 @@ test_expect_success 'test left-hand-side only prefixed globbing' ' svn_cmd commit -m "try to try" ) && git svn fetch two && - test $(git rev-list refs/remotes/two/tags/t_end | wc -l) -eq 6 && - test $(git rev-list refs/remotes/two/branches/b_start | wc -l) -eq 3 && + git rev-list refs/remotes/two/tags/t_end >actual && + test_line_count = 6 actual && + git rev-list refs/remotes/two/branches/b_start >actual && + test_line_count = 3 actual && test $(git rev-parse refs/remotes/two/branches/b_start~2) = \ $(git rev-parse refs/remotes/two/trunk) && test $(git rev-parse refs/remotes/two/tags/t_end~3) = \ $(git rev-parse refs/remotes/two/branches/b_start) && - git log --pretty=oneline refs/remotes/two/tags/t_end | \ - sed -e "s/^.\{41\}//" >output.two && + git log --pretty=oneline refs/remotes/two/tags/t_end >actual && + sed -e "s/^.\{41\}//" actual >output.two && test_cmp expect.two output.two ' @@ -118,14 +120,16 @@ test_expect_success 'test prefixed globs match just prefix' ' svn_cmd up ) && git svn fetch three && - test $(git rev-list refs/remotes/three/branches/b_ | wc -l) -eq 2 && - test $(git rev-list refs/remotes/three/tags/t_ | wc -l) -eq 3 && + git rev-list refs/remotes/three/branches/b_ >actual && + test_line_count = 2 actual && + git rev-list refs/remotes/three/tags/t_ >actual && + test_line_count = 3 actual && test $(git rev-parse refs/remotes/three/branches/b_~1) = \ $(git rev-parse refs/remotes/three/trunk) && test $(git rev-parse refs/remotes/three/tags/t_~1) = \ $(git rev-parse refs/remotes/three/branches/b_) && - git log --pretty=oneline refs/remotes/three/tags/t_ | \ - sed -e "s/^.\{41\}//" >output.three && + git log --pretty=oneline refs/remotes/three/tags/t_ >actual && + sed -e "s/^.\{41\}//" actual >output.three && test_cmp expect.three output.three ' @@ -186,14 +190,16 @@ test_expect_success 'test globbing in the middle of the word' ' svn_cmd up ) && git svn fetch five && - test $(git rev-list refs/remotes/five/branches/abcde | wc -l) -eq 2 && - test $(git rev-list refs/remotes/five/tags/fghij | wc -l) -eq 3 && + git rev-list refs/remotes/five/branches/abcde >actual && + test_line_count = 2 actual && + git rev-list refs/remotes/five/tags/fghij >actual && + test_line_count = 3 actual && test $(git rev-parse refs/remotes/five/branches/abcde~1) = \ $(git rev-parse refs/remotes/five/trunk) && test $(git rev-parse refs/remotes/five/tags/fghij~1) = \ $(git rev-parse refs/remotes/five/branches/abcde) && - git log --pretty=oneline refs/remotes/five/tags/fghij | \ - sed -e "s/^.\{41\}//" >output.five && + git log --pretty=oneline refs/remotes/five/tags/fghij >actual && + sed -e "s/^.\{41\}//" actual >output.five && test_cmp expect.five output.five ' diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index e4d06accc4..dc79df7b04 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -2654,7 +2654,7 @@ test_expect_success 'R: corrupt lines do not mess marks file' ' ## test_expect_success 'R: blob bigger than threshold' ' blobsize=$((2*1024*1024 + 53)) && - test-genrandom bar $blobsize >expect && + test-tool genrandom bar $blobsize >expect && cat >input <<-INPUT_END && commit refs/heads/big-file committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh index 866ddf6058..6a392e87bc 100755 --- a/t/t9350-fast-export.sh +++ b/t/t9350-fast-export.sh @@ -43,20 +43,20 @@ test_expect_success 'fast-export | fast-import' ' MUSS=$(git rev-parse --verify muss) && mkdir new && git --git-dir=new/.git init && - git fast-export --all | + git fast-export --all >actual && (cd new && git fast-import && test $MASTER = $(git rev-parse --verify refs/heads/master) && test $REIN = $(git rev-parse --verify refs/tags/rein) && test $WER = $(git rev-parse --verify refs/heads/wer) && - test $MUSS = $(git rev-parse --verify refs/tags/muss)) + test $MUSS = $(git rev-parse --verify refs/tags/muss)) <actual ' test_expect_success 'fast-export master~2..master' ' - git fast-export master~2..master | - sed "s/master/partial/" | + git fast-export master~2..master >actual && + sed "s/master/partial/" actual | (cd new && git fast-import && test $MASTER != $(git rev-parse --verify refs/heads/partial) && @@ -74,11 +74,12 @@ test_expect_success 'iso-8859-1' ' test_tick && echo rosten >file && git commit -s -m den file && - git fast-export wer^..wer | - sed "s/wer/i18n/" | + git fast-export wer^..wer >iso8859-1.fi && + sed "s/wer/i18n/" iso8859-1.fi | (cd new && git fast-import && - git cat-file commit i18n | grep "Áéí óú") + git cat-file commit i18n >actual && + grep "Áéí óú" actual) ' test_expect_success 'import/export-marks' ' @@ -87,20 +88,14 @@ test_expect_success 'import/export-marks' ' git fast-export --export-marks=tmp-marks HEAD && test -s tmp-marks && test_line_count = 3 tmp-marks && - test $( - git fast-export --import-marks=tmp-marks\ - --export-marks=tmp-marks HEAD | - grep ^commit | - wc -l) \ - -eq 0 && + git fast-export --import-marks=tmp-marks \ + --export-marks=tmp-marks HEAD >actual && + test $(grep ^commit actual | wc -l) -eq 0 && echo change > file && git commit -m "last commit" file && - test $( - git fast-export --import-marks=tmp-marks \ - --export-marks=tmp-marks HEAD | - grep ^commit\ | - wc -l) \ - -eq 1 && + git fast-export --import-marks=tmp-marks \ + --export-marks=tmp-marks HEAD >actual && + test $(grep ^commit\ actual | wc -l) -eq 1 && test_line_count = 4 tmp-marks ' @@ -184,7 +179,7 @@ test_expect_success 'submodule fast-export | fast-import' ' rm -rf new && mkdir new && git --git-dir=new/.git init && - git fast-export --signed-tags=strip --all | + git fast-export --signed-tags=strip --all >actual && (cd new && git fast-import && test "$SUBENT1" = "$(git ls-tree refs/heads/master^ sub)" && @@ -192,7 +187,7 @@ test_expect_success 'submodule fast-export | fast-import' ' git checkout master && git submodule init && git submodule update && - cmp sub/file ../sub/file) + cmp sub/file ../sub/file) <actual ' @@ -367,12 +362,14 @@ test_expect_success 'path limiting with import-marks does not lose unmodified fi echo more content >> file && test_tick && git commit -mnext file && - git fast-export --import-marks=marks simple -- file file0 | grep file0 + git fast-export --import-marks=marks simple -- file file0 >actual && + grep file0 actual ' test_expect_success 'full-tree re-shows unmodified files' ' git checkout -f simple && - test $(git fast-export --full-tree simple | grep -c file0) -eq 3 + git fast-export --full-tree simple >actual && + test $(grep -c file0 actual) -eq 3 ' test_expect_success 'set-up a few more tags for tag export tests' ' @@ -505,8 +502,8 @@ test_expect_success 'refs are updated even if no commits need to be exported' ' ' test_expect_success 'use refspec' ' - git fast-export --refspec refs/heads/master:refs/heads/foobar master | \ - grep "^commit " | sort | uniq > actual && + git fast-export --refspec refs/heads/master:refs/heads/foobar master >actual2 && + grep "^commit " actual2 | sort | uniq >actual && echo "commit refs/heads/foobar" > expected && test_cmp expected actual ' @@ -534,10 +531,29 @@ test_expect_success 'when using -C, do not declare copy when source of copy is a git -C src commit -m 2nd_commit && test_create_repo dst && - git -C src fast-export --all -C | git -C dst fast-import && + git -C src fast-export --all -C >actual && + git -C dst fast-import <actual && git -C src show >expected && git -C dst show >actual && test_cmp expected actual ' +test_expect_success 'merge commit gets exported with --import-marks' ' + test_create_repo merging && + ( + cd merging && + test_commit initial && + git checkout -b topic && + test_commit on-topic && + git checkout master && + test_commit on-master && + test_tick && + git merge --no-ff -m Yeah topic && + + echo ":1 $(git rev-parse HEAD^^)" >marks && + git fast-export --import-marks=marks master >out && + grep Yeah out + ) +' + test_done diff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh index eb9a8ed197..1fc9b33aeb 100755 --- a/t/t9802-git-p4-filetype.sh +++ b/t/t9802-git-p4-filetype.sh @@ -237,7 +237,7 @@ test_expect_success 'ignore apple' ' build_gendouble && ( cd "$cli" && - test-genrandom apple 1024 >double.png && + test-tool genrandom apple 1024 >double.png && "$PYTHON_PATH" "$TRASH_DIRECTORY/gendouble.py" >%double.png && p4 add -t apple double.png && p4 submit -d appledouble diff --git a/t/t9803-git-p4-shell-metachars.sh b/t/t9803-git-p4-shell-metachars.sh index d950c7d665..d5c3675100 100755 --- a/t/t9803-git-p4-shell-metachars.sh +++ b/t/t9803-git-p4-shell-metachars.sh @@ -28,7 +28,7 @@ test_expect_success 'shell metachars in filenames' ' echo f2 >"file with spaces" && git add "file with spaces" && git commit -m "add files" && - P4EDITOR="test-chmtime +5" git p4 submit + P4EDITOR="test-tool chmtime +5" git p4 submit ) && ( cd "$cli" && @@ -47,7 +47,7 @@ test_expect_success 'deleting with shell metachars' ' git rm foo\$bar && git rm file\ with\ spaces && git commit -m "remove files" && - P4EDITOR="test-chmtime +5" git p4 submit + P4EDITOR="test-tool chmtime +5" git p4 submit ) && ( cd "$cli" && diff --git a/t/t9813-git-p4-preserve-users.sh b/t/t9813-git-p4-preserve-users.sh index bda222aa02..783c6ad165 100755 --- a/t/t9813-git-p4-preserve-users.sh +++ b/t/t9813-git-p4-preserve-users.sh @@ -53,7 +53,7 @@ test_expect_success 'preserve users' ' git commit --author "Alice <alice@example.com>" -m "a change by alice" file1 && git commit --author "Bob <bob@example.com>" -m "a change by bob" file2 && git config git-p4.skipSubmitEditCheck true && - P4EDITOR="test-chmtime +5" P4USER=alice P4PASSWD=secret && + P4EDITOR="test-tool chmtime +5" P4USER=alice P4PASSWD=secret && export P4EDITOR P4USER P4PASSWD && git p4 commit --preserve-user && p4_check_commit_author file1 alice && @@ -71,7 +71,7 @@ test_expect_success 'refuse to preserve users without perms' ' git config git-p4.skipSubmitEditCheck true && echo "username-noperms: a change by alice" >>file1 && git commit --author "Alice <alice@example.com>" -m "perms: a change by alice" file1 && - P4EDITOR="test-chmtime +5" P4USER=bob P4PASSWD=secret && + P4EDITOR="test-tool chmtime +5" P4USER=bob P4PASSWD=secret && export P4EDITOR P4USER P4PASSWD && test_must_fail git p4 commit --preserve-user && ! git diff --exit-code HEAD..p4/master @@ -89,7 +89,7 @@ test_expect_success 'preserve user where author is unknown to p4' ' git commit --author "Bob <bob@example.com>" -m "preserve: a change by bob" file1 && echo "username-unknown: a change by charlie" >>file1 && git commit --author "Charlie <charlie@example.com>" -m "preserve: a change by charlie" file1 && - P4EDITOR="test-chmtime +5" P4USER=alice P4PASSWD=secret && + P4EDITOR="test-tool chmtime +5" P4USER=alice P4PASSWD=secret && export P4EDITOR P4USER P4PASSWD && test_must_fail git p4 commit --preserve-user && ! git diff --exit-code HEAD..p4/master && diff --git a/t/t9820-git-p4-editor-handling.sh b/t/t9820-git-p4-editor-handling.sh index 6dc6df032e..3c22f74bd4 100755 --- a/t/t9820-git-p4-editor-handling.sh +++ b/t/t9820-git-p4-editor-handling.sh @@ -26,7 +26,7 @@ test_expect_success 'EDITOR with options' ' cd "$git" && echo change >file1 && git commit -m "change" file1 && - P4EDITOR=": >\"$git/touched\" && test-chmtime +5" git p4 submit && + P4EDITOR=": >\"$git/touched\" && test-tool chmtime +5" git p4 submit && test_path_is_file "$git/touched" ) ' diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index b7f5b1e632..1b34caa1e1 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -1454,6 +1454,12 @@ test_expect_success 'completion used <cmd> completion for alias: !f() { : git <c EOF ' +test_expect_success 'completion without explicit _git_xxx function' ' + test_completion "git version --" <<-\EOF + --build-options Z + EOF +' + test_expect_failure 'complete with tilde expansion' ' git init tmp && cd tmp && test_when_finished "cd .. && rm -rf tmp" && diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index b895366fee..7d620bf2a9 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -782,11 +782,8 @@ verbose () { # otherwise. test_must_be_empty () { - if ! test -f "$1" - then - echo "'$1' is missing" - return 1 - elif test -s "$1" + test_path_is_file "$1" && + if test -s "$1" then echo "'$1' is not empty, it contains:" cat "$1" diff --git a/t/test-lib.sh b/t/test-lib.sh index 7740d511d2..ea2bbaaa7a 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -963,10 +963,10 @@ test -d "$GIT_BUILD_DIR"/templates/blt || { error "You haven't built things yet, have you?" } -if ! test -x "$GIT_BUILD_DIR"/t/helper/test-chmtime +if ! test -x "$GIT_BUILD_DIR"/t/helper/test-tool then - echo >&2 'You need to build test-chmtime:' - echo >&2 'Run "make t/helper/test-chmtime" in the source (toplevel) directory' + echo >&2 'You need to build test-tool:' + echo >&2 'Run "make t/helper/test-tool" in the source (toplevel) directory' exit 1 fi @@ -1206,5 +1206,9 @@ test_lazy_prereq LONG_IS_64BIT ' test 8 -le "$(build_option sizeof-long)" ' -test_lazy_prereq TIME_IS_64BIT 'test-date is64bit' -test_lazy_prereq TIME_T_IS_64BIT 'test-date time_t-is64bit' +test_lazy_prereq TIME_IS_64BIT 'test-tool date is64bit' +test_lazy_prereq TIME_T_IS_64BIT 'test-tool date time_t-is64bit' + +test_lazy_prereq CURL ' + curl --version +' |