revert(3p/git): Revert merge of git upstream at v2.26.2

This causes cgit to serve error pages, which is undesirable.

This reverts commit 5229c9b232, reversing
changes made to f2b211131f.
This commit is contained in:
Vincent Ambo 2020-05-26 00:06:52 +01:00
parent 6f8fbf4aa4
commit 93ba78d6f4
1006 changed files with 60537 additions and 148724 deletions

View file

@ -352,8 +352,8 @@ details.
GIT_TEST_SPLIT_INDEX=<boolean> forces split-index mode on the whole
test suite. Accept any boolean values that are accepted by git-config.
GIT_TEST_PROTOCOL_VERSION=<n>, when set, makes 'protocol.version'
default to n.
GIT_TEST_PROTOCOL_VERSION=<n>, when set, overrides the
'protocol.version' setting to n if it is less than n.
GIT_TEST_FULL_IN_PACK_ARRAY=<boolean> exercises the uncommon
pack-objects code path where there are more than 1024 packs even if
@ -397,10 +397,6 @@ GIT_TEST_STASH_USE_BUILTIN=<boolean>, when false, disables the
built-in version of git-stash. See 'stash.useBuiltin' in
git-config(1).
GIT_TEST_ADD_I_USE_BUILTIN=<boolean>, when true, enables the
built-in version of git add -i. See 'add.interactive.useBuiltin' in
git-config(1).
GIT_TEST_INDEX_THREADS=<n> enables exercising the multi-threaded loading
of the index for the whole test suite by bypassing the default number of
cache entries and thread minimums. Setting this to 1 will make the
@ -982,15 +978,6 @@ library for your script to use.
output to the downstream---unlike the real version, it generates
only up to 99 lines.
- test_bool_env <env-variable-name> <default-value>
Given the name of an environment variable with a bool value,
normalize its value to a 0 (true) or 1 (false or empty string)
return code. Return with code corresponding to the given default
value if the variable is unset.
Abort the test script if either the value of the variable or the
default are not valid bool values.
Prerequisites
-------------

View file

@ -46,7 +46,7 @@ while (<>) {
/(?:\$\(seq|^\s*seq\b)/ and err 'seq is not portable (use test_seq)';
/\bgrep\b.*--file\b/ and err 'grep --file FILE is not portable (use grep -f FILE)';
/\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)';
/^\s*([A-Z0-9_]+=(\w*|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
/^\s*([A-Z0-9_]+=(\w+|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
err '"FOO=bar shell_func" assignment extends beyond "shell_func"';
$line = '';
# this resets our $. for each file

View file

@ -58,11 +58,10 @@ gitweb_run () {
GATEWAY_INTERFACE='CGI/1.1'
HTTP_ACCEPT='*/*'
REQUEST_METHOD='GET'
QUERY_STRING=$1
PATH_INFO=$2
REQUEST_URI=/gitweb.cgi$PATH_INFO
QUERY_STRING=""$1""
PATH_INFO=""$2""
export GATEWAY_INTERFACE HTTP_ACCEPT REQUEST_METHOD \
QUERY_STRING PATH_INFO REQUEST_URI
QUERY_STRING PATH_INFO
GITWEB_CONFIG=$(pwd)/gitweb_config.perl
export GITWEB_CONFIG

View file

@ -1,4 +1,5 @@
/test-tool
/test-fake-ssh
/test-line-buffer
/test-svn-fe
*
!*.sh
!*.[ch]
!*.gitignore

View file

@ -37,6 +37,21 @@
*
*/
static const char *scope_name(enum config_scope scope)
{
switch (scope) {
case CONFIG_SCOPE_SYSTEM:
return "system";
case CONFIG_SCOPE_GLOBAL:
return "global";
case CONFIG_SCOPE_REPO:
return "repo";
case CONFIG_SCOPE_CMDLINE:
return "cmdline";
default:
return "unknown";
}
}
static int iterate_cb(const char *var, const char *value, void *data)
{
static int nr;
@ -48,8 +63,7 @@ static int iterate_cb(const char *var, const char *value, void *data)
printf("value=%s\n", value ? value : "(null)");
printf("origin=%s\n", current_config_origin_type());
printf("name=%s\n", current_config_name());
printf("lno=%d\n", current_config_line());
printf("scope=%s\n", config_scope_name(current_config_scope()));
printf("scope=%s\n", scope_name(current_config_scope()));
return 0;
}

View file

@ -12,13 +12,13 @@ static const char *usage_msg = "\n"
" test-tool date is64bit\n"
" test-tool date time_t-is64bit\n";
static void show_relative_dates(const char **argv)
static void show_relative_dates(const char **argv, struct timeval *now)
{
struct strbuf buf = STRBUF_INIT;
for (; *argv; argv++) {
time_t t = atoi(*argv);
show_date_relative(t, &buf);
show_date_relative(t, now, &buf);
printf("%s -> %s\n", *argv, buf.buf);
}
strbuf_release(&buf);
@ -74,20 +74,20 @@ static void parse_dates(const char **argv)
strbuf_release(&result);
}
static void parse_approxidate(const char **argv)
static void parse_approxidate(const char **argv, struct timeval *now)
{
for (; *argv; argv++) {
timestamp_t t;
t = approxidate_relative(*argv);
t = approxidate_relative(*argv, now);
printf("%s -> %s\n", *argv, show_date(t, 0, DATE_MODE(ISO8601)));
}
}
static void parse_approx_timestamp(const char **argv)
static void parse_approx_timestamp(const char **argv, struct timeval *now)
{
for (; *argv; argv++) {
timestamp_t t;
t = approxidate_relative(*argv);
t = approxidate_relative(*argv, now);
printf("%s -> %"PRItime"\n", *argv, t);
}
}
@ -103,13 +103,22 @@ static void getnanos(const char **argv)
int cmd__date(int argc, const char **argv)
{
struct timeval now;
const char *x;
x = getenv("GIT_TEST_DATE_NOW");
if (x) {
now.tv_sec = atoi(x);
now.tv_usec = 0;
}
else
gettimeofday(&now, NULL);
argv++;
if (!*argv)
usage(usage_msg);
if (!strcmp(*argv, "relative"))
show_relative_dates(argv+1);
show_relative_dates(argv+1, &now);
else if (!strcmp(*argv, "human"))
show_human_dates(argv+1);
else if (skip_prefix(*argv, "show:", &x))
@ -117,9 +126,9 @@ int cmd__date(int argc, const char **argv)
else if (!strcmp(*argv, "parse"))
parse_dates(argv+1);
else if (!strcmp(*argv, "approxidate"))
parse_approxidate(argv+1);
parse_approxidate(argv+1, &now);
else if (!strcmp(*argv, "timestamp"))
parse_approx_timestamp(argv+1);
parse_approx_timestamp(argv+1, &now);
else if (!strcmp(*argv, "getnanos"))
getnanos(argv+1);
else if (!strcmp(*argv, "is64bit"))

View file

@ -8,21 +8,18 @@ static int cmd_sync(void)
{
char Buffer[MAX_PATH];
DWORD dwRet;
char szVolumeAccessPath[] = "\\\\.\\XXXX:";
char szVolumeAccessPath[] = "\\\\.\\X:";
HANDLE hVolWrite;
int success = 0, dos_drive_prefix;
int success = 0;
dwRet = GetCurrentDirectory(MAX_PATH, Buffer);
if ((0 == dwRet) || (dwRet > MAX_PATH))
return error("Error getting current directory");
dos_drive_prefix = has_dos_drive_prefix(Buffer);
if (!dos_drive_prefix)
if (!has_dos_drive_prefix(Buffer))
return error("'%s': invalid drive letter", Buffer);
memcpy(szVolumeAccessPath, Buffer, dos_drive_prefix);
szVolumeAccessPath[dos_drive_prefix] = '\0';
szVolumeAccessPath[4] = Buffer[0];
hVolWrite = CreateFile(szVolumeAccessPath, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (INVALID_HANDLE_VALUE == hVolWrite)

View file

@ -13,7 +13,7 @@ int cmd__dump_fsmonitor(int ac, const char **av)
printf("no fsmonitor\n");
return 0;
}
printf("fsmonitor last update %s\n", istate->fsmonitor_last_update);
printf("fsmonitor last update %"PRIuMAX"\n", (uintmax_t)istate->fsmonitor_last_update);
for (i = 0; i < istate->cache_nr; i++)
printf((istate->cache[i]->ce_flags & CE_FSMONITOR_VALID) ? "+" : "-");

View file

@ -5,7 +5,6 @@
struct test_entry
{
int padding; /* hashmap entry no longer needs to be the first member */
struct hashmap_entry ent;
/* key and value as two \0-terminated strings */
char key[FLEX_ARRAY];
@ -17,17 +16,15 @@ static const char *get_value(const struct test_entry *e)
}
static int test_entry_cmp(const void *cmp_data,
const struct hashmap_entry *eptr,
const struct hashmap_entry *entry_or_key,
const void *entry,
const void *entry_or_key,
const void *keydata)
{
const int ignore_case = cmp_data ? *((int *)cmp_data) : 0;
const struct test_entry *e1, *e2;
const struct test_entry *e1 = entry;
const struct test_entry *e2 = entry_or_key;
const char *key = keydata;
e1 = container_of(eptr, const struct test_entry, ent);
e2 = container_of(entry_or_key, const struct test_entry, ent);
if (ignore_case)
return strcasecmp(e1->key, key ? key : e2->key);
else
@ -40,7 +37,7 @@ static struct test_entry *alloc_test_entry(unsigned int hash,
size_t klen = strlen(key);
size_t vlen = strlen(value);
struct test_entry *entry = xmalloc(st_add4(sizeof(*entry), klen, vlen, 2));
hashmap_entry_init(&entry->ent, hash);
hashmap_entry_init(entry, hash);
memcpy(entry->key, key, klen + 1);
memcpy(entry->key + klen + 1, value, vlen + 1);
return entry;
@ -106,11 +103,11 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
/* add entries */
for (i = 0; i < TEST_SIZE; i++) {
hashmap_entry_init(&entries[i]->ent, hashes[i]);
hashmap_add(&map, &entries[i]->ent);
hashmap_entry_init(entries[i], hashes[i]);
hashmap_add(&map, entries[i]);
}
hashmap_free(&map);
hashmap_free(&map, 0);
}
} else {
/* test map lookups */
@ -119,8 +116,8 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
/* fill the map (sparsely if specified) */
j = (method & TEST_SPARSE) ? TEST_SIZE / 10 : TEST_SIZE;
for (i = 0; i < j; i++) {
hashmap_entry_init(&entries[i]->ent, hashes[i]);
hashmap_add(&map, &entries[i]->ent);
hashmap_entry_init(entries[i], hashes[i]);
hashmap_add(&map, entries[i]);
}
for (j = 0; j < rounds; j++) {
@ -130,7 +127,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
}
}
hashmap_free(&map);
hashmap_free(&map, 0);
}
}
@ -182,7 +179,7 @@ int cmd__hashmap(int argc, const char **argv)
entry = alloc_test_entry(hash, p1, p2);
/* add to hashmap */
hashmap_add(&map, &entry->ent);
hashmap_add(&map, entry);
} else if (!strcmp("put", cmd) && p1 && p2) {
@ -190,44 +187,43 @@ int cmd__hashmap(int argc, const char **argv)
entry = alloc_test_entry(hash, p1, p2);
/* add / replace entry */
entry = hashmap_put_entry(&map, entry, ent);
entry = hashmap_put(&map, entry);
/* print and free replaced entry, if any */
puts(entry ? get_value(entry) : "NULL");
free(entry);
} else if (!strcmp("get", cmd) && p1) {
/* lookup entry in hashmap */
entry = hashmap_get_entry_from_hash(&map, hash, p1,
struct test_entry, ent);
entry = hashmap_get_from_hash(&map, hash, p1);
/* print result */
if (!entry)
puts("NULL");
hashmap_for_each_entry_from(&map, entry, ent)
while (entry) {
puts(get_value(entry));
entry = hashmap_get_next(&map, entry);
}
} else if (!strcmp("remove", cmd) && p1) {
/* setup static key */
struct hashmap_entry key;
struct hashmap_entry *rm;
hashmap_entry_init(&key, hash);
/* remove entry from hashmap */
rm = hashmap_remove(&map, &key, p1);
entry = rm ? container_of(rm, struct test_entry, ent)
: NULL;
entry = hashmap_remove(&map, &key, p1);
/* print result and free entry*/
puts(entry ? get_value(entry) : "NULL");
free(entry);
} else if (!strcmp("iterate", cmd)) {
struct hashmap_iter iter;
hashmap_for_each_entry(&map, &iter, entry,
ent /* member name */)
struct hashmap_iter iter;
hashmap_iter_init(&map, &iter);
while ((entry = hashmap_iter_next(&iter)))
printf("%s %s\n", entry->key, get_value(entry));
} else if (!strcmp("size", cmd)) {
@ -262,6 +258,6 @@ int cmd__hashmap(int argc, const char **argv)
}
strbuf_release(&line);
hashmap_free_entries(&map, struct test_entry, ent);
hashmap_free(&map, 1);
return 0;
}

View file

@ -41,13 +41,17 @@ static void dump_run(void)
die("non-threaded code path used");
}
hashmap_for_each_entry(&the_index.dir_hash, &iter_dir, dir,
ent /* member name */)
dir = hashmap_iter_first(&the_index.dir_hash, &iter_dir);
while (dir) {
printf("dir %08x %7d %s\n", dir->ent.hash, dir->nr, dir->name);
dir = hashmap_iter_next(&iter_dir);
}
hashmap_for_each_entry(&the_index.name_hash, &iter_cache, ce,
ent /* member name */)
ce = hashmap_iter_first(&the_index.name_hash, &iter_cache);
while (ce) {
printf("name %08x %s\n", ce->ent.hash, ce->name);
ce = hashmap_iter_next(&iter_cache);
}
discard_cache();
}

View file

@ -121,8 +121,6 @@ int cmd__parse_options(int argc, const char **argv)
OPT_INTEGER('j', NULL, &integer, "get a integer, too"),
OPT_MAGNITUDE('m', "magnitude", &magnitude, "get a magnitude"),
OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23),
OPT_CMDMODE(0, "mode1", &integer, "set integer to 1 (cmdmode option)", 1),
OPT_CMDMODE(0, "mode2", &integer, "set integer to 2 (cmdmode option)", 2),
OPT_CALLBACK('L', "length", &integer, "str",
"get length of <str>", length_callback),
OPT_FILENAME('F', "file", &file, "set file to <file>"),

View file

@ -1,33 +0,0 @@
#include "test-tool.h"
#include "parse-options.h"
#include "pathspec.h"
#include "gettext.h"
int cmd__parse_pathspec_file(int argc, const char **argv)
{
struct pathspec pathspec;
const char *pathspec_from_file = 0;
int pathspec_file_nul = 0, i;
static const char *const usage[] = {
"test-tool parse-pathspec-file --pathspec-from-file [--pathspec-file-nul]",
NULL
};
struct option options[] = {
OPT_PATHSPEC_FROM_FILE(&pathspec_from_file),
OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul),
OPT_END()
};
parse_options(argc, argv, 0, options, usage, 0);
parse_pathspec_file(&pathspec, 0, 0, 0, pathspec_from_file,
pathspec_file_nul);
for (i = 0; i < pathspec.nr; i++)
printf("%s\n", pathspec.items[i].original);
clear_pathspec(&pathspec);
return 0;
}

View file

@ -185,99 +185,6 @@ static int cmp_by_st_size(const void *a, const void *b)
return x > y ? -1 : (x < y ? +1 : 0);
}
/*
* A very simple, reproducible pseudo-random generator. Copied from
* `test-genrandom.c`.
*/
static uint64_t my_random_value = 1234;
static uint64_t my_random(void)
{
my_random_value = my_random_value * 1103515245 + 12345;
return my_random_value;
}
/*
* A fast approximation of the square root, without requiring math.h.
*
* It uses Newton's method to approximate the solution of 0 = x^2 - value.
*/
static double my_sqrt(double value)
{
const double epsilon = 1e-6;
double x = value;
if (value == 0)
return 0;
for (;;) {
double delta = (value / x - x) / 2;
if (delta < epsilon && delta > -epsilon)
return x + delta;
x += delta;
}
}
static int protect_ntfs_hfs_benchmark(int argc, const char **argv)
{
size_t i, j, nr, min_len = 3, max_len = 20;
char **names;
int repetitions = 15, file_mode = 0100644;
uint64_t begin, end;
double m[3][2], v[3][2];
uint64_t cumul;
double cumul2;
if (argc > 1 && !strcmp(argv[1], "--with-symlink-mode")) {
file_mode = 0120000;
argc--;
argv++;
}
nr = argc > 1 ? strtoul(argv[1], NULL, 0) : 1000000;
ALLOC_ARRAY(names, nr);
if (argc > 2) {
min_len = strtoul(argv[2], NULL, 0);
if (argc > 3)
max_len = strtoul(argv[3], NULL, 0);
if (min_len > max_len)
die("min_len > max_len");
}
for (i = 0; i < nr; i++) {
size_t len = min_len + (my_random() % (max_len + 1 - min_len));
names[i] = xmallocz(len);
while (len > 0)
names[i][--len] = (char)(' ' + (my_random() % ('\x7f' - ' ')));
}
for (protect_ntfs = 0; protect_ntfs < 2; protect_ntfs++)
for (protect_hfs = 0; protect_hfs < 2; protect_hfs++) {
cumul = 0;
cumul2 = 0;
for (i = 0; i < repetitions; i++) {
begin = getnanotime();
for (j = 0; j < nr; j++)
verify_path(names[j], file_mode);
end = getnanotime();
printf("protect_ntfs = %d, protect_hfs = %d: %lfms\n", protect_ntfs, protect_hfs, (end-begin) / (double)1e6);
cumul += end - begin;
cumul2 += (end - begin) * (end - begin);
}
m[protect_ntfs][protect_hfs] = cumul / (double)repetitions;
v[protect_ntfs][protect_hfs] = my_sqrt(cumul2 / (double)repetitions - m[protect_ntfs][protect_hfs] * m[protect_ntfs][protect_hfs]);
printf("mean: %lfms, stddev: %lfms\n", m[protect_ntfs][protect_hfs] / (double)1e6, v[protect_ntfs][protect_hfs] / (double)1e6);
}
for (protect_ntfs = 0; protect_ntfs < 2; protect_ntfs++)
for (protect_hfs = 0; protect_hfs < 2; protect_hfs++)
printf("ntfs=%d/hfs=%d: %lf%% slower\n", protect_ntfs, protect_hfs, (m[protect_ntfs][protect_hfs] - m[0][0]) * 100 / m[0][0]);
return 0;
}
int cmd__path_utils(int argc, const char **argv)
{
if (argc == 3 && !strcmp(argv[1], "normalize_path_copy")) {
@ -448,26 +355,6 @@ int cmd__path_utils(int argc, const char **argv)
return !!res;
}
if (argc > 1 && !strcmp(argv[1], "protect_ntfs_hfs"))
return !!protect_ntfs_hfs_benchmark(argc - 1, argv + 1);
if (argc > 1 && !strcmp(argv[1], "is_valid_path")) {
int res = 0, expect = 1, i;
for (i = 2; i < argc; i++)
if (!strcmp("--not", argv[i]))
expect = 0;
else if (expect != is_valid_path(argv[i]))
res = error("'%s' is%s a valid path",
argv[i], expect ? " not" : "");
else
fprintf(stderr,
"'%s' is%s a valid path\n",
argv[i], expect ? "" : " not");
return !!res;
}
fprintf(stderr, "%s: unknown function name: %s\n", argv[0],
argv[1] ? argv[1] : "(there was none)");
return 1;

View file

@ -1,81 +0,0 @@
/*
* A test helper to exercise the progress display.
*
* Reads instructions from standard input, one instruction per line:
*
* "progress <items>" - Call display_progress() with the given item count
* as parameter.
* "throughput <bytes> <millis> - Call display_throughput() with the given
* byte count as parameter. The 'millis'
* specify the time elapsed since the
* start_progress() call.
* "update" - Set the 'progress_update' flag.
*
* See 't0500-progress-display.sh' for examples.
*/
#include "test-tool.h"
#include "gettext.h"
#include "parse-options.h"
#include "progress.h"
#include "strbuf.h"
/*
* These are defined in 'progress.c', but are not exposed in 'progress.h',
* because they are exclusively for testing.
*/
extern int progress_testing;
extern uint64_t progress_test_ns;
void progress_test_force_update(void);
int cmd__progress(int argc, const char **argv)
{
int total = 0;
const char *title;
struct strbuf line = STRBUF_INIT;
struct progress *progress;
const char *usage[] = {
"test-tool progress [--total=<n>] <progress-title>",
NULL
};
struct option options[] = {
OPT_INTEGER(0, "total", &total, "total number of items"),
OPT_END(),
};
argc = parse_options(argc, argv, NULL, options, usage, 0);
if (argc != 1)
die("need a title for the progress output");
title = argv[0];
progress_testing = 1;
progress = start_progress(title, total);
while (strbuf_getline(&line, stdin) != EOF) {
char *end;
if (skip_prefix(line.buf, "progress ", (const char **) &end)) {
uint64_t item_count = strtoull(end, &end, 10);
if (*end != '\0')
die("invalid input: '%s'\n", line.buf);
display_progress(progress, item_count);
} else if (skip_prefix(line.buf, "throughput ",
(const char **) &end)) {
uint64_t byte_count, test_ms;
byte_count = strtoull(end, &end, 10);
if (*end != ' ')
die("invalid input: '%s'\n", line.buf);
test_ms = strtoull(end + 1, &end, 10);
if (*end != '\0')
die("invalid input: '%s'\n", line.buf);
progress_test_ns = test_ms * 1000 * 1000;
display_throughput(progress, byte_count);
} else if (!strcmp(line.buf, "update"))
progress_test_force_update();
else
die("invalid input: '%s'\n", line.buf);
}
stop_progress(&progress);
return 0;
}

View file

@ -4,10 +4,11 @@
int cmd__read_cache(int argc, const char **argv)
{
int i, cnt = 1;
int i, cnt = 1, namelen;
const char *name = NULL;
if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) {
namelen = strlen(name);
argc--;
argv++;
}
@ -23,7 +24,7 @@ int cmd__read_cache(int argc, const char **argv)
refresh_index(&the_index, REFRESH_QUIET,
NULL, NULL, NULL);
pos = index_name_pos(&the_index, name, strlen(name));
pos = index_name_pos(&the_index, name, namelen);
if (pos < 0)
die("%s not in index", name);
printf("%s is%s up to date\n", name,

View file

@ -1,53 +0,0 @@
#include "test-tool.h"
#include "cache.h"
#include "commit-graph.h"
#include "repository.h"
#include "object-store.h"
int cmd__read_graph(int argc, const char **argv)
{
struct commit_graph *graph = NULL;
char *graph_name;
int open_ok;
int fd;
struct stat st;
struct object_directory *odb;
setup_git_directory();
odb = the_repository->objects->odb;
graph_name = get_commit_graph_filename(odb);
open_ok = open_commit_graph(graph_name, &fd, &st);
if (!open_ok)
die_errno(_("Could not open commit-graph '%s'"), graph_name);
graph = load_commit_graph_one_fd_st(fd, &st, odb);
if (!graph)
return 1;
FREE_AND_NULL(graph_name);
printf("header: %08x %d %d %d %d\n",
ntohl(*(uint32_t*)graph->data),
*(unsigned char*)(graph->data + 4),
*(unsigned char*)(graph->data + 5),
*(unsigned char*)(graph->data + 6),
*(unsigned char*)(graph->data + 7));
printf("num_commits: %u\n", graph->num_commits);
printf("chunks:");
if (graph->chunk_oid_fanout)
printf(" oid_fanout");
if (graph->chunk_oid_lookup)
printf(" oid_lookup");
if (graph->chunk_commit_data)
printf(" commit_metadata");
if (graph->chunk_extra_edges)
printf(" extra_edges");
printf("\n");
UNLEAK(graph);
return 0;
}

View file

@ -10,16 +10,11 @@
#include "test-tool.h"
#include "git-compat-util.h"
#include "cache.h"
#include "run-command.h"
#include "argv-array.h"
#include "strbuf.h"
#include "parse-options.h"
#include "string-list.h"
#include "thread-utils.h"
#include "wildmatch.h"
#include "gettext.h"
#include "parse-options.h"
#include <string.h>
#include <errno.h>
static int number_callbacks;
static int parallel_next(struct child_process *cp,
@ -55,337 +50,11 @@ static int task_finished(int result,
return 1;
}
struct testsuite {
struct string_list tests, failed;
int next;
int quiet, immediate, verbose, verbose_log, trace, write_junit_xml;
};
#define TESTSUITE_INIT \
{ STRING_LIST_INIT_DUP, STRING_LIST_INIT_DUP, -1, 0, 0, 0, 0, 0, 0 }
static int next_test(struct child_process *cp, struct strbuf *err, void *cb,
void **task_cb)
{
struct testsuite *suite = cb;
const char *test;
if (suite->next >= suite->tests.nr)
return 0;
test = suite->tests.items[suite->next++].string;
argv_array_pushl(&cp->args, "sh", test, NULL);
if (suite->quiet)
argv_array_push(&cp->args, "--quiet");
if (suite->immediate)
argv_array_push(&cp->args, "-i");
if (suite->verbose)
argv_array_push(&cp->args, "-v");
if (suite->verbose_log)
argv_array_push(&cp->args, "-V");
if (suite->trace)
argv_array_push(&cp->args, "-x");
if (suite->write_junit_xml)
argv_array_push(&cp->args, "--write-junit-xml");
strbuf_addf(err, "Output of '%s':\n", test);
*task_cb = (void *)test;
return 1;
}
static int test_finished(int result, struct strbuf *err, void *cb,
void *task_cb)
{
struct testsuite *suite = cb;
const char *name = (const char *)task_cb;
if (result)
string_list_append(&suite->failed, name);
strbuf_addf(err, "%s: '%s'\n", result ? "FAIL" : "SUCCESS", name);
return 0;
}
static int test_failed(struct strbuf *out, void *cb, void *task_cb)
{
struct testsuite *suite = cb;
const char *name = (const char *)task_cb;
string_list_append(&suite->failed, name);
strbuf_addf(out, "FAILED TO START: '%s'\n", name);
return 0;
}
static const char * const testsuite_usage[] = {
"test-run-command testsuite [<options>] [<pattern>...]",
NULL
};
static int testsuite(int argc, const char **argv)
{
struct testsuite suite = TESTSUITE_INIT;
int max_jobs = 1, i, ret;
DIR *dir;
struct dirent *d;
struct option options[] = {
OPT_BOOL('i', "immediate", &suite.immediate,
"stop at first failed test case(s)"),
OPT_INTEGER('j', "jobs", &max_jobs, "run <N> jobs in parallel"),
OPT_BOOL('q', "quiet", &suite.quiet, "be terse"),
OPT_BOOL('v', "verbose", &suite.verbose, "be verbose"),
OPT_BOOL('V', "verbose-log", &suite.verbose_log,
"be verbose, redirected to a file"),
OPT_BOOL('x', "trace", &suite.trace, "trace shell commands"),
OPT_BOOL(0, "write-junit-xml", &suite.write_junit_xml,
"write JUnit-style XML files"),
OPT_END()
};
memset(&suite, 0, sizeof(suite));
suite.tests.strdup_strings = suite.failed.strdup_strings = 1;
argc = parse_options(argc, argv, NULL, options,
testsuite_usage, PARSE_OPT_STOP_AT_NON_OPTION);
if (max_jobs <= 0)
max_jobs = online_cpus();
dir = opendir(".");
if (!dir)
die("Could not open the current directory");
while ((d = readdir(dir))) {
const char *p = d->d_name;
if (*p != 't' || !isdigit(p[1]) || !isdigit(p[2]) ||
!isdigit(p[3]) || !isdigit(p[4]) || p[5] != '-' ||
!ends_with(p, ".sh"))
continue;
/* No pattern: match all */
if (!argc) {
string_list_append(&suite.tests, p);
continue;
}
for (i = 0; i < argc; i++)
if (!wildmatch(argv[i], p, 0)) {
string_list_append(&suite.tests, p);
break;
}
}
closedir(dir);
if (!suite.tests.nr)
die("No tests match!");
if (max_jobs > suite.tests.nr)
max_jobs = suite.tests.nr;
fprintf(stderr, "Running %d tests (%d at a time)\n",
suite.tests.nr, max_jobs);
ret = run_processes_parallel(max_jobs, next_test, test_failed,
test_finished, &suite);
if (suite.failed.nr > 0) {
ret = 1;
fprintf(stderr, "%d tests failed:\n\n", suite.failed.nr);
for (i = 0; i < suite.failed.nr; i++)
fprintf(stderr, "\t%s\n", suite.failed.items[i].string);
}
string_list_clear(&suite.tests, 0);
string_list_clear(&suite.failed, 0);
return !!ret;
}
static uint64_t my_random_next = 1234;
static uint64_t my_random(void)
{
uint64_t res = my_random_next;
my_random_next = my_random_next * 1103515245 + 12345;
return res;
}
static int quote_stress_test(int argc, const char **argv)
{
/*
* We are running a quote-stress test.
* spawn a subprocess that runs quote-stress with a
* special option that echoes back the arguments that
* were passed in.
*/
char special[] = ".?*\\^_\"'`{}()[]<>@~&+:;$%"; // \t\r\n\a";
int i, j, k, trials = 100, skip = 0, msys2 = 0;
struct strbuf out = STRBUF_INIT;
struct argv_array args = ARGV_ARRAY_INIT;
struct option options[] = {
OPT_INTEGER('n', "trials", &trials, "Number of trials"),
OPT_INTEGER('s', "skip", &skip, "Skip <n> trials"),
OPT_BOOL('m', "msys2", &msys2, "Test quoting for MSYS2's sh"),
OPT_END()
};
const char * const usage[] = {
"test-tool run-command quote-stress-test <options>",
NULL
};
argc = parse_options(argc, argv, NULL, options, usage, 0);
setenv("MSYS_NO_PATHCONV", "1", 0);
for (i = 0; i < trials; i++) {
struct child_process cp = CHILD_PROCESS_INIT;
size_t arg_count, arg_offset;
int ret = 0;
argv_array_clear(&args);
if (msys2)
argv_array_pushl(&args, "sh", "-c",
"printf %s\\\\0 \"$@\"", "skip", NULL);
else
argv_array_pushl(&args, "test-tool", "run-command",
"quote-echo", NULL);
arg_offset = args.argc;
if (argc > 0) {
trials = 1;
arg_count = argc;
for (j = 0; j < arg_count; j++)
argv_array_push(&args, argv[j]);
} else {
arg_count = 1 + (my_random() % 5);
for (j = 0; j < arg_count; j++) {
char buf[20];
size_t min_len = 1;
size_t arg_len = min_len +
(my_random() % (ARRAY_SIZE(buf) - min_len));
for (k = 0; k < arg_len; k++)
buf[k] = special[my_random() %
ARRAY_SIZE(special)];
buf[arg_len] = '\0';
argv_array_push(&args, buf);
}
}
if (i < skip)
continue;
cp.argv = args.argv;
strbuf_reset(&out);
if (pipe_command(&cp, NULL, 0, &out, 0, NULL, 0) < 0)
return error("Failed to spawn child process");
for (j = 0, k = 0; j < arg_count; j++) {
const char *arg = args.argv[j + arg_offset];
if (strcmp(arg, out.buf + k))
ret = error("incorrectly quoted arg: '%s', "
"echoed back as '%s'",
arg, out.buf + k);
k += strlen(out.buf + k) + 1;
}
if (k != out.len)
ret = error("got %d bytes, but consumed only %d",
(int)out.len, (int)k);
if (ret) {
fprintf(stderr, "Trial #%d failed. Arguments:\n", i);
for (j = 0; j < arg_count; j++)
fprintf(stderr, "arg #%d: '%s'\n",
(int)j, args.argv[j + arg_offset]);
strbuf_release(&out);
argv_array_clear(&args);
return ret;
}
if (i && (i % 100) == 0)
fprintf(stderr, "Trials completed: %d\n", (int)i);
}
strbuf_release(&out);
argv_array_clear(&args);
return 0;
}
static int quote_echo(int argc, const char **argv)
{
while (argc > 1) {
fwrite(argv[1], strlen(argv[1]), 1, stdout);
fputc('\0', stdout);
argv++;
argc--;
}
return 0;
}
static int inherit_handle(const char *argv0)
{
struct child_process cp = CHILD_PROCESS_INIT;
char path[PATH_MAX];
int tmp;
/* First, open an inheritable handle */
xsnprintf(path, sizeof(path), "out-XXXXXX");
tmp = xmkstemp(path);
argv_array_pushl(&cp.args,
"test-tool", argv0, "inherited-handle-child", NULL);
cp.in = -1;
cp.no_stdout = cp.no_stderr = 1;
if (start_command(&cp) < 0)
die("Could not start child process");
/* Then close it, and try to delete it. */
close(tmp);
if (unlink(path))
die("Could not delete '%s'", path);
if (close(cp.in) < 0 || finish_command(&cp) < 0)
die("Child did not finish");
return 0;
}
static int inherit_handle_child(void)
{
struct strbuf buf = STRBUF_INIT;
if (strbuf_read(&buf, 0, 0) < 0)
die("Could not read stdin");
printf("Received %s\n", buf.buf);
strbuf_release(&buf);
return 0;
}
int cmd__run_command(int argc, const char **argv)
{
struct child_process proc = CHILD_PROCESS_INIT;
int jobs;
if (argc > 1 && !strcmp(argv[1], "testsuite"))
exit(testsuite(argc - 1, argv + 1));
if (!strcmp(argv[1], "inherited-handle"))
exit(inherit_handle(argv[0]));
if (!strcmp(argv[1], "inherited-handle-child"))
exit(inherit_handle_child());
if (argc >= 2 && !strcmp(argv[1], "quote-stress-test"))
return !!quote_stress_test(argc - 1, argv + 1);
if (argc >= 2 && !strcmp(argv[1], "quote-echo"))
return !!quote_echo(argc - 1, argv + 1);
if (argc < 3)
return 1;
while (!strcmp(argv[1], "env")) {

View file

@ -39,14 +39,11 @@ static struct test_cmd cmds[] = {
{ "oidmap", cmd__oidmap },
{ "online-cpus", cmd__online_cpus },
{ "parse-options", cmd__parse_options },
{ "parse-pathspec-file", cmd__parse_pathspec_file },
{ "path-utils", cmd__path_utils },
{ "pkt-line", cmd__pkt_line },
{ "prio-queue", cmd__prio_queue },
{ "progress", cmd__progress },
{ "reach", cmd__reach },
{ "read-cache", cmd__read_cache },
{ "read-graph", cmd__read_graph },
{ "read-midx", cmd__read_midx },
{ "ref-store", cmd__ref_store },
{ "regex", cmd__regex },

View file

@ -29,14 +29,11 @@ int cmd__mktemp(int argc, const char **argv);
int cmd__oidmap(int argc, const char **argv);
int cmd__online_cpus(int argc, const char **argv);
int cmd__parse_options(int argc, const char **argv);
int cmd__parse_pathspec_file(int argc, const char** argv);
int cmd__path_utils(int argc, const char **argv);
int cmd__pkt_line(int argc, const char **argv);
int cmd__prio_queue(int argc, const char **argv);
int cmd__progress(int argc, const char **argv);
int cmd__reach(int argc, const char **argv);
int cmd__read_cache(int argc, const char **argv);
int cmd__read_graph(int argc, const char **argv);
int cmd__read_midx(int argc, const char **argv);
int cmd__ref_store(int argc, const char **argv);
int cmd__regex(int argc, const char **argv);

View file

@ -19,7 +19,7 @@ int cmd__windows_named_pipe(int argc, const char **argv)
if (argc < 2)
goto print_usage;
filename = argv[1];
if (strpbrk(filename, "/\\"))
if (strchr(filename, '/') || strchr(filename, '\\'))
goto print_usage;
strbuf_addf(&pathname, "//./pipe/%s", filename);

View file

@ -2,12 +2,10 @@
# to run under Bash; primarily intended for tests of the completion
# script.
if test -n "$BASH" && test -z "$POSIXLY_CORRECT"
then
if test -n "$BASH" && test -z "$POSIXLY_CORRECT"; then
# we are in full-on bash mode
true
elif type bash >/dev/null 2>&1
then
elif type bash >/dev/null 2>&1; then
# execute in full-on bash mode
unset POSIXLY_CORRECT
exec bash "$0" "$@"

View file

@ -19,7 +19,7 @@ check() {
false
fi &&
test_cmp expect-stdout stdout &&
test_i18ncmp expect-stderr stderr
test_cmp expect-stderr stderr
}
read_chunk() {

View file

@ -15,7 +15,7 @@
#
# test_done
if ! test_bool_env GIT_TEST_GIT_DAEMON true
if ! git env--helper --type=bool --default=true --exit-code GIT_TEST_GIT_DAEMON
then
skip_all="git-daemon testing disabled (unset GIT_TEST_GIT_DAEMON to enable)"
test_done

View file

@ -175,7 +175,7 @@ stop_and_cleanup_p4d () {
cleanup_git () {
retry_until_success rm -r "$git"
test_path_is_missing "$git" &&
test_must_fail test -d "$git" &&
retry_until_success mkdir "$git"
}

View file

@ -69,7 +69,7 @@ svn_cmd () {
maybe_start_httpd () {
loc=${1-svn}
if test_bool_env GIT_TEST_SVN_HTTPD false
if git env--helper --type=bool --default=false --exit-code GIT_TEST_HTTPD
then
. "$TEST_DIRECTORY"/lib-httpd.sh
LIB_HTTPD_SVN="$loc"
@ -104,7 +104,7 @@ EOF
}
require_svnserve () {
if ! test_bool_env GIT_TEST_SVNSERVE false
if ! git env--helper --type=bool --default=false --exit-code GIT_TEST_SVNSERVE
then
skip_all='skipping svnserve test. (set $GIT_TEST_SVNSERVE to enable)'
test_done

View file

@ -41,7 +41,7 @@ then
test_done
fi
if ! test_bool_env GIT_TEST_HTTPD true
if ! git env--helper --type=bool --default=true --exit-code GIT_TEST_HTTPD
then
skip_all="Network testing disabled (unset GIT_TEST_HTTPD to enable)"
test_done
@ -132,7 +132,7 @@ prepare_httpd() {
install_script broken-smart-http.sh
install_script error-smart-http.sh
install_script error.sh
install_script apply-one-time-perl.sh
install_script apply-one-time-sed.sh
ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules"

View file

@ -113,7 +113,7 @@ Alias /auth/dumb/ www/auth/dumb/
SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
SetEnv GIT_HTTP_EXPORT_ALL
</LocationMatch>
<LocationMatch /one_time_perl/>
<LocationMatch /one_time_sed/>
SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
SetEnv GIT_HTTP_EXPORT_ALL
</LocationMatch>
@ -122,7 +122,7 @@ ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1
ScriptAlias /broken_smart/ broken-smart-http.sh/
ScriptAlias /error_smart/ error-smart-http.sh/
ScriptAlias /error/ error.sh/
ScriptAliasMatch /one_time_perl/(.*) apply-one-time-perl.sh/$1
ScriptAliasMatch /one_time_sed/(.*) apply-one-time-sed.sh/$1
<Directory ${GIT_EXEC_PATH}>
Options FollowSymlinks
</Directory>
@ -135,7 +135,7 @@ ScriptAliasMatch /one_time_perl/(.*) apply-one-time-perl.sh/$1
<Files error.sh>
Options ExecCGI
</Files>
<Files apply-one-time-perl.sh>
<Files apply-one-time-sed.sh>
Options ExecCGI
</Files>
<Files ${GIT_EXEC_PATH}/git-http-backend>

View file

@ -1,27 +0,0 @@
#!/bin/sh
# If "one-time-perl" exists in $HTTPD_ROOT_PATH, run perl on the HTTP response,
# using the contents of "one-time-perl" as the perl command to be run. If the
# response was modified as a result, delete "one-time-perl" so that subsequent
# HTTP responses are no longer modified.
#
# This can be used to simulate the effects of the repository changing in
# between HTTP request-response pairs.
if test -f one-time-perl
then
LC_ALL=C
export LC_ALL
"$GIT_EXEC_PATH/git-http-backend" >out
perl -pe "$(cat one-time-perl)" out >out_modified
if cmp -s out out_modified
then
cat out
else
cat out_modified
rm one-time-perl
fi
else
"$GIT_EXEC_PATH/git-http-backend"
fi

View file

@ -0,0 +1,22 @@
#!/bin/sh
# If "one-time-sed" exists in $HTTPD_ROOT_PATH, run sed on the HTTP response,
# using the contents of "one-time-sed" as the sed command to be run. If the
# response was modified as a result, delete "one-time-sed" so that subsequent
# HTTP responses are no longer modified.
#
# This can be used to simulate the effects of the repository changing in
# between HTTP request-response pairs.
if [ -e one-time-sed ]; then
"$GIT_EXEC_PATH/git-http-backend" >out
sed "$(cat one-time-sed)" <out >out_modified
if diff out out_modified >/dev/null; then
cat out
else
cat out_modified
rm one-time-sed
fi
else
"$GIT_EXEC_PATH/git-http-backend"
fi

View file

@ -1,28 +0,0 @@
# Helps shared by the test scripts for comparing log graphs.
sanitize_log_output () {
sed -e 's/ *$//' \
-e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
-e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
-e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
-e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
-e 's/index [0-9a-f]*\.\.[0-9a-f]*/index BEFORE..AFTER/'
}
lib_test_cmp_graph () {
git log --graph "$@" >output &&
sed 's/ *$//' >output.sanitized <output &&
test_i18ncmp expect output.sanitized
}
lib_test_cmp_short_graph () {
git log --graph --pretty=short "$@" >output &&
sanitize_log_output >output.sanitized <output &&
test_i18ncmp expect output.sanitized
}
lib_test_cmp_colored_graph () {
git log --graph --color=always "$@" >output.colors.raw &&
test_decode_color <output.colors.raw | sed "s/ *\$//" >output.colors &&
test_cmp expect.colors output.colors
}

View file

@ -35,11 +35,9 @@ pack_header () {
# have hardcoded some well-known objects. See the case statements below for the
# complete list.
pack_obj () {
test_oid_init
case "$1" in
# empty blob
$EMPTY_BLOB)
e69de29bb2d1d6434b8b29ae775ad8c2e48c5391)
case "$2" in
'')
printf '\060\170\234\003\0\0\0\0\1'
@ -49,7 +47,7 @@ pack_obj () {
;;
# blob containing "\7\76"
$(test_oid packlib_7_76))
e68fe8129b546b101aee9510c5328e7f21ca1d18)
case "$2" in
'')
printf '\062\170\234\143\267\3\0\0\116\0\106'
@ -61,18 +59,11 @@ pack_obj () {
printf '\234\143\142\142\142\267\003\0\0\151\0\114'
return
;;
37c8e2c15bb22b912e59b43fd51a4f7e9465ed0b5084c5a1411d991cbe630683)
printf '\165\67\310\342\301\133\262\53\221\56\131' &&
printf '\264\77\325\32\117\176\224\145\355\13\120' &&
printf '\204\305\241\101\35\231\34\276\143\6\203\170' &&
printf '\234\143\142\142\142\267\003\0\0\151\0\114'
return
;;
esac
;;
# blob containing "\7\0"
$(test_oid packlib_7_0))
01d7713666f4de822776c7622c10f1b07de280dc)
case "$2" in
'')
printf '\062\170\234\143\147\0\0\0\20\0\10'
@ -84,13 +75,6 @@ pack_obj () {
printf '\143\142\142\142\147\0\0\0\53\0\16'
return
;;
5d8e6fc40f2dab00e6983a48523fe57e621f46434cb58dbd4422fba03380d886)
printf '\165\135\216\157\304\17\55\253\0\346\230\72' &&
printf '\110\122\77\345\176\142\37\106\103\114\265' &&
printf '\215\275\104\42\373\240\63\200\330\206\170\234' &&
printf '\143\142\142\142\147\0\0\0\53\0\16'
return
;;
esac
;;
esac
@ -102,7 +86,7 @@ pack_obj () {
then
echo "$1" | git pack-objects --stdout >pack_obj.tmp &&
size=$(wc -c <pack_obj.tmp) &&
dd if=pack_obj.tmp bs=1 count=$((size - $(test_oid rawsz) - 12)) skip=12 &&
dd if=pack_obj.tmp bs=1 count=$((size - 20 - 12)) skip=12 &&
rm -f pack_obj.tmp
return
fi
@ -113,8 +97,7 @@ pack_obj () {
# Compute and append pack trailer to "$1"
pack_trailer () {
test_oid_init &&
test-tool $(test_oid algo) -b <"$1" >trailer.tmp &&
test-tool sha1 -b <"$1" >trailer.tmp &&
cat trailer.tmp >>"$1" &&
rm -f trailer.tmp
}
@ -125,11 +108,3 @@ pack_trailer () {
clear_packs () {
rm -f .git/objects/pack/*
}
test_oid_cache <<-EOF
packlib_7_0 sha1:01d7713666f4de822776c7622c10f1b07de280dc
packlib_7_0 sha256:37c8e2c15bb22b912e59b43fd51a4f7e9465ed0b5084c5a1411d991cbe630683
packlib_7_76 sha1:e68fe8129b546b101aee9510c5328e7f21ca1d18
packlib_7_76 sha256:5d8e6fc40f2dab00e6983a48523fe57e621f46434cb58dbd4422fba03380d886
EOF

View file

@ -44,10 +44,10 @@ set_fake_editor () {
rm -f "$1"
echo 'rebase -i script before editing:'
cat "$1".tmp
action=\&
action=pick
for line in $FAKE_LINES; do
case $line in
pick|p|squash|s|fixup|f|edit|e|reword|r|drop|d|label|l|reset|r|merge|m)
pick|p|squash|s|fixup|f|edit|e|reword|r|drop|d)
action="$line";;
exec_*|x_*|break|b)
echo "$line" | sed 's/_/ /g' >> "$1";;
@ -58,12 +58,11 @@ set_fake_editor () {
bad)
action="badcmd";;
fakesha)
test \& != "$action" || action=pick
echo "$action XXXXXXX False commit" >> "$1"
action=pick;;
*)
sed -n "${line}s/^[a-z][a-z]*/$action/p" < "$1".tmp >> "$1"
action=\&;;
sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1"
action=pick;;
esac
done
echo 'rebase -i script after editing:'
@ -119,31 +118,3 @@ make_empty () {
git commit --allow-empty -m "$1" &&
git tag "$1"
}
# Call this (inside test_expect_success) at the end of a test file to
# check that no tests have changed editor related environment
# variables or config settings
test_editor_unchanged () {
# We're only interested in exported variables hence 'sh -c'
sh -c 'cat >actual <<-EOF
EDITOR=$EDITOR
FAKE_COMMIT_AMEND=$FAKE_COMMIT_AMEND
FAKE_COMMIT_MESSAGE=$FAKE_COMMIT_MESSAGE
FAKE_LINES=$FAKE_LINES
GIT_EDITOR=$GIT_EDITOR
GIT_SEQUENCE_EDITOR=$GIT_SEQUENCE_EDITOR
core.editor=$(git config core.editor)
sequence.editor=$(git config sequence.editor)
EOF'
cat >expect <<-\EOF
EDITOR=:
FAKE_COMMIT_AMEND=
FAKE_COMMIT_MESSAGE=
FAKE_LINES=
GIT_EDITOR=
GIT_SEQUENCE_EDITOR=
core.editor=
sequence.editor=
EOF
test_cmp expect actual
}

View file

@ -6,12 +6,3 @@ hexsz sha256:64
zero sha1:0000000000000000000000000000000000000000
zero sha256:0000000000000000000000000000000000000000000000000000000000000000
algo sha1:sha1
algo sha256:sha256
empty_blob sha1:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
empty_blob sha256:473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813
empty_tree sha1:4b825dc642cb6eb9a060e54bf8d69288fbee4904
empty_tree sha256:6ef19b41225c5369f1c104d45d8d85efa9b057b53b14b4b9b939dd74decc5321

View file

@ -4,6 +4,7 @@ use lib '../../perl/build/lib';
use strict;
use warnings;
use Getopt::Long;
use Git;
use Cwd qw(realpath);
sub get_times {
@ -84,11 +85,6 @@ sub format_size {
return $out;
}
sub sane_backticks {
open(my $fh, '-|', @_);
return <$fh>;
}
my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests,
$codespeed, $sortby, $subsection, $reponame);
@ -106,8 +102,7 @@ while (scalar @ARGV) {
my $prefix = '';
last if -f $arg or $arg eq "--";
if (! -d $arg) {
my $rev = sane_backticks(qw(git rev-parse --verify), $arg);
chomp $rev;
my $rev = Git::command_oneline(qw(rev-parse --verify), $arg);
$dir = "build/".$rev;
} elsif ($arg eq '.') {
$dir = '.';
@ -224,7 +219,13 @@ sub print_default_results {
for my $i (0..$#dirs) {
my $d = $dirs[$i];
my $base = "$resultsdir/$prefixes{$d}$t";
$times{$prefixes{$d}.$t} = [get_times("$base.result")];
$times{$prefixes{$d}.$t} = [];
foreach my $type (qw(times size)) {
if (-e "$base.$type") {
$times{$prefixes{$d}.$t} = [get_times("$base.$type")];
last;
}
}
my ($r,$u,$s) = @{$times{$prefixes{$d}.$t}};
my $w = length format_times($r,$u,$s,$firstr);
$colwidth[$i] = $w if $w > $colwidth[$i];
@ -266,7 +267,7 @@ sub print_sorted_results {
my ($prevr, $prevu, $prevs, $prevrev);
for my $i (0..$#dirs) {
my $d = $dirs[$i];
my ($r, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.result");
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,
@ -326,7 +327,7 @@ sub print_codespeed_results {
my $commitid = $prefixes{$d};
$commitid =~ s/^build_//;
$commitid =~ s/\.$//;
my ($result_value, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.result");
my ($result_value, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times");
my %vals = (
"commitid" => $commitid,

View file

@ -51,7 +51,7 @@ 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' should be greater than old time '$oldtime'"
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'"

View file

@ -77,7 +77,6 @@ do
# actual pack generation, without smudging the on-disk setup
# between trials.
test_perf "repack ($nr_packs)" '
GIT_TEST_FULL_IN_PACK_ARRAY=1 \
git pack-objects --keep-true-parents \
--honor-pack-keep --non-empty --all \
--reflog --indexed-objects --delta-base-offset \
@ -85,22 +84,4 @@ do
'
done
# Measure pack loading with 10,000 packs.
test_expect_success 'generate lots of packs' '
for i in $(test_seq 10000); do
echo "blob"
echo "data <<EOF"
echo "blob $i"
echo "EOF"
echo "checkpoint"
done |
git -c fastimport.unpackLimit=0 fast-import
'
# The purpose of this test is to evaluate load time for a large number
# of packs while doing as little other work as possible.
test_perf "load 10,000 packs" '
git rev-parse --verify "HEAD^{commit}"
'
test_done

View file

@ -39,28 +39,6 @@ test_perf 'pack to file (bitmap)' '
git pack-objects --use-bitmap-index --all pack1b </dev/null >/dev/null
'
test_perf 'rev-list (commits)' '
git rev-list --all --use-bitmap-index >/dev/null
'
test_perf 'rev-list (objects)' '
git rev-list --all --use-bitmap-index --objects >/dev/null
'
test_perf 'rev-list count with blob:none' '
git rev-list --use-bitmap-index --count --objects --all \
--filter=blob:none >/dev/null
'
test_perf 'rev-list count with blob:limit=1k' '
git rev-list --use-bitmap-index --count --objects --all \
--filter=blob:limit=1k >/dev/null
'
test_perf 'simulated partial clone' '
git pack-objects --stdout --all --filter=blob:none </dev/null >/dev/null
'
test_expect_success 'create partial bitmap state' '
# pick a commit to represent the repo tip in the past
cutoff=$(git rev-list HEAD~100 -1) &&

View file

@ -214,7 +214,7 @@ test_perf_ () {
else
test_ok_ "$1"
fi
"$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".result
"$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".times
}
test_perf () {
@ -223,7 +223,7 @@ test_perf () {
test_size_ () {
say >&3 "running: $2"
if test_eval_ "$2" 3>"$base".result; then
if test_eval_ "$2" 3>"$base".size; then
test_ok_ "$1"
else
test_failure_ "$@"

View file

@ -20,9 +20,9 @@ modification *should* take notice and update the test vectors here.
. ./test-lib.sh
try_local_xy () {
local x="local" y="alsolocal" &&
echo "$x $y"
try_local_x () {
local x="local" &&
echo "$x"
}
# Check whether the shell supports the "local" keyword. "local" is not
@ -35,12 +35,11 @@ try_local_xy () {
# relying on "local".
test_expect_success 'verify that the running shell supports "local"' '
x="notlocal" &&
y="alsonotlocal" &&
echo "local alsolocal" >expected1 &&
try_local_xy >actual1 &&
echo "local" >expected1 &&
try_local_x >actual1 &&
test_cmp expected1 actual1 &&
echo "notlocal alsonotlocal" >expected2 &&
echo "$x $y" >actual2 &&
echo "notlocal" >expected2 &&
echo "$x" >actual2 &&
test_cmp expected2 actual2
'
@ -127,7 +126,7 @@ check_sub_test_lib_test () {
check_sub_test_lib_test_err () {
name="$1" # stdin is the expected output from the test
# expected error output is in descriptor 3
# expected error output is in descriptior 3
(
cd "$name" &&
sed -e 's/^> //' -e 's/Z$//' >expect.out &&
@ -155,7 +154,7 @@ test_expect_success 'pretend we have a fully passing test suite' "
"
test_expect_success 'pretend we have a partially passing test suite' "
run_sub_test_lib_test_err \
test_must_fail run_sub_test_lib_test \
partial-pass '2/3 tests passing' <<-\\EOF &&
test_expect_success 'passing test #1' 'true'
test_expect_success 'failing test #2' 'false'
@ -219,7 +218,7 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su
"
test_expect_success 'pretend we have a pass, fail, and known breakage' "
run_sub_test_lib_test_err \
test_must_fail run_sub_test_lib_test \
mixed-results1 'mixed results #1' <<-\\EOF &&
test_expect_success 'passing test' 'true'
test_expect_success 'failing test' 'false'
@ -238,7 +237,7 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' "
"
test_expect_success 'pretend we have a mix of all possible results' "
run_sub_test_lib_test_err \
test_must_fail run_sub_test_lib_test \
mixed-results2 'mixed results #2' <<-\\EOF &&
test_expect_success 'passing test' 'true'
test_expect_success 'passing test' 'true'
@ -274,24 +273,24 @@ test_expect_success 'pretend we have a mix of all possible results' "
"
test_expect_success C_LOCALE_OUTPUT 'test --verbose' '
run_sub_test_lib_test_err \
t1234-verbose "test verbose" --verbose <<-\EOF &&
test_must_fail run_sub_test_lib_test \
test-verbose "test verbose" --verbose <<-\EOF &&
test_expect_success "passing test" true
test_expect_success "test with output" "echo foo"
test_expect_success "failing test" false
test_done
EOF
mv t1234-verbose/out t1234-verbose/out+ &&
grep -v "^Initialized empty" t1234-verbose/out+ >t1234-verbose/out &&
check_sub_test_lib_test t1234-verbose <<-\EOF
> expecting success of 1234.1 '\''passing test'\'': true
mv test-verbose/out test-verbose/out+ &&
grep -v "^Initialized empty" test-verbose/out+ >test-verbose/out &&
check_sub_test_lib_test test-verbose <<-\EOF
> expecting success: true
> ok 1 - passing test
> Z
> expecting success of 1234.2 '\''test with output'\'': echo foo
> expecting success: echo foo
> foo
> ok 2 - test with output
> Z
> expecting success of 1234.3 '\''failing test'\'': false
> expecting success: false
> not ok 3 - failing test
> # false
> Z
@ -301,18 +300,18 @@ test_expect_success C_LOCALE_OUTPUT 'test --verbose' '
'
test_expect_success 'test --verbose-only' '
run_sub_test_lib_test_err \
t2345-verbose-only-2 "test verbose-only=2" \
test_must_fail run_sub_test_lib_test \
test-verbose-only-2 "test verbose-only=2" \
--verbose-only=2 <<-\EOF &&
test_expect_success "passing test" true
test_expect_success "test with output" "echo foo"
test_expect_success "failing test" false
test_done
EOF
check_sub_test_lib_test t2345-verbose-only-2 <<-\EOF
check_sub_test_lib_test test-verbose-only-2 <<-\EOF
> ok 1 - passing test
> Z
> expecting success of 2345.2 '\''test with output'\'': echo foo
> expecting success: echo foo
> foo
> ok 2 - test with output
> Z
@ -392,44 +391,6 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' "
)
"
test_expect_success 'GIT_SKIP_TESTS entire suite' "
(
GIT_SKIP_TESTS='git' && export GIT_SKIP_TESTS &&
run_sub_test_lib_test git-skip-tests-entire-suite \
'GIT_SKIP_TESTS entire suite' <<-\\EOF &&
for i in 1 2 3
do
test_expect_success \"passing test #\$i\" 'true'
done
test_done
EOF
check_sub_test_lib_test git-skip-tests-entire-suite <<-\\EOF
> 1..0 # SKIP skip all tests in git
EOF
)
"
test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' "
(
GIT_SKIP_TESTS='notgit' && export GIT_SKIP_TESTS &&
run_sub_test_lib_test git-skip-tests-unmatched-suite \
'GIT_SKIP_TESTS does not skip unmatched suite' <<-\\EOF &&
for i in 1 2 3
do
test_expect_success \"passing test #\$i\" 'true'
done
test_done
EOF
check_sub_test_lib_test git-skip-tests-unmatched-suite <<-\\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 - passing test #3
> # passed all 3 test(s)
> 1..3
EOF
)
"
test_expect_success '--run basic' "
run_sub_test_lib_test run-basic \
'--run basic' --run='1 3 5' <<-\\EOF &&
@ -834,7 +795,7 @@ then
fi
test_expect_success 'tests clean up even on failures' "
run_sub_test_lib_test_err \
test_must_fail run_sub_test_lib_test \
failing-cleanup 'Failing tests with cleanup commands' <<-\\EOF &&
test_expect_success 'tests clean up even after a failure' '
touch clean-after-failure &&
@ -863,7 +824,7 @@ test_expect_success 'tests clean up even on failures' "
"
test_expect_success 'test_atexit is run' "
run_sub_test_lib_test_err \
test_must_fail run_sub_test_lib_test \
atexit-cleanup 'Run atexit commands' -i <<-\\EOF &&
test_expect_success 'tests clean up even after a failure' '
> ../../clean-atexit &&
@ -917,40 +878,6 @@ test_expect_success 'test_oid can look up data for SHA-256' '
test "$hexsz" -eq 64
'
test_expect_success 'test_bool_env' '
(
sane_unset envvar &&
test_bool_env envvar true &&
! test_bool_env envvar false &&
envvar= &&
export envvar &&
! test_bool_env envvar true &&
! test_bool_env envvar false &&
envvar=true &&
test_bool_env envvar true &&
test_bool_env envvar false &&
envvar=false &&
! test_bool_env envvar true &&
! test_bool_env envvar false &&
envvar=invalid &&
# When encountering an invalid bool value, test_bool_env
# prints its error message to the original stderr of the
# test script, hence the redirection of fd 7, and aborts
# with "exit 1", hence the subshell.
! ( test_bool_env envvar true ) 7>err &&
grep "error: test_bool_env requires bool values" err &&
envvar=true &&
! ( test_bool_env envvar invalid ) 7>err &&
grep "error: test_bool_env requires bool values" err
)
'
################################################################
# Basics of the basics

View file

@ -5,16 +5,19 @@ test_description=gitattributes
. ./test-lib.sh
attr_check () {
path="$1" expect="$2" git_opts="$3" &&
path="$1" expect="$2"
git $git_opts check-attr test -- "$path" >actual 2>err &&
echo "$path: test: $expect" >expect &&
git $3 check-attr test -- "$path" >actual 2>err &&
echo "$path: test: $2" >expect &&
test_cmp expect actual &&
test_must_be_empty err
test_line_count = 0 err
}
attr_check_quote () {
path="$1" quoted_path="$2" expect="$3" &&
path="$1"
quoted_path="$2"
expect="$3"
git check-attr test -- "$path" >actual &&
echo "\"$quoted_path\": test: $expect" >expect &&
@ -24,7 +27,7 @@ attr_check_quote () {
test_expect_success 'open-quoted pathname' '
echo "\"a test=a" >.gitattributes &&
attr_check a unspecified
test_must_fail attr_check a a
'
@ -109,20 +112,20 @@ test_expect_success 'attribute test' '
test_expect_success 'attribute matching is case sensitive when core.ignorecase=0' '
attr_check F unspecified "-c core.ignorecase=0" &&
attr_check a/F unspecified "-c core.ignorecase=0" &&
attr_check a/c/F unspecified "-c core.ignorecase=0" &&
attr_check a/G unspecified "-c core.ignorecase=0" &&
attr_check a/B/g a/g "-c core.ignorecase=0" &&
attr_check a/b/G unspecified "-c core.ignorecase=0" &&
attr_check a/b/H unspecified "-c core.ignorecase=0" &&
attr_check a/b/D/g a/g "-c core.ignorecase=0" &&
attr_check oNoFf unspecified "-c core.ignorecase=0" &&
attr_check oFfOn unspecified "-c core.ignorecase=0" &&
test_must_fail attr_check F f "-c core.ignorecase=0" &&
test_must_fail attr_check a/F f "-c core.ignorecase=0" &&
test_must_fail attr_check a/c/F f "-c core.ignorecase=0" &&
test_must_fail attr_check a/G a/g "-c core.ignorecase=0" &&
test_must_fail attr_check a/B/g a/b/g "-c core.ignorecase=0" &&
test_must_fail attr_check a/b/G a/b/g "-c core.ignorecase=0" &&
test_must_fail attr_check a/b/H a/b/h "-c core.ignorecase=0" &&
test_must_fail attr_check a/b/D/g "a/b/d/*" "-c core.ignorecase=0" &&
test_must_fail attr_check oNoFf unset "-c core.ignorecase=0" &&
test_must_fail attr_check oFfOn set "-c core.ignorecase=0" &&
attr_check NO unspecified "-c core.ignorecase=0" &&
attr_check a/b/D/NO unspecified "-c core.ignorecase=0" &&
test_must_fail attr_check a/b/D/NO "a/b/d/*" "-c core.ignorecase=0" &&
attr_check a/b/d/YES a/b/d/* "-c core.ignorecase=0" &&
attr_check a/E/f f "-c core.ignorecase=0"
test_must_fail attr_check a/E/f "A/e/F" "-c core.ignorecase=0"
'
@ -146,8 +149,8 @@ test_expect_success 'attribute matching is case insensitive when core.ignorecase
'
test_expect_success CASE_INSENSITIVE_FS 'additional case insensitivity tests' '
attr_check a/B/D/g a/g "-c core.ignorecase=0" &&
attr_check A/B/D/NO unspecified "-c core.ignorecase=0" &&
test_must_fail attr_check a/B/D/g "a/b/d/*" "-c core.ignorecase=0" &&
test_must_fail attr_check A/B/D/NO "a/b/d/*" "-c core.ignorecase=0" &&
attr_check A/b/h a/b/h "-c core.ignorecase=1" &&
attr_check a/B/D/g "a/b/d/*" "-c core.ignorecase=1" &&
attr_check A/B/D/NO "a/b/d/*" "-c core.ignorecase=1"
@ -241,7 +244,7 @@ EOF
git check-attr foo -- "a/b/f" >>actual 2>>err &&
git check-attr foo -- "a/b/c/f" >>actual 2>>err &&
test_cmp expect actual &&
test_must_be_empty err
test_line_count = 0 err
'
test_expect_success '"**" with no slashes test' '
@ -262,7 +265,7 @@ EOF
git check-attr foo -- "a/b/f" >>actual 2>>err &&
git check-attr foo -- "a/b/c/f" >>actual 2>>err &&
test_cmp expect actual &&
test_must_be_empty err
test_line_count = 0 err
'
test_expect_success 'using --git-dir and --work-tree' '

View file

@ -424,24 +424,9 @@ test_expect_success 'local ignore inside a sub-directory with --verbose' '
)
'
test_expect_success 'nested include of negated pattern' '
expect "" &&
test_check_ignore "a/b/one" 1
'
test_expect_success 'nested include of negated pattern with -q' '
expect "" &&
test_check_ignore "-q a/b/one" 1
'
test_expect_success 'nested include of negated pattern with -v' '
expect "a/b/.gitignore:8:!on* a/b/one" &&
test_check_ignore "-v a/b/one" 0
'
test_expect_success 'nested include of negated pattern with -v -n' '
expect "a/b/.gitignore:8:!on* a/b/one" &&
test_check_ignore "-v -n a/b/one" 0
test_expect_success_multi 'nested include' \
'a/b/.gitignore:8:!on* a/b/one' '
test_check_ignore "a/b/one"
'
############################################################################
@ -475,6 +460,7 @@ test_expect_success 'cd to ignored sub-directory' '
expect_from_stdin <<-\EOF &&
foo
twoooo
../one
seven
../../one
EOF
@ -557,6 +543,7 @@ test_expect_success 'global ignore' '
globalthree
a/globalthree
a/per-repo
globaltwo
EOF
test_check_ignore "globalone per-repo globalthree a/globalthree a/per-repo not-ignored globaltwo"
'
@ -599,7 +586,17 @@ EOF
cat <<-\EOF >expected-default
one
a/one
a/b/on
a/b/one
a/b/one one
a/b/one two
"a/b/one\"three"
a/b/two
a/b/twooo
globaltwo
a/globaltwo
a/b/globaltwo
b/globaltwo
EOF
cat <<-EOF >expected-verbose
.gitignore:1:one one
@ -699,12 +696,8 @@ cat <<-EOF >expected-all
$global_excludes:2:!globaltwo ../b/globaltwo
:: c/not-ignored
EOF
cat <<-EOF >expected-default
../one
one
b/twooo
EOF
grep -v '^:: ' expected-all >expected-verbose
sed -e 's/.* //' expected-verbose >expected-default
broken_c_unquote stdin >stdin0

View file

@ -37,11 +37,4 @@ test_expect_success 'looping aliases - internal execution' '
# test_i18ngrep "^fatal: alias loop detected: expansion of" output
#'
test_expect_success 'run-command formats empty args properly' '
test_must_fail env GIT_TRACE=1 git frotz a "" b " " c 2>actual.raw &&
sed -ne "/run_command:/s/.*trace: run_command: //p" actual.raw >actual &&
echo "git-frotz a '\'''\'' b '\'' '\'' c" >expect &&
test_cmp expect actual
'
test_done

View file

@ -159,8 +159,8 @@ test_expect_success 'checkout with autocrlf=input' '
rm -f tmp one dir/two three &&
git config core.autocrlf input &&
git read-tree --reset -u HEAD &&
! has_cr one &&
! has_cr dir/two &&
test_must_fail has_cr one &&
test_must_fail has_cr dir/two &&
git update-index -- one dir/two &&
test "$one" = $(git hash-object --stdin <one) &&
test "$two" = $(git hash-object --stdin <dir/two) &&
@ -237,9 +237,9 @@ test_expect_success '.gitattributes says two is binary' '
git config core.autocrlf true &&
git read-tree --reset -u HEAD &&
! has_cr dir/two &&
test_must_fail has_cr dir/two &&
verbose has_cr one &&
! has_cr three
test_must_fail has_cr three
'
test_expect_success '.gitattributes says two is input' '
@ -248,7 +248,7 @@ test_expect_success '.gitattributes says two is input' '
echo "two crlf=input" >.gitattributes &&
git read-tree --reset -u HEAD &&
! has_cr dir/two
test_must_fail has_cr dir/two
'
test_expect_success '.gitattributes says two and three are text' '
@ -270,7 +270,7 @@ test_expect_success 'in-tree .gitattributes (1)' '
rm -rf tmp one dir .gitattributes patch.file three &&
git read-tree --reset -u HEAD &&
! has_cr one &&
test_must_fail has_cr one &&
verbose has_cr three
'
@ -280,7 +280,7 @@ test_expect_success 'in-tree .gitattributes (2)' '
git read-tree --reset HEAD &&
git checkout-index -f -q -u -a &&
! has_cr one &&
test_must_fail has_cr one &&
verbose has_cr three
'
@ -291,7 +291,7 @@ test_expect_success 'in-tree .gitattributes (3)' '
git checkout-index -u .gitattributes &&
git checkout-index -u one dir/two three &&
! has_cr one &&
test_must_fail has_cr one &&
verbose has_cr three
'
@ -302,7 +302,7 @@ test_expect_success 'in-tree .gitattributes (4)' '
git checkout-index -u one dir/two three &&
git checkout-index -u .gitattributes &&
! has_cr one &&
test_must_fail has_cr one &&
verbose has_cr three
'

View file

@ -35,7 +35,7 @@ filter_git () {
# Compare two files and ensure that `clean` and `smudge` respectively are
# called at least once if specified in the `expect` file. The actual
# invocation count is not relevant because their number can vary.
# c.f. http://lore.kernel.org/git/xmqqshv18i8i.fsf@gitster.mtv.corp.google.com/
# c.f. http://public-inbox.org/git/xmqqshv18i8i.fsf@gitster.mtv.corp.google.com/
test_cmp_count () {
expect=$1
actual=$2
@ -50,7 +50,7 @@ test_cmp_count () {
# Compare two files but exclude all `clean` invocations because Git can
# call `clean` zero or more times.
# c.f. http://lore.kernel.org/git/xmqqshv18i8i.fsf@gitster.mtv.corp.google.com/
# c.f. http://public-inbox.org/git/xmqqshv18i8i.fsf@gitster.mtv.corp.google.com/
test_cmp_exclude_clean () {
expect=$1
actual=$2
@ -390,9 +390,6 @@ test_expect_success PERL 'required process filter should filter data' '
EOF
test_cmp_exclude_clean expected.log debug.log &&
# Make sure that the file appears dirty, so checkout below has to
# run the configured filter.
touch test.r &&
filter_git checkout --quiet --no-progress empty-branch &&
cat >expected.log <<-EOF &&
START
@ -795,6 +792,7 @@ test_expect_success PERL 'missing file in delayed checkout' '
rm -rf repo-cloned &&
test_must_fail git clone repo repo-cloned 2>git-stderr.log &&
cat git-stderr.log &&
grep "error: .missing-delay\.a. was not filtered properly" git-stderr.log
'

View file

@ -215,7 +215,7 @@ stats_ascii () {
}
# construct the attr/ returned by git ls-files --eol
# contruct the attr/ returned by git ls-files --eol
# Take none (=empty), one or two args
# convert.c: eol=XX overrides text=auto
attr_ascii () {

View file

@ -17,7 +17,7 @@ test_lazy_prereq NO_UTF32_BOM '
write_utf16 () {
if test_have_prereq NO_UTF16_BOM
then
printf '\376\377'
printf '\xfe\xff'
fi &&
iconv -f UTF-8 -t UTF-16
}
@ -25,7 +25,7 @@ write_utf16 () {
write_utf32 () {
if test_have_prereq NO_UTF32_BOM
then
printf '\0\0\376\377'
printf '\x00\x00\xfe\xff'
fi &&
iconv -f UTF-8 -t UTF-32
}
@ -40,7 +40,7 @@ test_expect_success 'setup test files' '
printf "$text" | write_utf16 >test.utf16.raw &&
printf "$text" | write_utf32 >test.utf32.raw &&
printf "\377\376" >test.utf16lebom.raw &&
printf "$text" | iconv -f UTF-8 -t UTF-16LE >>test.utf16lebom.raw &&
printf "$text" | iconv -f UTF-8 -t UTF-32LE >>test.utf16lebom.raw &&
# Line ending tests
printf "one\ntwo\nthree\n" >lf.utf8.raw &&
@ -280,43 +280,4 @@ test_expect_success ICONV_SHIFT_JIS 'check roundtrip encoding' '
git reset
'
# $1: checkout encoding
# $2: test string
# $3: binary test string in checkout encoding
test_commit_utf8_checkout_other () {
encoding="$1"
orig_string="$2"
expect_bytes="$3"
test_expect_success "Commit UTF-8, checkout $encoding" '
test_when_finished "git checkout HEAD -- .gitattributes" &&
test_ext="commit_utf8_checkout_$encoding" &&
test_file="test.$test_ext" &&
# Commit as UTF-8
echo "*.$test_ext text working-tree-encoding=UTF-8" >.gitattributes &&
printf "$orig_string" >$test_file &&
git add $test_file &&
git commit -m "Test data" &&
# Checkout in tested encoding
rm $test_file &&
echo "*.$test_ext text working-tree-encoding=$encoding" >.gitattributes &&
git checkout HEAD -- $test_file &&
# Test
printf $expect_bytes >$test_file.raw &&
test_cmp_bin $test_file.raw $test_file
'
}
test_commit_utf8_checkout_other "UTF-8" "Test Тест" "\124\145\163\164\040\320\242\320\265\321\201\321\202"
test_commit_utf8_checkout_other "UTF-16LE" "Test Тест" "\124\000\145\000\163\000\164\000\040\000\042\004\065\004\101\004\102\004"
test_commit_utf8_checkout_other "UTF-16BE" "Test Тест" "\000\124\000\145\000\163\000\164\000\040\004\042\004\065\004\101\004\102"
test_commit_utf8_checkout_other "UTF-16LE-BOM" "Test Тест" "\377\376\124\000\145\000\163\000\164\000\040\000\042\004\065\004\101\004\102\004"
test_commit_utf8_checkout_other "UTF-16BE-BOM" "Test Тест" "\376\377\000\124\000\145\000\163\000\164\000\040\004\042\004\065\004\101\004\102"
test_commit_utf8_checkout_other "UTF-32LE" "Test Тест" "\124\000\000\000\145\000\000\000\163\000\000\000\164\000\000\000\040\000\000\000\042\004\000\000\065\004\000\000\101\004\000\000\102\004\000\000"
test_commit_utf8_checkout_other "UTF-32BE" "Test Тест" "\000\000\000\124\000\000\000\145\000\000\000\163\000\000\000\164\000\000\000\040\000\000\004\042\000\000\004\065\000\000\004\101\000\000\004\102"
test_done

View file

@ -23,8 +23,6 @@ usage: test-tool parse-options <options>
-j <n> get a integer, too
-m, --magnitude <n> get a magnitude
--set23 set integer to 23
--mode1 set integer to 1 (cmdmode option)
--mode2 set integer to 2 (cmdmode option)
-L, --length <str> get length of <str>
-F, --file <file> set file to <file>
@ -244,7 +242,7 @@ test_expect_success 'Alias options do not contribute to abbreviation' '
'
cat >typo.err <<\EOF
error: did you mean `--boolean` (with two dashes)?
error: did you mean `--boolean` (with two dashes ?)
EOF
test_expect_success 'detect possible typos' '
@ -254,7 +252,7 @@ test_expect_success 'detect possible typos' '
'
cat >typo.err <<\EOF
error: did you mean `--ambiguous` (with two dashes)?
error: did you mean `--ambiguous` (with two dashes ?)
EOF
test_expect_success 'detect possible typos' '
@ -326,22 +324,6 @@ test_expect_success 'OPT_NEGBIT() works' '
test-tool parse-options --expect="boolean: 6" -bb --no-neg-or4
'
test_expect_success 'OPT_CMDMODE() works' '
test-tool parse-options --expect="integer: 1" --mode1
'
test_expect_success 'OPT_CMDMODE() detects incompatibility' '
test_must_fail test-tool parse-options --mode1 --mode2 >output 2>output.err &&
test_must_be_empty output &&
test_i18ngrep "incompatible with --mode" output.err
'
test_expect_success 'OPT_CMDMODE() detects incompatibility with something else' '
test_must_fail test-tool parse-options --set23 --mode2 >output 2>output.err &&
test_must_be_empty output &&
test_i18ngrep "incompatible with something else" output.err
'
test_expect_success 'OPT_COUNTUP() with PARSE_OPT_NODASH works' '
test-tool parse-options --expect="boolean: 6" + + + + + +
'
@ -417,11 +399,4 @@ test_expect_success 'GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS works' '
test-tool parse-options --ye
'
test_expect_success '--end-of-options treats remainder as args' '
test-tool parse-options \
--expect="verbose: -1" \
--expect="arg 00: --verbose" \
--end-of-options --verbose
'
test_done

View file

@ -131,24 +131,4 @@ $test_unicode 'merge (silent unicode normalization)' '
git merge topic
'
test_expect_success CASE_INSENSITIVE_FS 'checkout with no pathspec and a case insensitive fs' '
git init repo &&
(
cd repo &&
>Gitweb &&
git add Gitweb &&
git commit -m "add Gitweb" &&
git checkout --orphan todo &&
git reset --hard &&
mkdir -p gitweb/subdir &&
>gitweb/subdir/file &&
git add gitweb &&
git commit -m "add gitweb/subdir/file" &&
git checkout master
)
'
test_done

View file

@ -165,15 +165,6 @@ test_expect_success 'absolute path rejects the empty string' '
test_must_fail test-tool path-utils absolute_path ""
'
test_expect_success MINGW '<drive-letter>:\\abc is an absolute path' '
for letter in : \" C Z 1 ä
do
path=$letter:\\abc &&
absolute="$(test-tool path-utils absolute_path "$path")" &&
test "$path" = "$absolute" || return 1
done
'
test_expect_success 'real path rejects the empty string' '
test_must_fail test-tool path-utils real_path ""
'
@ -294,13 +285,9 @@ test_git_path GIT_OBJECT_DIRECTORY=foo objects/foo foo/foo
test_git_path GIT_OBJECT_DIRECTORY=foo objects2 .git/objects2
test_expect_success 'setup common repository' 'git --git-dir=bar init'
test_git_path GIT_COMMON_DIR=bar index .git/index
test_git_path GIT_COMMON_DIR=bar index.lock .git/index.lock
test_git_path GIT_COMMON_DIR=bar HEAD .git/HEAD
test_git_path GIT_COMMON_DIR=bar logs/HEAD .git/logs/HEAD
test_git_path GIT_COMMON_DIR=bar logs/HEAD.lock .git/logs/HEAD.lock
test_git_path GIT_COMMON_DIR=bar logs/refs/bisect/foo .git/logs/refs/bisect/foo
test_git_path GIT_COMMON_DIR=bar logs/refs bar/logs/refs
test_git_path GIT_COMMON_DIR=bar logs/refs/ bar/logs/refs/
test_git_path GIT_COMMON_DIR=bar logs/refs/bisec/foo bar/logs/refs/bisec/foo
test_git_path GIT_COMMON_DIR=bar logs/refs/bisec bar/logs/refs/bisec
test_git_path GIT_COMMON_DIR=bar logs/refs/bisectfoo bar/logs/refs/bisectfoo
@ -436,9 +423,6 @@ test_expect_success 'match .gitmodules' '
~1000000 \
~9999999 \
\
.gitmodules:\$DATA \
"gitmod~4 . :\$DATA" \
\
--not \
".gitmodules x" \
".gitmodules .x" \
@ -463,34 +447,7 @@ test_expect_success 'match .gitmodules' '
\
GI7EB~1 \
GI7EB~01 \
GI7EB~1X \
\
.gitmodules,:\$DATA
'
test_expect_success MINGW 'is_valid_path() on Windows' '
test-tool path-utils is_valid_path \
win32 \
"win32 x" \
../hello.txt \
C:\\git \
comm \
conout.c \
lptN \
\
--not \
"win32 " \
"win32 /x " \
"win32." \
"win32 . ." \
.../hello.txt \
colon:test \
"AUX.c" \
"abc/conOut\$ .xyz/test" \
lpt8 \
"lpt*" \
Nul \
"PRN./abc"
GI7EB~1X
'
test_done

View file

@ -12,10 +12,6 @@ cat >hello-script <<-EOF
cat hello-script
EOF
test_expect_success MINGW 'subprocess inherits only std handles' '
test-tool run-command inherited-handle
'
test_expect_success 'start_command reports ENOENT (slash)' '
test-tool run-command start-command-ENOENT ./does-not-exist 2>err &&
test_i18ngrep "\./does-not-exist" err
@ -214,23 +210,10 @@ test_expect_success MINGW 'verify curlies are quoted properly' '
test_cmp expect actual
'
test_expect_success MINGW 'can spawn .bat with argv[0] containing spaces' '
bat="$TRASH_DIRECTORY/bat with spaces in name.bat" &&
# Every .bat invocation will log its arguments to file "out"
rm -f out &&
echo "echo %* >>out" >"$bat" &&
# Ask git to invoke .bat; clone will fail due to fake SSH helper
test_must_fail env GIT_SSH="$bat" git clone myhost:src ssh-clone &&
# Spawning .bat can fail if there are two quoted cmd.exe arguments.
# .bat itself is first (due to spaces in name), so just one more is
# needed to verify. GIT_SSH will invoke .bat multiple times:
# 1) -G myhost
# 2) myhost "git-upload-pack src"
# First invocation will always succeed. Test the second one.
grep "git-upload-pack" out
test_expect_success MINGW 'can spawn with argv[0] containing spaces' '
cp "$GIT_BUILD_DIR/t/helper/test-fake-ssh$X" ./ &&
test_must_fail "$PWD/test-fake-ssh$X" 2>err &&
grep TRASH_DIRECTORY err
'
test_done

View file

@ -1,108 +0,0 @@
#!/bin/sh
test_description='Test parse_pathspec_file()'
. ./test-lib.sh
test_expect_success 'one item from stdin' '
cat >expect <<-\EOF &&
fileA.t
EOF
echo fileA.t |
test-tool parse-pathspec-file --pathspec-from-file=- >actual &&
test_cmp expect actual
'
test_expect_success 'one item from file' '
cat >expect <<-\EOF &&
fileA.t
EOF
echo fileA.t >list &&
test-tool parse-pathspec-file --pathspec-from-file=list >actual &&
test_cmp expect actual
'
test_expect_success 'NUL delimiters' '
cat >expect <<-\EOF &&
fileA.t
fileB.t
EOF
printf "fileA.t\0fileB.t\0" |
test-tool parse-pathspec-file --pathspec-from-file=- --pathspec-file-nul >actual &&
test_cmp expect actual
'
test_expect_success 'LF delimiters' '
cat >expect <<-\EOF &&
fileA.t
fileB.t
EOF
printf "fileA.t\nfileB.t\n" |
test-tool parse-pathspec-file --pathspec-from-file=- >actual &&
test_cmp expect actual
'
test_expect_success 'no trailing delimiter' '
cat >expect <<-\EOF &&
fileA.t
fileB.t
EOF
printf "fileA.t\nfileB.t" |
test-tool parse-pathspec-file --pathspec-from-file=- >actual &&
test_cmp expect actual
'
test_expect_success 'CRLF delimiters' '
cat >expect <<-\EOF &&
fileA.t
fileB.t
EOF
printf "fileA.t\r\nfileB.t\r\n" |
test-tool parse-pathspec-file --pathspec-from-file=- >actual &&
test_cmp expect actual
'
test_expect_success 'quotes' '
cat >expect <<-\EOF &&
fileA.t
EOF
cat >list <<-\EOF &&
"file\101.t"
EOF
test-tool parse-pathspec-file --pathspec-from-file=list >actual &&
test_cmp expect actual
'
test_expect_success '--pathspec-file-nul takes quotes literally' '
# Note: there is an extra newline because --pathspec-file-nul takes
# input \n literally, too
cat >expect <<-\EOF &&
"file\101.t"
EOF
cat >list <<-\EOF &&
"file\101.t"
EOF
test-tool parse-pathspec-file --pathspec-from-file=list --pathspec-file-nul >actual &&
test_cmp expect actual
'
test_done

View file

@ -21,10 +21,9 @@ generate_expected_cache_tree_rec () {
parent="$2" &&
# ls-files might have foo/bar, foo/bar/baz, and foo/bar/quux
# We want to count only foo because it's the only direct child
git ls-files >files &&
subtrees=$(grep / files|cut -d / -f 1|uniq) &&
subtrees=$(git ls-files|grep /|cut -d / -f 1|uniq) &&
subtree_count=$(echo "$subtrees"|awk -v c=0 '$1 != "" {++c} END {print c}') &&
entries=$(wc -l <files) &&
entries=$(git ls-files|wc -l) &&
printf "SHA $dir (%d entries, %d subtrees)\n" "$entries" "$subtree_count" &&
for subtree in $subtrees
do

View file

@ -130,11 +130,11 @@ test_expect_success 'perf stream, child processes' '
d0|main|version|||||$V
d0|main|start||_T_ABS_|||_EXE_ trace2 004child test-tool trace2 004child test-tool trace2 001return 0
d0|main|cmd_name|||||trace2 (trace2)
d0|main|child_start||_T_ABS_|||[ch0] class:? argv:[test-tool trace2 004child test-tool trace2 001return 0]
d0|main|child_start||_T_ABS_|||[ch0] class:? argv: test-tool trace2 004child test-tool trace2 001return 0
d1|main|version|||||$V
d1|main|start||_T_ABS_|||_EXE_ trace2 004child test-tool trace2 001return 0
d1|main|cmd_name|||||trace2 (trace2/trace2)
d1|main|child_start||_T_ABS_|||[ch0] class:? argv:[test-tool trace2 001return 0]
d1|main|child_start||_T_ABS_|||[ch0] class:? argv: test-tool trace2 001return 0
d2|main|version|||||$V
d2|main|start||_T_ABS_|||_EXE_ trace2 001return 0
d2|main|cmd_name|||||trace2 (trace2/trace2/trace2)

View file

@ -265,23 +265,4 @@ test_expect_success JSON_PP 'using global config, event stream, error event' '
test_cmp expect actual
'
test_expect_success 'discard traces when there are too many files' '
mkdir trace_target_dir &&
test_when_finished "rm -r trace_target_dir" &&
(
GIT_TRACE2_MAX_FILES=5 &&
export GIT_TRACE2_MAX_FILES &&
cd trace_target_dir &&
test_seq $GIT_TRACE2_MAX_FILES >../expected_filenames.txt &&
xargs touch <../expected_filenames.txt &&
cd .. &&
GIT_TRACE2_EVENT="$(pwd)/trace_target_dir" test-tool trace2 001return 0
) &&
echo git-trace2-discard >>expected_filenames.txt &&
ls trace_target_dir >ls_output.txt &&
test_cmp expected_filenames.txt ls_output.txt &&
head -n1 trace_target_dir/git-trace2-discard | grep \"event\":\"version\" &&
head -n2 trace_target_dir/git-trace2-discard | tail -n1 | grep \"event\":\"too_many_files\"
'
test_done

View file

@ -22,11 +22,6 @@ test_expect_success 'setup helper scripts' '
exit 0
EOF
write_script git-credential-quit <<-\EOF &&
. ./dump
echo quit=1
EOF
write_script git-credential-verbatim <<-\EOF &&
user=$1; shift
pass=$1; shift
@ -40,71 +35,43 @@ test_expect_success 'setup helper scripts' '
test_expect_success 'credential_fill invokes helper' '
check fill "verbatim foo bar" <<-\EOF
protocol=http
host=example.com
--
protocol=http
host=example.com
username=foo
password=bar
--
verbatim: get
verbatim: protocol=http
verbatim: host=example.com
EOF
'
test_expect_success 'credential_fill invokes multiple helpers' '
check fill useless "verbatim foo bar" <<-\EOF
protocol=http
host=example.com
--
protocol=http
host=example.com
username=foo
password=bar
--
useless: get
useless: protocol=http
useless: host=example.com
verbatim: get
verbatim: protocol=http
verbatim: host=example.com
EOF
'
test_expect_success 'credential_fill stops when we get a full response' '
check fill "verbatim one two" "verbatim three four" <<-\EOF
protocol=http
host=example.com
--
protocol=http
host=example.com
username=one
password=two
--
verbatim: get
verbatim: protocol=http
verbatim: host=example.com
EOF
'
test_expect_success 'credential_fill continues through partial response' '
check fill "verbatim one \"\"" "verbatim two three" <<-\EOF
protocol=http
host=example.com
--
protocol=http
host=example.com
username=two
password=three
--
verbatim: get
verbatim: protocol=http
verbatim: host=example.com
verbatim: get
verbatim: protocol=http
verbatim: host=example.com
verbatim: username=one
EOF
'
@ -130,20 +97,14 @@ test_expect_success 'credential_fill passes along metadata' '
test_expect_success 'credential_approve calls all helpers' '
check approve useless "verbatim one two" <<-\EOF
protocol=http
host=example.com
username=foo
password=bar
--
--
useless: store
useless: protocol=http
useless: host=example.com
useless: username=foo
useless: password=bar
verbatim: store
verbatim: protocol=http
verbatim: host=example.com
verbatim: username=foo
verbatim: password=bar
EOF
@ -151,8 +112,6 @@ test_expect_success 'credential_approve calls all helpers' '
test_expect_success 'do not bother storing password-less credential' '
check approve useless <<-\EOF
protocol=http
host=example.com
username=foo
--
--
@ -162,20 +121,14 @@ test_expect_success 'do not bother storing password-less credential' '
test_expect_success 'credential_reject calls all helpers' '
check reject useless "verbatim one two" <<-\EOF
protocol=http
host=example.com
username=foo
password=bar
--
--
useless: erase
useless: protocol=http
useless: host=example.com
useless: username=foo
useless: password=bar
verbatim: erase
verbatim: protocol=http
verbatim: host=example.com
verbatim: username=foo
verbatim: password=bar
EOF
@ -183,49 +136,33 @@ test_expect_success 'credential_reject calls all helpers' '
test_expect_success 'usernames can be preserved' '
check fill "verbatim \"\" three" <<-\EOF
protocol=http
host=example.com
username=one
--
protocol=http
host=example.com
username=one
password=three
--
verbatim: get
verbatim: protocol=http
verbatim: host=example.com
verbatim: username=one
EOF
'
test_expect_success 'usernames can be overridden' '
check fill "verbatim two three" <<-\EOF
protocol=http
host=example.com
username=one
--
protocol=http
host=example.com
username=two
password=three
--
verbatim: get
verbatim: protocol=http
verbatim: host=example.com
verbatim: username=one
EOF
'
test_expect_success 'do not bother completing already-full credential' '
check fill "verbatim three four" <<-\EOF
protocol=http
host=example.com
username=one
password=two
--
protocol=http
host=example.com
username=one
password=two
--
@ -237,31 +174,23 @@ test_expect_success 'do not bother completing already-full credential' '
# askpass helper is run, we know the internal getpass is working.
test_expect_success 'empty helper list falls back to internal getpass' '
check fill <<-\EOF
protocol=http
host=example.com
--
protocol=http
host=example.com
username=askpass-username
password=askpass-password
--
askpass: Username for '\''http://example.com'\'':
askpass: Password for '\''http://askpass-username@example.com'\'':
askpass: Username:
askpass: Password:
EOF
'
test_expect_success 'internal getpass does not ask for known username' '
check fill <<-\EOF
protocol=http
host=example.com
username=foo
--
protocol=http
host=example.com
username=foo
password=askpass-password
--
askpass: Password for '\''http://foo@example.com'\'':
askpass: Password:
EOF
'
@ -273,11 +202,7 @@ HELPER="!f() {
test_expect_success 'respect configured credentials' '
test_config credential.helper "$HELPER" &&
check fill <<-\EOF
protocol=http
host=example.com
--
protocol=http
host=example.com
username=foo
password=bar
--
@ -315,57 +240,6 @@ test_expect_success 'do not match configured credential' '
EOF
'
test_expect_success 'match multiple configured helpers' '
test_config credential.helper "verbatim \"\" \"\"" &&
test_config credential.https://example.com.helper "$HELPER" &&
check fill <<-\EOF
protocol=https
host=example.com
path=repo.git
--
protocol=https
host=example.com
username=foo
password=bar
--
verbatim: get
verbatim: protocol=https
verbatim: host=example.com
EOF
'
test_expect_success 'match multiple configured helpers with URLs' '
test_config credential.https://example.com/repo.git.helper "verbatim \"\" \"\"" &&
test_config credential.https://example.com.helper "$HELPER" &&
check fill <<-\EOF
protocol=https
host=example.com
path=repo.git
--
protocol=https
host=example.com
username=foo
password=bar
--
verbatim: get
verbatim: protocol=https
verbatim: host=example.com
EOF
'
test_expect_success 'match percent-encoded values' '
test_config credential.https://example.com/%2566.git.helper "$HELPER" &&
check fill <<-\EOF
url=https://example.com/%2566.git
--
protocol=https
host=example.com
username=foo
password=bar
--
EOF
'
test_expect_success 'pull username from config' '
test_config credential.https://example.com.username foo &&
check fill <<-\EOF
@ -381,63 +255,6 @@ test_expect_success 'pull username from config' '
EOF
'
test_expect_success 'honors username from URL over helper (URL)' '
test_config credential.https://example.com.username bob &&
test_config credential.https://example.com.helper "verbatim \"\" bar" &&
check fill <<-\EOF
url=https://alice@example.com
--
protocol=https
host=example.com
username=alice
password=bar
--
verbatim: get
verbatim: protocol=https
verbatim: host=example.com
verbatim: username=alice
EOF
'
test_expect_success 'honors username from URL over helper (components)' '
test_config credential.https://example.com.username bob &&
test_config credential.https://example.com.helper "verbatim \"\" bar" &&
check fill <<-\EOF
protocol=https
host=example.com
username=alice
--
protocol=https
host=example.com
username=alice
password=bar
--
verbatim: get
verbatim: protocol=https
verbatim: host=example.com
verbatim: username=alice
EOF
'
test_expect_success 'last matching username wins' '
test_config credential.https://example.com/path.git.username bob &&
test_config credential.https://example.com.username alice &&
test_config credential.https://example.com.helper "verbatim \"\" bar" &&
check fill <<-\EOF
url=https://example.com/path.git
--
protocol=https
host=example.com
username=alice
password=bar
--
verbatim: get
verbatim: protocol=https
verbatim: host=example.com
verbatim: username=alice
EOF
'
test_expect_success 'http paths can be part of context' '
check fill "verbatim foo bar" <<-\EOF &&
protocol=https
@ -472,107 +289,23 @@ test_expect_success 'http paths can be part of context' '
EOF
'
test_expect_success 'context uses urlmatch' '
test_config "credential.https://*.org.useHttpPath" true &&
check fill "verbatim foo bar" <<-\EOF
protocol=https
host=example.org
path=foo.git
--
protocol=https
host=example.org
path=foo.git
username=foo
password=bar
--
verbatim: get
verbatim: protocol=https
verbatim: host=example.org
verbatim: path=foo.git
EOF
'
test_expect_success 'helpers can abort the process' '
test_must_fail git \
-c credential.helper=quit \
-c credential.helper="!f() { echo quit=1; }; f" \
-c credential.helper="verbatim foo bar" \
credential fill >stdout 2>stderr <<-\EOF &&
protocol=http
host=example.com
EOF
test_must_be_empty stdout &&
cat >expect <<-\EOF &&
quit: get
quit: protocol=http
quit: host=example.com
fatal: credential helper '\''quit'\'' told us to quit
EOF
test_i18ncmp expect stderr
credential fill >stdout &&
test_must_be_empty stdout
'
test_expect_success 'empty helper spec resets helper list' '
test_config credential.helper "verbatim file file" &&
check fill "" "verbatim cmdline cmdline" <<-\EOF
protocol=http
host=example.com
--
protocol=http
host=example.com
username=cmdline
password=cmdline
--
verbatim: get
verbatim: protocol=http
verbatim: host=example.com
EOF
'
test_expect_success 'url parser rejects embedded newlines' '
test_must_fail git credential fill 2>stderr <<-\EOF &&
url=https://one.example.com?%0ahost=two.example.com/
EOF
cat >expect <<-\EOF &&
warning: url contains a newline in its host component: https://one.example.com?%0ahost=two.example.com/
fatal: credential url cannot be parsed: https://one.example.com?%0ahost=two.example.com/
EOF
test_i18ncmp expect stderr
'
test_expect_success 'host-less URLs are parsed as empty host' '
check fill "verbatim foo bar" <<-\EOF
url=cert:///path/to/cert.pem
--
protocol=cert
host=
path=path/to/cert.pem
username=foo
password=bar
--
verbatim: get
verbatim: protocol=cert
verbatim: host=
verbatim: path=path/to/cert.pem
EOF
'
test_expect_success 'credential system refuses to work with missing host' '
test_must_fail git credential fill 2>stderr <<-\EOF &&
protocol=http
EOF
cat >expect <<-\EOF &&
fatal: refusing to work with credential missing host field
EOF
test_i18ncmp expect stderr
'
test_expect_success 'credential system refuses to work with missing protocol' '
test_must_fail git credential fill 2>stderr <<-\EOF &&
host=example.com
EOF
cat >expect <<-\EOF &&
fatal: refusing to work with credential missing protocol field
EOF
test_i18ncmp expect stderr
'
test_done

View file

@ -26,7 +26,7 @@ promise_and_delete () {
test_expect_success 'extensions.partialclone without filter' '
test_create_repo server &&
git clone --filter="blob:none" "file://$(pwd)/server" client &&
git -C client config --unset remote.origin.partialclonefilter &&
git -C client config --unset core.partialclonefilter &&
git -C client fetch origin
'
@ -166,9 +166,8 @@ test_expect_success 'fetching of missing objects' '
# associated packfile contains the object
ls repo/.git/objects/pack/pack-*.promisor >promisorlist &&
test_line_count = 1 promisorlist &&
IDX=$(sed "s/promisor$/idx/" promisorlist) &&
git verify-pack --verbose "$IDX" >out &&
grep "$HASH" out
IDX=$(cat promisorlist | sed "s/promisor$/idx/") &&
git verify-pack --verbose "$IDX" | grep "$HASH"
'
test_expect_success 'fetching of missing objects works with ref-in-want enabled' '
@ -183,55 +182,8 @@ test_expect_success 'fetching of missing objects works with ref-in-want enabled'
grep "git< fetch=.*ref-in-want" trace
'
test_expect_success 'fetching of missing objects from another promisor remote' '
git clone "file://$(pwd)/server" server2 &&
test_commit -C server2 bar &&
git -C server2 repack -a -d --write-bitmap-index &&
HASH2=$(git -C server2 rev-parse bar) &&
git -C repo remote add server2 "file://$(pwd)/server2" &&
git -C repo config remote.server2.promisor true &&
git -C repo cat-file -p "$HASH2" &&
git -C repo fetch server2 &&
rm -rf repo/.git/objects/* &&
git -C repo cat-file -p "$HASH2" &&
# Ensure that the .promisor file is written, and check that its
# associated packfile contains the object
ls repo/.git/objects/pack/pack-*.promisor >promisorlist &&
test_line_count = 1 promisorlist &&
IDX=$(sed "s/promisor$/idx/" promisorlist) &&
git verify-pack --verbose "$IDX" >out &&
grep "$HASH2" out
'
test_expect_success 'fetching of missing objects configures a promisor remote' '
git clone "file://$(pwd)/server" server3 &&
test_commit -C server3 baz &&
git -C server3 repack -a -d --write-bitmap-index &&
HASH3=$(git -C server3 rev-parse baz) &&
git -C server3 config uploadpack.allowfilter 1 &&
rm repo/.git/objects/pack/pack-*.promisor &&
git -C repo remote add server3 "file://$(pwd)/server3" &&
git -C repo fetch --filter="blob:none" server3 $HASH3 &&
test_cmp_config -C repo true remote.server3.promisor &&
# Ensure that the .promisor file is written, and check that its
# associated packfile contains the object
ls repo/.git/objects/pack/pack-*.promisor >promisorlist &&
test_line_count = 1 promisorlist &&
IDX=$(sed "s/promisor$/idx/" promisorlist) &&
git verify-pack --verbose "$IDX" >out &&
grep "$HASH3" out
'
test_expect_success 'fetching of missing blobs works' '
rm -rf server server2 repo &&
rm -rf server server3 repo &&
rm -rf server repo &&
test_create_repo server &&
test_commit -C server foo &&
git -C server repack -a -d --write-bitmap-index &&
@ -282,7 +234,7 @@ test_expect_success 'rev-list stops traversal at missing and promised commit' '
git -C repo config core.repositoryformatversion 1 &&
git -C repo config extensions.partialclone "arbitrary string" &&
GIT_TEST_COMMIT_GRAPH=0 git -C repo -c core.commitGraph=false rev-list --exclude-promisor-objects --objects bar >out &&
GIT_TEST_COMMIT_GRAPH=0 git -C repo rev-list --exclude-promisor-objects --objects bar >out &&
grep $(git -C repo rev-parse bar) out &&
! grep $FOO out
'
@ -429,19 +381,6 @@ test_expect_success 'rev-list dies for missing objects on cmd line' '
done
'
test_expect_success 'single promisor remote can be re-initialized gracefully' '
# ensure one promisor is in the promisors list
rm -rf repo &&
test_create_repo repo &&
test_create_repo other &&
git -C repo remote add foo "file://$(pwd)/other" &&
git -C repo config remote.foo.promisor true &&
git -C repo config extensions.partialclone foo &&
# reinitialize the promisors list
git -C repo fetch --filter=blob:none foo
'
test_expect_success 'gc repacks promisor objects separately from non-promisor objects' '
rm -rf repo &&
test_create_repo repo &&
@ -553,20 +492,6 @@ test_expect_success 'gc stops traversal when a missing but promised object is re
! grep "$TREE_HASH" out
'
test_expect_success 'do not fetch when checking existence of tree we construct ourselves' '
rm -rf repo &&
test_create_repo repo &&
test_commit -C repo base &&
test_commit -C repo side1 &&
git -C repo checkout base &&
test_commit -C repo side2 &&
git -C repo config core.repositoryformatversion 1 &&
git -C repo config extensions.partialclone "arbitrary string" &&
git -C repo cherry-pick side1
'
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd
@ -589,12 +514,8 @@ test_expect_success 'fetching of missing objects from an HTTP server' '
# associated packfile contains the object
ls repo/.git/objects/pack/pack-*.promisor >promisorlist &&
test_line_count = 1 promisorlist &&
IDX=$(sed "s/promisor$/idx/" promisorlist) &&
git verify-pack --verbose "$IDX" >out &&
grep "$HASH" out
IDX=$(cat promisorlist | sed "s/promisor$/idx/") &&
git verify-pack --verbose "$IDX" | grep "$HASH"
'
# DO NOT add non-httpd-specific tests here, because the last part of this
# test script is only executed when httpd is available and enabled.
test_done

View file

@ -1,286 +0,0 @@
#!/bin/sh
test_description='progress display'
. ./test-lib.sh
show_cr () {
tr '\015' Q | sed -e "s/Q/<CR>\\$LF/g"
}
test_expect_success 'simple progress display' '
cat >expect <<-\EOF &&
Working hard: 1<CR>
Working hard: 2<CR>
Working hard: 5<CR>
Working hard: 5, done.
EOF
cat >in <<-\EOF &&
update
progress 1
update
progress 2
progress 3
progress 4
update
progress 5
EOF
test-tool progress "Working hard" <in 2>stderr &&
show_cr <stderr >out &&
test_i18ncmp expect out
'
test_expect_success 'progress display with total' '
cat >expect <<-\EOF &&
Working hard: 33% (1/3)<CR>
Working hard: 66% (2/3)<CR>
Working hard: 100% (3/3)<CR>
Working hard: 100% (3/3), done.
EOF
cat >in <<-\EOF &&
progress 1
progress 2
progress 3
EOF
test-tool progress --total=3 "Working hard" <in 2>stderr &&
show_cr <stderr >out &&
test_i18ncmp expect out
'
test_expect_success 'progress display breaks long lines #1' '
sed -e "s/Z$//" >expect <<\EOF &&
Working hard.......2.........3.........4.........5.........6: 0% (100/100000)<CR>
Working hard.......2.........3.........4.........5.........6: 1% (1000/100000)<CR>
Working hard.......2.........3.........4.........5.........6: Z
10% (10000/100000)<CR>
100% (100000/100000)<CR>
100% (100000/100000), done.
EOF
cat >in <<-\EOF &&
progress 100
progress 1000
progress 10000
progress 100000
EOF
test-tool progress --total=100000 \
"Working hard.......2.........3.........4.........5.........6" \
<in 2>stderr &&
show_cr <stderr >out &&
test_i18ncmp expect out
'
test_expect_success 'progress display breaks long lines #2' '
# Note: we do not need that many spaces after the title to cover up
# the last line before breaking the progress line.
sed -e "s/Z$//" >expect <<\EOF &&
Working hard.......2.........3.........4.........5.........6: 0% (1/100000)<CR>
Working hard.......2.........3.........4.........5.........6: 0% (2/100000)<CR>
Working hard.......2.........3.........4.........5.........6: Z
10% (10000/100000)<CR>
100% (100000/100000)<CR>
100% (100000/100000), done.
EOF
cat >in <<-\EOF &&
update
progress 1
update
progress 2
progress 10000
progress 100000
EOF
test-tool progress --total=100000 \
"Working hard.......2.........3.........4.........5.........6" \
<in 2>stderr &&
show_cr <stderr >out &&
test_i18ncmp expect out
'
test_expect_success 'progress display breaks long lines #3 - even the first is too long' '
# Note: we do not actually need any spaces at the end of the title
# line, because there is no previous progress line to cover up.
sed -e "s/Z$//" >expect <<\EOF &&
Working hard.......2.........3.........4.........5.........6: Z
25% (25000/100000)<CR>
50% (50000/100000)<CR>
75% (75000/100000)<CR>
100% (100000/100000)<CR>
100% (100000/100000), done.
EOF
cat >in <<-\EOF &&
progress 25000
progress 50000
progress 75000
progress 100000
EOF
test-tool progress --total=100000 \
"Working hard.......2.........3.........4.........5.........6" \
<in 2>stderr &&
show_cr <stderr >out &&
test_i18ncmp expect out
'
test_expect_success 'progress display breaks long lines #4 - title line matches terminal width' '
cat >expect <<\EOF &&
Working hard.......2.........3.........4.........5.........6.........7.........:
25% (25000/100000)<CR>
50% (50000/100000)<CR>
75% (75000/100000)<CR>
100% (100000/100000)<CR>
100% (100000/100000), done.
EOF
cat >in <<-\EOF &&
progress 25000
progress 50000
progress 75000
progress 100000
EOF
test-tool progress --total=100000 \
"Working hard.......2.........3.........4.........5.........6.........7........." \
<in 2>stderr &&
show_cr <stderr >out &&
test_i18ncmp expect out
'
# Progress counter goes backwards, this should not happen in practice.
test_expect_success 'progress shortens - crazy caller' '
cat >expect <<-\EOF &&
Working hard: 10% (100/1000)<CR>
Working hard: 20% (200/1000)<CR>
Working hard: 0% (1/1000) <CR>
Working hard: 100% (1000/1000)<CR>
Working hard: 100% (1000/1000), done.
EOF
cat >in <<-\EOF &&
progress 100
progress 200
progress 1
progress 1000
EOF
test-tool progress --total=1000 "Working hard" <in 2>stderr &&
show_cr <stderr >out &&
test_i18ncmp expect out
'
test_expect_success 'progress display with throughput' '
cat >expect <<-\EOF &&
Working hard: 10<CR>
Working hard: 20, 200.00 KiB | 100.00 KiB/s<CR>
Working hard: 30, 300.00 KiB | 100.00 KiB/s<CR>
Working hard: 40, 400.00 KiB | 100.00 KiB/s<CR>
Working hard: 40, 400.00 KiB | 100.00 KiB/s, done.
EOF
cat >in <<-\EOF &&
throughput 102400 1000
update
progress 10
throughput 204800 2000
update
progress 20
throughput 307200 3000
update
progress 30
throughput 409600 4000
update
progress 40
EOF
test-tool progress "Working hard" <in 2>stderr &&
show_cr <stderr >out &&
test_i18ncmp expect out
'
test_expect_success 'progress display with throughput and total' '
cat >expect <<-\EOF &&
Working hard: 25% (10/40)<CR>
Working hard: 50% (20/40), 200.00 KiB | 100.00 KiB/s<CR>
Working hard: 75% (30/40), 300.00 KiB | 100.00 KiB/s<CR>
Working hard: 100% (40/40), 400.00 KiB | 100.00 KiB/s<CR>
Working hard: 100% (40/40), 400.00 KiB | 100.00 KiB/s, done.
EOF
cat >in <<-\EOF &&
throughput 102400 1000
progress 10
throughput 204800 2000
progress 20
throughput 307200 3000
progress 30
throughput 409600 4000
progress 40
EOF
test-tool progress --total=40 "Working hard" <in 2>stderr &&
show_cr <stderr >out &&
test_i18ncmp expect out
'
test_expect_success 'cover up after throughput shortens' '
cat >expect <<-\EOF &&
Working hard: 1<CR>
Working hard: 2, 800.00 KiB | 400.00 KiB/s<CR>
Working hard: 3, 1.17 MiB | 400.00 KiB/s <CR>
Working hard: 4, 1.56 MiB | 400.00 KiB/s<CR>
Working hard: 4, 1.56 MiB | 400.00 KiB/s, done.
EOF
cat >in <<-\EOF &&
throughput 409600 1000
update
progress 1
throughput 819200 2000
update
progress 2
throughput 1228800 3000
update
progress 3
throughput 1638400 4000
update
progress 4
EOF
test-tool progress "Working hard" <in 2>stderr &&
show_cr <stderr >out &&
test_i18ncmp expect out
'
test_expect_success 'cover up after throughput shortens a lot' '
cat >expect <<-\EOF &&
Working hard: 1<CR>
Working hard: 2, 1000.00 KiB | 1000.00 KiB/s<CR>
Working hard: 3, 3.00 MiB | 1.50 MiB/s <CR>
Working hard: 3, 3.00 MiB | 1024.00 KiB/s, done.
EOF
cat >in <<-\EOF &&
throughput 1 1000
update
progress 1
throughput 1024000 2000
update
progress 2
throughput 3145728 3000
update
progress 3
EOF
test-tool progress "Working hard" <in 2>stderr &&
show_cr <stderr >out &&
test_i18ncmp expect out
'
test_done

View file

@ -215,6 +215,7 @@ test_expect_success 'read-tree adds to worktree, dirty case' '
'
test_expect_success 'index removal and worktree narrowing at the same time' '
>empty &&
echo init.t >.git/info/sparse-checkout &&
echo sub/added >>.git/info/sparse-checkout &&
git checkout -f top &&
@ -222,7 +223,7 @@ test_expect_success 'index removal and worktree narrowing at the same time' '
git checkout removed &&
git ls-files sub/added >result &&
test ! -f sub/added &&
test_must_be_empty result
test_cmp empty result
'
test_expect_success 'read-tree --reset removes outside worktree' '

View file

@ -49,7 +49,6 @@ git~1
.git.SPACE .git.{space}
.\\\\.GIT\\\\foobar backslashes
.git\\\\foobar backslashes2
.git...:alternate-stream
EOF
test_expect_success 'utf-8 paths allowed with core.protectHFS off' '

View file

@ -53,8 +53,7 @@ test_expect_success 'add a large file or two' '
for p in .git/objects/pack/pack-*.pack
do
count=$(( $count + 1 ))
if test_path_is_file "$p" &&
idx=${p%.pack}.idx && test_path_is_file "$idx"
if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
then
continue
fi
@ -66,7 +65,7 @@ test_expect_success 'add a large file or two' '
test $cnt = 2 &&
for l in .git/objects/??/??????????????????????????????????????
do
test_path_is_file "$l" || continue
test -f "$l" || continue
bad=t
done &&
test -z "$bad" &&
@ -77,8 +76,7 @@ test_expect_success 'add a large file or two' '
for p in .git/objects/pack/pack-*.pack
do
count=$(( $count + 1 ))
if test_path_is_file "$p" &&
idx=${p%.pack}.idx && test_path_is_file "$idx"
if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
then
continue
fi
@ -113,7 +111,7 @@ test_expect_success 'packsize limit' '
count=0 &&
for pi in .git/objects/pack/pack-*.idx
do
test_path_is_file "$pi" && count=$(( $count + 1 ))
test -f "$pi" && count=$(( $count + 1 ))
done &&
test $count = 2 &&
@ -196,15 +194,15 @@ test_expect_success 'pack-objects with large loose object' '
test_cmp huge actual
'
test_expect_success 'tar archiving' '
test_expect_success 'tar achiving' '
git archive --format=tar HEAD >/dev/null
'
test_expect_success 'zip archiving, store only' '
test_expect_success 'zip achiving, store only' '
git archive --format=zip -0 HEAD >/dev/null
'
test_expect_success 'zip archiving, deflate' '
test_expect_success 'zip achiving, deflate' '
git archive --format=zip HEAD >/dev/null
'

View file

@ -1,524 +0,0 @@
#!/bin/sh
test_description='sparse checkout builtin tests'
. ./test-lib.sh
list_files() {
# Do not replace this with 'ls "$1"', as "ls" with BSD-lineage
# enables "-A" by default for root and ends up including ".git" and
# such in its output. (Note, though, that running the test suite as
# root is generally not recommended.)
(cd "$1" && printf '%s\n' *)
}
check_files() {
list_files "$1" >actual &&
shift &&
printf "%s\n" $@ >expect &&
test_cmp expect actual
}
test_expect_success 'setup' '
git init repo &&
(
cd repo &&
echo "initial" >a &&
mkdir folder1 folder2 deep &&
mkdir deep/deeper1 deep/deeper2 &&
mkdir deep/deeper1/deepest &&
cp a folder1 &&
cp a folder2 &&
cp a deep &&
cp a deep/deeper1 &&
cp a deep/deeper2 &&
cp a deep/deeper1/deepest &&
git add . &&
git commit -m "initial commit"
)
'
test_expect_success 'git sparse-checkout list (empty)' '
git -C repo sparse-checkout list >list 2>err &&
test_must_be_empty list &&
test_i18ngrep "this worktree is not sparse (sparse-checkout file may not exist)" err
'
test_expect_success 'git sparse-checkout list (populated)' '
test_when_finished rm -f repo/.git/info/sparse-checkout &&
cat >repo/.git/info/sparse-checkout <<-\EOF &&
/folder1/*
/deep/
**/a
!*bin*
EOF
cp repo/.git/info/sparse-checkout expect &&
git -C repo sparse-checkout list >list &&
test_cmp expect list
'
test_expect_success 'git sparse-checkout init' '
git -C repo sparse-checkout init &&
cat >expect <<-\EOF &&
/*
!/*/
EOF
test_cmp expect repo/.git/info/sparse-checkout &&
test_cmp_config -C repo true core.sparsecheckout &&
check_files repo a
'
test_expect_success 'git sparse-checkout list after init' '
git -C repo sparse-checkout list >actual &&
cat >expect <<-\EOF &&
/*
!/*/
EOF
test_cmp expect actual
'
test_expect_success 'init with existing sparse-checkout' '
echo "*folder*" >> repo/.git/info/sparse-checkout &&
git -C repo sparse-checkout init &&
cat >expect <<-\EOF &&
/*
!/*/
*folder*
EOF
test_cmp expect repo/.git/info/sparse-checkout &&
check_files repo a folder1 folder2
'
test_expect_success 'clone --sparse' '
git clone --sparse "file://$(pwd)/repo" clone &&
git -C clone sparse-checkout list >actual &&
cat >expect <<-\EOF &&
/*
!/*/
EOF
test_cmp expect actual &&
check_files clone a
'
test_expect_success 'set enables config' '
git init empty-config &&
(
cd empty-config &&
test_commit test file &&
test_path_is_missing .git/config.worktree &&
test_must_fail git sparse-checkout set nothing &&
test_path_is_file .git/config.worktree &&
test_must_fail git config core.sparseCheckout &&
git sparse-checkout set "/*" &&
test_cmp_config true core.sparseCheckout
)
'
test_expect_success 'set sparse-checkout using builtin' '
git -C repo sparse-checkout set "/*" "!/*/" "*folder*" &&
cat >expect <<-\EOF &&
/*
!/*/
*folder*
EOF
git -C repo sparse-checkout list >actual &&
test_cmp expect actual &&
test_cmp expect repo/.git/info/sparse-checkout &&
check_files repo a folder1 folder2
'
test_expect_success 'set sparse-checkout using --stdin' '
cat >expect <<-\EOF &&
/*
!/*/
/folder1/
/folder2/
EOF
git -C repo sparse-checkout set --stdin <expect &&
git -C repo sparse-checkout list >actual &&
test_cmp expect actual &&
test_cmp expect repo/.git/info/sparse-checkout &&
check_files repo "a folder1 folder2"
'
test_expect_success 'add to sparse-checkout' '
cat repo/.git/info/sparse-checkout >expect &&
cat >add <<-\EOF &&
pattern1
/folder1/
pattern2
EOF
cat add >>expect &&
git -C repo sparse-checkout add --stdin <add &&
git -C repo sparse-checkout list >actual &&
test_cmp expect actual &&
test_cmp expect repo/.git/info/sparse-checkout &&
check_files repo "a folder1 folder2"
'
test_expect_success 'cone mode: match patterns' '
git -C repo config --worktree core.sparseCheckoutCone true &&
rm -rf repo/a repo/folder1 repo/folder2 &&
git -C repo read-tree -mu HEAD 2>err &&
test_i18ngrep ! "disabling cone patterns" err &&
git -C repo reset --hard &&
check_files repo a folder1 folder2
'
test_expect_success 'cone mode: warn on bad pattern' '
test_when_finished mv sparse-checkout repo/.git/info/ &&
cp repo/.git/info/sparse-checkout . &&
echo "!/deep/deeper/*" >>repo/.git/info/sparse-checkout &&
git -C repo read-tree -mu HEAD 2>err &&
test_i18ngrep "unrecognized negative pattern" err
'
test_expect_success 'sparse-checkout disable' '
test_when_finished rm -rf repo/.git/info/sparse-checkout &&
git -C repo sparse-checkout disable &&
test_path_is_file repo/.git/info/sparse-checkout &&
git -C repo config --list >config &&
test_must_fail git config core.sparseCheckout &&
check_files repo a deep folder1 folder2
'
test_expect_success 'cone mode: init and set' '
git -C repo sparse-checkout init --cone &&
git -C repo config --list >config &&
test_i18ngrep "core.sparsecheckoutcone=true" config &&
list_files repo >dir &&
echo a >expect &&
test_cmp expect dir &&
git -C repo sparse-checkout set deep/deeper1/deepest/ 2>err &&
test_must_be_empty err &&
check_files repo a deep &&
check_files repo/deep a deeper1 &&
check_files repo/deep/deeper1 a deepest &&
cat >expect <<-\EOF &&
/*
!/*/
/deep/
!/deep/*/
/deep/deeper1/
!/deep/deeper1/*/
/deep/deeper1/deepest/
EOF
test_cmp expect repo/.git/info/sparse-checkout &&
git -C repo sparse-checkout set --stdin 2>err <<-\EOF &&
folder1
folder2
EOF
test_must_be_empty err &&
check_files repo a folder1 folder2
'
test_expect_success 'cone mode: list' '
cat >expect <<-\EOF &&
folder1
folder2
EOF
git -C repo sparse-checkout set --stdin <expect &&
git -C repo sparse-checkout list >actual 2>err &&
test_must_be_empty err &&
test_cmp expect actual
'
test_expect_success 'cone mode: set with nested folders' '
git -C repo sparse-checkout set deep deep/deeper1/deepest 2>err &&
test_line_count = 0 err &&
cat >expect <<-\EOF &&
/*
!/*/
/deep/
EOF
test_cmp repo/.git/info/sparse-checkout expect
'
test_expect_success 'cone mode: add independent path' '
git -C repo sparse-checkout set deep/deeper1 &&
git -C repo sparse-checkout add folder1 &&
cat >expect <<-\EOF &&
/*
!/*/
/deep/
!/deep/*/
/deep/deeper1/
/folder1/
EOF
test_cmp expect repo/.git/info/sparse-checkout &&
check_files repo a deep folder1
'
test_expect_success 'cone mode: add sibling path' '
git -C repo sparse-checkout set deep/deeper1 &&
git -C repo sparse-checkout add deep/deeper2 &&
cat >expect <<-\EOF &&
/*
!/*/
/deep/
!/deep/*/
/deep/deeper1/
/deep/deeper2/
EOF
test_cmp expect repo/.git/info/sparse-checkout &&
check_files repo a deep
'
test_expect_success 'cone mode: add parent path' '
git -C repo sparse-checkout set deep/deeper1 folder1 &&
git -C repo sparse-checkout add deep &&
cat >expect <<-\EOF &&
/*
!/*/
/deep/
/folder1/
EOF
test_cmp expect repo/.git/info/sparse-checkout &&
check_files repo a deep folder1
'
test_expect_success 'revert to old sparse-checkout on bad update' '
test_when_finished git -C repo reset --hard &&
git -C repo sparse-checkout set deep &&
echo update >repo/deep/deeper2/a &&
cp repo/.git/info/sparse-checkout expect &&
test_must_fail git -C repo sparse-checkout set deep/deeper1 2>err &&
test_i18ngrep "cannot set sparse-checkout patterns" err &&
test_cmp repo/.git/info/sparse-checkout expect &&
check_files repo/deep a deeper1 deeper2
'
test_expect_success 'revert to old sparse-checkout on empty update' '
git init empty-test &&
(
echo >file &&
git add file &&
git commit -m "test" &&
test_must_fail git sparse-checkout set nothing 2>err &&
test_i18ngrep "Sparse checkout leaves no entry on working directory" err &&
test_i18ngrep ! ".git/index.lock" err &&
git sparse-checkout set file
)
'
test_expect_success 'fail when lock is taken' '
test_when_finished rm -rf repo/.git/info/sparse-checkout.lock &&
touch repo/.git/info/sparse-checkout.lock &&
test_must_fail git -C repo sparse-checkout set deep 2>err &&
test_i18ngrep "Unable to create .*\.lock" err
'
test_expect_success '.gitignore should not warn about cone mode' '
git -C repo config --worktree core.sparseCheckoutCone true &&
echo "**/bin/*" >repo/.gitignore &&
git -C repo reset --hard 2>err &&
test_i18ngrep ! "disabling cone patterns" err
'
test_expect_success 'sparse-checkout (init|set|disable) fails with dirty status' '
git clone repo dirty &&
echo dirty >dirty/folder1/a &&
test_must_fail git -C dirty sparse-checkout init &&
test_must_fail git -C dirty sparse-checkout set /folder2/* /deep/deeper1/* &&
test_must_fail git -C dirty sparse-checkout disable &&
git -C dirty reset --hard &&
git -C dirty sparse-checkout init &&
git -C dirty sparse-checkout set /folder2/* /deep/deeper1/* &&
git -C dirty sparse-checkout disable
'
test_expect_success 'cone mode: set with core.ignoreCase=true' '
git -C repo sparse-checkout init --cone &&
git -C repo -c core.ignoreCase=true sparse-checkout set folder1 &&
cat >expect <<-\EOF &&
/*
!/*/
/folder1/
EOF
test_cmp expect repo/.git/info/sparse-checkout &&
check_files repo a folder1
'
test_expect_success 'interaction with submodules' '
git clone repo super &&
(
cd super &&
mkdir modules &&
git submodule add ../repo modules/child &&
git add . &&
git commit -m "add submodule" &&
git sparse-checkout init --cone &&
git sparse-checkout set folder1
) &&
check_files super a folder1 modules &&
check_files super/modules/child a deep folder1 folder2
'
test_expect_success 'different sparse-checkouts with worktrees' '
git -C repo worktree add --detach ../worktree &&
check_files worktree "a deep folder1 folder2" &&
git -C worktree sparse-checkout init --cone &&
git -C repo sparse-checkout set folder1 &&
git -C worktree sparse-checkout set deep/deeper1 &&
check_files repo a folder1 &&
check_files worktree a deep
'
test_expect_success 'set using filename keeps file on-disk' '
git -C repo sparse-checkout set a deep &&
cat >expect <<-\EOF &&
/*
!/*/
/a/
/deep/
EOF
test_cmp expect repo/.git/info/sparse-checkout &&
check_files repo a deep
'
check_read_tree_errors () {
REPO=$1
FILES=$2
ERRORS=$3
git -C $REPO -c core.sparseCheckoutCone=false read-tree -mu HEAD 2>err &&
test_must_be_empty err &&
check_files $REPO "$FILES" &&
git -C $REPO read-tree -mu HEAD 2>err &&
if test -z "$ERRORS"
then
test_must_be_empty err
else
test_i18ngrep "$ERRORS" err
fi &&
check_files $REPO $FILES
}
test_expect_success 'pattern-checks: /A/**' '
cat >repo/.git/info/sparse-checkout <<-\EOF &&
/*
!/*/
/folder1/**
EOF
check_read_tree_errors repo "a folder1" "disabling cone pattern matching"
'
test_expect_success 'pattern-checks: /A/**/B/' '
cat >repo/.git/info/sparse-checkout <<-\EOF &&
/*
!/*/
/deep/**/deepest
EOF
check_read_tree_errors repo "a deep" "disabling cone pattern matching" &&
check_files repo/deep "deeper1" &&
check_files repo/deep/deeper1 "deepest"
'
test_expect_success 'pattern-checks: too short' '
cat >repo/.git/info/sparse-checkout <<-\EOF &&
/*
!/*/
/
EOF
check_read_tree_errors repo "a" "disabling cone pattern matching"
'
test_expect_success 'pattern-checks: not too short' '
cat >repo/.git/info/sparse-checkout <<-\EOF &&
/*
!/*/
/b/
EOF
git -C repo read-tree -mu HEAD 2>err &&
test_must_be_empty err &&
check_files repo a
'
test_expect_success 'pattern-checks: trailing "*"' '
cat >repo/.git/info/sparse-checkout <<-\EOF &&
/*
!/*/
/a*
EOF
check_read_tree_errors repo "a" "disabling cone pattern matching"
'
test_expect_success 'pattern-checks: starting "*"' '
cat >repo/.git/info/sparse-checkout <<-\EOF &&
/*
!/*/
*eep/
EOF
check_read_tree_errors repo "a deep" "disabling cone pattern matching"
'
test_expect_success 'pattern-checks: contained glob characters' '
for c in "[a]" "\\" "?" "*"
do
cat >repo/.git/info/sparse-checkout <<-EOF &&
/*
!/*/
something$c-else/
EOF
check_read_tree_errors repo "a" "disabling cone pattern matching"
done
'
test_expect_success BSLASHPSPEC 'pattern-checks: escaped characters' '
git clone repo escaped &&
TREEOID=$(git -C escaped rev-parse HEAD:folder1) &&
NEWTREE=$(git -C escaped mktree <<-EOF
$(git -C escaped ls-tree HEAD)
040000 tree $TREEOID zbad\\dir
040000 tree $TREEOID zdoes*exist
040000 tree $TREEOID zglob[!a]?
EOF
) &&
COMMIT=$(git -C escaped commit-tree $NEWTREE -p HEAD) &&
git -C escaped reset --hard $COMMIT &&
check_files escaped "a deep folder1 folder2 zbad\\dir zdoes*exist" zglob[!a]? &&
git -C escaped sparse-checkout init --cone &&
git -C escaped sparse-checkout set zbad\\dir/bogus "zdoes*not*exist" "zdoes*exist" "zglob[!a]?" &&
cat >expect <<-\EOF &&
/*
!/*/
/zbad\\dir/
!/zbad\\dir/*/
/zbad\\dir/bogus/
/zdoes\*exist/
/zdoes\*not\*exist/
/zglob\[!a]\?/
EOF
test_cmp expect escaped/.git/info/sparse-checkout &&
check_read_tree_errors escaped "a zbad\\dir zdoes*exist zglob[!a]?" &&
git -C escaped ls-tree -d --name-only HEAD >list-expect &&
git -C escaped sparse-checkout set --stdin <list-expect &&
cat >expect <<-\EOF &&
/*
!/*/
/deep/
/folder1/
/folder2/
/zbad\\dir/
/zdoes\*exist/
/zglob\[!a]\?/
EOF
test_cmp expect escaped/.git/info/sparse-checkout &&
check_files escaped "a deep folder1 folder2 zbad\\dir zdoes*exist" zglob[!a]? &&
git -C escaped sparse-checkout list >list-actual &&
test_cmp list-expect list-actual
'
test_expect_success MINGW 'cone mode replaces backslashes with slashes' '
git -C repo sparse-checkout set deep\\deeper1 &&
cat >expect <<-\EOF &&
/*
!/*/
/deep/
!/deep/*/
/deep/deeper1/
EOF
test_cmp expect repo/.git/info/sparse-checkout &&
check_files repo a deep &&
check_files repo/deep a deeper1
'
test_done

View file

@ -1191,47 +1191,47 @@ test_expect_success 'old-fashioned settings are case insensitive' '
test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" &&
cat >testConfig_actual <<-EOF &&
[V.A]
r = value1
[V.A]
r = value1
EOF
q_to_tab >testConfig_expect <<-EOF &&
[V.A]
Qr = value2
[V.A]
Qr = value2
EOF
git config -f testConfig_actual "v.a.r" value2 &&
test_cmp testConfig_expect testConfig_actual &&
cat >testConfig_actual <<-EOF &&
[V.A]
r = value1
[V.A]
r = value1
EOF
q_to_tab >testConfig_expect <<-EOF &&
[V.A]
QR = value2
[V.A]
QR = value2
EOF
git config -f testConfig_actual "V.a.R" value2 &&
test_cmp testConfig_expect testConfig_actual &&
cat >testConfig_actual <<-EOF &&
[V.A]
r = value1
[V.A]
r = value1
EOF
q_to_tab >testConfig_expect <<-EOF &&
[V.A]
r = value1
Qr = value2
[V.A]
r = value1
Qr = value2
EOF
git config -f testConfig_actual "V.A.r" value2 &&
test_cmp testConfig_expect testConfig_actual &&
cat >testConfig_actual <<-EOF &&
[V.A]
r = value1
[V.A]
r = value1
EOF
q_to_tab >testConfig_expect <<-EOF &&
[V.A]
r = value1
Qr = value2
[V.A]
r = value1
Qr = value2
EOF
git config -f testConfig_actual "v.A.r" value2 &&
test_cmp testConfig_expect testConfig_actual
@ -1241,26 +1241,26 @@ test_expect_success 'setting different case sensitive subsections ' '
test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" &&
cat >testConfig_actual <<-EOF &&
[V "A"]
R = v1
[K "E"]
Y = v1
[a "b"]
c = v1
[d "e"]
f = v1
[V "A"]
R = v1
[K "E"]
Y = v1
[a "b"]
c = v1
[d "e"]
f = v1
EOF
q_to_tab >testConfig_expect <<-EOF &&
[V "A"]
Qr = v2
[K "E"]
Qy = v2
[a "b"]
Qc = v2
[d "e"]
f = v1
[d "E"]
Qf = v2
[V "A"]
Qr = v2
[K "E"]
Qy = v2
[a "b"]
Qc = v2
[d "e"]
f = v1
[d "E"]
Qf = v2
EOF
# exact match
git config -f testConfig_actual a.b.c v2 &&
@ -1294,25 +1294,26 @@ test_expect_success 'git -c is not confused by empty environment' '
GIT_CONFIG_PARAMETERS="" git -c x.one=1 config --list
'
sq="'"
test_expect_success 'detect bogus GIT_CONFIG_PARAMETERS' '
cat >expect <<-\EOF &&
env.one one
env.two two
EOF
GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ} ${SQ}env.two=two${SQ}" \
GIT_CONFIG_PARAMETERS="${sq}env.one=one${sq} ${sq}env.two=two${sq}" \
git config --get-regexp "env.*" >actual &&
test_cmp expect actual &&
cat >expect <<-EOF &&
env.one one${SQ}
env.one one${sq}
env.two two
EOF
GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ}\\$SQ$SQ$SQ ${SQ}env.two=two${SQ}" \
GIT_CONFIG_PARAMETERS="${sq}env.one=one${sq}\\$sq$sq$sq ${sq}env.two=two${sq}" \
git config --get-regexp "env.*" >actual &&
test_cmp expect actual &&
test_must_fail env \
GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ}\\$SQ ${SQ}env.two=two${SQ}" \
GIT_CONFIG_PARAMETERS="${sq}env.one=one${sq}\\$sq ${sq}env.two=two${sq}" \
git config --get-regexp "env.*"
'
@ -1408,8 +1409,6 @@ test_expect_success 'urlmatch favors more specific URLs' '
cookieFile = /tmp/wildcard.txt
[http "https://*.example.com/wildcardwithsubdomain"]
cookieFile = /tmp/wildcardwithsubdomain.txt
[http "https://*.example.*"]
cookieFile = /tmp/multiwildcard.txt
[http "https://trailing.example.com"]
cookieFile = /tmp/trailing.txt
[http "https://user@*.example.com/"]
@ -1456,10 +1455,6 @@ test_expect_success 'urlmatch favors more specific URLs' '
echo http.cookiefile /tmp/sub.txt >expect &&
git config --get-urlmatch HTTP https://user@sub.example.com >actual &&
test_cmp expect actual &&
echo http.cookiefile /tmp/multiwildcard.txt >expect &&
git config --get-urlmatch HTTP https://wildcard.example.org >actual &&
test_cmp expect actual
'
@ -1628,40 +1623,40 @@ test_expect_success 'set up --show-origin tests' '
INCLUDE_DIR="$HOME/include" &&
mkdir -p "$INCLUDE_DIR" &&
cat >"$INCLUDE_DIR"/absolute.include <<-\EOF &&
[user]
absolute = include
[user]
absolute = include
EOF
cat >"$INCLUDE_DIR"/relative.include <<-\EOF &&
[user]
relative = include
[user]
relative = include
EOF
cat >"$HOME"/.gitconfig <<-EOF &&
[user]
global = true
override = global
[include]
path = "$INCLUDE_DIR/absolute.include"
[user]
global = true
override = global
[include]
path = "$INCLUDE_DIR/absolute.include"
EOF
cat >.git/config <<-\EOF
[user]
local = true
override = local
[include]
path = ../include/relative.include
[user]
local = true
override = local
[include]
path = ../include/relative.include
EOF
'
test_expect_success '--show-origin with --list' '
cat >expect <<-EOF &&
file:$HOME/.gitconfig user.global=true
file:$HOME/.gitconfig user.override=global
file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include
file:$INCLUDE_DIR/absolute.include user.absolute=include
file:.git/config user.local=true
file:.git/config user.override=local
file:.git/config include.path=../include/relative.include
file:.git/../include/relative.include user.relative=include
command line: user.cmdline=true
file:$HOME/.gitconfig user.global=true
file:$HOME/.gitconfig user.override=global
file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include
file:$INCLUDE_DIR/absolute.include user.absolute=include
file:.git/config user.local=true
file:.git/config user.override=local
file:.git/config include.path=../include/relative.include
file:.git/../include/relative.include user.relative=include
command line: user.cmdline=true
EOF
git -c user.cmdline=true config --list --show-origin >output &&
test_cmp expect output
@ -1669,16 +1664,16 @@ test_expect_success '--show-origin with --list' '
test_expect_success '--show-origin with --list --null' '
cat >expect <<-EOF &&
file:$HOME/.gitconfigQuser.global
trueQfile:$HOME/.gitconfigQuser.override
globalQfile:$HOME/.gitconfigQinclude.path
$INCLUDE_DIR/absolute.includeQfile:$INCLUDE_DIR/absolute.includeQuser.absolute
includeQfile:.git/configQuser.local
trueQfile:.git/configQuser.override
localQfile:.git/configQinclude.path
../include/relative.includeQfile:.git/../include/relative.includeQuser.relative
includeQcommand line:Quser.cmdline
trueQ
file:$HOME/.gitconfigQuser.global
trueQfile:$HOME/.gitconfigQuser.override
globalQfile:$HOME/.gitconfigQinclude.path
$INCLUDE_DIR/absolute.includeQfile:$INCLUDE_DIR/absolute.includeQuser.absolute
includeQfile:.git/configQuser.local
trueQfile:.git/configQuser.override
localQfile:.git/configQinclude.path
../include/relative.includeQfile:.git/../include/relative.includeQuser.relative
includeQcommand line:Quser.cmdline
trueQ
EOF
git -c user.cmdline=true config --null --list --show-origin >output.raw &&
nul_to_q <output.raw >output &&
@ -1690,9 +1685,9 @@ test_expect_success '--show-origin with --list --null' '
test_expect_success '--show-origin with single file' '
cat >expect <<-\EOF &&
file:.git/config user.local=true
file:.git/config user.override=local
file:.git/config include.path=../include/relative.include
file:.git/config user.local=true
file:.git/config user.override=local
file:.git/config include.path=../include/relative.include
EOF
git config --local --list --show-origin >output &&
test_cmp expect output
@ -1700,8 +1695,8 @@ test_expect_success '--show-origin with single file' '
test_expect_success '--show-origin with --get-regexp' '
cat >expect <<-EOF &&
file:$HOME/.gitconfig user.global true
file:.git/config user.local true
file:$HOME/.gitconfig user.global true
file:.git/config user.local true
EOF
git config --show-origin --get-regexp "user\.[g|l].*" >output &&
test_cmp expect output
@ -1709,36 +1704,31 @@ test_expect_success '--show-origin with --get-regexp' '
test_expect_success '--show-origin getting a single key' '
cat >expect <<-\EOF &&
file:.git/config local
file:.git/config local
EOF
git config --show-origin user.override >output &&
test_cmp expect output
'
test_expect_success 'set up custom config file' '
CUSTOM_CONFIG_FILE="custom.conf" &&
CUSTOM_CONFIG_FILE="file\" (dq) and spaces.conf" &&
cat >"$CUSTOM_CONFIG_FILE" <<-\EOF
[user]
custom = true
[user]
custom = true
EOF
'
test_expect_success !MINGW 'set up custom config file with special name characters' '
WEIRDLY_NAMED_FILE="file\" (dq) and spaces.conf" &&
cp "$CUSTOM_CONFIG_FILE" "$WEIRDLY_NAMED_FILE"
'
test_expect_success !MINGW '--show-origin escape special file name characters' '
cat >expect <<-\EOF &&
file:"file\" (dq) and spaces.conf" user.custom=true
file:"file\" (dq) and spaces.conf" user.custom=true
EOF
git config --file "$WEIRDLY_NAMED_FILE" --show-origin --list >output &&
git config --file "$CUSTOM_CONFIG_FILE" --show-origin --list >output &&
test_cmp expect output
'
test_expect_success '--show-origin stdin' '
cat >expect <<-\EOF &&
standard input: user.custom=true
standard input: user.custom=true
EOF
git config --file - --show-origin --list <"$CUSTOM_CONFIG_FILE" >output &&
test_cmp expect output
@ -1746,11 +1736,11 @@ test_expect_success '--show-origin stdin' '
test_expect_success '--show-origin stdin with file include' '
cat >"$INCLUDE_DIR"/stdin.include <<-EOF &&
[user]
stdin = include
[user]
stdin = include
EOF
cat >expect <<-EOF &&
file:$INCLUDE_DIR/stdin.include include
file:$INCLUDE_DIR/stdin.include include
EOF
echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" |
git config --show-origin --includes --file - user.stdin >output &&
@ -1758,18 +1748,18 @@ test_expect_success '--show-origin stdin with file include' '
test_cmp expect output
'
test_expect_success '--show-origin blob' '
test_expect_success !MINGW '--show-origin blob' '
blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
cat >expect <<-EOF &&
blob:$blob user.custom=true
blob:$blob user.custom=true
EOF
git config --blob=$blob --show-origin --list >output &&
test_cmp expect output
'
test_expect_success '--show-origin blob ref' '
test_expect_success !MINGW '--show-origin blob ref' '
cat >expect <<-\EOF &&
blob:master:custom.conf user.custom=true
blob:"master:file\" (dq) and spaces.conf" user.custom=true
EOF
git add "$CUSTOM_CONFIG_FILE" &&
git commit -m "new config file" &&
@ -1777,65 +1767,6 @@ test_expect_success '--show-origin blob ref' '
test_cmp expect output
'
test_expect_success '--show-scope with --list' '
cat >expect <<-EOF &&
global user.global=true
global user.override=global
global include.path=$INCLUDE_DIR/absolute.include
global user.absolute=include
local user.local=true
local user.override=local
local include.path=../include/relative.include
local user.relative=include
command user.cmdline=true
EOF
git -c user.cmdline=true config --list --show-scope >output &&
test_cmp expect output
'
test_expect_success !MINGW '--show-scope with --blob' '
blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
cat >expect <<-EOF &&
command user.custom=true
EOF
git config --blob=$blob --show-scope --list >output &&
test_cmp expect output
'
test_expect_success '--show-scope with --local' '
cat >expect <<-\EOF &&
local user.local=true
local user.override=local
local include.path=../include/relative.include
EOF
git config --local --list --show-scope >output &&
test_cmp expect output
'
test_expect_success '--show-scope getting a single value' '
cat >expect <<-\EOF &&
local true
EOF
git config --show-scope --get user.local >output &&
test_cmp expect output
'
test_expect_success '--show-scope with --show-origin' '
cat >expect <<-EOF &&
global file:$HOME/.gitconfig user.global=true
global file:$HOME/.gitconfig user.override=global
global file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include
global file:$INCLUDE_DIR/absolute.include user.absolute=include
local file:.git/config user.local=true
local file:.git/config user.override=local
local file:.git/config include.path=../include/relative.include
local file:.git/../include/relative.include user.relative=include
command command line: user.cmdline=true
EOF
git -c user.cmdline=true config --list --show-origin --show-scope >output &&
test_cmp expect output
'
test_expect_success '--local requires a repo' '
# we expect 128 to ensure that we do not simply
# fail to find anything and return code "1"

View file

@ -63,7 +63,7 @@ test_expect_success 'listing includes option and expansion' '
test.one=1
EOF
git config --list >actual.full &&
grep -v -e ^core -e ^extensions actual.full >actual &&
grep -v ^core actual.full >actual &&
test_cmp expect actual
'

View file

@ -153,7 +153,7 @@ test_expect_success 'Checking attributes in both XDG and local attributes files'
test_expect_success 'Checking attributes in a non-XDG global attributes file' '
rm -f .gitattributes &&
test_might_fail rm .gitattributes &&
echo "f attr_f=test" >"$HOME"/my_gitattributes &&
git config core.attributesfile "$HOME"/my_gitattributes &&
echo "f: attr_f: test" >expected &&
@ -165,7 +165,7 @@ test_expect_success 'Checking attributes in a non-XDG global attributes file' '
test_expect_success 'write: xdg file exists and ~/.gitconfig doesn'\''t' '
mkdir -p "$HOME"/.config/git &&
>"$HOME"/.config/git/config &&
rm -f "$HOME"/.gitconfig &&
test_might_fail rm "$HOME"/.gitconfig &&
git config --global user.name "write_config" &&
echo "[user]" >expected &&
echo " name = write_config" >>expected &&
@ -183,8 +183,8 @@ test_expect_success 'write: xdg file exists and ~/.gitconfig exists' '
test_expect_success 'write: ~/.config/git/ exists and config file doesn'\''t' '
rm -f "$HOME"/.gitconfig &&
rm -f "$HOME"/.config/git/config &&
test_might_fail rm "$HOME"/.gitconfig &&
test_might_fail rm "$HOME"/.config/git/config &&
git config --global user.name "write_gitconfig" &&
echo "[user]" >expected &&
echo " name = write_gitconfig" >>expected &&

View file

@ -74,7 +74,7 @@ test_expect_success 'can parse blob ending with CR' '
'
test_expect_success 'config --blob outside of a repository is an error' '
nongit test_must_fail git config --blob=foo --list
test_must_fail nongit git config --blob=foo --list
'
test_done

View file

@ -166,14 +166,14 @@ test_expect_success 'find value with highest priority from a configset' '
'
test_expect_success 'find value_list for a key from a configset' '
cat >expect <<-\EOF &&
lama
ball
cat >except <<-\EOF &&
sam
bat
hask
lama
ball
EOF
test-tool config configset_get_value_multi case.baz config2 .git/config >actual &&
test-tool config configset_get_value case.baz config2 .git/config >actual &&
test_cmp expect actual
'
@ -238,8 +238,8 @@ test_expect_success 'error on modifying repo config without repo' '
cmdline_config="'foo.bar=from-cmdline'"
test_expect_success 'iteration shows correct origins' '
printf "[ignore]\n\tthis = please\n[foo]bar = from-repo\n" >.git/config &&
printf "[foo]\n\tbar = from-home\n" >.gitconfig &&
echo "[foo]bar = from-repo" >.git/config &&
echo "[foo]bar = from-home" >.gitconfig &&
if test_have_prereq MINGW
then
# Use Windows path (i.e. *not* $HOME)
@ -253,29 +253,19 @@ test_expect_success 'iteration shows correct origins' '
value=from-home
origin=file
name=$HOME_GITCONFIG
lno=2
scope=global
key=ignore.this
value=please
origin=file
name=.git/config
lno=2
scope=local
key=foo.bar
value=from-repo
origin=file
name=.git/config
lno=3
scope=local
scope=repo
key=foo.bar
value=from-cmdline
origin=command line
name=
lno=-1
scope=command
scope=cmdline
EOF
GIT_CONFIG_PARAMETERS=$cmdline_config test-tool config iterate >actual &&
test_cmp expect actual

View file

@ -29,7 +29,7 @@ test_expect_success 'ceiling' '
cd sub &&
test-tool config read_early_config early.config
) >output &&
test_must_be_empty output
test -z "$(cat output)"
'
test_expect_success 'ceiling #2' '
@ -91,12 +91,7 @@ test_expect_failure 'ignore .git/ with invalid config' '
test_expect_success 'early config and onbranch' '
echo "[broken" >broken &&
test_with_config "[includeif \"onbranch:master\"]path=../broken"
'
test_expect_success 'onbranch config outside of git repo' '
test_config_global includeIf.onbranch:master.path non-existent &&
nongit git help
test_with_config "[includeif \"onbranch:refs/heads/master\"]path=../broken"
'
test_done

View file

@ -344,16 +344,14 @@ test_expect_success "verifying $m's log (logged by config)" '
test_cmp expect .git/logs/$m
'
test_expect_success 'set up for querying the reflog' '
git update-ref $m $D &&
cat >.git/logs/$m <<-EOF
$Z $C $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
$C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150350 -0500
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500
$F $Z $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500
$Z $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500
EOF
'
git update-ref $m $D
cat >.git/logs/$m <<EOF
$Z $C $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
$C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150350 -0500
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500
$F $Z $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500
$Z $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500
EOF
ed="Thu, 26 May 2005 18:32:00 -0500"
gd="Thu, 26 May 2005 18:33:00 -0500"
@ -361,67 +359,55 @@ ld="Thu, 26 May 2005 18:43:00 -0500"
test_expect_success 'Query "master@{May 25 2005}" (before history)' '
test_when_finished "rm -f o e" &&
git rev-parse --verify "master@{May 25 2005}" >o 2>e &&
echo "$C" >expect &&
test_cmp expect o &&
echo "warning: log for '\''master'\'' only goes back to $ed" >expect &&
test_i18ncmp expect e
test $C = $(cat o) &&
test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"
'
test_expect_success 'Query master@{2005-05-25} (before history)' '
test_when_finished "rm -f o e" &&
git rev-parse --verify master@{2005-05-25} >o 2>e &&
echo "$C" >expect &&
test_cmp expect o &&
echo "warning: log for '\''master'\'' only goes back to $ed" >expect &&
test_i18ncmp expect e
test $C = $(cat o) &&
test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"
'
test_expect_success 'Query "master@{May 26 2005 23:31:59}" (1 second before history)' '
test_when_finished "rm -f o e" &&
git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&
echo "$C" >expect &&
test_cmp expect o &&
echo "warning: log for '\''master'\'' only goes back to $ed" >expect &&
test_i18ncmp expect e
test $C = $(cat o) &&
test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"
'
test_expect_success 'Query "master@{May 26 2005 23:32:00}" (exactly history start)' '
test_when_finished "rm -f o e" &&
git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
echo "$C" >expect &&
test_cmp expect o &&
test_must_be_empty e
test $C = $(cat o) &&
test "" = "$(cat e)"
'
test_expect_success 'Query "master@{May 26 2005 23:32:30}" (first non-creation change)' '
test_when_finished "rm -f o e" &&
git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e &&
echo "$A" >expect &&
test_cmp expect o &&
test_must_be_empty e
test $A = $(cat o) &&
test "" = "$(cat e)"
'
test_expect_success 'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' '
test_when_finished "rm -f o e" &&
git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e &&
echo "$B" >expect &&
test_cmp expect o &&
test $B = $(cat o) &&
test_i18ngrep -F "warning: log for ref $m has gap after $gd" e
'
test_expect_success 'Query "master@{2005-05-26 23:38:00}" (middle of history)' '
test_when_finished "rm -f o e" &&
git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e &&
echo "$Z" >expect &&
test_cmp expect o &&
test_must_be_empty e
test $Z = $(cat o) &&
test "" = "$(cat e)"
'
test_expect_success 'Query "master@{2005-05-26 23:43:00}" (exact end of history)' '
test_when_finished "rm -f o e" &&
git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e &&
echo "$E" >expect &&
test_cmp expect o &&
test_must_be_empty e
test $E = $(cat o) &&
test "" = "$(cat e)"
'
test_expect_success 'Query "master@{2005-05-28}" (past end of history)' '
test_when_finished "rm -f o e" &&
git rev-parse --verify "master@{2005-05-28}" >o 2>e &&
echo "$D" >expect &&
test_cmp expect o &&
test $D = $(cat o) &&
test_i18ngrep -F "warning: log for ref $m unexpectedly ended on $ld" e
'

View file

@ -32,6 +32,8 @@ test_update_rejected () {
test_cmp unchanged actual
}
Q="'"
# Test adding and deleting D/F-conflicting references in a single
# transaction.
df_test() {
@ -91,7 +93,7 @@ df_test() {
delname="$delref"
fi &&
cat >expected-err <<-EOF &&
fatal: cannot lock ref $SQ$addname$SQ: $SQ$delref$SQ exists; cannot create $SQ$addref$SQ
fatal: cannot lock ref $Q$addname$Q: $Q$delref$Q exists; cannot create $Q$addref$Q
EOF
$pack &&
if $add_del
@ -121,7 +123,7 @@ test_expect_success 'existing loose ref is a simple prefix of new' '
prefix=refs/1l &&
test_update_rejected "a c e" false "b c/x d" \
"$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x$SQ"
"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x$Q"
'
@ -129,7 +131,7 @@ test_expect_success 'existing packed ref is a simple prefix of new' '
prefix=refs/1p &&
test_update_rejected "a c e" true "b c/x d" \
"$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x$SQ"
"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x$Q"
'
@ -137,7 +139,7 @@ test_expect_success 'existing loose ref is a deeper prefix of new' '
prefix=refs/2l &&
test_update_rejected "a c e" false "b c/x/y d" \
"$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x/y$SQ"
"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x/y$Q"
'
@ -145,7 +147,7 @@ test_expect_success 'existing packed ref is a deeper prefix of new' '
prefix=refs/2p &&
test_update_rejected "a c e" true "b c/x/y d" \
"$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x/y$SQ"
"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x/y$Q"
'
@ -153,7 +155,7 @@ test_expect_success 'new ref is a simple prefix of existing loose' '
prefix=refs/3l &&
test_update_rejected "a c/x e" false "b c d" \
"$SQ$prefix/c/x$SQ exists; cannot create $SQ$prefix/c$SQ"
"$Q$prefix/c/x$Q exists; cannot create $Q$prefix/c$Q"
'
@ -161,7 +163,7 @@ test_expect_success 'new ref is a simple prefix of existing packed' '
prefix=refs/3p &&
test_update_rejected "a c/x e" true "b c d" \
"$SQ$prefix/c/x$SQ exists; cannot create $SQ$prefix/c$SQ"
"$Q$prefix/c/x$Q exists; cannot create $Q$prefix/c$Q"
'
@ -169,7 +171,7 @@ test_expect_success 'new ref is a deeper prefix of existing loose' '
prefix=refs/4l &&
test_update_rejected "a c/x/y e" false "b c d" \
"$SQ$prefix/c/x/y$SQ exists; cannot create $SQ$prefix/c$SQ"
"$Q$prefix/c/x/y$Q exists; cannot create $Q$prefix/c$Q"
'
@ -177,7 +179,7 @@ test_expect_success 'new ref is a deeper prefix of existing packed' '
prefix=refs/4p &&
test_update_rejected "a c/x/y e" true "b c d" \
"$SQ$prefix/c/x/y$SQ exists; cannot create $SQ$prefix/c$SQ"
"$Q$prefix/c/x/y$Q exists; cannot create $Q$prefix/c$Q"
'
@ -185,7 +187,7 @@ test_expect_success 'one new ref is a simple prefix of another' '
prefix=refs/5 &&
test_update_rejected "a e" false "b c c/x d" \
"cannot process $SQ$prefix/c$SQ and $SQ$prefix/c/x$SQ at the same time"
"cannot process $Q$prefix/c$Q and $Q$prefix/c/x$Q at the same time"
'
@ -332,7 +334,7 @@ test_expect_success 'D/F conflict prevents indirect delete long packed + indirec
test_expect_success 'missing old value blocks update' '
prefix=refs/missing-update &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ
fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q
EOF
printf "%s\n" "update $prefix/foo $E $D" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -343,7 +345,7 @@ test_expect_success 'incorrect old value blocks update' '
prefix=refs/incorrect-update &&
git update-ref $prefix/foo $C &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/foo$SQ: is at $C but expected $D
fatal: cannot lock ref $Q$prefix/foo$Q: is at $C but expected $D
EOF
printf "%s\n" "update $prefix/foo $E $D" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -354,7 +356,7 @@ test_expect_success 'existing old value blocks create' '
prefix=refs/existing-create &&
git update-ref $prefix/foo $C &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/foo$SQ: reference already exists
fatal: cannot lock ref $Q$prefix/foo$Q: reference already exists
EOF
printf "%s\n" "create $prefix/foo $E" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -365,7 +367,7 @@ test_expect_success 'incorrect old value blocks delete' '
prefix=refs/incorrect-delete &&
git update-ref $prefix/foo $C &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/foo$SQ: is at $C but expected $D
fatal: cannot lock ref $Q$prefix/foo$Q: is at $C but expected $D
EOF
printf "%s\n" "delete $prefix/foo $D" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -376,7 +378,7 @@ test_expect_success 'missing old value blocks indirect update' '
prefix=refs/missing-indirect-update &&
git symbolic-ref $prefix/symref $prefix/foo &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ
fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q
EOF
printf "%s\n" "update $prefix/symref $E $D" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -388,7 +390,7 @@ test_expect_success 'incorrect old value blocks indirect update' '
git symbolic-ref $prefix/symref $prefix/foo &&
git update-ref $prefix/foo $C &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D
fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
EOF
printf "%s\n" "update $prefix/symref $E $D" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -400,7 +402,7 @@ test_expect_success 'existing old value blocks indirect create' '
git symbolic-ref $prefix/symref $prefix/foo &&
git update-ref $prefix/foo $C &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/symref$SQ: reference already exists
fatal: cannot lock ref $Q$prefix/symref$Q: reference already exists
EOF
printf "%s\n" "create $prefix/symref $E" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -412,7 +414,7 @@ test_expect_success 'incorrect old value blocks indirect delete' '
git symbolic-ref $prefix/symref $prefix/foo &&
git update-ref $prefix/foo $C &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D
fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
EOF
printf "%s\n" "delete $prefix/symref $D" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -423,7 +425,7 @@ test_expect_success 'missing old value blocks indirect no-deref update' '
prefix=refs/missing-noderef-update &&
git symbolic-ref $prefix/symref $prefix/foo &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/symref$SQ: reference is missing but expected $D
fatal: cannot lock ref $Q$prefix/symref$Q: reference is missing but expected $D
EOF
printf "%s\n" "option no-deref" "update $prefix/symref $E $D" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -435,7 +437,7 @@ test_expect_success 'incorrect old value blocks indirect no-deref update' '
git symbolic-ref $prefix/symref $prefix/foo &&
git update-ref $prefix/foo $C &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D
fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
EOF
printf "%s\n" "option no-deref" "update $prefix/symref $E $D" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -447,7 +449,7 @@ test_expect_success 'existing old value blocks indirect no-deref create' '
git symbolic-ref $prefix/symref $prefix/foo &&
git update-ref $prefix/foo $C &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/symref$SQ: reference already exists
fatal: cannot lock ref $Q$prefix/symref$Q: reference already exists
EOF
printf "%s\n" "option no-deref" "create $prefix/symref $E" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -459,7 +461,7 @@ test_expect_success 'incorrect old value blocks indirect no-deref delete' '
git symbolic-ref $prefix/symref $prefix/foo &&
git update-ref $prefix/foo $C &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D
fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
EOF
printf "%s\n" "option no-deref" "delete $prefix/symref $D" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -472,13 +474,13 @@ test_expect_success 'non-empty directory blocks create' '
: >.git/$prefix/foo/bar/baz.lock &&
test_when_finished "rm -f .git/$prefix/foo/bar/baz.lock" &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/foo$SQ: there is a non-empty directory $SQ.git/$prefix/foo$SQ blocking reference $SQ$prefix/foo$SQ
fatal: cannot lock ref $Q$prefix/foo$Q: there is a non-empty directory $Q.git/$prefix/foo$Q blocking reference $Q$prefix/foo$Q
EOF
printf "%s\n" "update $prefix/foo $C" |
test_must_fail git update-ref --stdin 2>output.err &&
test_cmp expected output.err &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ
fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q
EOF
printf "%s\n" "update $prefix/foo $D $C" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -491,13 +493,13 @@ test_expect_success 'broken reference blocks create' '
echo "gobbledigook" >.git/$prefix/foo &&
test_when_finished "rm -f .git/$prefix/foo" &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken
EOF
printf "%s\n" "update $prefix/foo $C" |
test_must_fail git update-ref --stdin 2>output.err &&
test_cmp expected output.err &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken
EOF
printf "%s\n" "update $prefix/foo $D $C" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -511,13 +513,13 @@ test_expect_success 'non-empty directory blocks indirect create' '
: >.git/$prefix/foo/bar/baz.lock &&
test_when_finished "rm -f .git/$prefix/foo/bar/baz.lock" &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/symref$SQ: there is a non-empty directory $SQ.git/$prefix/foo$SQ blocking reference $SQ$prefix/foo$SQ
fatal: cannot lock ref $Q$prefix/symref$Q: there is a non-empty directory $Q.git/$prefix/foo$Q blocking reference $Q$prefix/foo$Q
EOF
printf "%s\n" "update $prefix/symref $C" |
test_must_fail git update-ref --stdin 2>output.err &&
test_cmp expected output.err &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ
fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q
EOF
printf "%s\n" "update $prefix/symref $D $C" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -530,13 +532,13 @@ test_expect_success 'broken reference blocks indirect create' '
echo "gobbledigook" >.git/$prefix/foo &&
test_when_finished "rm -f .git/$prefix/foo" &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken
EOF
printf "%s\n" "update $prefix/symref $C" |
test_must_fail git update-ref --stdin 2>output.err &&
test_cmp expected output.err &&
cat >expected <<-EOF &&
fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken
EOF
printf "%s\n" "update $prefix/symref $D $C" |
test_must_fail git update-ref --stdin 2>output.err &&
@ -612,7 +614,7 @@ test_expect_success 'delete fails cleanly if packed-refs file is locked' '
test_when_finished "rm -f .git/packed-refs.lock" &&
test_must_fail git update-ref -d $prefix/foo >out 2>err &&
git for-each-ref $prefix >actual &&
test_i18ngrep "Unable to create $SQ.*packed-refs.lock$SQ: " err &&
test_i18ngrep "Unable to create $Q.*packed-refs.lock$Q: " err &&
test_cmp unchanged actual
'

View file

@ -75,7 +75,7 @@ test_expect_success 'for_each_reflog()' '
'
test_expect_success 'for_each_reflog_ent()' '
$RUN for-each-reflog-ent HEAD >actual &&
$RUN for-each-reflog-ent HEAD >actual && cat actual &&
head -n1 actual | grep first &&
tail -n2 actual | head -n1 | grep master.to.new
'

View file

@ -8,7 +8,7 @@ test_description='avoid rewriting packed-refs unnecessarily'
# shouldn't upset readers, and it should be omitted if the file is
# ever rewritten.
mark_packed_refs () {
sed -e "s/^\(#.*\)/\1 t1409 /" .git/packed-refs >.git/packed-refs.new &&
sed -e "s/^\(#.*\)/\1 t1409 /" <.git/packed-refs >.git/packed-refs.new &&
mv .git/packed-refs.new .git/packed-refs
}
@ -27,15 +27,15 @@ test_expect_success 'setup' '
'
test_expect_success 'do not create packed-refs file gratuitously' '
test_path_is_missing .git/packed-refs &&
test_must_fail test -f .git/packed-refs &&
git update-ref refs/heads/foo $A &&
test_path_is_missing .git/packed-refs &&
test_must_fail test -f .git/packed-refs &&
git update-ref refs/heads/foo $B &&
test_path_is_missing .git/packed-refs &&
test_must_fail test -f .git/packed-refs &&
git update-ref refs/heads/foo $C $B &&
test_path_is_missing .git/packed-refs &&
test_must_fail test -f .git/packed-refs &&
git update-ref -d refs/heads/foo &&
test_path_is_missing .git/packed-refs
test_must_fail test -f .git/packed-refs
'
test_expect_success 'check that marking the packed-refs file works' '
@ -46,7 +46,7 @@ test_expect_success 'check that marking the packed-refs file works' '
git for-each-ref >actual &&
test_cmp expected actual &&
git pack-refs --all &&
! check_packed_refs_marked &&
test_must_fail check_packed_refs_marked &&
git for-each-ref >actual2 &&
test_cmp expected actual2
'
@ -80,7 +80,7 @@ test_expect_success 'touch packed-refs on delete of packed' '
git pack-refs --all &&
mark_packed_refs &&
git update-ref -d refs/heads/packed-delete &&
! check_packed_refs_marked
test_must_fail check_packed_refs_marked
'
test_expect_success 'leave packed-refs untouched on update of loose' '

View file

@ -195,7 +195,7 @@ test_expect_success 'delete' '
git reflog delete master@{1} &&
git reflog show master > output &&
test_line_count = $(($master_entry_count - 1)) output &&
test $(($master_entry_count - 1)) = $(wc -l < output) &&
test $HEAD_entry_count = $(git reflog | wc -l) &&
! grep ox < output &&
@ -209,7 +209,7 @@ test_expect_success 'delete' '
git reflog delete master@{07.04.2005.15:15:00.-0700} &&
git reflog show master > output &&
test_line_count = $(($master_entry_count - 1)) output &&
test $(($master_entry_count - 1)) = $(wc -l < output) &&
! grep dragon < output
'

View file

@ -18,9 +18,10 @@ do_walk () {
git log -g --format="%gd %gs" "$@"
}
sq="'"
test_expect_success 'set up expected reflog' '
cat >expect.all <<-EOF
HEAD@{0} commit (merge): Merge branch ${SQ}master${SQ} into side
HEAD@{0} commit (merge): Merge branch ${sq}master${sq} into side
HEAD@{1} commit: three
HEAD@{2} checkout: moving from master to side
HEAD@{3} commit: two

View file

@ -70,6 +70,7 @@ test_expect_success 'object with bad sha1' '
test_when_finished "git update-ref -d refs/heads/bogus" &&
test_must_fail git fsck 2>out &&
cat out &&
test_i18ngrep "$sha.*corrupt" out
'
@ -77,6 +78,7 @@ test_expect_success 'branch pointing to non-commit' '
git rev-parse HEAD^{tree} >.git/refs/heads/invalid &&
test_when_finished "git update-ref -d refs/heads/invalid" &&
test_must_fail git fsck 2>out &&
cat out &&
test_i18ngrep "not a commit" out
'
@ -86,6 +88,7 @@ test_expect_success 'HEAD link pointing at a funny object' '
echo $ZERO_OID >.git/HEAD &&
# avoid corrupt/broken HEAD from interfering with repo discovery
test_must_fail env GIT_DIR=.git git fsck 2>out &&
cat out &&
test_i18ngrep "detached HEAD points" out
'
@ -95,6 +98,7 @@ test_expect_success 'HEAD link pointing at a funny place' '
echo "ref: refs/funny/place" >.git/HEAD &&
# avoid corrupt/broken HEAD from interfering with repo discovery
test_must_fail env GIT_DIR=.git git fsck 2>out &&
cat out &&
test_i18ngrep "HEAD points to something strange" out
'
@ -141,6 +145,7 @@ test_expect_success 'email without @ is okay' '
git update-ref refs/heads/bogus "$new" &&
test_when_finished "git update-ref -d refs/heads/bogus" &&
git fsck 2>out &&
cat out &&
! grep "commit $new" out
'
@ -152,6 +157,7 @@ test_expect_success 'email with embedded > is not okay' '
git update-ref refs/heads/bogus "$new" &&
test_when_finished "git update-ref -d refs/heads/bogus" &&
test_must_fail git fsck 2>out &&
cat out &&
test_i18ngrep "error in commit $new" out
'
@ -163,6 +169,7 @@ test_expect_success 'missing < email delimiter is reported nicely' '
git update-ref refs/heads/bogus "$new" &&
test_when_finished "git update-ref -d refs/heads/bogus" &&
test_must_fail git fsck 2>out &&
cat out &&
test_i18ngrep "error in commit $new.* - bad name" out
'
@ -174,6 +181,7 @@ test_expect_success 'missing email is reported nicely' '
git update-ref refs/heads/bogus "$new" &&
test_when_finished "git update-ref -d refs/heads/bogus" &&
test_must_fail git fsck 2>out &&
cat out &&
test_i18ngrep "error in commit $new.* - missing email" out
'
@ -185,6 +193,7 @@ test_expect_success '> in name is reported' '
git update-ref refs/heads/bogus "$new" &&
test_when_finished "git update-ref -d refs/heads/bogus" &&
test_must_fail git fsck 2>out &&
cat out &&
test_i18ngrep "error in commit $new" out
'
@ -198,6 +207,7 @@ test_expect_success 'integer overflow in timestamps is reported' '
git update-ref refs/heads/bogus "$new" &&
test_when_finished "git update-ref -d refs/heads/bogus" &&
test_must_fail git fsck 2>out &&
cat out &&
test_i18ngrep "error in commit $new.*integer overflow" out
'
@ -209,6 +219,7 @@ test_expect_success 'commit with NUL in header' '
git update-ref refs/heads/bogus "$new" &&
test_when_finished "git update-ref -d refs/heads/bogus" &&
test_must_fail git fsck 2>out &&
cat out &&
test_i18ngrep "error in commit $new.*unterminated header: NUL at offset" out
'
@ -286,6 +297,7 @@ test_expect_success 'tag pointing to nonexistent' '
echo $tag >.git/refs/tags/invalid &&
test_when_finished "git update-ref -d refs/tags/invalid" &&
test_must_fail git fsck --tags >out &&
cat out &&
test_i18ngrep "broken link" out
'
@ -366,6 +378,7 @@ test_expect_success 'tag with NUL in header' '
echo $tag >.git/refs/tags/wrong &&
test_when_finished "git update-ref -d refs/tags/wrong" &&
test_must_fail git fsck --tags 2>out &&
cat out &&
test_i18ngrep "error in tag $tag.*unterminated header: NUL at offset" out
'
@ -396,6 +409,7 @@ test_expect_success 'rev-list --verify-objects with bad sha1' '
test_when_finished "git update-ref -d refs/heads/bogus" &&
test_might_fail git rev-list --verify-objects refs/heads/bogus >/dev/null 2>out &&
cat out &&
test_i18ngrep -q "error: hash mismatch $(dirname $new)$(test_oid ff_2)" out
'
@ -419,6 +433,7 @@ test_expect_success 'fsck notices blob entry pointing to null sha1' '
sha=$(printf "100644 file$_bz$_bzoid" |
git hash-object -w --stdin -t tree) &&
git fsck 2>out &&
cat out &&
test_i18ngrep "warning.*null sha1" out
)
'
@ -429,6 +444,7 @@ test_expect_success 'fsck notices submodule entry pointing to null sha1' '
sha=$(printf "160000 submodule$_bz$_bzoid" |
git hash-object -w --stdin -t tree) &&
git fsck 2>out &&
cat out &&
test_i18ngrep "warning.*null sha1" out
)
'
@ -440,7 +456,6 @@ while read name path pretty; do
(
git init $name-$type &&
cd $name-$type &&
git config core.protectNTFS false &&
echo content >file &&
git add file &&
git commit -m base &&
@ -450,6 +465,7 @@ while read name path pretty; do
printf "$mode $type %s\t%s" "$value" "$path" >bad &&
bad_tree=$(git mktree <bad) &&
git fsck 2>out &&
cat out &&
test_i18ngrep "warning.*tree $bad_tree" out
)'
done <<-\EOF
@ -616,7 +632,7 @@ test_expect_success 'fsck --name-objects' '
remove_object $(git rev-parse julius:caesar.t) &&
test_must_fail git fsck --name-objects >out &&
tree=$(git rev-parse --verify julius:) &&
test_i18ngrep "$tree (refs/tags/julius:" out
test_i18ngrep -E "$tree \((refs/heads/master|HEAD)@\{[0-9]*\}:" out
)
'

View file

@ -59,7 +59,6 @@ test_rev_parse () {
ROOT=$(pwd)
test_expect_success 'setup' '
test_oid_init &&
mkdir -p sub/dir work &&
cp -R .git repo.git
'
@ -132,30 +131,6 @@ test_expect_success 'rev-parse --is-shallow-repository in non-shallow repo' '
test_cmp expect actual
'
test_expect_success 'rev-parse --show-object-format in repo' '
echo "$(test_oid algo)" >expect &&
git rev-parse --show-object-format >actual &&
test_cmp expect actual &&
git rev-parse --show-object-format=storage >actual &&
test_cmp expect actual &&
git rev-parse --show-object-format=input >actual &&
test_cmp expect actual &&
git rev-parse --show-object-format=output >actual &&
test_cmp expect actual &&
test_must_fail git rev-parse --show-object-format=squeamish-ossifrage 2>err &&
grep "unknown mode for --show-object-format: squeamish-ossifrage" err
'
test_expect_success '--show-toplevel from subdir of working tree' '
pwd >expect &&
git -C sub/dir rev-parse --show-toplevel >actual &&
test_cmp expect actual
'
test_expect_success '--show-toplevel from inside .git' '
test_must_fail git -C .git rev-parse --show-toplevel
'
test_expect_success 'showing the superproject correctly' '
git rev-parse --show-superproject-working-tree >out &&
test_must_be_empty out &&

View file

@ -350,7 +350,7 @@ test_expect_success 'Multi-worktree setup' '
mkdir work &&
mkdir -p repo.git/repos/foo &&
cp repo.git/HEAD repo.git/index repo.git/repos/foo &&
{ cp repo.git/sharedindex.* repo.git/repos/foo || :; } &&
test_might_fail cp repo.git/sharedindex.* repo.git/repos/foo &&
sane_unset GIT_DIR GIT_CONFIG GIT_WORK_TREE
'

View file

@ -8,11 +8,12 @@ exec </dev/null
test_did_you_mean ()
{
sq="'" &&
cat >expected <<-EOF &&
fatal: path '$2$3' $4, but not ${5:-$SQ$3$SQ}
hint: Did you mean '$1:$2$3'${2:+ aka $SQ$1:./$3$SQ}?
fatal: Path '$2$3' $4, but not ${5:-$sq$3$sq}.
Did you mean '$1:$2$3'${2:+ aka $sq$1:./$3$sq}?
EOF
test_i18ncmp expected error
test_cmp expected error
}
HASH_file=
@ -103,66 +104,66 @@ test_expect_success 'correct relative file objects (6)' '
test_expect_success 'incorrect revision id' '
test_must_fail git rev-parse foobar:file.txt 2>error &&
test_i18ngrep "invalid object name .foobar." error &&
test_must_fail git rev-parse foobar 2>error &&
grep "Invalid object name '"'"'foobar'"'"'." error &&
test_must_fail git rev-parse foobar 2> error &&
test_i18ngrep "unknown revision or path not in the working tree." error
'
test_expect_success 'incorrect file in sha1:path' '
test_must_fail git rev-parse HEAD:nothing.txt 2>error &&
test_i18ngrep "path .nothing.txt. does not exist in .HEAD." error &&
test_must_fail git rev-parse HEAD:index-only.txt 2>error &&
test_i18ngrep "path .index-only.txt. exists on disk, but not in .HEAD." error &&
test_must_fail git rev-parse HEAD:nothing.txt 2> error &&
grep "fatal: Path '"'"'nothing.txt'"'"' does not exist in '"'"'HEAD'"'"'" error &&
test_must_fail git rev-parse HEAD:index-only.txt 2> error &&
grep "fatal: Path '"'"'index-only.txt'"'"' exists on disk, but not in '"'"'HEAD'"'"'." error &&
(cd subdir &&
test_must_fail git rev-parse HEAD:file2.txt 2>error &&
test_must_fail git rev-parse HEAD:file2.txt 2> error &&
test_did_you_mean HEAD subdir/ file2.txt exists )
'
test_expect_success 'incorrect file in :path and :N:path' '
test_must_fail git rev-parse :nothing.txt 2>error &&
test_i18ngrep "path .nothing.txt. does not exist (neither on disk nor in the index)" error &&
test_must_fail git rev-parse :1:nothing.txt 2>error &&
test_i18ngrep "path .nothing.txt. does not exist (neither on disk nor in the index)" error &&
test_must_fail git rev-parse :1:file.txt 2>error &&
test_must_fail git rev-parse :nothing.txt 2> error &&
grep "fatal: Path '"'"'nothing.txt'"'"' does not exist (neither on disk nor in the index)." error &&
test_must_fail git rev-parse :1:nothing.txt 2> error &&
grep "Path '"'"'nothing.txt'"'"' does not exist (neither on disk nor in the index)." error &&
test_must_fail git rev-parse :1:file.txt 2> error &&
test_did_you_mean ":0" "" file.txt "is in the index" "at stage 1" &&
(cd subdir &&
test_must_fail git rev-parse :1:file.txt 2>error &&
test_must_fail git rev-parse :1:file.txt 2> error &&
test_did_you_mean ":0" "" file.txt "is in the index" "at stage 1" &&
test_must_fail git rev-parse :file2.txt 2>error &&
test_must_fail git rev-parse :file2.txt 2> error &&
test_did_you_mean ":0" subdir/ file2.txt "is in the index" &&
test_must_fail git rev-parse :2:file2.txt 2>error &&
test_must_fail git rev-parse :2:file2.txt 2> error &&
test_did_you_mean :0 subdir/ file2.txt "is in the index") &&
test_must_fail git rev-parse :disk-only.txt 2>error &&
test_i18ngrep "path .disk-only.txt. exists on disk, but not in the index" error
test_must_fail git rev-parse :disk-only.txt 2> error &&
grep "fatal: Path '"'"'disk-only.txt'"'"' exists on disk, but not in the index." error
'
test_expect_success 'invalid @{n} reference' '
test_must_fail git rev-parse master@{99999} >output 2>error &&
test_must_be_empty output &&
test_i18ngrep "log for [^ ]* only has [0-9][0-9]* entries" error &&
test -z "$(cat output)" &&
grep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error &&
test_must_fail git rev-parse --verify master@{99999} >output 2>error &&
test_must_be_empty output &&
test_i18ngrep "log for [^ ]* only has [0-9][0-9]* entries" error
test -z "$(cat output)" &&
grep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error
'
test_expect_success 'relative path not found' '
(
cd subdir &&
test_must_fail git rev-parse HEAD:./nonexistent.txt 2>error &&
test_i18ngrep subdir/nonexistent.txt error
grep subdir/nonexistent.txt error
)
'
test_expect_success 'relative path outside worktree' '
test_must_fail git rev-parse HEAD:../file.txt >output 2>error &&
test_must_be_empty output &&
test -z "$(cat output)" &&
test_i18ngrep "outside repository" error
'
test_expect_success 'relative path when cwd is outside worktree' '
test_must_fail git --git-dir=.git --work-tree=subdir rev-parse HEAD:./file.txt >output 2>error &&
test_must_be_empty output &&
test_i18ngrep "relative path syntax can.t be used outside working tree" error
test -z "$(cat output)" &&
grep "relative path syntax can.t be used outside working tree." error
'
test_expect_success '<commit>:file correctly diagnosed after a pathname' '
@ -214,26 +215,4 @@ test_expect_success 'arg before dashdash must be a revision (ambiguous)' '
test_cmp expect actual
'
test_expect_success 'reject Nth parent if N is too high' '
test_must_fail git rev-parse HEAD^100000000000000000000000000000000
'
test_expect_success 'reject Nth ancestor if N is too high' '
test_must_fail git rev-parse HEAD~100000000000000000000000000000000
'
test_expect_success 'pathspecs with wildcards are not ambiguous' '
echo "*.c" >expect &&
git rev-parse "*.c" >actual &&
test_cmp expect actual
'
test_expect_success 'backslash does not trigger wildcard rule' '
test_must_fail git rev-parse "foo\\bar"
'
test_expect_success 'escaped char does not trigger wildcard rule' '
test_must_fail git rev-parse "foo\\*bar"
'
test_done

View file

@ -28,9 +28,16 @@ test_expect_success 'setup' '
)
'
sq="'"
full_name () {
(cd clone &&
git rev-parse --symbolic-full-name "$@")
}
commit_subject () {
(cd clone &&
git show -s --pretty=tformat:%s "$@")
git show -s --pretty=format:%s "$@")
}
error_message () {
@ -39,78 +46,63 @@ error_message () {
}
test_expect_success '@{upstream} resolves to correct full name' '
echo refs/remotes/origin/master >expect &&
git -C clone rev-parse --symbolic-full-name @{upstream} >actual &&
test_cmp expect actual &&
git -C clone rev-parse --symbolic-full-name @{UPSTREAM} >actual &&
test_cmp expect actual &&
git -C clone rev-parse --symbolic-full-name @{UpSTReam} >actual &&
test_cmp expect actual
test refs/remotes/origin/master = "$(full_name @{upstream})" &&
test refs/remotes/origin/master = "$(full_name @{UPSTREAM})" &&
test refs/remotes/origin/master = "$(full_name @{UpSTReam})"
'
test_expect_success '@{u} resolves to correct full name' '
echo refs/remotes/origin/master >expect &&
git -C clone rev-parse --symbolic-full-name @{u} >actual &&
test_cmp expect actual &&
git -C clone rev-parse --symbolic-full-name @{U} >actual &&
test_cmp expect actual
test refs/remotes/origin/master = "$(full_name @{u})" &&
test refs/remotes/origin/master = "$(full_name @{U})"
'
test_expect_success 'my-side@{upstream} resolves to correct full name' '
echo refs/remotes/origin/side >expect &&
git -C clone rev-parse --symbolic-full-name my-side@{u} >actual &&
test_cmp expect actual
test refs/remotes/origin/side = "$(full_name my-side@{u})"
'
test_expect_success 'upstream of branch with @ in middle' '
git -C clone rev-parse --symbolic-full-name fun@ny@{u} >actual &&
full_name fun@ny@{u} >actual &&
echo refs/remotes/origin/side >expect &&
test_cmp expect actual &&
git -C clone rev-parse --symbolic-full-name fun@ny@{U} >actual &&
full_name fun@ny@{U} >actual &&
test_cmp expect actual
'
test_expect_success 'upstream of branch with @ at start' '
git -C clone rev-parse --symbolic-full-name @funny@{u} >actual &&
full_name @funny@{u} >actual &&
echo refs/remotes/origin/side >expect &&
test_cmp expect actual
'
test_expect_success 'upstream of branch with @ at end' '
git -C clone rev-parse --symbolic-full-name funny@@{u} >actual &&
full_name funny@@{u} >actual &&
echo refs/remotes/origin/side >expect &&
test_cmp expect actual
'
test_expect_success 'refs/heads/my-side@{upstream} does not resolve to my-side{upstream}' '
test_must_fail git -C clone rev-parse --symbolic-full-name refs/heads/my-side@{upstream}
test_must_fail full_name refs/heads/my-side@{upstream}
'
test_expect_success 'my-side@{u} resolves to correct commit' '
git checkout side &&
test_commit 5 &&
(cd clone && git fetch) &&
echo 2 >expect &&
commit_subject my-side >actual &&
test_cmp expect actual &&
echo 5 >expect &&
commit_subject my-side@{u} >actual
test 2 = "$(commit_subject my-side)" &&
test 5 = "$(commit_subject my-side@{u})"
'
test_expect_success 'not-tracking@{u} fails' '
test_must_fail git -C clone rev-parse --symbolic-full-name non-tracking@{u} &&
test_must_fail full_name non-tracking@{u} &&
(cd clone && git checkout --no-track -b non-tracking) &&
test_must_fail git -C clone rev-parse --symbolic-full-name non-tracking@{u}
test_must_fail full_name non-tracking@{u}
'
test_expect_success '<branch>@{u}@{1} resolves correctly' '
test_commit 6 &&
(cd clone && git fetch) &&
echo 5 >expect &&
commit_subject my-side@{u}@{1} >actual &&
test_cmp expect actual &&
commit_subject my-side@{U}@{1} >actual &&
test_cmp expect actual
test 5 = $(commit_subject my-side@{u}@{1}) &&
test 5 = $(commit_subject my-side@{U}@{1})
'
test_expect_success '@{u} without specifying branch fails on a detached HEAD' '
@ -137,7 +129,7 @@ test_expect_success 'merge my-side@{u} records the correct name' '
git branch -t new my-side@{u} &&
git merge -s ours new@{u} &&
git show -s --pretty=tformat:%s >actual &&
echo "Merge remote-tracking branch ${SQ}origin/side${SQ}" >expect &&
echo "Merge remote-tracking branch ${sq}origin/side${sq}" >expect &&
test_cmp expect actual
)
'
@ -159,14 +151,12 @@ test_expect_success 'checkout other@{u}' '
'
test_expect_success 'branch@{u} works when tracking a local branch' '
echo refs/heads/master >expect &&
git -C clone rev-parse --symbolic-full-name local-master@{u} >actual &&
test_cmp expect actual
test refs/heads/master = "$(full_name local-master@{u})"
'
test_expect_success 'branch@{u} error message when no upstream' '
cat >expect <<-EOF &&
fatal: no upstream configured for branch ${SQ}non-tracking${SQ}
fatal: no upstream configured for branch ${sq}non-tracking${sq}
EOF
error_message non-tracking@{u} &&
test_i18ncmp expect error
@ -174,7 +164,7 @@ test_expect_success 'branch@{u} error message when no upstream' '
test_expect_success '@{u} error message when no upstream' '
cat >expect <<-EOF &&
fatal: no upstream configured for branch ${SQ}master${SQ}
fatal: no upstream configured for branch ${sq}master${sq}
EOF
test_must_fail git rev-parse --verify @{u} 2>actual &&
test_i18ncmp expect actual
@ -182,7 +172,7 @@ test_expect_success '@{u} error message when no upstream' '
test_expect_success 'branch@{u} error message with misspelt branch' '
cat >expect <<-EOF &&
fatal: no such branch: ${SQ}no-such-branch${SQ}
fatal: no such branch: ${sq}no-such-branch${sq}
EOF
error_message no-such-branch@{u} &&
test_i18ncmp expect error
@ -199,7 +189,7 @@ test_expect_success '@{u} error message when not on a branch' '
test_expect_success 'branch@{u} error message if upstream branch not fetched' '
cat >expect <<-EOF &&
fatal: upstream branch ${SQ}refs/heads/side${SQ} not stored as a remote-tracking branch
fatal: upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
EOF
error_message bad-upstream@{u} &&
test_i18ncmp expect error
@ -215,37 +205,35 @@ test_expect_success 'pull works when tracking a local branch' '
# makes sense if the previous one succeeded
test_expect_success '@{u} works when tracking a local branch' '
echo refs/heads/master >expect &&
git -C clone rev-parse --symbolic-full-name @{u} >actual &&
test_cmp expect actual
test refs/heads/master = "$(full_name @{u})"
'
test_expect_success 'log -g other@{u}' '
commit=$(git rev-parse HEAD) &&
cat >expect <<-EOF &&
commit $commit
Reflog: master@{0} (C O Mitter <committer@example.com>)
Reflog message: branch: Created from HEAD
Author: A U Thor <author@example.com>
Date: Thu Apr 7 15:15:13 2005 -0700
commit=$(git rev-parse HEAD)
cat >expect <<EOF
commit $commit
Reflog: master@{0} (C O Mitter <committer@example.com>)
Reflog message: branch: Created from HEAD
Author: A U Thor <author@example.com>
Date: Thu Apr 7 15:15:13 2005 -0700
3
EOF
3
EOF
test_expect_success 'log -g other@{u}' '
git log -1 -g other@{u} >actual &&
test_cmp expect actual
'
test_expect_success 'log -g other@{u}@{now}' '
commit=$(git rev-parse HEAD) &&
cat >expect <<-EOF &&
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>
Date: Thu Apr 7 15:15:13 2005 -0700
cat >expect <<EOF
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>
Date: Thu Apr 7 15:15:13 2005 -0700
3
EOF
3
EOF
test_expect_success 'log -g other@{u}@{now}' '
git log -1 -g other@{u}@{now} >actual &&
test_cmp expect actual
'

View file

@ -282,7 +282,7 @@ test_expect_success 'rev-parse --disambiguate' '
# commits created by commit-tree in earlier tests share a
# different prefix.
git rev-parse --disambiguate=000000000 >actual &&
test_line_count = 16 actual &&
test $(wc -l <actual) = 16 &&
test "$(sed -e "s/^\(.........\).*/\1/" actual | sort -u)" = 000000000
'
@ -339,7 +339,7 @@ test_expect_success C_LOCALE_OUTPUT 'ambiguity hints' '
test_expect_success C_LOCALE_OUTPUT 'ambiguity hints respect type' '
test_must_fail git rev-parse 000000000^{commit} 2>stderr &&
grep ^hint: stderr >hints &&
# 5 commits, 1 tag (which is a committish), plus intro line
# 5 commits, 1 tag (which is a commitish), plus intro line
test_line_count = 7 hints
'

View file

@ -59,42 +59,17 @@ test_expect_success 'out of bounds index.version issues warning' '
)
'
test_index_version () {
INDEX_VERSION_CONFIG=$1 &&
FEATURE_MANY_FILES=$2 &&
ENV_VAR_VERSION=$3
EXPECTED_OUTPUT_VERSION=$4 &&
test_expect_success 'GIT_INDEX_VERSION takes precedence over config' '
(
rm -f .git/index &&
rm -f .git/config &&
if test "$INDEX_VERSION_CONFIG" -ne 0
then
git config --add index.version $INDEX_VERSION_CONFIG
fi &&
git config --add feature.manyFiles $FEATURE_MANY_FILES
if test "$ENV_VAR_VERSION" -ne 0
then
GIT_INDEX_VERSION=$ENV_VAR_VERSION &&
export GIT_INDEX_VERSION
else
unset GIT_INDEX_VERSION
fi &&
GIT_INDEX_VERSION=4 &&
export GIT_INDEX_VERSION &&
git config --add index.version 2 &&
git add a 2>&1 &&
echo $EXPECTED_OUTPUT_VERSION >expect &&
echo 4 >expect &&
test-tool index-version <.git/index >actual &&
test_cmp expect actual
)
}
test_expect_success 'index version config precedence' '
test_index_version 0 false 0 2 &&
test_index_version 2 false 0 2 &&
test_index_version 3 false 0 2 &&
test_index_version 4 false 0 4 &&
test_index_version 2 false 4 4 &&
test_index_version 2 true 0 2 &&
test_index_version 0 true 0 4 &&
test_index_version 0 true 2 2
'
test_done

View file

@ -1,76 +1,50 @@
#!/bin/sh
test_description='checkout'
test_description='checkout '
. ./test-lib.sh
# Arguments: [!] <branch> <oid> [<checkout options>]
# Arguments: <branch> <sha> [<checkout options>]
#
# Runs "git checkout" to switch to <branch>, testing that
#
# 1) we are on the specified branch, <branch>;
# 2) HEAD is <oid>; if <oid> is not specified, the old HEAD is used.
# 2) HEAD is <sha>; if <sha> is not specified, the old HEAD is used.
#
# If <checkout options> is not specified, "git checkout" is run with -b.
#
# If the first argument is `!`, "git checkout" is expected to fail when
# it is run.
do_checkout () {
should_fail= &&
if test "x$1" = "x!"
then
should_fail=yes &&
shift
fi &&
do_checkout() {
exp_branch=$1 &&
exp_ref="refs/heads/$exp_branch" &&
# if <oid> is not specified, use HEAD.
exp_oid=${2:-$(git rev-parse --verify HEAD)} &&
# if <sha> is not specified, use HEAD.
exp_sha=${2:-$(git rev-parse --verify HEAD)} &&
# default options for git checkout: -b
if test -z "$3"
then
if [ -z "$3" ]; then
opts="-b"
else
opts="$3"
fi
if test -n "$should_fail"
then
test_must_fail git checkout $opts $exp_branch $exp_oid
else
git checkout $opts $exp_branch $exp_oid &&
echo "$exp_ref" >ref.expect &&
git rev-parse --symbolic-full-name HEAD >ref.actual &&
test_cmp ref.expect ref.actual &&
echo "$exp_oid" >oid.expect &&
git rev-parse --verify HEAD >oid.actual &&
test_cmp oid.expect oid.actual
fi
git checkout $opts $exp_branch $exp_sha &&
test $exp_ref = $(git rev-parse --symbolic-full-name HEAD) &&
test $exp_sha = $(git rev-parse --verify HEAD)
}
test_dirty_unmergeable () {
test_expect_code 1 git diff --exit-code
test_dirty_unmergeable() {
! git diff --exit-code >/dev/null
}
test_dirty_unmergeable_discards_changes () {
git diff --exit-code
}
setup_dirty_unmergeable () {
setup_dirty_unmergeable() {
echo >>file1 change2
}
test_dirty_mergeable () {
test_expect_code 1 git diff --cached --exit-code
test_dirty_mergeable() {
! git diff --cached --exit-code >/dev/null
}
test_dirty_mergeable_discards_changes () {
git diff --cached --exit-code
}
setup_dirty_mergeable () {
setup_dirty_mergeable() {
echo >file2 file2 &&
git add file2
}
@ -108,7 +82,7 @@ test_expect_success 'checkout -b to a new branch, set to an explicit ref' '
test_expect_success 'checkout -b to a new branch with unmergeable changes fails' '
setup_dirty_unmergeable &&
do_checkout ! branch2 $HEAD1 &&
test_must_fail do_checkout branch2 $HEAD1 &&
test_dirty_unmergeable
'
@ -119,7 +93,7 @@ test_expect_success 'checkout -f -b to a new branch with unmergeable changes dis
# still dirty and on branch1
do_checkout branch2 $HEAD1 "-f -b" &&
test_dirty_unmergeable_discards_changes
test_must_fail test_dirty_unmergeable
'
test_expect_success 'checkout -b to a new branch preserves mergeable changes' '
@ -137,12 +111,12 @@ test_expect_success 'checkout -f -b to a new branch with mergeable changes disca
test_when_finished git reset --hard HEAD &&
setup_dirty_mergeable &&
do_checkout branch2 $HEAD1 "-f -b" &&
test_dirty_mergeable_discards_changes
test_must_fail test_dirty_mergeable
'
test_expect_success 'checkout -b to an existing branch fails' '
test_when_finished git reset --hard HEAD &&
do_checkout ! branch2 $HEAD2
test_must_fail do_checkout branch2 $HEAD2
'
test_expect_success 'checkout -b to @{-1} fails with the right branch name' '
@ -166,8 +140,7 @@ test_expect_success 'checkout -B to a merge base' '
'
test_expect_success 'checkout -B to an existing branch from detached HEAD resets branch to HEAD' '
head=$(git rev-parse --verify HEAD) &&
git checkout "$head" &&
git checkout $(git rev-parse --verify HEAD) &&
do_checkout branch2 "" -B
'
@ -182,14 +155,14 @@ test_expect_success 'checkout -B to an existing branch with unmergeable changes
git checkout branch1 &&
setup_dirty_unmergeable &&
do_checkout ! branch2 $HEAD1 -B &&
test_must_fail do_checkout branch2 $HEAD1 -B &&
test_dirty_unmergeable
'
test_expect_success 'checkout -f -B to an existing branch with unmergeable changes discards changes' '
# still dirty and on branch1
do_checkout branch2 $HEAD1 "-f -B" &&
test_dirty_unmergeable_discards_changes
test_must_fail test_dirty_unmergeable
'
test_expect_success 'checkout -B to an existing branch preserves mergeable changes' '
@ -206,7 +179,7 @@ test_expect_success 'checkout -f -B to an existing branch with mergeable changes
setup_dirty_mergeable &&
do_checkout branch2 $HEAD1 "-f -B" &&
test_dirty_mergeable_discards_changes
test_must_fail test_dirty_mergeable
'
test_expect_success 'checkout -b <describe>' '

View file

@ -78,15 +78,4 @@ test_expect_success 'do not touch files that are already up-to-date' '
test_cmp expect actual
'
test_expect_success 'checkout HEAD adds deleted intent-to-add file back to index' '
echo "nonempty" >nonempty &&
>empty &&
git add nonempty empty &&
git commit -m "create files to be deleted" &&
git rm --cached nonempty empty &&
git add -N nonempty empty &&
git checkout HEAD nonempty empty &&
git diff --cached --exit-code
'
test_done

View file

@ -37,9 +37,7 @@ test_expect_success 'setup' '
git checkout -b foo &&
test_commit a_foo &&
git checkout -b bar &&
test_commit a_bar &&
git checkout -b ambiguous_branch_and_file &&
test_commit a_ambiguous_branch_and_file
test_commit a_bar
) &&
git init repo_b &&
(
@ -48,9 +46,7 @@ test_expect_success 'setup' '
git checkout -b foo &&
test_commit b_foo &&
git checkout -b baz &&
test_commit b_baz &&
git checkout -b ambiguous_branch_and_file &&
test_commit b_ambiguous_branch_and_file
test_commit b_baz
) &&
git remote add repo_a repo_a &&
git remote add repo_b repo_b &&
@ -79,26 +75,6 @@ test_expect_success 'checkout of branch from multiple remotes fails #1' '
test_branch master
'
test_expect_success 'when arg matches multiple remotes, do not fallback to interpreting as pathspec' '
# create a file with name matching remote branch name
git checkout -b t_ambiguous_branch_and_file &&
>ambiguous_branch_and_file &&
git add ambiguous_branch_and_file &&
git commit -m "ambiguous_branch_and_file" &&
# modify file to verify that it will not be touched by checkout
test_when_finished "git checkout -- ambiguous_branch_and_file" &&
echo "file contents" >ambiguous_branch_and_file &&
cp ambiguous_branch_and_file expect &&
test_must_fail git checkout ambiguous_branch_and_file 2>err &&
test_i18ngrep "matched multiple (2) remote tracking branches" err &&
# file must not be altered
test_cmp expect ambiguous_branch_and_file
'
test_expect_success 'checkout of branch from multiple remotes fails with advice' '
git checkout -B master &&
test_might_fail git branch -D foo &&

View file

@ -1,163 +0,0 @@
#!/bin/sh
test_description='checkout --pathspec-from-file'
. ./test-lib.sh
test_tick
test_expect_success setup '
test_commit file0 &&
echo 1 >fileA.t &&
echo 1 >fileB.t &&
echo 1 >fileC.t &&
echo 1 >fileD.t &&
git add fileA.t fileB.t fileC.t fileD.t &&
git commit -m "files 1" &&
echo 2 >fileA.t &&
echo 2 >fileB.t &&
echo 2 >fileC.t &&
echo 2 >fileD.t &&
git add fileA.t fileB.t fileC.t fileD.t &&
git commit -m "files 2" &&
git tag checkpoint
'
restore_checkpoint () {
git reset --hard checkpoint
}
verify_expect () {
git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual &&
test_cmp expect actual
}
test_expect_success '--pathspec-from-file from stdin' '
restore_checkpoint &&
echo fileA.t | git checkout --pathspec-from-file=- HEAD^1 &&
cat >expect <<-\EOF &&
M fileA.t
EOF
verify_expect
'
test_expect_success '--pathspec-from-file from file' '
restore_checkpoint &&
echo fileA.t >list &&
git checkout --pathspec-from-file=list HEAD^1 &&
cat >expect <<-\EOF &&
M fileA.t
EOF
verify_expect
'
test_expect_success 'NUL delimiters' '
restore_checkpoint &&
printf "fileA.t\0fileB.t\0" | git checkout --pathspec-from-file=- --pathspec-file-nul HEAD^1 &&
cat >expect <<-\EOF &&
M fileA.t
M fileB.t
EOF
verify_expect
'
test_expect_success 'LF delimiters' '
restore_checkpoint &&
printf "fileA.t\nfileB.t\n" | git checkout --pathspec-from-file=- HEAD^1 &&
cat >expect <<-\EOF &&
M fileA.t
M fileB.t
EOF
verify_expect
'
test_expect_success 'no trailing delimiter' '
restore_checkpoint &&
printf "fileA.t\nfileB.t" | git checkout --pathspec-from-file=- HEAD^1 &&
cat >expect <<-\EOF &&
M fileA.t
M fileB.t
EOF
verify_expect
'
test_expect_success 'CRLF delimiters' '
restore_checkpoint &&
printf "fileA.t\r\nfileB.t\r\n" | git checkout --pathspec-from-file=- HEAD^1 &&
cat >expect <<-\EOF &&
M fileA.t
M fileB.t
EOF
verify_expect
'
test_expect_success 'quotes' '
restore_checkpoint &&
cat >list <<-\EOF &&
"file\101.t"
EOF
git checkout --pathspec-from-file=list HEAD^1 &&
cat >expect <<-\EOF &&
M fileA.t
EOF
verify_expect
'
test_expect_success 'quotes not compatible with --pathspec-file-nul' '
restore_checkpoint &&
cat >list <<-\EOF &&
"file\101.t"
EOF
test_must_fail git checkout --pathspec-from-file=list --pathspec-file-nul HEAD^1
'
test_expect_success 'only touches what was listed' '
restore_checkpoint &&
printf "fileB.t\nfileC.t\n" | git checkout --pathspec-from-file=- HEAD^1 &&
cat >expect <<-\EOF &&
M fileB.t
M fileC.t
EOF
verify_expect
'
test_expect_success 'error conditions' '
restore_checkpoint &&
echo fileA.t >list &&
test_must_fail git checkout --pathspec-from-file=list --detach 2>err &&
test_i18ngrep -e "--pathspec-from-file is incompatible with --detach" err &&
test_must_fail git checkout --pathspec-from-file=list --patch 2>err &&
test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err &&
test_must_fail git checkout --pathspec-from-file=list -- fileA.t 2>err &&
test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
test_must_fail git checkout --pathspec-file-nul 2>err &&
test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err
'
test_done

View file

@ -95,32 +95,4 @@ test_expect_success 'restore --ignore-unmerged ignores unmerged entries' '
)
'
test_expect_success 'restore --staged adds deleted intent-to-add file back to index' '
echo "nonempty" >nonempty &&
>empty &&
git add nonempty empty &&
git commit -m "create files to be deleted" &&
git rm --cached nonempty empty &&
git add -N nonempty empty &&
git restore --staged nonempty empty &&
git diff --cached --exit-code
'
test_expect_success 'restore --staged invalidates cache tree for deletions' '
test_when_finished git reset --hard &&
>new1 &&
>new2 &&
git add new1 new2 &&
# It is important to commit and then reset here, so that the index
# contains a valid cache-tree for the "both" tree.
git commit -m both &&
git reset --soft HEAD^ &&
git restore --staged new1 &&
git commit -m "just new2" &&
git rev-parse HEAD:new2 &&
test_must_fail git rev-parse HEAD:new1
'
test_done

View file

@ -1,164 +0,0 @@
#!/bin/sh
test_description='restore --pathspec-from-file'
. ./test-lib.sh
test_tick
test_expect_success setup '
test_commit file0 &&
echo 1 >fileA.t &&
echo 1 >fileB.t &&
echo 1 >fileC.t &&
echo 1 >fileD.t &&
git add fileA.t fileB.t fileC.t fileD.t &&
git commit -m "files 1" &&
echo 2 >fileA.t &&
echo 2 >fileB.t &&
echo 2 >fileC.t &&
echo 2 >fileD.t &&
git add fileA.t fileB.t fileC.t fileD.t &&
git commit -m "files 2" &&
git tag checkpoint
'
restore_checkpoint () {
git reset --hard checkpoint
}
verify_expect () {
git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual &&
test_cmp expect actual
}
test_expect_success '--pathspec-from-file from stdin' '
restore_checkpoint &&
echo fileA.t | git restore --pathspec-from-file=- --source=HEAD^1 &&
cat >expect <<-\EOF &&
M fileA.t
EOF
verify_expect
'
test_expect_success '--pathspec-from-file from file' '
restore_checkpoint &&
echo fileA.t >list &&
git restore --pathspec-from-file=list --source=HEAD^1 &&
cat >expect <<-\EOF &&
M fileA.t
EOF
verify_expect
'
test_expect_success 'NUL delimiters' '
restore_checkpoint &&
printf "fileA.t\0fileB.t\0" | git restore --pathspec-from-file=- --pathspec-file-nul --source=HEAD^1 &&
cat >expect <<-\EOF &&
M fileA.t
M fileB.t
EOF
verify_expect
'
test_expect_success 'LF delimiters' '
restore_checkpoint &&
printf "fileA.t\nfileB.t\n" | git restore --pathspec-from-file=- --source=HEAD^1 &&
cat >expect <<-\EOF &&
M fileA.t
M fileB.t
EOF
verify_expect
'
test_expect_success 'no trailing delimiter' '
restore_checkpoint &&
printf "fileA.t\nfileB.t" | git restore --pathspec-from-file=- --source=HEAD^1 &&
cat >expect <<-\EOF &&
M fileA.t
M fileB.t
EOF
verify_expect
'
test_expect_success 'CRLF delimiters' '
restore_checkpoint &&
printf "fileA.t\r\nfileB.t\r\n" | git restore --pathspec-from-file=- --source=HEAD^1 &&
cat >expect <<-\EOF &&
M fileA.t
M fileB.t
EOF
verify_expect
'
test_expect_success 'quotes' '
restore_checkpoint &&
cat >list <<-\EOF &&
"file\101.t"
EOF
git restore --pathspec-from-file=list --source=HEAD^1 &&
cat >expect <<-\EOF &&
M fileA.t
EOF
verify_expect
'
test_expect_success 'quotes not compatible with --pathspec-file-nul' '
restore_checkpoint &&
cat >list <<-\EOF &&
"file\101.t"
EOF
test_must_fail git restore --pathspec-from-file=list --pathspec-file-nul --source=HEAD^1
'
test_expect_success 'only touches what was listed' '
restore_checkpoint &&
printf "fileB.t\nfileC.t\n" | git restore --pathspec-from-file=- --source=HEAD^1 &&
cat >expect <<-\EOF &&
M fileB.t
M fileC.t
EOF
verify_expect
'
test_expect_success 'error conditions' '
restore_checkpoint &&
echo fileA.t >list &&
>empty_list &&
test_must_fail git restore --pathspec-from-file=list --patch --source=HEAD^1 2>err &&
test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err &&
test_must_fail git restore --pathspec-from-file=list --source=HEAD^1 -- fileA.t 2>err &&
test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
test_must_fail git restore --pathspec-file-nul --source=HEAD^1 2>err &&
test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err &&
test_must_fail git restore --pathspec-from-file=empty_list --source=HEAD^1 2>err &&
test_i18ngrep -e "you must specify path(s) to restore" err
'
test_done

View file

@ -9,6 +9,7 @@ Tests for command-line parsing and basic operation.
test_expect_success 'update-index --nonsense fails' '
test_must_fail git update-index --nonsense 2>msg &&
cat msg &&
test -s msg
'

View file

@ -438,7 +438,7 @@ test_expect_success 'git worktree add does not match remote' '
cd foo &&
test_must_fail git config "branch.foo.remote" &&
test_must_fail git config "branch.foo.merge" &&
test_cmp_rev ! refs/remotes/repo_a/foo refs/heads/foo
! test_cmp_rev refs/remotes/repo_a/foo refs/heads/foo
)
'
@ -483,7 +483,7 @@ test_expect_success 'git worktree --no-guess-remote option overrides config' '
cd foo &&
test_must_fail git config "branch.foo.remote" &&
test_must_fail git config "branch.foo.merge" &&
test_cmp_rev ! refs/remotes/repo_a/foo refs/heads/foo
! test_cmp_rev refs/remotes/repo_a/foo refs/heads/foo
)
'
@ -570,15 +570,6 @@ test_expect_success '"add" an existing locked but missing worktree' '
git worktree add --force --force --detach gnoo
'
test_expect_success '"add" not tripped up by magic worktree matching"' '
# if worktree "sub1/bar" exists, "git worktree add bar" in distinct
# directory `sub2` should not mistakenly complain that `bar` is an
# already-registered worktree
mkdir sub1 sub2 &&
git -C sub1 --git-dir=../.git worktree add --detach bozo &&
git -C sub2 --git-dir=../.git worktree add --detach bozo
'
test_expect_success FUNNYNAMES 'sanitize generated worktree name' '
git worktree add --detach ". weird*..?.lock.lock" &&
test -d .git/worktrees/---weird-.-
@ -596,28 +587,4 @@ test_expect_success '"add" should not fail because of another bad worktree' '
)
'
test_expect_success '"add" with uninitialized submodule, with submodule.recurse unset' '
test_create_repo submodule &&
test_commit -C submodule first &&
test_create_repo project &&
git -C project submodule add ../submodule &&
git -C project add submodule &&
test_tick &&
git -C project commit -m add_sub &&
git clone project project-clone &&
git -C project-clone worktree add ../project-2
'
test_expect_success '"add" with uninitialized submodule, with submodule.recurse set' '
git -C project-clone -c submodule.recurse worktree add ../project-3
'
test_expect_success '"add" with initialized submodule, with submodule.recurse unset' '
git -C project-clone submodule update --init &&
git -C project-clone worktree add ../project-4
'
test_expect_success '"add" with initialized submodule, with submodule.recurse set' '
git -C project-clone -c submodule.recurse worktree add ../project-5
'
test_done

View file

@ -151,10 +151,4 @@ test_expect_success 'linked worktrees are sorted' '
test_cmp expected sorted/main/actual
'
test_expect_success 'worktree path when called in .git directory' '
git worktree list >list1&&
git -C .git worktree list >list2 &&
test_cmp list1 list2
'
test_done

View file

@ -1,90 +0,0 @@
#!/bin/sh
test_description='Combination of submodules and multiple worktrees'
. ./test-lib.sh
base_path=$(pwd -P)
test_expect_success 'setup: create origin repos' '
git init origin/sub &&
test_commit -C origin/sub file1 &&
git init origin/main &&
test_commit -C origin/main first &&
git -C origin/main submodule add ../sub &&
git -C origin/main commit -m "add sub" &&
test_commit -C origin/sub "file1 updated" file1 file1updated file1updated &&
git -C origin/main/sub pull &&
git -C origin/main add sub &&
git -C origin/main commit -m "sub updated"
'
test_expect_success 'setup: clone superproject to create main worktree' '
git clone --recursive "$base_path/origin/main" main
'
rev1_hash_main=$(git --git-dir=origin/main/.git show --pretty=format:%h -q "HEAD~1")
rev1_hash_sub=$(git --git-dir=origin/sub/.git show --pretty=format:%h -q "HEAD~1")
test_expect_success 'add superproject worktree' '
git -C main worktree add "$base_path/worktree" "$rev1_hash_main"
'
test_expect_failure 'submodule is checked out just after worktree add' '
git -C worktree diff --submodule master"^!" >out &&
grep "file1 updated" out
'
test_expect_success 'add superproject worktree and initialize submodules' '
git -C main worktree add "$base_path/worktree-submodule-update" "$rev1_hash_main" &&
git -C worktree-submodule-update submodule update
'
test_expect_success 'submodule is checked out just after submodule update in linked worktree' '
git -C worktree-submodule-update diff --submodule master"^!" >out &&
grep "file1 updated" out
'
test_expect_success 'add superproject worktree and manually add submodule worktree' '
git -C main worktree add "$base_path/linked_submodule" "$rev1_hash_main" &&
git -C main/sub worktree add "$base_path/linked_submodule/sub" "$rev1_hash_sub"
'
test_expect_success 'submodule is checked out after manually adding submodule worktree' '
git -C linked_submodule diff --submodule master"^!" >out &&
grep "file1 updated" out
'
test_expect_success 'checkout --recurse-submodules uses $GIT_DIR for submodules in a linked worktree' '
git -C main worktree add "$base_path/checkout-recurse" --detach &&
git -C checkout-recurse submodule update --init &&
echo "gitdir: ../../main/.git/worktrees/checkout-recurse/modules/sub" >expect-gitfile &&
cat checkout-recurse/sub/.git >actual-gitfile &&
test_cmp expect-gitfile actual-gitfile &&
git -C main/sub rev-parse HEAD >expect-head-main &&
git -C checkout-recurse checkout --recurse-submodules HEAD~1 &&
cat checkout-recurse/sub/.git >actual-gitfile &&
git -C main/sub rev-parse HEAD >actual-head-main &&
test_cmp expect-gitfile actual-gitfile &&
test_cmp expect-head-main actual-head-main
'
test_expect_success 'core.worktree is removed in $GIT_DIR/modules/<name>/config, not in $GIT_COMMON_DIR/modules/<name>/config' '
echo "../../../sub" >expect-main &&
git -C main/sub config --get core.worktree >actual-main &&
test_cmp expect-main actual-main &&
echo "../../../../../../checkout-recurse/sub" >expect-linked &&
git -C checkout-recurse/sub config --get core.worktree >actual-linked &&
test_cmp expect-linked actual-linked &&
git -C checkout-recurse checkout --recurse-submodules first &&
test_expect_code 1 git -C main/.git/worktrees/checkout-recurse/modules/sub config --get core.worktree >linked-config &&
test_must_be_empty linked-config &&
git -C main/sub config --get core.worktree >actual-main &&
test_cmp expect-main actual-main
'
test_expect_success 'unsetting core.worktree does not prevent running commands directly against the submodule repository' '
git -C main/.git/worktrees/checkout-recurse/modules/sub log
'
test_done

View file

@ -7,6 +7,10 @@ This test runs git ls-files with various relative path arguments.
. ./test-lib.sh
new_line='
'
sq=\'
test_expect_success 'prepare' '
: >never-mind-me &&
git add never-mind-me &&
@ -40,9 +44,9 @@ test_expect_success 'ls-files -c' '
cd top/sub &&
for f in ../y*
do
echo "error: pathspec $SQ$f$SQ did not match any file(s) known to git"
echo "error: pathspec $sq$f$sq did not match any file(s) known to git"
done >expect.err &&
echo "Did you forget to ${SQ}git add${SQ}?" >>expect.err &&
echo "Did you forget to ${sq}git add${sq}?" >>expect.err &&
ls ../x* >expect.out &&
test_must_fail git ls-files -c --error-unmatch ../[xy]* >actual.out 2>actual.err &&
test_cmp expect.out actual.out &&
@ -55,9 +59,9 @@ test_expect_success 'ls-files -o' '
cd top/sub &&
for f in ../x*
do
echo "error: pathspec $SQ$f$SQ did not match any file(s) known to git"
echo "error: pathspec $sq$f$sq did not match any file(s) known to git"
done >expect.err &&
echo "Did you forget to ${SQ}git add${SQ}?" >>expect.err &&
echo "Did you forget to ${sq}git add${sq}?" >>expect.err &&
ls ../y* >expect.out &&
test_must_fail git ls-files -o --error-unmatch ../[xy]* >actual.out 2>actual.err &&
test_cmp expect.out actual.out &&

View file

@ -130,6 +130,7 @@ test_expect_success '--recurse-submodules and pathspecs setup' '
git ls-files --recurse-submodules >actual &&
test_cmp expect actual &&
cat actual &&
git ls-files --recurse-submodules "*" >actual &&
test_cmp expect actual
'

View file

@ -4,7 +4,7 @@ test_description='Test the lazy init name hash with various folder structures'
. ./test-lib.sh
if test 1 -eq $(test-tool 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

View file

@ -1,209 +0,0 @@
#!/bin/sh
test_description='directory traversal handling, especially with common prefixes'
. ./test-lib.sh
test_expect_success 'setup' '
test_commit hello &&
>empty &&
mkdir untracked_dir &&
>untracked_dir/empty &&
git init untracked_repo &&
>untracked_repo/empty &&
cat <<-EOF >.gitignore &&
ignored
an_ignored_dir/
EOF
mkdir an_ignored_dir &&
mkdir an_untracked_dir &&
>an_ignored_dir/ignored &&
>an_ignored_dir/untracked &&
>an_untracked_dir/ignored &&
>an_untracked_dir/untracked
'
test_expect_success 'git ls-files -o shows the right entries' '
cat <<-EOF >expect &&
.gitignore
actual
an_ignored_dir/ignored
an_ignored_dir/untracked
an_untracked_dir/ignored
an_untracked_dir/untracked
empty
expect
untracked_dir/empty
untracked_repo/
EOF
git ls-files -o >actual &&
test_cmp expect actual
'
test_expect_success 'git ls-files -o --exclude-standard shows the right entries' '
cat <<-EOF >expect &&
.gitignore
actual
an_untracked_dir/untracked
empty
expect
untracked_dir/empty
untracked_repo/
EOF
git ls-files -o --exclude-standard >actual &&
test_cmp expect actual
'
test_expect_success 'git ls-files -o untracked_dir recurses' '
echo untracked_dir/empty >expect &&
git ls-files -o untracked_dir >actual &&
test_cmp expect actual
'
test_expect_success 'git ls-files -o untracked_dir/ recurses' '
echo untracked_dir/empty >expect &&
git ls-files -o untracked_dir/ >actual &&
test_cmp expect actual
'
test_expect_success 'git ls-files -o --directory untracked_dir does not recurse' '
echo untracked_dir/ >expect &&
git ls-files -o --directory untracked_dir >actual &&
test_cmp expect actual
'
test_expect_success 'git ls-files -o --directory untracked_dir/ does not recurse' '
echo untracked_dir/ >expect &&
git ls-files -o --directory untracked_dir/ >actual &&
test_cmp expect actual
'
test_expect_success 'git ls-files -o untracked_repo does not recurse' '
echo untracked_repo/ >expect &&
git ls-files -o untracked_repo >actual &&
test_cmp expect actual
'
test_expect_success 'git ls-files -o untracked_repo/ does not recurse' '
echo untracked_repo/ >expect &&
git ls-files -o untracked_repo/ >actual &&
test_cmp expect actual
'
test_expect_success 'git ls-files -o untracked_dir untracked_repo recurses into untracked_dir only' '
cat <<-EOF >expect &&
untracked_dir/empty
untracked_repo/
EOF
git ls-files -o untracked_dir untracked_repo >actual &&
test_cmp expect actual
'
test_expect_success 'git ls-files -o untracked_dir/ untracked_repo/ recurses into untracked_dir only' '
cat <<-EOF >expect &&
untracked_dir/empty
untracked_repo/
EOF
git ls-files -o untracked_dir/ untracked_repo/ >actual &&
test_cmp expect actual
'
test_expect_success 'git ls-files -o --directory untracked_dir untracked_repo does not recurse' '
cat <<-EOF >expect &&
untracked_dir/
untracked_repo/
EOF
git ls-files -o --directory untracked_dir untracked_repo >actual &&
test_cmp expect actual
'
test_expect_success 'git ls-files -o --directory untracked_dir/ untracked_repo/ does not recurse' '
cat <<-EOF >expect &&
untracked_dir/
untracked_repo/
EOF
git ls-files -o --directory untracked_dir/ untracked_repo/ >actual &&
test_cmp expect actual
'
test_expect_success 'git ls-files -o .git shows nothing' '
git ls-files -o .git >actual &&
test_must_be_empty actual
'
test_expect_success 'git ls-files -o .git/ shows nothing' '
git ls-files -o .git/ >actual &&
test_must_be_empty actual
'
test_expect_success FUNNYNAMES 'git ls-files -o untracked_* recurses appropriately' '
mkdir "untracked_*" &&
>"untracked_*/empty" &&
cat <<-EOF >expect &&
untracked_*/empty
untracked_dir/empty
untracked_repo/
EOF
git ls-files -o "untracked_*" >actual &&
test_cmp expect actual
'
# It turns out fill_directory returns the right paths, but ls-files' post-call
# filtering in show_dir_entry() via calling dir_path_match() which ends up
# in git_fnmatch() has logic for PATHSPEC_ONESTAR that assumes the pathspec
# must match the full path; it doesn't check it for matching a leading
# directory.
test_expect_failure FUNNYNAMES 'git ls-files -o untracked_*/ recurses appropriately' '
cat <<-EOF >expect &&
untracked_*/empty
untracked_dir/empty
untracked_repo/
EOF
git ls-files -o "untracked_*/" >actual &&
test_cmp expect actual
'
test_expect_success FUNNYNAMES 'git ls-files -o --directory untracked_* does not recurse' '
cat <<-EOF >expect &&
untracked_*/
untracked_dir/
untracked_repo/
EOF
git ls-files -o --directory "untracked_*" >actual &&
test_cmp expect actual
'
test_expect_success FUNNYNAMES 'git ls-files -o --directory untracked_*/ does not recurse' '
cat <<-EOF >expect &&
untracked_*/
untracked_dir/
untracked_repo/
EOF
git ls-files -o --directory "untracked_*/" >actual &&
test_cmp expect actual
'
test_expect_success 'git ls-files -o consistent between one or two dirs' '
git ls-files -o --exclude-standard an_ignored_dir/ an_untracked_dir/ >tmp &&
! grep ^an_ignored_dir/ tmp >expect &&
git ls-files -o --exclude-standard an_ignored_dir/ >actual &&
test_cmp expect actual
'
# ls-files doesn't have a way to request showing both untracked and ignored
# files at the same time, so use `git status --ignored`
test_expect_success 'git status --ignored shows same files under dir with or without pathspec' '
cat <<-EOF >expect &&
?? an_untracked_dir/
!! an_untracked_dir/ignored
EOF
git status --porcelain --ignored >output &&
grep an_untracked_dir output >expect &&
git status --porcelain --ignored an_untracked_dir/ >actual &&
test_cmp expect actual
'
test_done

View file

@ -452,34 +452,6 @@ test_expect_success 'merge-recursive d/f conflict result' '
'
test_expect_success SYMLINKS 'dir in working tree with symlink ancestor does not produce d/f conflict' '
git init sym &&
(
cd sym &&
ln -s . foo &&
mkdir bar &&
>bar/file &&
git add foo bar/file &&
git commit -m "foo symlink" &&
git checkout -b branch1 &&
git commit --allow-empty -m "empty commit" &&
git checkout master &&
git rm foo &&
mkdir foo &&
>foo/bar &&
git add foo/bar &&
git commit -m "replace foo symlink with real foo dir and foo/bar file" &&
git checkout branch1 &&
git cherry-pick master &&
test_path_is_dir foo &&
test_path_is_file foo/bar
)
'
test_expect_success 'reset and 3-way merge' '
git reset --hard "$c2" &&
@ -604,7 +576,7 @@ test_expect_success 'merge removes empty directories' '
git commit -mremoved-d/e &&
git checkout master &&
git merge -s recursive rm &&
test_path_is_missing d
test_must_fail test -d d
'
test_expect_success 'merge-recursive simple w/submodule' '
@ -695,22 +667,15 @@ test_expect_success 'merging with triple rename across D/F conflict' '
test_expect_success 'merge-recursive remembers the names of all base trees' '
git reset --hard HEAD &&
# make the index match $c1 so that merge-recursive below does not
# fail early
git diff --binary HEAD $c1 -- | git apply --cached &&
# more trees than static slots used by oid_to_hex()
for commit in $c0 $c2 $c4 $c5 $c6 $c7
do
git rev-parse "$commit^{tree}"
done >trees &&
# ignore the return code; it only fails because the input is weird...
# ignore the return code -- it only fails because the input is weird
test_must_fail git -c merge.verbosity=5 merge-recursive $(cat trees) -- $c1 $c3 >out &&
# ...but make sure it fails in the expected way
test_i18ngrep CONFLICT.*rename/rename out &&
# merge-recursive prints in reverse order, but we do not care
sort <trees >expect &&
sed -n "s/^virtual //p" out | sort >actual &&

View file

@ -28,7 +28,7 @@ test_expect_success 'setup' '
git config core.sparseCheckout true &&
echo "/checked-out" >.git/info/sparse-checkout &&
git reset --hard &&
test_must_fail git merge theirs
! git merge theirs
'
test_expect_success 'reset --hard works after the conflict' '
@ -42,7 +42,7 @@ test_expect_success 'is reset properly' '
'
test_expect_success 'setup: conflict back' '
test_must_fail git merge theirs
! git merge theirs
'
test_expect_success 'Merge abort works after the conflict' '

View file

@ -47,7 +47,7 @@ test_expect_success setup '
git add .
'
test_expect_success 'git ls-files --with-tree should succeed from subdir' '
test_expect_success 'git -ls-files --with-tree should succeed from subdir' '
# We have to run from a sub-directory to trigger prune_path
# Then we finally get to run our --with-tree test
(
@ -57,7 +57,7 @@ test_expect_success 'git ls-files --with-tree should succeed from subdir' '
'
test_expect_success \
'git ls-files --with-tree should add entries from named tree.' \
'git -ls-files --with-tree should add entries from named tree.' \
'test_cmp expected output'
test_done

View file

@ -192,10 +192,10 @@ test_expect_success 'branch --merged with --verbose' '
EOF
test_cmp expect actual &&
git branch --verbose --merged topic >actual &&
cat >expect <<-EOF &&
master $(git rev-parse --short master) second on master
* topic $(git rev-parse --short topic ) [ahead 1] foo
zzz $(git rev-parse --short zzz ) second on master
cat >expect <<-\EOF &&
master c77a0a9 second on master
* topic 2c939f4 [ahead 1] foo
zzz c77a0a9 second on master
EOF
test_i18ncmp expect actual
'

View file

@ -8,212 +8,97 @@ test_description='range-diff tests'
# harm than good. We need some real history.
test_expect_success 'setup' '
git fast-import <"$TEST_DIRECTORY"/t3206/history.export &&
test_oid_cache <<-\EOF
# topic
t1 sha1:4de457d
t2 sha1:fccce22
t3 sha1:147e64e
t4 sha1:a63e992
t1 sha256:b89f8b9
t2 sha256:5f12aad
t3 sha256:ea8b273
t4 sha256:14b7336
# unmodified
u1 sha1:35b9b25
u2 sha1:de345ab
u3 sha1:9af6654
u4 sha1:2901f77
u1 sha256:e3731be
u2 sha256:14fadf8
u3 sha256:736c4bc
u4 sha256:673e77d
# reordered
r1 sha1:aca177a
r2 sha1:14ad629
r3 sha1:ee58208
r4 sha1:307b27a
r1 sha256:f59d3aa
r2 sha256:fb261a8
r3 sha256:cb2649b
r4 sha256:958577e
# removed (deleted)
d1 sha1:7657159
d2 sha1:43d84d3
d3 sha1:a740396
d1 sha256:e312513
d2 sha256:eb19258
d3 sha256:1ccb3c1
# added
a1 sha1:2716022
a2 sha1:b62accd
a3 sha1:df46cfa
a4 sha1:3e64548
a5 sha1:12b4063
a1 sha256:d724f4d
a2 sha256:1de7762
a3 sha256:e159431
a4 sha256:b3e483c
a5 sha256:90866a7
# rebased
b1 sha1:cc9c443
b2 sha1:c5d9641
b3 sha1:28cc2b6
b4 sha1:5628ab7
b5 sha1:a31b12e
b1 sha256:a1a8717
b2 sha256:20a5862
b3 sha256:587172a
b4 sha256:2721c5d
b5 sha256:7b57864
# changed
c1 sha1:a4b3333
c2 sha1:f51d370
c3 sha1:0559556
c4 sha1:d966c5c
c1 sha256:f8c2b9d
c2 sha256:3fb6318
c3 sha256:168ab68
c4 sha256:3526539
# changed-message
m1 sha1:f686024
m2 sha1:4ab067d
m3 sha1:b9cb956
m4 sha1:8add5f1
m1 sha256:31e6281
m2 sha256:a06bf1b
m3 sha256:82dc654
m4 sha256:48470c5
# renamed
n1 sha1:f258d75
n2 sha1:017b62d
n3 sha1:3ce7af6
n4 sha1:1e6226b
n1 sha256:ad52114
n2 sha256:3b54c8f
n3 sha256:3b0a644
n4 sha256:e461653
# mode change
o1 sha1:4d39cb3
o2 sha1:26c107f
o3 sha1:4c1e0f5
o1 sha256:d0dd598
o2 sha256:c4a279e
o3 sha256:78459d7
# added and removed
s1 sha1:096b1ba
s2 sha1:d92e698
s3 sha1:9a1db4d
s4 sha1:fea3b5c
s1 sha256:a7f9134
s2 sha256:b4c2580
s3 sha256:1d62aa2
s4 sha256:48160e8
# Empty delimiter (included so lines match neatly)
__ sha1:-------
__ sha256:-------
EOF
git fast-import < "$TEST_DIRECTORY"/t3206/history.export
'
test_expect_success 'simple A..B A..C (unmodified)' '
git range-diff --no-color master..topic master..unmodified \
>actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/
3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/
4: $(test_oid t4) = 4: $(test_oid u4) s/12/B/
cat >expected <<-EOF &&
1: 4de457d = 1: 35b9b25 s/5/A/
2: fccce22 = 2: de345ab s/4/A/
3: 147e64e = 3: 9af6654 s/11/B/
4: a63e992 = 4: 2901f77 s/12/B/
EOF
test_cmp expect actual
test_cmp expected actual
'
test_expect_success 'simple B...C (unmodified)' '
git range-diff --no-color topic...unmodified >actual &&
# same "expect" as above
test_cmp expect actual
# same "expected" as above
test_cmp expected actual
'
test_expect_success 'simple A B C (unmodified)' '
git range-diff --no-color master topic unmodified >actual &&
# same "expect" as above
test_cmp expect actual
# same "expected" as above
test_cmp expected actual
'
test_expect_success 'trivial reordering' '
git range-diff --no-color master topic reordered >actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid r1) s/5/A/
3: $(test_oid t3) = 2: $(test_oid r2) s/11/B/
4: $(test_oid t4) = 3: $(test_oid r3) s/12/B/
2: $(test_oid t2) = 4: $(test_oid r4) s/4/A/
cat >expected <<-EOF &&
1: 4de457d = 1: aca177a s/5/A/
3: 147e64e = 2: 14ad629 s/11/B/
4: a63e992 = 3: ee58208 s/12/B/
2: fccce22 = 4: 307b27a s/4/A/
EOF
test_cmp expect actual
test_cmp expected actual
'
test_expect_success 'removed a commit' '
git range-diff --no-color master topic removed >actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid d1) s/5/A/
2: $(test_oid t2) < -: $(test_oid __) s/4/A/
3: $(test_oid t3) = 2: $(test_oid d2) s/11/B/
4: $(test_oid t4) = 3: $(test_oid d3) s/12/B/
cat >expected <<-EOF &&
1: 4de457d = 1: 7657159 s/5/A/
2: fccce22 < -: ------- s/4/A/
3: 147e64e = 2: 43d84d3 s/11/B/
4: a63e992 = 3: a740396 s/12/B/
EOF
test_cmp expect actual
test_cmp expected actual
'
test_expect_success 'added a commit' '
git range-diff --no-color master topic added >actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid a1) s/5/A/
2: $(test_oid t2) = 2: $(test_oid a2) s/4/A/
-: $(test_oid __) > 3: $(test_oid a3) s/6/A/
3: $(test_oid t3) = 4: $(test_oid a4) s/11/B/
4: $(test_oid t4) = 5: $(test_oid a5) s/12/B/
cat >expected <<-EOF &&
1: 4de457d = 1: 2716022 s/5/A/
2: fccce22 = 2: b62accd s/4/A/
-: ------- > 3: df46cfa s/6/A/
3: 147e64e = 4: 3e64548 s/11/B/
4: a63e992 = 5: 12b4063 s/12/B/
EOF
test_cmp expect actual
test_cmp expected actual
'
test_expect_success 'new base, A B C' '
git range-diff --no-color master topic rebased >actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid b1) s/5/A/
2: $(test_oid t2) = 2: $(test_oid b2) s/4/A/
3: $(test_oid t3) = 3: $(test_oid b3) s/11/B/
4: $(test_oid t4) = 4: $(test_oid b4) s/12/B/
cat >expected <<-EOF &&
1: 4de457d = 1: cc9c443 s/5/A/
2: fccce22 = 2: c5d9641 s/4/A/
3: 147e64e = 3: 28cc2b6 s/11/B/
4: a63e992 = 4: 5628ab7 s/12/B/
EOF
test_cmp expect actual
test_cmp expected actual
'
test_expect_success 'new base, B...C' '
# this syntax includes the commits from master!
git range-diff --no-color topic...rebased >actual &&
cat >expect <<-EOF &&
-: $(test_oid __) > 1: $(test_oid b5) unrelated
1: $(test_oid t1) = 2: $(test_oid b1) s/5/A/
2: $(test_oid t2) = 3: $(test_oid b2) s/4/A/
3: $(test_oid t3) = 4: $(test_oid b3) s/11/B/
4: $(test_oid t4) = 5: $(test_oid b4) s/12/B/
cat >expected <<-EOF &&
-: ------- > 1: a31b12e unrelated
1: 4de457d = 2: cc9c443 s/5/A/
2: fccce22 = 3: c5d9641 s/4/A/
3: 147e64e = 4: 28cc2b6 s/11/B/
4: a63e992 = 5: 5628ab7 s/12/B/
EOF
test_cmp expect actual
test_cmp expected actual
'
test_expect_success 'changed commit' '
git range-diff --no-color topic...changed >actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/
2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/
3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/
cat >expected <<-EOF &&
1: 4de457d = 1: a4b3333 s/5/A/
2: fccce22 = 2: f51d370 s/4/A/
3: 147e64e ! 3: 0559556 s/11/B/
@@ file: A
9
10
@ -223,7 +108,7 @@ test_expect_success 'changed commit' '
12
13
14
4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/
4: a63e992 ! 4: d966c5c s/12/B/
@@ file
@@ file: A
9
@ -234,45 +119,45 @@ test_expect_success 'changed commit' '
+B
13
EOF
test_cmp expect actual
test_cmp expected actual
'
test_expect_success 'changed commit with --no-patch diff option' '
git range-diff --no-color --no-patch topic...changed >actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/
2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/
3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/
4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/
cat >expected <<-EOF &&
1: 4de457d = 1: a4b3333 s/5/A/
2: fccce22 = 2: f51d370 s/4/A/
3: 147e64e ! 3: 0559556 s/11/B/
4: a63e992 ! 4: d966c5c s/12/B/
EOF
test_cmp expect actual
test_cmp expected actual
'
test_expect_success 'changed commit with --stat diff option' '
git range-diff --no-color --stat topic...changed >actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/
cat >expected <<-EOF &&
1: 4de457d = 1: a4b3333 s/5/A/
a => b | 0
1 file changed, 0 insertions(+), 0 deletions(-)
2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/
2: fccce22 = 2: f51d370 s/4/A/
a => b | 0
1 file changed, 0 insertions(+), 0 deletions(-)
3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/
3: 147e64e ! 3: 0559556 s/11/B/
a => b | 0
1 file changed, 0 insertions(+), 0 deletions(-)
4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/
4: a63e992 ! 4: d966c5c s/12/B/
a => b | 0
1 file changed, 0 insertions(+), 0 deletions(-)
EOF
test_cmp expect actual
test_cmp expected actual
'
test_expect_success 'changed commit with sm config' '
git range-diff --no-color --submodule=log topic...changed >actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/
2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/
3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/
cat >expected <<-EOF &&
1: 4de457d = 1: a4b3333 s/5/A/
2: fccce22 = 2: f51d370 s/4/A/
3: 147e64e ! 3: 0559556 s/11/B/
@@ file: A
9
10
@ -282,7 +167,7 @@ test_expect_success 'changed commit with sm config' '
12
13
14
4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/
4: a63e992 ! 4: d966c5c s/12/B/
@@ file
@@ file: A
9
@ -293,14 +178,14 @@ test_expect_success 'changed commit with sm config' '
+B
13
EOF
test_cmp expect actual
test_cmp expected actual
'
test_expect_success 'renamed file' '
git range-diff --no-color --submodule=log topic...renamed-file >actual &&
sed s/Z/\ /g >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid n1) s/5/A/
2: $(test_oid t2) ! 2: $(test_oid n2) s/4/A/
sed s/Z/\ /g >expected <<-EOF &&
1: 4de457d = 1: f258d75 s/5/A/
2: fccce22 ! 2: 017b62d s/4/A/
@@ Metadata
ZAuthor: Thomas Rast <trast@inf.ethz.ch>
Z
@ -313,7 +198,7 @@ test_expect_success 'renamed file' '
Z@@
Z 1
Z 2
3: $(test_oid t3) ! 3: $(test_oid n3) s/11/B/
3: 147e64e ! 3: 3ce7af6 s/11/B/
@@ Metadata
Z ## Commit message ##
Z s/11/B/
@ -325,7 +210,7 @@ test_expect_success 'renamed file' '
Z 8
Z 9
Z 10
4: $(test_oid t4) ! 4: $(test_oid n4) s/12/B/
4: a63e992 ! 4: 1e6226b s/12/B/
@@ Metadata
Z ## Commit message ##
Z s/12/B/
@ -338,54 +223,14 @@ test_expect_success 'renamed file' '
Z 10
Z B
EOF
test_cmp expect actual
'
test_expect_success 'file with mode only change' '
git range-diff --no-color --submodule=log topic...mode-only-change >actual &&
sed s/Z/\ /g >expect <<-EOF &&
1: $(test_oid t2) ! 1: $(test_oid o1) s/4/A/
@@ Metadata
ZAuthor: Thomas Rast <trast@inf.ethz.ch>
Z
Z ## Commit message ##
- s/4/A/
+ s/4/A/ + add other-file
Z
Z ## file ##
Z@@
@@ file
Z A
Z 6
Z 7
+
+ ## other-file (new) ##
2: $(test_oid t3) ! 2: $(test_oid o2) s/11/B/
@@ Metadata
ZAuthor: Thomas Rast <trast@inf.ethz.ch>
Z
Z ## Commit message ##
- s/11/B/
+ s/11/B/ + mode change other-file
Z
Z ## file ##
Z@@ file: A
@@ file: A
Z 12
Z 13
Z 14
+
+ ## other-file (mode change 100644 => 100755) ##
3: $(test_oid t4) = 3: $(test_oid o3) s/12/B/
EOF
test_cmp expect actual
test_cmp expected actual
'
test_expect_success 'file added and later removed' '
git range-diff --no-color --submodule=log topic...added-removed >actual &&
sed s/Z/\ /g >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid s1) s/5/A/
2: $(test_oid t2) ! 2: $(test_oid s2) s/4/A/
sed s/Z/\ /g >expected <<-EOF &&
1: 4de457d = 1: 096b1ba s/5/A/
2: fccce22 ! 2: d92e698 s/4/A/
@@ Metadata
ZAuthor: Thomas Rast <trast@inf.ethz.ch>
Z
@ -401,7 +246,7 @@ test_expect_success 'file added and later removed' '
Z 7
+
+ ## new-file (new) ##
3: $(test_oid t3) ! 3: $(test_oid s3) s/11/B/
3: 147e64e ! 3: 9a1db4d s/11/B/
@@ Metadata
ZAuthor: Thomas Rast <trast@inf.ethz.ch>
Z
@ -417,9 +262,9 @@ test_expect_success 'file added and later removed' '
Z 14
+
+ ## new-file (deleted) ##
4: $(test_oid t4) = 4: $(test_oid s4) s/12/B/
4: a63e992 = 4: fea3b5c s/12/B/
EOF
test_cmp expect actual
test_cmp expected actual
'
test_expect_success 'no commits on one side' '
@ -429,9 +274,9 @@ test_expect_success 'no commits on one side' '
test_expect_success 'changed message' '
git range-diff --no-color topic...changed-message >actual &&
sed s/Z/\ /g >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid m1) s/5/A/
2: $(test_oid t2) ! 2: $(test_oid m2) s/4/A/
sed s/Z/\ /g >expected <<-EOF &&
1: 4de457d = 1: f686024 s/5/A/
2: fccce22 ! 2: 4ab067d s/4/A/
@@ Metadata
Z ## Commit message ##
Z s/4/A/
@ -441,16 +286,16 @@ test_expect_success 'changed message' '
Z ## file ##
Z@@
Z 1
3: $(test_oid t3) = 3: $(test_oid m3) s/11/B/
4: $(test_oid t4) = 4: $(test_oid m4) s/12/B/
3: 147e64e = 3: b9cb956 s/11/B/
4: a63e992 = 4: 8add5f1 s/12/B/
EOF
test_cmp expect actual
test_cmp expected actual
'
test_expect_success 'dual-coloring' '
sed -e "s|^:||" >expect <<-EOF &&
:<YELLOW>1: $(test_oid c1) = 1: $(test_oid m1) s/5/A/<RESET>
:<RED>2: $(test_oid c2) <RESET><YELLOW>!<RESET><GREEN> 2: $(test_oid m2)<RESET><YELLOW> s/4/A/<RESET>
sed -e "s|^:||" >expect <<-\EOF &&
:<YELLOW>1: a4b3333 = 1: f686024 s/5/A/<RESET>
:<RED>2: f51d370 <RESET><YELLOW>!<RESET><GREEN> 2: 4ab067d<RESET><YELLOW> s/4/A/<RESET>
: <REVERSE><CYAN>@@<RESET> <RESET>Metadata<RESET>
: ## Commit message ##<RESET>
: s/4/A/<RESET>
@ -460,7 +305,7 @@ test_expect_success 'dual-coloring' '
: ## file ##<RESET>
: <CYAN> @@<RESET>
: 1<RESET>
:<RED>3: $(test_oid c3) <RESET><YELLOW>!<RESET><GREEN> 3: $(test_oid m3)<RESET><YELLOW> s/11/B/<RESET>
:<RED>3: 0559556 <RESET><YELLOW>!<RESET><GREEN> 3: b9cb956<RESET><YELLOW> s/11/B/<RESET>
: <REVERSE><CYAN>@@<RESET> <RESET>file: A<RESET>
: 9<RESET>
: 10<RESET>
@ -470,7 +315,7 @@ test_expect_success 'dual-coloring' '
: 12<RESET>
: 13<RESET>
: 14<RESET>
:<RED>4: $(test_oid c4) <RESET><YELLOW>!<RESET><GREEN> 4: $(test_oid m4)<RESET><YELLOW> s/12/B/<RESET>
:<RED>4: d966c5c <RESET><YELLOW>!<RESET><GREEN> 4: 8add5f1<RESET><YELLOW> s/12/B/<RESET>
: <REVERSE><CYAN>@@<RESET> <RESET>file<RESET>
: <CYAN> @@ file: A<RESET>
: 9<RESET>
@ -509,206 +354,4 @@ test_expect_success 'format-patch --range-diff as commentary' '
grep "> 1: .* new message" 0001-*
'
test_expect_success 'range-diff overrides diff.noprefix internally' '
git -c diff.noprefix=true range-diff HEAD^...
'
test_expect_success 'range-diff compares notes by default' '
git notes add -m "topic note" topic &&
git notes add -m "unmodified note" unmodified &&
test_when_finished git notes remove topic unmodified &&
git range-diff --no-color master..topic master..unmodified \
>actual &&
sed s/Z/\ /g >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/
3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/
4: $(test_oid t4) ! 4: $(test_oid u4) s/12/B/
@@ Commit message
Z
Z
Z ## Notes ##
- topic note
+ unmodified note
Z
Z ## file ##
Z@@ file: A
EOF
test_cmp expect actual
'
test_expect_success 'range-diff with --no-notes' '
git notes add -m "topic note" topic &&
git notes add -m "unmodified note" unmodified &&
test_when_finished git notes remove topic unmodified &&
git range-diff --no-color --no-notes master..topic master..unmodified \
>actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/
3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/
4: $(test_oid t4) = 4: $(test_oid u4) s/12/B/
EOF
test_cmp expect actual
'
test_expect_success 'range-diff with multiple --notes' '
git notes --ref=note1 add -m "topic note1" topic &&
git notes --ref=note1 add -m "unmodified note1" unmodified &&
test_when_finished git notes --ref=note1 remove topic unmodified &&
git notes --ref=note2 add -m "topic note2" topic &&
git notes --ref=note2 add -m "unmodified note2" unmodified &&
test_when_finished git notes --ref=note2 remove topic unmodified &&
git range-diff --no-color --notes=note1 --notes=note2 master..topic master..unmodified \
>actual &&
sed s/Z/\ /g >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/
3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/
4: $(test_oid t4) ! 4: $(test_oid u4) s/12/B/
@@ Commit message
Z
Z
Z ## Notes (note1) ##
- topic note1
+ unmodified note1
Z
Z
Z ## Notes (note2) ##
- topic note2
+ unmodified note2
Z
Z ## file ##
Z@@ file: A
EOF
test_cmp expect actual
'
test_expect_success 'format-patch --range-diff does not compare notes by default' '
git notes add -m "topic note" topic &&
git notes add -m "unmodified note" unmodified &&
test_when_finished git notes remove topic unmodified &&
git format-patch --cover-letter --range-diff=$prev \
master..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
test_i18ngrep "^Range-diff:$" 0000-* &&
grep "= 1: .* s/5/A" 0000-* &&
grep "= 2: .* s/4/A" 0000-* &&
grep "= 3: .* s/11/B" 0000-* &&
grep "= 4: .* s/12/B" 0000-* &&
! grep "Notes" 0000-* &&
! grep "note" 0000-*
'
test_expect_success 'format-patch --range-diff with --no-notes' '
git notes add -m "topic note" topic &&
git notes add -m "unmodified note" unmodified &&
test_when_finished git notes remove topic unmodified &&
git format-patch --no-notes --cover-letter --range-diff=$prev \
master..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
test_i18ngrep "^Range-diff:$" 0000-* &&
grep "= 1: .* s/5/A" 0000-* &&
grep "= 2: .* s/4/A" 0000-* &&
grep "= 3: .* s/11/B" 0000-* &&
grep "= 4: .* s/12/B" 0000-* &&
! grep "Notes" 0000-* &&
! grep "note" 0000-*
'
test_expect_success 'format-patch --range-diff with --notes' '
git notes add -m "topic note" topic &&
git notes add -m "unmodified note" unmodified &&
test_when_finished git notes remove topic unmodified &&
git format-patch --notes --cover-letter --range-diff=$prev \
master..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
test_i18ngrep "^Range-diff:$" 0000-* &&
grep "= 1: .* s/5/A" 0000-* &&
grep "= 2: .* s/4/A" 0000-* &&
grep "= 3: .* s/11/B" 0000-* &&
grep "! 4: .* s/12/B" 0000-* &&
sed s/Z/\ /g >expect <<-EOF &&
@@ Commit message
Z
Z
Z ## Notes ##
- topic note
+ unmodified note
Z
Z ## file ##
Z@@ file: A
EOF
sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual &&
test_cmp expect actual
'
test_expect_success 'format-patch --range-diff with format.notes config' '
git notes add -m "topic note" topic &&
git notes add -m "unmodified note" unmodified &&
test_when_finished git notes remove topic unmodified &&
test_config format.notes true &&
git format-patch --cover-letter --range-diff=$prev \
master..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
test_i18ngrep "^Range-diff:$" 0000-* &&
grep "= 1: .* s/5/A" 0000-* &&
grep "= 2: .* s/4/A" 0000-* &&
grep "= 3: .* s/11/B" 0000-* &&
grep "! 4: .* s/12/B" 0000-* &&
sed s/Z/\ /g >expect <<-EOF &&
@@ Commit message
Z
Z
Z ## Notes ##
- topic note
+ unmodified note
Z
Z ## file ##
Z@@ file: A
EOF
sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual &&
test_cmp expect actual
'
test_expect_success 'format-patch --range-diff with multiple notes' '
git notes --ref=note1 add -m "topic note1" topic &&
git notes --ref=note1 add -m "unmodified note1" unmodified &&
test_when_finished git notes --ref=note1 remove topic unmodified &&
git notes --ref=note2 add -m "topic note2" topic &&
git notes --ref=note2 add -m "unmodified note2" unmodified &&
test_when_finished git notes --ref=note2 remove topic unmodified &&
git format-patch --notes=note1 --notes=note2 --cover-letter --range-diff=$prev \
master..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
test_i18ngrep "^Range-diff:$" 0000-* &&
grep "= 1: .* s/5/A" 0000-* &&
grep "= 2: .* s/4/A" 0000-* &&
grep "= 3: .* s/11/B" 0000-* &&
grep "! 4: .* s/12/B" 0000-* &&
sed s/Z/\ /g >expect <<-EOF &&
@@ Commit message
Z
Z
Z ## Notes (note1) ##
- topic note1
+ unmodified note1
Z
Z
Z ## Notes (note2) ##
- topic note2
+ unmodified note2
Z
Z ## file ##
Z@@ file: A
EOF
sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual &&
test_cmp expect actual
'
test_done

Some files were not shown because too many files have changed in this diff Show more