diff options
Diffstat (limited to 't')
578 files changed, 17464 insertions, 6428 deletions
diff --git a/t/.gitattributes b/t/.gitattributes index df05434d32..dafa17c3e6 100644 --- a/t/.gitattributes +++ b/t/.gitattributes @@ -1,13 +1,13 @@ t[0-9][0-9][0-9][0-9]/* -whitespace /chainlint/*.expect eol=lf -/diff-lib/* eol=lf +/lib-diff/* eol=lf /t0110/url-* binary /t3206/* eol=lf /t3900/*.txt eol=lf /t3901/*.txt eol=lf -/t4034/*/* eol=lf /t4013/* eol=lf /t4018/* eol=lf +/t4034/*/* eol=lf /t4051/* eol=lf /t4100/* eol=lf /t4101/* eol=lf @@ -196,6 +196,11 @@ appropriately before running "make". Short options can be bundled, i.e. this feature by setting the GIT_TEST_CHAIN_LINT environment variable to "1" or "0", respectively. + A few test scripts disable some of the more advanced + chain-linting detection in the name of efficiency. You can + override this by setting the GIT_TEST_CHAIN_LINT_HARDER + environment variable to "1". + --stress:: Run the test script repeatedly in multiple parallel jobs until one of them fails. Useful for reproducing rare failures in @@ -358,12 +363,6 @@ whether this mode is active, and e.g. skip some tests that are hard to refactor to deal with it. The "SYMLINKS" prerequisite is currently excluded as so much relies on it, but this might change in the future. -GIT_TEST_GETTEXT_POISON=<boolean> turns all strings marked for -translation into gibberish if true. Used for spotting those tests that -need to be marked with a C_LOCALE_OUTPUT prerequisite when adding more -strings for translation. See "Testing marked strings" in po/README for -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. @@ -439,6 +438,16 @@ GIT_TEST_DEFAULT_HASH=<hash-algo> specifies which hash algorithm to use in the test scripts. Recognized values for <hash-algo> are "sha1" and "sha256". +GIT_TEST_WRITE_REV_INDEX=<boolean>, when true enables the +'pack.writeReverseIndex' setting. + +GIT_TEST_SPARSE_INDEX=<boolean>, when true enables index writes to use the +sparse-index format by default. + +GIT_TEST_CHECKOUT_WORKERS=<n> overrides the 'checkout.workers' setting +to <n> and 'checkout.thresholdForParallelism' to 0, forcing the +execution of the parallel-checkout code. + Naming Tests ------------ @@ -917,13 +926,13 @@ library for your script to use. Check whether a file has the length it is expected to. - - test_path_is_file <path> [<diagnosis>] - test_path_is_dir <path> [<diagnosis>] - test_path_is_missing <path> [<diagnosis>] + - test_path_is_file <path> + test_path_is_dir <path> + test_path_is_missing <path> Check if the named path is a file, if the named path is a directory, or if the named path does not exist, respectively, - and fail otherwise, showing the <diagnosis> text. + and fail otherwise. - test_when_finished <script> @@ -1104,18 +1113,6 @@ use these, and "test_set_prereq" for how to define your own. Git was compiled with support for PCRE. Wrap any tests that use git-grep --perl-regexp or git-grep -P in these. - - LIBPCRE1 - - Git was compiled with PCRE v1 support via - USE_LIBPCRE1=YesPlease. Wrap any PCRE using tests that for some - reason need v1 of the PCRE library instead of v2 in these. - - - LIBPCRE2 - - Git was compiled with PCRE v2 support via - USE_LIBPCRE2=YesPlease. Wrap any PCRE using tests that for some - reason need v2 of the PCRE library instead of v1 in these. - - CASE_INSENSITIVE_FS Test is run on a case insensitive file system. diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index a2e46572d5..d3b299e75c 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -95,7 +95,7 @@ test_expect_success 'blame 2 authors' ' ' test_expect_success 'setup B1 lines (branch1)' ' - git checkout -b branch1 master && + git checkout -b branch1 main && echo "3A slow green fox jumps into the" >>file && echo "well." >>file && GIT_AUTHOR_NAME="B1" GIT_AUTHOR_EMAIL="B1@test.git" \ @@ -107,7 +107,7 @@ test_expect_success 'blame 2 authors + 1 branch1 author' ' ' test_expect_success 'setup B2 lines (branch2)' ' - git checkout -b branch2 master && + git checkout -b branch2 main && sed -e "s/2A quick brown/4A quick brown lazy dog/" <file >file.new && mv file.new file && GIT_AUTHOR_NAME="B2" GIT_AUTHOR_EMAIL="B2@test.git" \ @@ -131,11 +131,11 @@ test_expect_success 'blame --first-parent blames merge for branch1' ' ' test_expect_success 'blame ancestor' ' - check_count -h master A 2 B 2 + check_count -h main A 2 B 2 ' test_expect_success 'blame great-ancestor' ' - check_count -h master^ A 2 + check_count -h main^ A 2 ' test_expect_success 'setup evil merge' ' @@ -479,22 +479,26 @@ test_expect_success 'blame -L ^:RE (absolute: end-of-file)' ' check_count -f hello.c -L$n -L^:ma.. F 4 G 1 H 1 ' -test_expect_success 'setup -L :funcname with userdiff driver' ' - echo "fortran-* diff=fortran" >.gitattributes && - fortran_file=fortran-external-function && - orig_file="$TEST_DIRECTORY/t4018/$fortran_file" && - cp "$orig_file" . && - git add "$fortran_file" && - GIT_AUTHOR_NAME="A" GIT_AUTHOR_EMAIL="A@test.git" \ - git commit -m "add fortran file" && - sed -e "s/ChangeMe/IWasChanged/" <"$orig_file" >"$fortran_file" && - git add "$fortran_file" && - GIT_AUTHOR_NAME="B" GIT_AUTHOR_EMAIL="B@test.git" \ - git commit -m "change fortran file" -' - test_expect_success 'blame -L :funcname with userdiff driver' ' - check_count -f fortran-external-function -L:RIGHT A 7 B 1 + cat >file.template <<-\EOF && + DO NOT MATCH THIS LINE + function RIGHT(a, b) result(c) + AS THE DEFAULT DRIVER WOULD + + integer, intent(in) :: ChangeMe + EOF + + fortran_file=file.f03 && + test_when_finished "rm .gitattributes" && + echo "$fortran_file diff=fortran" >.gitattributes && + + test_commit --author "A <A@test.git>" \ + "add" "$fortran_file" \ + "$(cat file.template)" && + test_commit --author "B <B@test.git>" \ + "change" "$fortran_file" \ + "$(cat file.template | sed -e s/ChangeMe/IWasChanged/)" && + check_count -f "$fortran_file" -L:RIGHT A 3 B 1 ' test_expect_success 'setup incremental' ' diff --git a/t/helper/test-bitmap.c b/t/helper/test-bitmap.c new file mode 100644 index 0000000000..134a1e9d76 --- /dev/null +++ b/t/helper/test-bitmap.c @@ -0,0 +1,24 @@ +#include "test-tool.h" +#include "cache.h" +#include "pack-bitmap.h" + +static int bitmap_list_commits(void) +{ + return test_bitmap_commits(the_repository); +} + +int cmd__bitmap(int argc, const char **argv) +{ + setup_git_directory(); + + if (argc != 2) + goto usage; + + if (!strcmp(argv[1], "list-commits")) + return bitmap_list_commits(); + +usage: + usage("\ttest-tool bitmap list-commits"); + + return -1; +} diff --git a/t/helper/test-bloom.c b/t/helper/test-bloom.c index 46e97b04eb..ad3ef1cd77 100644 --- a/t/helper/test-bloom.c +++ b/t/helper/test-bloom.c @@ -48,7 +48,7 @@ static void get_bloom_filter_for_commit(const struct object_id *commit_oid) static const char *bloom_usage = "\n" " test-tool bloom get_murmur3 <string>\n" " test-tool bloom generate_filter <string> [<string>...]\n" -" test-tool get_filter_for_commit <commit-hex>\n"; +" test-tool bloom get_filter_for_commit <commit-hex>\n"; int cmd__bloom(int argc, const char **argv) { @@ -69,7 +69,7 @@ int cmd__bloom(int argc, const char **argv) struct bloom_filter filter; int i = 2; filter.len = (settings.bits_per_entry + BITS_PER_WORD - 1) / BITS_PER_WORD; - filter.data = xcalloc(filter.len, sizeof(unsigned char)); + CALLOC_ARRAY(filter.data, filter.len); if (argc - 1 < i) usage(bloom_usage); diff --git a/t/helper/test-chmtime.c b/t/helper/test-chmtime.c index aa22af48c2..524b55ca49 100644 --- a/t/helper/test-chmtime.c +++ b/t/helper/test-chmtime.c @@ -109,9 +109,9 @@ int cmd__chmtime(int argc, const char **argv) uintmax_t mtime; if (stat(argv[i], &sb) < 0) { - fprintf(stderr, "Failed to stat %s: %s\n", + fprintf(stderr, "Failed to stat %s: %s. Skipping\n", argv[i], strerror(errno)); - return 1; + continue; } #ifdef GIT_WINDOWS_NATIVE diff --git a/t/helper/test-example-decorate.c b/t/helper/test-example-decorate.c index c8a1cde7d2..b9d1200eb9 100644 --- a/t/helper/test-example-decorate.c +++ b/t/helper/test-example-decorate.c @@ -26,8 +26,8 @@ int cmd__example_decorate(int argc, const char **argv) * Add 2 objects, one with a non-NULL decoration and one with a NULL * decoration. */ - one = lookup_unknown_object(&one_oid); - two = lookup_unknown_object(&two_oid); + one = lookup_unknown_object(the_repository, &one_oid); + two = lookup_unknown_object(the_repository, &two_oid); ret = add_decoration(&n, one, &decoration_a); if (ret) BUG("when adding a brand-new object, NULL should be returned"); @@ -56,7 +56,7 @@ int cmd__example_decorate(int argc, const char **argv) ret = lookup_decoration(&n, two); if (ret != &decoration_b) BUG("lookup should return added declaration"); - three = lookup_unknown_object(&three_oid); + three = lookup_unknown_object(the_repository, &three_oid); ret = lookup_decoration(&n, three); if (ret) BUG("lookup for unknown object should return NULL"); diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c index 313a153209..229ed416b0 100644 --- a/t/helper/test-path-utils.c +++ b/t/helper/test-path-utils.c @@ -172,9 +172,22 @@ static struct test_data dirname_data[] = { { NULL, NULL } }; -static int is_dotgitmodules(const char *path) +static int check_dotfile(const char *x, const char **argv, + int (*is_hfs)(const char *), + int (*is_ntfs)(const char *)) { - return is_hfs_dotgitmodules(path) || is_ntfs_dotgitmodules(path); + int res = 0, expect = 1; + for (; *argv; argv++) { + if (!strcmp("--not", *argv)) + expect = !expect; + else if (expect != (is_hfs(*argv) || is_ntfs(*argv))) + res = error("'%s' is %s.git%s", *argv, + expect ? "not " : "", x); + else + fprintf(stderr, "ok: '%s' is %s.git%s\n", + *argv, expect ? "" : "not ", x); + } + return !!res; } static int cmp_by_st_size(const void *a, const void *b) @@ -382,17 +395,24 @@ int cmd__path_utils(int argc, const char **argv) return test_function(dirname_data, posix_dirname, argv[1]); if (argc > 2 && !strcmp(argv[1], "is_dotgitmodules")) { - int res = 0, expect = 1, i; - for (i = 2; i < argc; i++) - if (!strcmp("--not", argv[i])) - expect = !expect; - else if (expect != is_dotgitmodules(argv[i])) - res = error("'%s' is %s.gitmodules", argv[i], - expect ? "not " : ""); - else - fprintf(stderr, "ok: '%s' is %s.gitmodules\n", - argv[i], expect ? "" : "not "); - return !!res; + return check_dotfile("modules", argv + 2, + is_hfs_dotgitmodules, + is_ntfs_dotgitmodules); + } + if (argc > 2 && !strcmp(argv[1], "is_dotgitignore")) { + return check_dotfile("ignore", argv + 2, + is_hfs_dotgitignore, + is_ntfs_dotgitignore); + } + if (argc > 2 && !strcmp(argv[1], "is_dotgitattributes")) { + return check_dotfile("attributes", argv + 2, + is_hfs_dotgitattributes, + is_ntfs_dotgitattributes); + } + if (argc > 2 && !strcmp(argv[1], "is_dotmailmap")) { + return check_dotfile("mailmap", argv + 2, + is_hfs_dotmailmap, + is_ntfs_dotmailmap); } if (argc > 2 && !strcmp(argv[1], "file-size")) { diff --git a/t/helper/test-pcre2-config.c b/t/helper/test-pcre2-config.c new file mode 100644 index 0000000000..5258fdddba --- /dev/null +++ b/t/helper/test-pcre2-config.c @@ -0,0 +1,12 @@ +#include "test-tool.h" +#include "cache.h" +#include "grep.h" + +int cmd__pcre2_config(int argc, const char **argv) +{ + if (argc == 2 && !strcmp(argv[1], "has-PCRE2_MATCH_INVALID_UTF")) { + int value = PCRE2_MATCH_INVALID_UTF; + return !value; + } + return 1; +} diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c index 244977a29b..b52c174acc 100644 --- a/t/helper/test-read-cache.c +++ b/t/helper/test-read-cache.c @@ -1,36 +1,82 @@ #include "test-tool.h" #include "cache.h" #include "config.h" +#include "blob.h" +#include "commit.h" +#include "tree.h" +#include "sparse-index.h" + +static void print_cache_entry(struct cache_entry *ce) +{ + const char *type; + printf("%06o ", ce->ce_mode & 0177777); + + if (S_ISSPARSEDIR(ce->ce_mode)) + type = tree_type; + else if (S_ISGITLINK(ce->ce_mode)) + type = commit_type; + else + type = blob_type; + + printf("%s %s\t%s\n", + type, + oid_to_hex(&ce->oid), + ce->name); +} + +static void print_cache(struct index_state *istate) +{ + int i; + for (i = 0; i < istate->cache_nr; i++) + print_cache_entry(istate->cache[i]); +} int cmd__read_cache(int argc, const char **argv) { + struct repository *r = the_repository; int i, cnt = 1; const char *name = NULL; + int table = 0, expand = 0; + + initialize_the_repository(); + prepare_repo_settings(r); + r->settings.command_requires_full_index = 0; - if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) { - argc--; - argv++; + for (++argv, --argc; *argv && starts_with(*argv, "--"); ++argv, --argc) { + if (skip_prefix(*argv, "--print-and-refresh=", &name)) + continue; + if (!strcmp(*argv, "--table")) + table = 1; + else if (!strcmp(*argv, "--expand")) + expand = 1; } - if (argc == 2) - cnt = strtol(argv[1], NULL, 0); + if (argc == 1) + cnt = strtol(argv[0], NULL, 0); setup_git_directory(); git_config(git_default_config, NULL); + for (i = 0; i < cnt; i++) { - read_cache(); + repo_read_index(r); + + if (expand) + ensure_full_index(r->index); + if (name) { int pos; - refresh_index(&the_index, REFRESH_QUIET, + refresh_index(r->index, REFRESH_QUIET, NULL, NULL, NULL); - pos = index_name_pos(&the_index, name, strlen(name)); + pos = index_name_pos(r->index, name, strlen(name)); if (pos < 0) die("%s not in index", name); printf("%s is%s up to date\n", name, - ce_uptodate(the_index.cache[pos]) ? "" : " not"); + ce_uptodate(r->index->cache[pos]) ? "" : " not"); write_file(name, "%d\n", i); } - discard_cache(); + if (table) + print_cache(r->index); + discard_index(r->index); } return 0; } diff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c index 5f585a1725..75927b2c81 100644 --- a/t/helper/test-read-graph.c +++ b/t/helper/test-read-graph.c @@ -33,6 +33,10 @@ int cmd__read_graph(int argc, const char **argv) printf(" oid_lookup"); if (graph->chunk_commit_data) printf(" commit_metadata"); + if (graph->chunk_generation_data) + printf(" generation_data"); + if (graph->chunk_generation_data_overflow) + printf(" generation_data_overflow"); if (graph->chunk_extra_edges) printf(" extra_edges"); if (graph->chunk_bloom_indexes) diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c index 2430880f78..7c2eb11a8e 100644 --- a/t/helper/test-read-midx.c +++ b/t/helper/test-read-midx.c @@ -4,7 +4,7 @@ #include "repository.h" #include "object-store.h" -static int read_midx_file(const char *object_dir) +static int read_midx_file(const char *object_dir, int show_objects) { uint32_t i; struct multi_pack_index *m; @@ -43,13 +43,29 @@ static int read_midx_file(const char *object_dir) printf("object-dir: %s\n", m->object_dir); + if (show_objects) { + struct object_id oid; + struct pack_entry e; + + for (i = 0; i < m->num_objects; i++) { + nth_midxed_object_oid(&oid, m, i); + fill_midx_entry(the_repository, &oid, &e, m); + + printf("%s %"PRIu64"\t%s\n", + oid_to_hex(&oid), e.offset, e.p->pack_name); + } + return 0; + } + return 0; } int cmd__read_midx(int argc, const char **argv) { - if (argc != 2) - usage("read-midx <object-dir>"); + if (!(argc == 2 || argc == 3)) + usage("read-midx [--show-objects] <object-dir>"); - return read_midx_file(argv[1]); + if (!strcmp(argv[1], "--show-objects")) + return read_midx_file(argv[2], 1); + return read_midx_file(argv[1], 0); } diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index 759e69dc54..bba5f841c6 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -72,18 +72,6 @@ static int cmd_pack_refs(struct ref_store *refs, const char **argv) return refs_pack_refs(refs, flags); } -static int cmd_peel_ref(struct ref_store *refs, const char **argv) -{ - const char *refname = notnull(*argv++, "refname"); - struct object_id oid; - int ret; - - ret = refs_peel_ref(refs, refname, &oid); - if (!ret) - puts(oid_to_hex(&oid)); - return ret; -} - static int cmd_create_symref(struct ref_store *refs, const char **argv) { const char *refname = notnull(*argv++, "refname"); @@ -255,7 +243,6 @@ struct command { static struct command commands[] = { { "pack-refs", cmd_pack_refs }, - { "peel-ref", cmd_peel_ref }, { "create-symref", cmd_create_symref }, { "delete-refs", cmd_delete_refs }, { "rename-ref", cmd_rename_ref }, diff --git a/t/helper/test-simple-ipc.c b/t/helper/test-simple-ipc.c new file mode 100644 index 0000000000..42040ef81b --- /dev/null +++ b/t/helper/test-simple-ipc.c @@ -0,0 +1,787 @@ +/* + * test-simple-ipc.c: verify that the Inter-Process Communication works. + */ + +#include "test-tool.h" +#include "cache.h" +#include "strbuf.h" +#include "simple-ipc.h" +#include "parse-options.h" +#include "thread-utils.h" +#include "strvec.h" + +#ifndef SUPPORTS_SIMPLE_IPC +int cmd__simple_ipc(int argc, const char **argv) +{ + die("simple IPC not available on this platform"); +} +#else + +/* + * The test daemon defines an "application callback" that supports a + * series of commands (see `test_app_cb()`). + * + * Unknown commands are caught here and we send an error message back + * to the client process. + */ +static int app__unhandled_command(const char *command, + ipc_server_reply_cb *reply_cb, + struct ipc_server_reply_data *reply_data) +{ + struct strbuf buf = STRBUF_INIT; + int ret; + + strbuf_addf(&buf, "unhandled command: %s", command); + ret = reply_cb(reply_data, buf.buf, buf.len); + strbuf_release(&buf); + + return ret; +} + +/* + * Reply with a single very large buffer. This is to ensure that + * long response are properly handled -- whether the chunking occurs + * in the kernel or in the (probably pkt-line) layer. + */ +#define BIG_ROWS (10000) +static int app__big_command(ipc_server_reply_cb *reply_cb, + struct ipc_server_reply_data *reply_data) +{ + struct strbuf buf = STRBUF_INIT; + int row; + int ret; + + for (row = 0; row < BIG_ROWS; row++) + strbuf_addf(&buf, "big: %.75d\n", row); + + ret = reply_cb(reply_data, buf.buf, buf.len); + strbuf_release(&buf); + + return ret; +} + +/* + * Reply with a series of lines. This is to ensure that we can incrementally + * compute the response and chunk it to the client. + */ +#define CHUNK_ROWS (10000) +static int app__chunk_command(ipc_server_reply_cb *reply_cb, + struct ipc_server_reply_data *reply_data) +{ + struct strbuf buf = STRBUF_INIT; + int row; + int ret; + + for (row = 0; row < CHUNK_ROWS; row++) { + strbuf_setlen(&buf, 0); + strbuf_addf(&buf, "big: %.75d\n", row); + ret = reply_cb(reply_data, buf.buf, buf.len); + } + + strbuf_release(&buf); + + return ret; +} + +/* + * Slowly reply with a series of lines. This is to model an expensive to + * compute chunked response (which might happen if this callback is running + * in a thread and is fighting for a lock with other threads). + */ +#define SLOW_ROWS (1000) +#define SLOW_DELAY_MS (10) +static int app__slow_command(ipc_server_reply_cb *reply_cb, + struct ipc_server_reply_data *reply_data) +{ + struct strbuf buf = STRBUF_INIT; + int row; + int ret; + + for (row = 0; row < SLOW_ROWS; row++) { + strbuf_setlen(&buf, 0); + strbuf_addf(&buf, "big: %.75d\n", row); + ret = reply_cb(reply_data, buf.buf, buf.len); + sleep_millisec(SLOW_DELAY_MS); + } + + strbuf_release(&buf); + + return ret; +} + +/* + * The client sent a command followed by a (possibly very) large buffer. + */ +static int app__sendbytes_command(const char *received, + ipc_server_reply_cb *reply_cb, + struct ipc_server_reply_data *reply_data) +{ + struct strbuf buf_resp = STRBUF_INIT; + const char *p = "?"; + int len_ballast = 0; + int k; + int errs = 0; + int ret; + + if (skip_prefix(received, "sendbytes ", &p)) + len_ballast = strlen(p); + + /* + * Verify that the ballast is n copies of a single letter. + * And that the multi-threaded IO layer didn't cross the streams. + */ + for (k = 1; k < len_ballast; k++) + if (p[k] != p[0]) + errs++; + + if (errs) + strbuf_addf(&buf_resp, "errs:%d\n", errs); + else + strbuf_addf(&buf_resp, "rcvd:%c%08d\n", p[0], len_ballast); + + ret = reply_cb(reply_data, buf_resp.buf, buf_resp.len); + + strbuf_release(&buf_resp); + + return ret; +} + +/* + * An arbitrary fixed address to verify that the application instance + * data is handled properly. + */ +static int my_app_data = 42; + +static ipc_server_application_cb test_app_cb; + +/* + * This is the "application callback" that sits on top of the + * "ipc-server". It completely defines the set of commands supported + * by this application. + */ +static int test_app_cb(void *application_data, + const char *command, + ipc_server_reply_cb *reply_cb, + struct ipc_server_reply_data *reply_data) +{ + /* + * Verify that we received the application-data that we passed + * when we started the ipc-server. (We have several layers of + * callbacks calling callbacks and it's easy to get things mixed + * up (especially when some are "void*").) + */ + if (application_data != (void*)&my_app_data) + BUG("application_cb: application_data pointer wrong"); + + if (!strcmp(command, "quit")) { + /* + * The client sent a "quit" command. This is an async + * request for the server to shutdown. + * + * We DO NOT send the client a response message + * (because we have nothing to say and the other + * server threads have not yet stopped). + * + * Tell the ipc-server layer to start shutting down. + * This includes: stop listening for new connections + * on the socket/pipe and telling all worker threads + * to finish/drain their outgoing responses to other + * clients. + * + * This DOES NOT force an immediate sync shutdown. + */ + return SIMPLE_IPC_QUIT; + } + + if (!strcmp(command, "ping")) { + const char *answer = "pong"; + return reply_cb(reply_data, answer, strlen(answer)); + } + + if (!strcmp(command, "big")) + return app__big_command(reply_cb, reply_data); + + if (!strcmp(command, "chunk")) + return app__chunk_command(reply_cb, reply_data); + + if (!strcmp(command, "slow")) + return app__slow_command(reply_cb, reply_data); + + if (starts_with(command, "sendbytes ")) + return app__sendbytes_command(command, reply_cb, reply_data); + + return app__unhandled_command(command, reply_cb, reply_data); +} + +struct cl_args +{ + const char *subcommand; + const char *path; + const char *token; + + int nr_threads; + int max_wait_sec; + int bytecount; + int batchsize; + + char bytevalue; +}; + +static struct cl_args cl_args = { + .subcommand = NULL, + .path = "ipc-test", + .token = NULL, + + .nr_threads = 5, + .max_wait_sec = 60, + .bytecount = 1024, + .batchsize = 10, + + .bytevalue = 'x', +}; + +/* + * This process will run as a simple-ipc server and listen for IPC commands + * from client processes. + */ +static int daemon__run_server(void) +{ + int ret; + + struct ipc_server_opts opts = { + .nr_threads = cl_args.nr_threads, + }; + + /* + * Synchronously run the ipc-server. We don't need any application + * instance data, so pass an arbitrary pointer (that we'll later + * verify made the round trip). + */ + ret = ipc_server_run(cl_args.path, &opts, test_app_cb, (void*)&my_app_data); + if (ret == -2) + error(_("socket/pipe already in use: '%s'"), cl_args.path); + else if (ret == -1) + error_errno(_("could not start server on: '%s'"), cl_args.path); + + return ret; +} + +#ifndef GIT_WINDOWS_NATIVE +/* + * This is adapted from `daemonize()`. Use `fork()` to directly create and + * run the daemon in a child process. + */ +static int spawn_server(pid_t *pid) +{ + struct ipc_server_opts opts = { + .nr_threads = cl_args.nr_threads, + }; + + *pid = fork(); + + switch (*pid) { + case 0: + if (setsid() == -1) + error_errno(_("setsid failed")); + close(0); + close(1); + close(2); + sanitize_stdfds(); + + return ipc_server_run(cl_args.path, &opts, test_app_cb, + (void*)&my_app_data); + + case -1: + return error_errno(_("could not spawn daemon in the background")); + + default: + return 0; + } +} +#else +/* + * Conceptually like `daemonize()` but different because Windows does not + * have `fork(2)`. Spawn a normal Windows child process but without the + * limitations of `start_command()` and `finish_command()`. + */ +static int spawn_server(pid_t *pid) +{ + char test_tool_exe[MAX_PATH]; + struct strvec args = STRVEC_INIT; + int in, out; + + GetModuleFileNameA(NULL, test_tool_exe, MAX_PATH); + + in = open("/dev/null", O_RDONLY); + out = open("/dev/null", O_WRONLY); + + strvec_push(&args, test_tool_exe); + strvec_push(&args, "simple-ipc"); + strvec_push(&args, "run-daemon"); + strvec_pushf(&args, "--name=%s", cl_args.path); + strvec_pushf(&args, "--threads=%d", cl_args.nr_threads); + + *pid = mingw_spawnvpe(args.v[0], args.v, NULL, NULL, in, out, out); + close(in); + close(out); + + strvec_clear(&args); + + if (*pid < 0) + return error(_("could not spawn daemon in the background")); + + return 0; +} +#endif + +/* + * This is adapted from `wait_or_whine()`. Watch the child process and + * let it get started and begin listening for requests on the socket + * before reporting our success. + */ +static int wait_for_server_startup(pid_t pid_child) +{ + int status; + pid_t pid_seen; + enum ipc_active_state s; + time_t time_limit, now; + + time(&time_limit); + time_limit += cl_args.max_wait_sec; + + for (;;) { + pid_seen = waitpid(pid_child, &status, WNOHANG); + + if (pid_seen == -1) + return error_errno(_("waitpid failed")); + + else if (pid_seen == 0) { + /* + * The child is still running (this should be + * the normal case). Try to connect to it on + * the socket and see if it is ready for + * business. + * + * If there is another daemon already running, + * our child will fail to start (possibly + * after a timeout on the lock), but we don't + * care (who responds) if the socket is live. + */ + s = ipc_get_active_state(cl_args.path); + if (s == IPC_STATE__LISTENING) + return 0; + + time(&now); + if (now > time_limit) + return error(_("daemon not online yet")); + + continue; + } + + else if (pid_seen == pid_child) { + /* + * The new child daemon process shutdown while + * it was starting up, so it is not listening + * on the socket. + * + * Try to ping the socket in the odd chance + * that another daemon started (or was already + * running) while our child was starting. + * + * Again, we don't care who services the socket. + */ + s = ipc_get_active_state(cl_args.path); + if (s == IPC_STATE__LISTENING) + return 0; + + /* + * We don't care about the WEXITSTATUS() nor + * any of the WIF*(status) values because + * `cmd__simple_ipc()` does the `!!result` + * trick on all function return values. + * + * So it is sufficient to just report the + * early shutdown as an error. + */ + return error(_("daemon failed to start")); + } + + else + return error(_("waitpid is confused")); + } +} + +/* + * This process will start a simple-ipc server in a background process and + * wait for it to become ready. This is like `daemonize()` but gives us + * more control and better error reporting (and makes it easier to write + * unit tests). + */ +static int daemon__start_server(void) +{ + pid_t pid_child; + int ret; + + /* + * Run the actual daemon in a background process. + */ + ret = spawn_server(&pid_child); + if (pid_child <= 0) + return ret; + + /* + * Let the parent wait for the child process to get started + * and begin listening for requests on the socket. + */ + ret = wait_for_server_startup(pid_child); + + return ret; +} + +/* + * This process will run a quick probe to see if a simple-ipc server + * is active on this path. + * + * Returns 0 if the server is alive. + */ +static int client__probe_server(void) +{ + enum ipc_active_state s; + + s = ipc_get_active_state(cl_args.path); + switch (s) { + case IPC_STATE__LISTENING: + return 0; + + case IPC_STATE__NOT_LISTENING: + return error("no server listening at '%s'", cl_args.path); + + case IPC_STATE__PATH_NOT_FOUND: + return error("path not found '%s'", cl_args.path); + + case IPC_STATE__INVALID_PATH: + return error("invalid pipe/socket name '%s'", cl_args.path); + + case IPC_STATE__OTHER_ERROR: + default: + return error("other error for '%s'", cl_args.path); + } +} + +/* + * Send an IPC command token to an already-running server daemon and + * print the response. + * + * This is a simple 1 word command/token that `test_app_cb()` (in the + * daemon process) will understand. + */ +static int client__send_ipc(void) +{ + const char *command = "(no-command)"; + struct strbuf buf = STRBUF_INIT; + struct ipc_client_connect_options options + = IPC_CLIENT_CONNECT_OPTIONS_INIT; + + if (cl_args.token && *cl_args.token) + command = cl_args.token; + + options.wait_if_busy = 1; + options.wait_if_not_found = 0; + + if (!ipc_client_send_command(cl_args.path, &options, command, &buf)) { + if (buf.len) { + printf("%s\n", buf.buf); + fflush(stdout); + } + strbuf_release(&buf); + + return 0; + } + + return error("failed to send '%s' to '%s'", command, cl_args.path); +} + +/* + * Send an IPC command to an already-running server and ask it to + * shutdown. "send quit" is an async request and queues a shutdown + * event in the server, so we spin and wait here for it to actually + * shutdown to make the unit tests a little easier to write. + */ +static int client__stop_server(void) +{ + int ret; + time_t time_limit, now; + enum ipc_active_state s; + + time(&time_limit); + time_limit += cl_args.max_wait_sec; + + cl_args.token = "quit"; + + ret = client__send_ipc(); + if (ret) + return ret; + + for (;;) { + sleep_millisec(100); + + s = ipc_get_active_state(cl_args.path); + + if (s != IPC_STATE__LISTENING) { + /* + * The socket/pipe is gone and/or has stopped + * responding. Lets assume that the daemon + * process has exited too. + */ + return 0; + } + + time(&now); + if (now > time_limit) + return error(_("daemon has not shutdown yet")); + } +} + +/* + * Send an IPC command followed by ballast to confirm that a large + * message can be sent and that the kernel or pkt-line layers will + * properly chunk it and that the daemon receives the entire message. + */ +static int do_sendbytes(int bytecount, char byte, const char *path, + const struct ipc_client_connect_options *options) +{ + struct strbuf buf_send = STRBUF_INIT; + struct strbuf buf_resp = STRBUF_INIT; + + strbuf_addstr(&buf_send, "sendbytes "); + strbuf_addchars(&buf_send, byte, bytecount); + + if (!ipc_client_send_command(path, options, buf_send.buf, &buf_resp)) { + strbuf_rtrim(&buf_resp); + printf("sent:%c%08d %s\n", byte, bytecount, buf_resp.buf); + fflush(stdout); + strbuf_release(&buf_send); + strbuf_release(&buf_resp); + + return 0; + } + + return error("client failed to sendbytes(%d, '%c') to '%s'", + bytecount, byte, path); +} + +/* + * Send an IPC command with ballast to an already-running server daemon. + */ +static int client__sendbytes(void) +{ + struct ipc_client_connect_options options + = IPC_CLIENT_CONNECT_OPTIONS_INIT; + + options.wait_if_busy = 1; + options.wait_if_not_found = 0; + options.uds_disallow_chdir = 0; + + return do_sendbytes(cl_args.bytecount, cl_args.bytevalue, cl_args.path, + &options); +} + +struct multiple_thread_data { + pthread_t pthread_id; + struct multiple_thread_data *next; + const char *path; + int bytecount; + int batchsize; + int sum_errors; + int sum_good; + char letter; +}; + +static void *multiple_thread_proc(void *_multiple_thread_data) +{ + struct multiple_thread_data *d = _multiple_thread_data; + int k; + struct ipc_client_connect_options options + = IPC_CLIENT_CONNECT_OPTIONS_INIT; + + options.wait_if_busy = 1; + options.wait_if_not_found = 0; + /* + * A multi-threaded client should not be randomly calling chdir(). + * The test will pass without this restriction because the test is + * not otherwise accessing the filesystem, but it makes us honest. + */ + options.uds_disallow_chdir = 1; + + trace2_thread_start("multiple"); + + for (k = 0; k < d->batchsize; k++) { + if (do_sendbytes(d->bytecount + k, d->letter, d->path, &options)) + d->sum_errors++; + else + d->sum_good++; + } + + trace2_thread_exit(); + return NULL; +} + +/* + * Start a client-side thread pool. Each thread sends a series of + * IPC requests. Each request is on a new connection to the server. + */ +static int client__multiple(void) +{ + struct multiple_thread_data *list = NULL; + int k; + int sum_join_errors = 0; + int sum_thread_errors = 0; + int sum_good = 0; + + for (k = 0; k < cl_args.nr_threads; k++) { + struct multiple_thread_data *d = xcalloc(1, sizeof(*d)); + d->next = list; + d->path = cl_args.path; + d->bytecount = cl_args.bytecount + cl_args.batchsize*(k/26); + d->batchsize = cl_args.batchsize; + d->sum_errors = 0; + d->sum_good = 0; + d->letter = 'A' + (k % 26); + + if (pthread_create(&d->pthread_id, NULL, multiple_thread_proc, d)) { + warning("failed to create thread[%d] skipping remainder", k); + free(d); + break; + } + + list = d; + } + + while (list) { + struct multiple_thread_data *d = list; + + if (pthread_join(d->pthread_id, NULL)) + sum_join_errors++; + + sum_thread_errors += d->sum_errors; + sum_good += d->sum_good; + + list = d->next; + free(d); + } + + printf("client (good %d) (join %d), (errors %d)\n", + sum_good, sum_join_errors, sum_thread_errors); + + return (sum_join_errors + sum_thread_errors) ? 1 : 0; +} + +int cmd__simple_ipc(int argc, const char **argv) +{ + const char * const simple_ipc_usage[] = { + N_("test-helper simple-ipc is-active [<name>] [<options>]"), + N_("test-helper simple-ipc run-daemon [<name>] [<threads>]"), + N_("test-helper simple-ipc start-daemon [<name>] [<threads>] [<max-wait>]"), + N_("test-helper simple-ipc stop-daemon [<name>] [<max-wait>]"), + N_("test-helper simple-ipc send [<name>] [<token>]"), + N_("test-helper simple-ipc sendbytes [<name>] [<bytecount>] [<byte>]"), + N_("test-helper simple-ipc multiple [<name>] [<threads>] [<bytecount>] [<batchsize>]"), + NULL + }; + + const char *bytevalue = NULL; + + struct option options[] = { +#ifndef GIT_WINDOWS_NATIVE + OPT_STRING(0, "name", &cl_args.path, N_("name"), N_("name or pathname of unix domain socket")), +#else + OPT_STRING(0, "name", &cl_args.path, N_("name"), N_("named-pipe name")), +#endif + OPT_INTEGER(0, "threads", &cl_args.nr_threads, N_("number of threads in server thread pool")), + OPT_INTEGER(0, "max-wait", &cl_args.max_wait_sec, N_("seconds to wait for daemon to start or stop")), + + OPT_INTEGER(0, "bytecount", &cl_args.bytecount, N_("number of bytes")), + OPT_INTEGER(0, "batchsize", &cl_args.batchsize, N_("number of requests per thread")), + + OPT_STRING(0, "byte", &bytevalue, N_("byte"), N_("ballast character")), + OPT_STRING(0, "token", &cl_args.token, N_("token"), N_("command token to send to the server")), + + OPT_END() + }; + + if (argc < 2) + usage_with_options(simple_ipc_usage, options); + + if (argc == 2 && !strcmp(argv[1], "-h")) + usage_with_options(simple_ipc_usage, options); + + if (argc == 2 && !strcmp(argv[1], "SUPPORTS_SIMPLE_IPC")) + return 0; + + cl_args.subcommand = argv[1]; + + argc--; + argv++; + + argc = parse_options(argc, argv, NULL, options, simple_ipc_usage, 0); + + if (cl_args.nr_threads < 1) + cl_args.nr_threads = 1; + if (cl_args.max_wait_sec < 0) + cl_args.max_wait_sec = 0; + if (cl_args.bytecount < 1) + cl_args.bytecount = 1; + if (cl_args.batchsize < 1) + cl_args.batchsize = 1; + + if (bytevalue && *bytevalue) + cl_args.bytevalue = bytevalue[0]; + + /* + * Use '!!' on all dispatch functions to map from `error()` style + * (returns -1) style to `test_must_fail` style (expects 1). This + * makes shell error messages less confusing. + */ + + if (!strcmp(cl_args.subcommand, "is-active")) + return !!client__probe_server(); + + if (!strcmp(cl_args.subcommand, "run-daemon")) + return !!daemon__run_server(); + + if (!strcmp(cl_args.subcommand, "start-daemon")) + return !!daemon__start_server(); + + /* + * Client commands follow. Ensure a server is running before + * sending any data. This might be overkill, but then again + * this is a test harness. + */ + + if (!strcmp(cl_args.subcommand, "stop-daemon")) { + if (client__probe_server()) + return 1; + return !!client__stop_server(); + } + + if (!strcmp(cl_args.subcommand, "send")) { + if (client__probe_server()) + return 1; + return !!client__send_ipc(); + } + + if (!strcmp(cl_args.subcommand, "sendbytes")) { + if (client__probe_server()) + return 1; + return !!client__sendbytes(); + } + + if (!strcmp(cl_args.subcommand, "multiple")) { + if (client__probe_server()) + return 1; + return !!client__multiple(); + } + + die("Unhandled subcommand: '%s'", cl_args.subcommand); +} +#endif diff --git a/t/helper/test-submodule-nested-repo-config.c b/t/helper/test-submodule-nested-repo-config.c index c5fd4527dc..e3f11ff5a7 100644 --- a/t/helper/test-submodule-nested-repo-config.c +++ b/t/helper/test-submodule-nested-repo-config.c @@ -18,7 +18,7 @@ int cmd__submodule_nested_repo_config(int argc, const char **argv) setup_git_directory(); - sub = submodule_from_path(the_repository, &null_oid, argv[1]); + sub = submodule_from_path(the_repository, null_oid(), argv[1]); if (repo_submodule_init(&subrepo, the_repository, sub)) { die_usage(argv, "Submodule not found."); } diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index 9d6d14d929..c5bd0c6d4c 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -15,6 +15,7 @@ struct test_cmd { static struct test_cmd cmds[] = { { "advise", cmd__advise_if_enabled }, + { "bitmap", cmd__bitmap }, { "bloom", cmd__bloom }, { "chmtime", cmd__chmtime }, { "config", cmd__config }, @@ -46,6 +47,7 @@ static struct test_cmd cmds[] = { { "parse-options", cmd__parse_options }, { "parse-pathspec-file", cmd__parse_pathspec_file }, { "path-utils", cmd__path_utils }, + { "pcre2-config", cmd__pcre2_config }, { "pkt-line", cmd__pkt_line }, { "prio-queue", cmd__prio_queue }, { "proc-receive", cmd__proc_receive}, @@ -64,12 +66,14 @@ static struct test_cmd cmds[] = { { "sha1", cmd__sha1 }, { "sha256", cmd__sha256 }, { "sigchain", cmd__sigchain }, + { "simple-ipc", cmd__simple_ipc }, { "strcmp-offset", cmd__strcmp_offset }, { "string-list", cmd__string_list }, { "submodule-config", cmd__submodule_config }, { "submodule-nested-repo-config", cmd__submodule_nested_repo_config }, { "subprocess", cmd__subprocess }, { "trace2", cmd__trace2 }, + { "userdiff", cmd__userdiff }, { "urlmatch-normalization", cmd__urlmatch_normalization }, { "xml-encode", cmd__xml_encode }, { "wildmatch", cmd__wildmatch }, diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h index a6470ff62c..e8069a3b22 100644 --- a/t/helper/test-tool.h +++ b/t/helper/test-tool.h @@ -5,6 +5,7 @@ #include "git-compat-util.h" int cmd__advise_if_enabled(int argc, const char **argv); +int cmd__bitmap(int argc, const char **argv); int cmd__bloom(int argc, const char **argv); int cmd__chmtime(int argc, const char **argv); int cmd__config(int argc, const char **argv); @@ -35,6 +36,7 @@ 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__pcre2_config(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__proc_receive(int argc, const char **argv); @@ -54,12 +56,14 @@ int cmd__sha1(int argc, const char **argv); int cmd__oid_array(int argc, const char **argv); int cmd__sha256(int argc, const char **argv); int cmd__sigchain(int argc, const char **argv); +int cmd__simple_ipc(int argc, const char **argv); int cmd__strcmp_offset(int argc, const char **argv); int cmd__string_list(int argc, const char **argv); int cmd__submodule_config(int argc, const char **argv); int cmd__submodule_nested_repo_config(int argc, const char **argv); int cmd__subprocess(int argc, const char **argv); int cmd__trace2(int argc, const char **argv); +int cmd__userdiff(int argc, const char **argv); int cmd__urlmatch_normalization(int argc, const char **argv); int cmd__xml_encode(int argc, const char **argv); int cmd__wildmatch(int argc, const char **argv); diff --git a/t/helper/test-trace2.c b/t/helper/test-trace2.c index 823f33ceff..f93633f895 100644 --- a/t/helper/test-trace2.c +++ b/t/helper/test-trace2.c @@ -198,6 +198,14 @@ static int ut_006data(int argc, const char **argv) return 0; } +static int ut_007bug(int argc, const char **argv) +{ + /* + * Exercise BUG() to ensure that the message is printed to trace2. + */ + BUG("the bug message"); +} + /* * Usage: * test-tool trace2 <ut_name_1> <ut_usage_1> @@ -214,6 +222,7 @@ static struct unit_test ut_table[] = { { ut_004child, "004child", "[<child_command_line>]" }, { ut_005exec, "005exec", "<git_command_args>" }, { ut_006data, "006data", "[<category> <key> <value>]+" }, + { ut_007bug, "007bug", "" }, }; /* clang-format on */ diff --git a/t/helper/test-userdiff.c b/t/helper/test-userdiff.c new file mode 100644 index 0000000000..f013f8a31e --- /dev/null +++ b/t/helper/test-userdiff.c @@ -0,0 +1,46 @@ +#include "test-tool.h" +#include "cache.h" +#include "userdiff.h" +#include "config.h" + +static int driver_cb(struct userdiff_driver *driver, + enum userdiff_driver_type type, void *priv) +{ + enum userdiff_driver_type *want_type = priv; + if (type & *want_type && driver->funcname.pattern) + puts(driver->name); + return 0; +} + +static int cmd__userdiff_config(const char *var, const char *value, void *cb) +{ + if (userdiff_config(var, value) < 0) + return -1; + return 0; +} + +int cmd__userdiff(int argc, const char **argv) +{ + enum userdiff_driver_type want = 0; + if (argc != 2) + return 1; + + if (!strcmp(argv[1], "list-drivers")) + want = (USERDIFF_DRIVER_TYPE_BUILTIN | + USERDIFF_DRIVER_TYPE_CUSTOM); + else if (!strcmp(argv[1], "list-builtin-drivers")) + want = USERDIFF_DRIVER_TYPE_BUILTIN; + else if (!strcmp(argv[1], "list-custom-drivers")) + want = USERDIFF_DRIVER_TYPE_CUSTOM; + else + return error("unknown argument %s", argv[1]); + + if (want & USERDIFF_DRIVER_TYPE_CUSTOM) { + setup_git_directory(); + git_config(cmd__userdiff_config, NULL); + } + + for_each_userdiff_driver(driver_cb, &want); + + return 0; +} diff --git a/t/lib-bitmap.sh b/t/lib-bitmap.sh new file mode 100644 index 0000000000..fe3f98be24 --- /dev/null +++ b/t/lib-bitmap.sh @@ -0,0 +1,26 @@ +# Compare a file containing rev-list bitmap traversal output to its non-bitmap +# counterpart. You can't just use test_cmp for this, because the two produce +# subtly different output: +# +# - regular output is in traversal order, whereas bitmap is split by type, +# with non-packed objects at the end +# +# - regular output has a space and the pathname appended to non-commit +# objects; bitmap output omits this +# +# This function normalizes and compares the two. The second file should +# always be the bitmap output. +test_bitmap_traversal () { + if test "$1" = "--no-confirm-bitmaps" + then + shift + elif cmp "$1" "$2" + then + echo >&2 "identical raw outputs; are you sure bitmaps were used?" + return 1 + fi && + cut -d' ' -f1 "$1" | sort >"$1.normalized" && + sort "$2" >"$2.normalized" && + test_cmp "$1.normalized" "$2.normalized" && + rm -f "$1.normalized" "$2.normalized" +} diff --git a/t/lib-bundle.sh b/t/lib-bundle.sh new file mode 100644 index 0000000000..cf7ed818b2 --- /dev/null +++ b/t/lib-bundle.sh @@ -0,0 +1,42 @@ +# Library of git-bundle related functions. + +# Display the pack data contained in the bundle file, bypassing the +# header that contains the signature, prerequisites and references. +convert_bundle_to_pack () { + while read x && test -n "$x" + do + :; + done + cat +} + +# Check count of objects in a bundle file. +# We can use "--thin" opiton to check thin pack, which must be fixed by +# command `git-index-pack --fix-thin --stdin`. +test_bundle_object_count () { + thin= + if test "$1" = "--thin" + then + thin=t + shift + fi + if test $# -ne 2 + then + echo >&2 "args should be: <bundle> <count>" + return 1 + fi + bundle=$1 + pack=$bundle.pack + convert_bundle_to_pack <"$bundle" >"$pack" && + if test -n "$thin" + then + mv "$pack" "$bundle.thin.pack" && + git index-pack --stdin --fix-thin "$pack" <"$bundle.thin.pack" + else + git index-pack "$pack" + fi || return 1 + count=$(git show-index <"${pack%pack}idx" | wc -l) && + test $2 = $count && return 0 + echo >&2 "error: object count for $bundle is $count, not $2" + return 1 +} diff --git a/t/lib-credential.sh b/t/lib-credential.sh index dea2cbef51..5ea8bc9f1d 100644 --- a/t/lib-credential.sh +++ b/t/lib-credential.sh @@ -20,7 +20,7 @@ check() { false fi && test_cmp expect-stdout stdout && - test_i18ncmp expect-stderr stderr + test_cmp expect-stderr stderr } read_chunk() { diff --git a/t/lib-cvs.sh b/t/lib-cvs.sh index 9b2bcfb1b0..32b3473379 100644 --- a/t/lib-cvs.sh +++ b/t/lib-cvs.sh @@ -36,7 +36,7 @@ setup_cvs_test_repository () { test_cvs_co () { # Usage: test_cvs_co BRANCH_NAME rm -rf module-cvs-"$1" - if [ "$1" = "master" ] + if [ "$1" = "main" ] then $CVS co -P -d module-cvs-"$1" -A module else diff --git a/t/diff-lib.sh b/t/lib-diff.sh index 2de880f7a5..2de880f7a5 100644 --- a/t/diff-lib.sh +++ b/t/lib-diff.sh diff --git a/t/diff-lib/COPYING b/t/lib-diff/COPYING index 6ff87c4664..6ff87c4664 100644 --- a/t/diff-lib/COPYING +++ b/t/lib-diff/COPYING diff --git a/t/diff-lib/README b/t/lib-diff/README index 548142c327..548142c327 100644 --- a/t/diff-lib/README +++ b/t/lib-diff/README diff --git a/t/lib-encoding.sh b/t/lib-encoding.sh new file mode 100644 index 0000000000..2dabc8c73e --- /dev/null +++ b/t/lib-encoding.sh @@ -0,0 +1,25 @@ +# Encoding helpers + +test_lazy_prereq NO_UTF16_BOM ' + test $(printf abc | iconv -f UTF-8 -t UTF-16 | wc -c) = 6 +' + +test_lazy_prereq NO_UTF32_BOM ' + test $(printf abc | iconv -f UTF-8 -t UTF-32 | wc -c) = 12 +' + +write_utf16 () { + if test_have_prereq NO_UTF16_BOM + then + printf '\376\377' + fi && + iconv -f UTF-8 -t UTF-16 +} + +write_utf32 () { + if test_have_prereq NO_UTF32_BOM + then + printf '\0\0\376\377' + fi && + iconv -f UTF-8 -t UTF-32 +} diff --git a/t/lib-gettext.sh b/t/lib-gettext.sh index 2139b427ca..cc6bb2cdea 100644 --- a/t/lib-gettext.sh +++ b/t/lib-gettext.sh @@ -17,7 +17,7 @@ else . "$GIT_BUILD_DIR"/git-sh-i18n fi -if test_have_prereq GETTEXT && test_have_prereq C_LOCALE_OUTPUT +if test_have_prereq GETTEXT then # is_IS.UTF-8 on Solaris and FreeBSD, is_IS.utf8 on Debian is_IS_locale=$(locale -a 2>/dev/null | diff --git a/t/gitweb-lib.sh b/t/lib-gitweb.sh index 1f32ca66ea..1f32ca66ea 100644 --- a/t/gitweb-lib.sh +++ b/t/lib-gitweb.sh diff --git a/t/lib-log-graph.sh b/t/lib-log-graph.sh index 1184cceef2..bf952ef920 100644 --- a/t/lib-log-graph.sh +++ b/t/lib-log-graph.sh @@ -12,13 +12,13 @@ sanitize_log_output () { lib_test_cmp_graph () { git log --graph "$@" >output && sed 's/ *$//' >output.sanitized <output && - test_i18ncmp expect output.sanitized + test_cmp 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 + test_cmp expect output.sanitized } lib_test_cmp_colored_graph () { diff --git a/t/lib-parallel-checkout.sh b/t/lib-parallel-checkout.sh new file mode 100644 index 0000000000..83b279a846 --- /dev/null +++ b/t/lib-parallel-checkout.sh @@ -0,0 +1,45 @@ +# Helpers for tests invoking parallel-checkout + +# Parallel checkout tests need full control of the number of workers +unset GIT_TEST_CHECKOUT_WORKERS + +set_checkout_config () { + if test $# -ne 2 + then + BUG "usage: set_checkout_config <workers> <threshold>" + fi && + + test_config_global checkout.workers $1 && + test_config_global checkout.thresholdForParallelism $2 +} + +# Run "${@:2}" and check that $1 checkout workers were used +test_checkout_workers () { + if test $# -lt 2 + then + BUG "too few arguments to test_checkout_workers" + fi && + + local expected_workers=$1 && + shift && + + local trace_file=trace-test-checkout-workers && + rm -f "$trace_file" && + GIT_TRACE2="$(pwd)/$trace_file" "$@" 2>&8 && + + local workers="$(grep "child_start\[..*\] git checkout--worker" "$trace_file" | wc -l)" && + test $workers -eq $expected_workers && + rm "$trace_file" +} 8>&2 2>&4 + +# Verify that both the working tree and the index were created correctly +verify_checkout () { + if test $# -ne 1 + then + BUG "usage: verify_checkout <repository path>" + fi && + + git -C "$1" diff-index --ignore-submodules=none --exit-code HEAD -- && + git -C "$1" status --porcelain >"$1".status && + test_must_be_empty "$1".status +} diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index b72c051f47..dc75b83451 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -4,6 +4,7 @@ # # - override the commit message with $FAKE_COMMIT_MESSAGE # - amend the commit message with $FAKE_COMMIT_AMEND +# - copy the original commit message to a file with $FAKE_MESSAGE_COPY # - check that non-commit messages have a certain line count with $EXPECT_COUNT # - check the commit count in the commit message header with $EXPECT_HEADER_COUNT # - rewrite a rebase -i script as directed by $FAKE_LINES. @@ -14,10 +15,11 @@ # specified line. # # "<cmd> <lineno>" -- add a line with the specified command -# ("pick", "squash", "fixup", "edit", "reword" or "drop") and the -# SHA1 taken from the specified line. +# ("pick", "squash", "fixup"|"fixup_-C"|"fixup_-c", "edit", "reword" or "drop") +# and the SHA1 taken from the specified line. # -# "exec_cmd_with_args" -- add an "exec cmd with args" line. +# "_" -- add a space, like "fixup_-C" implies "fixup -C" and +# "exec_cmd_with_args" add an "exec cmd with args" line. # # "#" -- Add a comment line. # @@ -29,10 +31,10 @@ set_fake_editor () { */COMMIT_EDITMSG) test -z "$EXPECT_HEADER_COUNT" || test "$EXPECT_HEADER_COUNT" = "$(sed -n '1s/^# This is a combination of \(.*\) commits\./\1/p' < "$1")" || - test "# # GETTEXT POISON #" = "$(sed -n '1p' < "$1")" || exit test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1" test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1" + test -z "$FAKE_MESSAGE_COPY" || cat "$1" >"$FAKE_MESSAGE_COPY" exit ;; esac @@ -51,6 +53,8 @@ set_fake_editor () { action="$line";; exec_*|x_*|break|b) echo "$line" | sed 's/_/ /g' >> "$1";; + merge_*|fixup_*) + action=$(echo "$line" | sed 's/_/ /g');; "#") echo '# comment' >> "$1";; ">") diff --git a/t/oid-info/README b/t/oid-info/README index 27f843fc00..ca56a74b1e 100644 --- a/t/oid-info/README +++ b/t/oid-info/README @@ -5,7 +5,7 @@ starting with `#` are ignored. The key and value are separated by whitespace (specifically, those whitespace in the default `$IFS`). The key consists only of shell identifier characters, and the value consists of a hash algorithm, colon, and value. The hash algorithm also consists only of shell identifier -characters; it should match the value in sha1-file.c. +characters; it should match the value in object-file.c. For example, the following lines map the key "rawsz" to "20" if SHA-1 is in use and to "32" if SHA-256 is in use: diff --git a/t/perf/.gitignore b/t/perf/.gitignore index 982eb8e3a9..72f5d0d314 100644 --- a/t/perf/.gitignore +++ b/t/perf/.gitignore @@ -1,3 +1,4 @@ /build/ /test-results/ +/test-trace/ /trash directory*/ diff --git a/t/perf/Makefile b/t/perf/Makefile index fcb0e8865e..2465770a78 100644 --- a/t/perf/Makefile +++ b/t/perf/Makefile @@ -7,10 +7,10 @@ perf: pre-clean ./run pre-clean: - rm -rf test-results + rm -rf test-results test-trace clean: - rm -rf build "trash directory".* test-results + rm -rf build "trash directory".* test-results test-trace test-lint: $(MAKE) -C .. test-lint diff --git a/t/perf/p2000-sparse-operations.sh b/t/perf/p2000-sparse-operations.sh new file mode 100755 index 0000000000..94513c9774 --- /dev/null +++ b/t/perf/p2000-sparse-operations.sh @@ -0,0 +1,101 @@ +#!/bin/sh + +test_description="test performance of Git operations using the index" + +. ./perf-lib.sh + +test_perf_default_repo + +SPARSE_CONE=f2/f4/f1 + +test_expect_success 'setup repo and indexes' ' + git reset --hard HEAD && + + # Remove submodules from the example repo, because our + # duplication of the entire repo creates an unlikely data shape. + if git config --file .gitmodules --get-regexp "submodule.*.path" >modules + then + git rm $(awk "{print \$2}" modules) && + git commit -m "remove submodules" || return 1 + fi && + + echo bogus >a && + cp a b && + git add a b && + git commit -m "level 0" && + BLOB=$(git rev-parse HEAD:a) && + OLD_COMMIT=$(git rev-parse HEAD) && + OLD_TREE=$(git rev-parse HEAD^{tree}) && + + for i in $(test_seq 1 4) + do + cat >in <<-EOF && + 100755 blob $BLOB a + 040000 tree $OLD_TREE f1 + 040000 tree $OLD_TREE f2 + 040000 tree $OLD_TREE f3 + 040000 tree $OLD_TREE f4 + EOF + NEW_TREE=$(git mktree <in) && + NEW_COMMIT=$(git commit-tree $NEW_TREE -p $OLD_COMMIT -m "level $i") && + OLD_TREE=$NEW_TREE && + OLD_COMMIT=$NEW_COMMIT || return 1 + done && + + git sparse-checkout init --cone && + git branch -f wide $OLD_COMMIT && + git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . full-index-v3 && + ( + cd full-index-v3 && + git sparse-checkout init --cone && + git sparse-checkout set $SPARSE_CONE && + git config index.version 3 && + git update-index --index-version=3 + ) && + git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . full-index-v4 && + ( + cd full-index-v4 && + git sparse-checkout init --cone && + git sparse-checkout set $SPARSE_CONE && + git config index.version 4 && + git update-index --index-version=4 + ) && + git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . sparse-index-v3 && + ( + cd sparse-index-v3 && + git sparse-checkout init --cone --sparse-index && + git sparse-checkout set $SPARSE_CONE && + git config index.version 3 && + git update-index --index-version=3 + ) && + git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . sparse-index-v4 && + ( + cd sparse-index-v4 && + git sparse-checkout init --cone --sparse-index && + git sparse-checkout set $SPARSE_CONE && + git config index.version 4 && + git update-index --index-version=4 + ) +' + +test_perf_on_all () { + command="$@" + for repo in full-index-v3 full-index-v4 \ + sparse-index-v3 sparse-index-v4 + do + test_perf "$command ($repo)" " + ( + cd $repo && + echo >>$SPARSE_CONE/a && + $command + ) + " + done +} + +test_perf_on_all git status +test_perf_on_all git add -A +test_perf_on_all git add . +test_perf_on_all git commit -a -m A + +test_done diff --git a/t/perf/p4205-log-pretty-formats.sh b/t/perf/p4205-log-pretty-formats.sh index 7c26f4f337..609fecd65d 100755 --- a/t/perf/p4205-log-pretty-formats.sh +++ b/t/perf/p4205-log-pretty-formats.sh @@ -6,7 +6,7 @@ test_description='Tests the performance of various pretty format placeholders' test_perf_default_repo -for format in %H %h %T %t %P %p %h-%h-%h +for format in %H %h %T %t %P %p %h-%h-%h %an-%ae-%s do test_perf "log with $format" " git log --format=\"$format\" >/dev/null diff --git a/t/perf/p5303-many-packs.sh b/t/perf/p5303-many-packs.sh index ce0c42cc9f..35c0cbdf49 100755 --- a/t/perf/p5303-many-packs.sh +++ b/t/perf/p5303-many-packs.sh @@ -28,11 +28,18 @@ repack_into_n () { push @commits, $_ if $. % 5 == 1; } print reverse @commits; - ' "$1" >pushes + ' "$1" >pushes && # create base packfile - head -n 1 pushes | - git pack-objects --delta-base-offset --revs staging/pack + base_pack=$( + head -n 1 pushes | + git pack-objects --delta-base-offset --revs staging/pack + ) && + test_export base_pack && + + # create an empty packfile + empty_pack=$(git pack-objects staging/pack </dev/null) && + test_export empty_pack && # and then incrementals between each pair of commits last= && @@ -49,6 +56,12 @@ repack_into_n () { last=$rev done <pushes && + ( + find staging -type f -name 'pack-*.pack' | + xargs -n 1 basename | grep -v "$base_pack" && + printf "^pack-%s.pack\n" $base_pack + ) >stdin.packs + # and install the whole thing rm -f .git/objects/pack/* && mv staging/* .git/objects/pack/ @@ -91,6 +104,23 @@ do --reflog --indexed-objects --delta-base-offset \ --stdout </dev/null >/dev/null ' + + test_perf "repack with kept ($nr_packs)" ' + git pack-objects --keep-true-parents \ + --keep-pack=pack-$empty_pack.pack \ + --honor-pack-keep --non-empty --all \ + --reflog --indexed-objects --delta-base-offset \ + --stdout </dev/null >/dev/null + ' + + test_perf "repack with --stdin-packs ($nr_packs)" ' + git pack-objects \ + --keep-true-parents \ + --stdin-packs \ + --non-empty \ + --delta-base-offset \ + --stdout <stdin.packs >/dev/null + ' done # Measure pack loading with 10,000 packs. diff --git a/t/perf/p5310-pack-bitmaps.sh b/t/perf/p5310-pack-bitmaps.sh index b3e725f031..452be01056 100755 --- a/t/perf/p5310-pack-bitmaps.sh +++ b/t/perf/p5310-pack-bitmaps.sh @@ -15,6 +15,12 @@ test_expect_success 'setup bitmap config' ' git config pack.writebitmaps true ' +# we need to create the tag up front such that it is covered by the repack and +# thus by generated bitmaps. +test_expect_success 'create tags' ' + git tag --message="tag pointing to HEAD" perf-tag HEAD +' + test_perf 'repack to disk' ' git repack -ad ' @@ -43,6 +49,14 @@ test_perf 'rev-list (objects)' ' git rev-list --all --use-bitmap-index --objects >/dev/null ' +test_perf 'rev-list with tag negated via --not --all (objects)' ' + git rev-list perf-tag --not --all --use-bitmap-index --objects >/dev/null +' + +test_perf 'rev-list with negative tag (objects)' ' + git rev-list HEAD --not perf-tag --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 diff --git a/t/perf/p5600-partial-clone.sh b/t/perf/p5600-partial-clone.sh index 3e04bd2ae1..a965f2c4d6 100755 --- a/t/perf/p5600-partial-clone.sh +++ b/t/perf/p5600-partial-clone.sh @@ -23,4 +23,20 @@ test_perf 'checkout of result' ' git -C worktree checkout -f ' +test_perf 'fsck' ' + git -C bare.git fsck +' + +test_perf 'count commits' ' + git -C bare.git rev-list --all --count +' + +test_perf 'count non-promisor commits' ' + git -C bare.git rev-list --all --count --exclude-promisor-objects +' + +test_perf 'gc' ' + git -C bare.git gc +' + test_done diff --git a/t/perf/p7519-fsmonitor.sh b/t/perf/p7519-fsmonitor.sh index 1e20a184c7..5eb5044a10 100755 --- a/t/perf/p7519-fsmonitor.sh +++ b/t/perf/p7519-fsmonitor.sh @@ -32,6 +32,8 @@ test_description="Test core.fsmonitor" # # GIT_PERF_7519_DROP_CACHE: if set, the OS caches are dropped between tests # +# GIT_PERF_7519_TRACE: if set, enable trace logging during the test. +# Trace logs will be grouped by fsmonitor provider. test_perf_large_repo test_checkout_worktree @@ -70,6 +72,32 @@ then fi fi +trace_start() { + if test -n "$GIT_PERF_7519_TRACE" + then + name="$1" + TEST_TRACE_DIR="$TEST_OUTPUT_DIRECTORY/test-trace/p7519/" + echo "Writing trace logging to $TEST_TRACE_DIR" + + mkdir -p "$TEST_TRACE_DIR" + + # Start Trace2 logging and any other GIT_TRACE_* logs that you + # want for this named test case. + + GIT_TRACE2_PERF="$TEST_TRACE_DIR/$name.trace2perf" + export GIT_TRACE2_PERF + + >"$GIT_TRACE2_PERF" + fi +} + +trace_stop() { + if test -n "$GIT_PERF_7519_TRACE" + then + unset GIT_TRACE2_PERF + fi +} + test_expect_success "one time repo setup" ' # set untrackedCache depending on the environment if test -n "$GIT_PERF_7519_UNTRACKED_CACHE" @@ -101,7 +129,7 @@ test_expect_success "one time repo setup" ' # If Watchman exists, watch the work tree and attempt a query. if test_have_prereq WATCHMAN; then watchman watch "$GIT_WORK_TREE" && - watchman watch-list | grep -q -F "$GIT_WORK_TREE" + watchman watch-list | grep -q -F "p7519-fsmonitor" fi ' @@ -169,8 +197,18 @@ test_fsmonitor_suite() { git status -uall ' + # Update the mtimes on upto 100k files to make status think + # that they are dirty. For simplicity, omit any files with + # LFs (i.e. anything that ls-files thinks it needs to dquote). + # Then fully backslash-quote the paths to capture any + # whitespace so that they pass thru xargs properly. + # test_perf_w_drop_caches "status (dirty) ($DESC)" ' - git ls-files | head -100000 | xargs -d "\n" touch -h && + git ls-files | \ + head -100000 | \ + grep -v \" | \ + sed '\''s/\(.\)/\\\1/g'\'' | \ + xargs test-tool chmtime -300 && git status ' @@ -178,6 +216,10 @@ test_fsmonitor_suite() { git diff ' + test_perf_w_drop_caches "diff HEAD ($DESC)" ' + git diff HEAD + ' + test_perf_w_drop_caches "diff -- 0_files ($DESC)" ' git diff -- 1_file ' @@ -203,6 +245,12 @@ test_fsmonitor_suite() { ' } +# +# Run a full set of perf tests using each Hook-based fsmonitor provider, +# such as Watchman. +# + +trace_start fsmonitor-watchman if test -n "$GIT_PERF_7519_FSMONITOR"; then for INTEGRATION_PATH in $GIT_PERF_7519_FSMONITOR; do test_expect_success "setup for fsmonitor $INTEGRATION_PATH" 'setup_for_fsmonitor' @@ -213,14 +261,6 @@ else test_fsmonitor_suite fi -test_expect_success "setup without fsmonitor" ' - unset INTEGRATION_SCRIPT && - git config --unset core.fsmonitor && - git update-index --no-fsmonitor -' - -test_fsmonitor_suite - if test_have_prereq WATCHMAN then watchman watch-del "$GIT_WORK_TREE" >/dev/null 2>&1 && @@ -229,5 +269,20 @@ then # preventing the removal of the trash directory watchman shutdown-server >/dev/null 2>&1 fi +trace_stop + +# +# Run a full set of perf tests with the fsmonitor feature disabled. +# + +trace_start fsmonitor-disabled +test_expect_success "setup without fsmonitor" ' + unset INTEGRATION_SCRIPT && + git config --unset core.fsmonitor && + git update-index --no-fsmonitor +' + +test_fsmonitor_suite +trace_stop test_done diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh index 22d727cef8..601d9f67dd 100644 --- a/t/perf/perf-lib.sh +++ b/t/perf/perf-lib.sh @@ -70,6 +70,19 @@ test_perf_do_repo_symlink_config_ () { test_have_prereq SYMLINKS || git config core.symlinks false } +test_perf_copy_repo_contents () { + for stuff in "$1"/* + do + case "$stuff" in + */objects|*/hooks|*/config|*/commondir|*/gitdir|*/worktrees) + ;; + *) + cp -R "$stuff" "$repo/.git/" || exit 1 + ;; + esac + done +} + test_perf_create_repo_from () { test "$#" = 2 || BUG "not 2 parameters to test-create-repo" @@ -77,20 +90,20 @@ test_perf_create_repo_from () { source="$2" source_git="$("$MODERN_GIT" -C "$source" rev-parse --git-dir)" objects_dir="$("$MODERN_GIT" -C "$source" rev-parse --git-path objects)" + common_dir="$("$MODERN_GIT" -C "$source" rev-parse --git-common-dir)" mkdir -p "$repo/.git" ( cd "$source" && { cp -Rl "$objects_dir" "$repo/.git/" 2>/dev/null || cp -R "$objects_dir" "$repo/.git/"; } && - for stuff in "$source_git"/*; do - case "$stuff" in - */objects|*/hooks|*/config|*/commondir) - ;; - *) - cp -R "$stuff" "$repo/.git/" || exit 1 - ;; - esac - done + + # common_dir must come first here, since we want source_git to + # take precedence and overwrite any overlapping files + test_perf_copy_repo_contents "$common_dir" + if test "$source_git" != "$common_dir" + then + test_perf_copy_repo_contents "$source_git" + fi ) && ( cd "$repo" && @@ -147,10 +160,7 @@ test_run_perf_ () { "$GTIME" -f "%E %U %S" -o test_time.$i "$SHELL" -c ' . '"$TEST_DIRECTORY"/test-lib-functions.sh' test_export () { - [ $# != 0 ] || return 0 - test_export_="$test_export_ $1" - shift - test_export "$@" + test_export_="$test_export_ $*" } '"$1"' ret=$? diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index f4ba2e8c85..705d62cc27 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -135,32 +135,32 @@ check_sub_test_lib_test_err () { ) } -test_expect_success 'pretend we have a fully passing test suite' " - run_sub_test_lib_test full-pass '3 passing tests' <<-\\EOF && +test_expect_success 'pretend we have a fully passing test suite' ' + run_sub_test_lib_test full-pass "3 passing tests" <<-\EOF && for i in 1 2 3 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test full-pass <<-\\EOF + check_sub_test_lib_test full-pass <<-\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 'pretend we have a partially passing test suite' " +test_expect_success 'pretend we have a partially passing test suite' ' run_sub_test_lib_test_err \ - partial-pass '2/3 tests passing' <<-\\EOF && - test_expect_success 'passing test #1' 'true' - test_expect_success 'failing test #2' 'false' - test_expect_success 'passing test #3' 'true' + partial-pass "2/3 tests passing" <<-\EOF && + test_expect_success "passing test #1" "true" + test_expect_success "failing test #2" "false" + test_expect_success "passing test #3" "true" test_done EOF - check_sub_test_lib_test partial-pass <<-\\EOF + check_sub_test_lib_test partial-pass <<-\EOF > ok 1 - passing test #1 > not ok 2 - failing test #2 # false @@ -168,44 +168,44 @@ test_expect_success 'pretend we have a partially passing test suite' " > # failed 1 among 3 test(s) > 1..3 EOF -" +' -test_expect_success 'pretend we have a known breakage' " - run_sub_test_lib_test failing-todo 'A failing TODO test' <<-\\EOF && - test_expect_success 'passing test' 'true' - test_expect_failure 'pretend we have a known breakage' 'false' +test_expect_success 'pretend we have a known breakage' ' + run_sub_test_lib_test failing-todo "A failing TODO test" <<-\EOF && + test_expect_success "passing test" "true" + test_expect_failure "pretend we have a known breakage" "false" test_done EOF - check_sub_test_lib_test failing-todo <<-\\EOF + check_sub_test_lib_test failing-todo <<-\EOF > ok 1 - passing test > not ok 2 - pretend we have a known breakage # TODO known breakage > # still have 1 known breakage(s) > # passed all remaining 1 test(s) > 1..2 EOF -" +' -test_expect_success 'pretend we have fixed a known breakage' " - run_sub_test_lib_test passing-todo 'A passing TODO test' <<-\\EOF && - test_expect_failure 'pretend we have fixed a known breakage' 'true' +test_expect_success 'pretend we have fixed a known breakage' ' + run_sub_test_lib_test passing-todo "A passing TODO test" <<-\EOF && + test_expect_failure "pretend we have fixed a known breakage" "true" test_done EOF - check_sub_test_lib_test passing-todo <<-\\EOF + check_sub_test_lib_test passing-todo <<-\EOF > ok 1 - pretend we have fixed a known breakage # TODO known breakage vanished > # 1 known breakage(s) vanished; please update test(s) > 1..1 EOF -" +' -test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' " +test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' ' run_sub_test_lib_test partially-passing-todos \ - '2 TODO tests, one passing' <<-\\EOF && - test_expect_failure 'pretend we have a known breakage' 'false' - test_expect_success 'pretend we have a passing test' 'true' - test_expect_failure 'pretend we have fixed another known breakage' 'true' + "2 TODO tests, one passing" <<-\EOF && + test_expect_failure "pretend we have a known breakage" "false" + test_expect_success "pretend we have a passing test" "true" + test_expect_failure "pretend we have fixed another known breakage" "true" test_done EOF - check_sub_test_lib_test partially-passing-todos <<-\\EOF + check_sub_test_lib_test partially-passing-todos <<-\EOF > not ok 1 - pretend we have a known breakage # TODO known breakage > ok 2 - pretend we have a passing test > ok 3 - pretend we have fixed another known breakage # TODO known breakage vanished @@ -214,17 +214,17 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su > # passed all remaining 1 test(s) > 1..3 EOF -" +' -test_expect_success 'pretend we have a pass, fail, and known breakage' " +test_expect_success 'pretend we have a pass, fail, and known breakage' ' run_sub_test_lib_test_err \ - mixed-results1 'mixed results #1' <<-\\EOF && - test_expect_success 'passing test' 'true' - test_expect_success 'failing test' 'false' - test_expect_failure 'pretend we have a known breakage' 'false' + mixed-results1 "mixed results #1" <<-\EOF && + test_expect_success "passing test" "true" + test_expect_success "failing test" "false" + test_expect_failure "pretend we have a known breakage" "false" test_done EOF - check_sub_test_lib_test mixed-results1 <<-\\EOF + check_sub_test_lib_test mixed-results1 <<-\EOF > ok 1 - passing test > not ok 2 - failing test > # false @@ -233,24 +233,24 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' " > # failed 1 among remaining 2 test(s) > 1..3 EOF -" +' -test_expect_success 'pretend we have a mix of all possible results' " +test_expect_success 'pretend we have a mix of all possible results' ' run_sub_test_lib_test_err \ - mixed-results2 'mixed results #2' <<-\\EOF && - test_expect_success 'passing test' 'true' - test_expect_success 'passing test' 'true' - test_expect_success 'passing test' 'true' - test_expect_success 'passing test' 'true' - test_expect_success 'failing test' 'false' - test_expect_success 'failing test' 'false' - test_expect_success 'failing test' 'false' - test_expect_failure 'pretend we have a known breakage' 'false' - test_expect_failure 'pretend we have a known breakage' 'false' - test_expect_failure 'pretend we have fixed a known breakage' 'true' + mixed-results2 "mixed results #2" <<-\EOF && + test_expect_success "passing test" "true" + test_expect_success "passing test" "true" + test_expect_success "passing test" "true" + test_expect_success "passing test" "true" + test_expect_success "failing test" "false" + test_expect_success "failing test" "false" + test_expect_success "failing test" "false" + test_expect_failure "pretend we have a known breakage" "false" + test_expect_failure "pretend we have a known breakage" "false" + test_expect_failure "pretend we have fixed a known breakage" "true" test_done EOF - check_sub_test_lib_test mixed-results2 <<-\\EOF + check_sub_test_lib_test mixed-results2 <<-\EOF > ok 1 - passing test > ok 2 - passing test > ok 3 - passing test @@ -269,9 +269,9 @@ test_expect_success 'pretend we have a mix of all possible results' " > # failed 3 among remaining 7 test(s) > 1..10 EOF -" +' -test_expect_success C_LOCALE_OUTPUT 'test --verbose' ' +test_expect_success 'test --verbose' ' run_sub_test_lib_test_err \ t1234-verbose "test verbose" --verbose <<-\EOF && test_expect_success "passing test" true @@ -321,18 +321,18 @@ test_expect_success 'test --verbose-only' ' EOF ' -test_expect_success 'GIT_SKIP_TESTS' " +test_expect_success 'GIT_SKIP_TESTS' ' ( - GIT_SKIP_TESTS='git.2' && export GIT_SKIP_TESTS && + GIT_SKIP_TESTS="git.2" && export GIT_SKIP_TESTS && run_sub_test_lib_test git-skip-tests-basic \ - 'GIT_SKIP_TESTS' <<-\\EOF && + "GIT_SKIP_TESTS" <<-\EOF && for i in 1 2 3 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test git-skip-tests-basic <<-\\EOF + check_sub_test_lib_test git-skip-tests-basic <<-\EOF > ok 1 - passing test #1 > ok 2 # skip passing test #2 (GIT_SKIP_TESTS) > ok 3 - passing test #3 @@ -340,20 +340,20 @@ test_expect_success 'GIT_SKIP_TESTS' " > 1..3 EOF ) -" +' -test_expect_success 'GIT_SKIP_TESTS several tests' " +test_expect_success 'GIT_SKIP_TESTS several tests' ' ( - GIT_SKIP_TESTS='git.2 git.5' && export GIT_SKIP_TESTS && + GIT_SKIP_TESTS="git.2 git.5" && export GIT_SKIP_TESTS && run_sub_test_lib_test git-skip-tests-several \ - 'GIT_SKIP_TESTS several tests' <<-\\EOF && + "GIT_SKIP_TESTS several tests" <<-\EOF && for i in 1 2 3 4 5 6 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test git-skip-tests-several <<-\\EOF + check_sub_test_lib_test git-skip-tests-several <<-\EOF > ok 1 - passing test #1 > ok 2 # skip passing test #2 (GIT_SKIP_TESTS) > ok 3 - passing test #3 @@ -364,20 +364,20 @@ test_expect_success 'GIT_SKIP_TESTS several tests' " > 1..6 EOF ) -" +' -test_expect_success 'GIT_SKIP_TESTS sh pattern' " +test_expect_success 'GIT_SKIP_TESTS sh pattern' ' ( - GIT_SKIP_TESTS='git.[2-5]' && export GIT_SKIP_TESTS && + GIT_SKIP_TESTS="git.[2-5]" && export GIT_SKIP_TESTS && run_sub_test_lib_test git-skip-tests-sh-pattern \ - 'GIT_SKIP_TESTS sh pattern' <<-\\EOF && + "GIT_SKIP_TESTS sh pattern" <<-\EOF && for i in 1 2 3 4 5 6 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test git-skip-tests-sh-pattern <<-\\EOF + check_sub_test_lib_test git-skip-tests-sh-pattern <<-\EOF > ok 1 - passing test #1 > ok 2 # skip passing test #2 (GIT_SKIP_TESTS) > ok 3 # skip passing test #3 (GIT_SKIP_TESTS) @@ -388,37 +388,37 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' " > 1..6 EOF ) -" +' -test_expect_success 'GIT_SKIP_TESTS entire suite' " +test_expect_success 'GIT_SKIP_TESTS entire suite' ' ( - GIT_SKIP_TESTS='git' && export GIT_SKIP_TESTS && + GIT_SKIP_TESTS="git" && export GIT_SKIP_TESTS && run_sub_test_lib_test git-skip-tests-entire-suite \ - 'GIT_SKIP_TESTS entire suite' <<-\\EOF && + "GIT_SKIP_TESTS entire suite" <<-\EOF && for i in 1 2 3 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test git-skip-tests-entire-suite <<-\\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' " +test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' ' ( - GIT_SKIP_TESTS='notgit' && export GIT_SKIP_TESTS && + 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 && + "GIT_SKIP_TESTS does not skip unmatched suite" <<-\EOF && for i in 1 2 3 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test git-skip-tests-unmatched-suite <<-\\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 @@ -426,18 +426,18 @@ test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' " > 1..3 EOF ) -" +' -test_expect_success '--run basic' " +test_expect_success '--run basic' ' run_sub_test_lib_test run-basic \ - '--run basic' --run='1,3,5' <<-\\EOF && + "--run basic" --run="1,3,5" <<-\EOF && for i in 1 2 3 4 5 6 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test run-basic <<-\\EOF + check_sub_test_lib_test run-basic <<-\EOF > ok 1 - passing test #1 > ok 2 # skip passing test #2 (--run) > ok 3 - passing test #3 @@ -447,18 +447,18 @@ test_expect_success '--run basic' " > # passed all 6 test(s) > 1..6 EOF -" +' -test_expect_success '--run with a range' " +test_expect_success '--run with a range' ' run_sub_test_lib_test run-range \ - '--run with a range' --run='1-3' <<-\\EOF && + "--run with a range" --run="1-3" <<-\EOF && for i in 1 2 3 4 5 6 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test run-range <<-\\EOF + check_sub_test_lib_test run-range <<-\EOF > ok 1 - passing test #1 > ok 2 - passing test #2 > ok 3 - passing test #3 @@ -468,18 +468,18 @@ test_expect_success '--run with a range' " > # passed all 6 test(s) > 1..6 EOF -" +' -test_expect_success '--run with two ranges' " +test_expect_success '--run with two ranges' ' run_sub_test_lib_test run-two-ranges \ - '--run with two ranges' --run='1-2,5-6' <<-\\EOF && + "--run with two ranges" --run="1-2,5-6" <<-\EOF && for i in 1 2 3 4 5 6 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test run-two-ranges <<-\\EOF + check_sub_test_lib_test run-two-ranges <<-\EOF > ok 1 - passing test #1 > ok 2 - passing test #2 > ok 3 # skip passing test #3 (--run) @@ -489,18 +489,18 @@ test_expect_success '--run with two ranges' " > # passed all 6 test(s) > 1..6 EOF -" +' -test_expect_success '--run with a left open range' " +test_expect_success '--run with a left open range' ' run_sub_test_lib_test run-left-open-range \ - '--run with a left open range' --run='-3' <<-\\EOF && + "--run with a left open range" --run="-3" <<-\EOF && for i in 1 2 3 4 5 6 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test run-left-open-range <<-\\EOF + check_sub_test_lib_test run-left-open-range <<-\EOF > ok 1 - passing test #1 > ok 2 - passing test #2 > ok 3 - passing test #3 @@ -510,18 +510,18 @@ test_expect_success '--run with a left open range' " > # passed all 6 test(s) > 1..6 EOF -" +' -test_expect_success '--run with a right open range' " +test_expect_success '--run with a right open range' ' run_sub_test_lib_test run-right-open-range \ - '--run with a right open range' --run='4-' <<-\\EOF && + "--run with a right open range" --run="4-" <<-\EOF && for i in 1 2 3 4 5 6 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test run-right-open-range <<-\\EOF + check_sub_test_lib_test run-right-open-range <<-\EOF > ok 1 # skip passing test #1 (--run) > ok 2 # skip passing test #2 (--run) > ok 3 # skip passing test #3 (--run) @@ -531,18 +531,18 @@ test_expect_success '--run with a right open range' " > # passed all 6 test(s) > 1..6 EOF -" +' -test_expect_success '--run with basic negation' " +test_expect_success '--run with basic negation' ' run_sub_test_lib_test run-basic-neg \ - '--run with basic negation' --run='"'!3'"' <<-\\EOF && + "--run with basic negation" --run="!3" <<-\EOF && for i in 1 2 3 4 5 6 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test run-basic-neg <<-\\EOF + check_sub_test_lib_test run-basic-neg <<-\EOF > ok 1 - passing test #1 > ok 2 - passing test #2 > ok 3 # skip passing test #3 (--run) @@ -552,18 +552,18 @@ test_expect_success '--run with basic negation' " > # passed all 6 test(s) > 1..6 EOF -" +' -test_expect_success '--run with two negations' " +test_expect_success '--run with two negations' ' run_sub_test_lib_test run-two-neg \ - '--run with two negations' --run='"'!3,!6'"' <<-\\EOF && + "--run with two negations" --run="!3,!6" <<-\EOF && for i in 1 2 3 4 5 6 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test run-two-neg <<-\\EOF + check_sub_test_lib_test run-two-neg <<-\EOF > ok 1 - passing test #1 > ok 2 - passing test #2 > ok 3 # skip passing test #3 (--run) @@ -573,18 +573,18 @@ test_expect_success '--run with two negations' " > # passed all 6 test(s) > 1..6 EOF -" +' -test_expect_success '--run a range and negation' " +test_expect_success '--run a range and negation' ' run_sub_test_lib_test run-range-and-neg \ - '--run a range and negation' --run='"'-4,!2'"' <<-\\EOF && + "--run a range and negation" --run="-4,!2" <<-\EOF && for i in 1 2 3 4 5 6 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test run-range-and-neg <<-\\EOF + check_sub_test_lib_test run-range-and-neg <<-\EOF > ok 1 - passing test #1 > ok 2 # skip passing test #2 (--run) > ok 3 - passing test #3 @@ -594,18 +594,18 @@ test_expect_success '--run a range and negation' " > # passed all 6 test(s) > 1..6 EOF -" +' -test_expect_success '--run range negation' " +test_expect_success '--run range negation' ' run_sub_test_lib_test run-range-neg \ - '--run range negation' --run='"'!1-3'"' <<-\\EOF && + "--run range negation" --run="!1-3" <<-\EOF && for i in 1 2 3 4 5 6 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test run-range-neg <<-\\EOF + check_sub_test_lib_test run-range-neg <<-\EOF > ok 1 # skip passing test #1 (--run) > ok 2 # skip passing test #2 (--run) > ok 3 # skip passing test #3 (--run) @@ -615,19 +615,19 @@ test_expect_success '--run range negation' " > # passed all 6 test(s) > 1..6 EOF -" +' -test_expect_success '--run include, exclude and include' " +test_expect_success '--run include, exclude and include' ' run_sub_test_lib_test run-inc-neg-inc \ - '--run include, exclude and include' \ - --run='"'1-5,!1-3,2'"' <<-\\EOF && + "--run include, exclude and include" \ + --run="1-5,!1-3,2" <<-\EOF && for i in 1 2 3 4 5 6 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test run-inc-neg-inc <<-\\EOF + check_sub_test_lib_test run-inc-neg-inc <<-\EOF > ok 1 # skip passing test #1 (--run) > ok 2 - passing test #2 > ok 3 # skip passing test #3 (--run) @@ -637,19 +637,19 @@ test_expect_success '--run include, exclude and include' " > # passed all 6 test(s) > 1..6 EOF -" +' -test_expect_success '--run include, exclude and include, comma separated' " +test_expect_success '--run include, exclude and include, comma separated' ' run_sub_test_lib_test run-inc-neg-inc-comma \ - '--run include, exclude and include, comma separated' \ - --run=1-5,\!1-3,2 <<-\\EOF && + "--run include, exclude and include, comma separated" \ + --run=1-5,!1-3,2 <<-\EOF && for i in 1 2 3 4 5 6 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test run-inc-neg-inc-comma <<-\\EOF + check_sub_test_lib_test run-inc-neg-inc-comma <<-\EOF > ok 1 # skip passing test #1 (--run) > ok 2 - passing test #2 > ok 3 # skip passing test #3 (--run) @@ -659,19 +659,19 @@ test_expect_success '--run include, exclude and include, comma separated' " > # passed all 6 test(s) > 1..6 EOF -" +' -test_expect_success '--run exclude and include' " +test_expect_success '--run exclude and include' ' run_sub_test_lib_test run-neg-inc \ - '--run exclude and include' \ - --run='"'!3-,5'"' <<-\\EOF && + "--run exclude and include" \ + --run="!3-,5" <<-\EOF && for i in 1 2 3 4 5 6 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test run-neg-inc <<-\\EOF + check_sub_test_lib_test run-neg-inc <<-\EOF > ok 1 - passing test #1 > ok 2 - passing test #2 > ok 3 # skip passing test #3 (--run) @@ -681,19 +681,19 @@ test_expect_success '--run exclude and include' " > # passed all 6 test(s) > 1..6 EOF -" +' -test_expect_success '--run empty selectors' " +test_expect_success '--run empty selectors' ' run_sub_test_lib_test run-empty-sel \ - '--run empty selectors' \ - --run='1,,3,,,5' <<-\\EOF && + "--run empty selectors" \ + --run="1,,3,,,5" <<-\EOF && for i in 1 2 3 4 5 6 do - test_expect_success \"passing test #\$i\" 'true' + test_expect_success "passing test #$i" "true" done test_done EOF - check_sub_test_lib_test run-empty-sel <<-\\EOF + check_sub_test_lib_test run-empty-sel <<-\EOF > ok 1 - passing test #1 > ok 2 # skip passing test #2 (--run) > ok 3 - passing test #3 @@ -703,20 +703,20 @@ test_expect_success '--run empty selectors' " > # passed all 6 test(s) > 1..6 EOF -" +' -test_expect_success '--run substring selector' " +test_expect_success '--run substring selector' ' run_sub_test_lib_test run-substring-selector \ - '--run empty selectors' \ - --run='relevant' <<-\\EOF && - test_expect_success \"relevant test\" 'true' + "--run empty selectors" \ + --run="relevant" <<-\EOF && + test_expect_success "relevant test" "true" for i in 1 2 3 4 5 6 do - test_expect_success \"other test #\$i\" 'true' + test_expect_success "other test #$i" "true" done test_done EOF - check_sub_test_lib_test run-substring-selector <<-\\EOF + check_sub_test_lib_test run-substring-selector <<-\EOF > ok 1 - relevant test > ok 2 # skip other test #1 (--run) > ok 3 # skip other test #2 (--run) @@ -727,167 +727,165 @@ test_expect_success '--run substring selector' " > # passed all 7 test(s) > 1..7 EOF -" +' -test_expect_success '--run keyword selection' " +test_expect_success '--run keyword selection' ' run_sub_test_lib_test_err run-inv-range-start \ - '--run invalid range start' \ - --run='a-5' <<-\\EOF && - test_expect_success \"passing test #1\" 'true' + "--run invalid range start" \ + --run="a-5" <<-\EOF && + test_expect_success "passing test #1" "true" test_done EOF check_sub_test_lib_test_err run-inv-range-start \ - <<-\\EOF_OUT 3<<-\\EOF_ERR + <<-\EOF_OUT 3<<-EOF_ERR > FATAL: Unexpected exit with code 1 EOF_OUT - > error: --run: invalid non-numeric in range start: 'a-5' + > error: --run: invalid non-numeric in range start: ${SQ}a-5${SQ} EOF_ERR -" +' -test_expect_success '--run invalid range end' " +test_expect_success '--run invalid range end' ' run_sub_test_lib_test_err run-inv-range-end \ - '--run invalid range end' \ - --run='1-z' <<-\\EOF && - test_expect_success \"passing test #1\" 'true' + "--run invalid range end" \ + --run="1-z" <<-\EOF && + test_expect_success "passing test #1" "true" test_done EOF check_sub_test_lib_test_err run-inv-range-end \ - <<-\\EOF_OUT 3<<-\\EOF_ERR + <<-\EOF_OUT 3<<-EOF_ERR > FATAL: Unexpected exit with code 1 EOF_OUT - > error: --run: invalid non-numeric in range end: '1-z' + > error: --run: invalid non-numeric in range end: ${SQ}1-z${SQ} EOF_ERR -" - - -test_set_prereq HAVEIT -haveit=no -test_expect_success HAVEIT 'test runs if prerequisite is satisfied' ' - test_have_prereq HAVEIT && - haveit=yes -' -donthaveit=yes -test_expect_success DONTHAVEIT 'unmet prerequisite causes test to be skipped' ' - donthaveit=no -' -if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" -a $haveit$donthaveit != yesyes -then - say "bug in test framework: prerequisite tags do not work reliably" - exit 1 -fi - -test_set_prereq HAVETHIS -haveit=no -test_expect_success HAVETHIS,HAVEIT 'test runs if prerequisites are satisfied' ' - test_have_prereq HAVEIT && - test_have_prereq HAVETHIS && - haveit=yes -' -donthaveit=yes -test_expect_success HAVEIT,DONTHAVEIT 'unmet prerequisites causes test to be skipped' ' - donthaveit=no -' -donthaveiteither=yes -test_expect_success DONTHAVEIT,HAVEIT 'unmet prerequisites causes test to be skipped' ' - donthaveiteither=no -' -if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" -a $haveit$donthaveit$donthaveiteither != yesyesyes -then - say "bug in test framework: multiple prerequisite tags do not work reliably" - exit 1 -fi - -test_lazy_prereq LAZY_TRUE true -havetrue=no -test_expect_success LAZY_TRUE 'test runs if lazy prereq is satisfied' ' - havetrue=yes -' -donthavetrue=yes -test_expect_success !LAZY_TRUE 'missing lazy prereqs skip tests' ' - donthavetrue=no -' - -if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" -a "$havetrue$donthavetrue" != yesyes -then - say 'bug in test framework: lazy prerequisites do not work' - exit 1 -fi - -test_lazy_prereq LAZY_FALSE false -nothavefalse=no -test_expect_success !LAZY_FALSE 'negative lazy prereqs checked' ' - nothavefalse=yes -' -havefalse=yes -test_expect_success LAZY_FALSE 'missing negative lazy prereqs will skip' ' - havefalse=no -' - -if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" -a "$nothavefalse$havefalse" != yesyes -then - say 'bug in test framework: negative lazy prerequisites do not work' - exit 1 -fi - -clean=no -test_expect_success 'tests clean up after themselves' ' - test_when_finished clean=yes ' -if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" -a $clean != yes -then - say "bug in test framework: basic cleanup command does not work reliably" - exit 1 -fi +test_expect_success 'tests respect prerequisites' ' + run_sub_test_lib_test prereqs "tests respect prereqs" <<-\EOF && -test_lazy_prereq NESTED_INNER ' - >inner && - rm -f outer -' -test_lazy_prereq NESTED_PREREQ ' - >outer && - test_have_prereq NESTED_INNER && - echo "can create new file in cwd" >file && - test -f outer && - test ! -f inner + test_set_prereq HAVEIT + test_expect_success HAVEIT "prereq is satisfied" "true" + test_expect_success "have_prereq works" " + test_have_prereq HAVEIT + " + test_expect_success DONTHAVEIT "prereq not satisfied" "false" + + test_set_prereq HAVETHIS + test_expect_success HAVETHIS,HAVEIT "multiple prereqs" "true" + test_expect_success HAVEIT,DONTHAVEIT "mixed prereqs (yes,no)" "false" + test_expect_success DONTHAVEIT,HAVEIT "mixed prereqs (no,yes)" "false" + + test_done + EOF + + check_sub_test_lib_test prereqs <<-\EOF + ok 1 - prereq is satisfied + ok 2 - have_prereq works + ok 3 # skip prereq not satisfied (missing DONTHAVEIT) + ok 4 - multiple prereqs + ok 5 # skip mixed prereqs (yes,no) (missing DONTHAVEIT of HAVEIT,DONTHAVEIT) + ok 6 # skip mixed prereqs (no,yes) (missing DONTHAVEIT of DONTHAVEIT,HAVEIT) + # passed all 6 test(s) + 1..6 + EOF ' -test_expect_success NESTED_PREREQ 'evaluating nested lazy prereqs dont interfere with each other' ' - nestedworks=yes + +test_expect_success 'tests respect lazy prerequisites' ' + run_sub_test_lib_test lazy-prereqs "respect lazy prereqs" <<-\EOF && + + test_lazy_prereq LAZY_TRUE true + test_expect_success LAZY_TRUE "lazy prereq is satisifed" "true" + test_expect_success !LAZY_TRUE "negative lazy prereq" "false" + + test_lazy_prereq LAZY_FALSE false + test_expect_success LAZY_FALSE "lazy prereq not satisfied" "false" + test_expect_success !LAZY_FALSE "negative false prereq" "true" + + test_done + EOF + + check_sub_test_lib_test lazy-prereqs <<-\EOF + ok 1 - lazy prereq is satisifed + ok 2 # skip negative lazy prereq (missing !LAZY_TRUE) + ok 3 # skip lazy prereq not satisfied (missing LAZY_FALSE) + ok 4 - negative false prereq + # passed all 4 test(s) + 1..4 + EOF ' -if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" && test "$nestedworks" != yes -then - say 'bug in test framework: nested lazy prerequisites do not work' - exit 1 -fi +test_expect_success 'nested lazy prerequisites' ' + run_sub_test_lib_test nested-lazy "nested lazy prereqs" <<-\EOF && + + test_lazy_prereq NESTED_INNER " + >inner && + rm -f outer + " + test_lazy_prereq NESTED_PREREQ " + >outer && + test_have_prereq NESTED_INNER && + echo can create new file in cwd >file && + test_path_is_file outer && + test_path_is_missing inner + " + test_expect_success NESTED_PREREQ "evaluate nested prereq" "true" -test_expect_success 'lazy prereqs do not turn off tracing' " + test_done + EOF + + check_sub_test_lib_test nested-lazy <<-\EOF + ok 1 - evaluate nested prereq + # passed all 1 test(s) + 1..1 + EOF +' + +test_expect_success 'lazy prereqs do not turn off tracing' ' run_sub_test_lib_test lazy-prereq-and-tracing \ - 'lazy prereqs and -x' -v -x <<-\\EOF && + "lazy prereqs and -x" -v -x <<-\EOF && test_lazy_prereq LAZY true - test_expect_success lazy 'test_have_prereq LAZY && echo trace' + test_expect_success lazy "test_have_prereq LAZY && echo trace" + + test_done + EOF + + grep "echo trace" lazy-prereq-and-tracing/err +' +test_expect_success 'tests clean up after themselves' ' + run_sub_test_lib_test cleanup "test with cleanup" <<-\EOF && + clean=no + test_expect_success "do cleanup" " + test_when_finished clean=yes + " + test_expect_success "cleanup happened" " + test $clean = yes + " test_done EOF - grep 'echo trace' lazy-prereq-and-tracing/err -" + check_sub_test_lib_test cleanup <<-\EOF + ok 1 - do cleanup + ok 2 - cleanup happened + # passed all 2 test(s) + 1..2 + EOF +' -test_expect_success 'tests clean up even on failures' " +test_expect_success 'tests clean up even on failures' ' run_sub_test_lib_test_err \ - failing-cleanup 'Failing tests with cleanup commands' <<-\\EOF && - test_expect_success 'tests clean up even after a failure' ' + failing-cleanup "Failing tests with cleanup commands" <<-\EOF && + test_expect_success "tests clean up even after a failure" " touch clean-after-failure && test_when_finished rm clean-after-failure && (exit 1) - ' - test_expect_success 'failure to clean up causes the test to fail' ' + " + test_expect_success "failure to clean up causes the test to fail" " test_when_finished \"(exit 2)\" - ' + " test_done EOF - check_sub_test_lib_test failing-cleanup <<-\\EOF + check_sub_test_lib_test failing-cleanup <<-\EOF > not ok 1 - tests clean up even after a failure > # Z > # touch clean-after-failure && @@ -896,30 +894,30 @@ test_expect_success 'tests clean up even on failures' " > # Z > not ok 2 - failure to clean up causes the test to fail > # Z - > # test_when_finished \"(exit 2)\" + > # test_when_finished "(exit 2)" > # Z > # failed 2 among 2 test(s) > 1..2 EOF -" +' -test_expect_success 'test_atexit is run' " +test_expect_success 'test_atexit is run' ' run_sub_test_lib_test_err \ - atexit-cleanup 'Run atexit commands' -i <<-\\EOF && - test_expect_success 'tests clean up even after a failure' ' + atexit-cleanup "Run atexit commands" -i <<-\EOF && + test_expect_success "tests clean up even after a failure" " > ../../clean-atexit && test_atexit rm ../../clean-atexit && > ../../also-clean-atexit && test_atexit rm ../../also-clean-atexit && > ../../dont-clean-atexit && (exit 1) - ' + " test_done EOF test_path_is_file dont-clean-atexit && test_path_is_missing clean-atexit && test_path_is_missing also-clean-atexit -" +' test_expect_success 'test_oid provides sane info by default' ' test_oid zero >actual && diff --git a/t/t0001-init.sh b/t/t0001-init.sh index 0803994874..acd662e403 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -186,21 +186,33 @@ test_expect_success 'init with --template (blank)' ' test_path_is_missing template-blank/.git/info/exclude ' -test_expect_success 'init with init.templatedir set' ' - mkdir templatedir-source && - echo Content >templatedir-source/file && - test_config_global init.templatedir "${HOME}/templatedir-source" && +init_no_templatedir_env () { ( - mkdir templatedir-set && - cd templatedir-set && sane_unset GIT_TEMPLATE_DIR && NO_SET_GIT_TEMPLATE_DIR=t && export NO_SET_GIT_TEMPLATE_DIR && - git init - ) && + git init "$1" + ) +} + +test_expect_success 'init with init.templatedir set' ' + mkdir templatedir-source && + echo Content >templatedir-source/file && + test_config_global init.templatedir "${HOME}/templatedir-source" && + + init_no_templatedir_env templatedir-set && test_cmp templatedir-source/file templatedir-set/.git/file ' +test_expect_success 'init with init.templatedir using ~ expansion' ' + mkdir -p templatedir-source && + echo Content >templatedir-source/file && + test_config_global init.templatedir "~/templatedir-source" && + + init_no_templatedir_env templatedir-expansion && + test_cmp templatedir-source/file templatedir-expansion/.git/file +' + test_expect_success 'init --bare/--shared overrides system/global config' ' test_config_global core.bare false && test_config_global core.sharedRepository 0640 && diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh index 960ed150cb..8440e6add1 100755 --- a/t/t0002-gitfile.sh +++ b/t/t0002-gitfile.sh @@ -4,6 +4,9 @@ test_description='.git file Verify that plumbing commands work when .git is a file ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh objpath() { @@ -96,7 +99,7 @@ test_expect_success 'enter_repo non-strict mode' ' git ls-remote enter_repo >actual && cat >expected <<-EOF && $head HEAD - $head refs/heads/master + $head refs/heads/main $head refs/tags/foo EOF test_cmp expected actual @@ -111,7 +114,7 @@ test_expect_success 'enter_repo linked checkout' ' git ls-remote foo >actual && cat >expected <<-EOF && $head HEAD - $head refs/heads/master + $head refs/heads/main $head refs/tags/foo EOF test_cmp expected actual @@ -122,7 +125,7 @@ test_expect_success 'enter_repo strict mode' ' git ls-remote --upload-pack="git upload-pack --strict" foo/.git >actual && cat >expected <<-EOF && $head HEAD - $head refs/heads/master + $head refs/heads/main $head refs/tags/foo EOF test_cmp expected actual diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh index b660593c20..1e4c672b84 100755 --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@ -4,12 +4,16 @@ test_description=gitattributes . ./test-lib.sh -attr_check () { +attr_check_basic () { path="$1" expect="$2" git_opts="$3" && git $git_opts check-attr test -- "$path" >actual 2>err && echo "$path: test: $expect" >expect && - test_cmp expect actual && + test_cmp expect actual +} + +attr_check () { + attr_check_basic "$@" && test_must_be_empty err } @@ -331,7 +335,6 @@ test_expect_success 'binary macro expanded by -a' ' test_cmp expect actual ' - test_expect_success 'query binary macro directly' ' echo "file binary" >.gitattributes && echo file: binary: set >expect && @@ -339,4 +342,31 @@ test_expect_success 'query binary macro directly' ' test_cmp expect actual ' +test_expect_success SYMLINKS 'set up symlink tests' ' + echo "* test" >attr && + rm -f .gitattributes +' + +test_expect_success SYMLINKS 'symlinks respected in core.attributesFile' ' + test_when_finished "rm symlink" && + ln -s attr symlink && + test_config core.attributesFile "$(pwd)/symlink" && + attr_check file set +' + +test_expect_success SYMLINKS 'symlinks respected in info/attributes' ' + test_when_finished "rm .git/info/attributes" && + ln -s ../../attr .git/info/attributes && + attr_check file set +' + +test_expect_success SYMLINKS 'symlinks not respected in-tree' ' + test_when_finished "rm -rf .gitattributes subdir" && + ln -s attr .gitattributes && + mkdir subdir && + ln -s ../attr subdir/.gitattributes && + attr_check_basic subdir/file unspecified && + test_i18ngrep "unable to access.*gitattributes" err +' + test_done diff --git a/t/t0006-date.sh b/t/t0006-date.sh index 75ee9a96b8..6b757d7169 100755 --- a/t/t0006-date.sh +++ b/t/t0006-date.sh @@ -11,7 +11,7 @@ check_relative() { echo "$t -> $2" >expect test_expect_${3:-success} "relative date ($2)" " test-tool date relative $t >actual && - test_i18ncmp expect actual + test_cmp expect actual " } @@ -139,7 +139,7 @@ check_date_format_human() { echo "$t -> $2" >expect test_expect_success "human date $t" ' test-tool date human $t >actual && - test_i18ncmp expect actual + test_cmp expect actual ' } diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh index 370a389e5c..a594b4aa7d 100755 --- a/t/t0008-ignores.sh +++ b/t/t0008-ignores.sh @@ -34,7 +34,7 @@ expect_from_stdin () { test_stderr () { expected="$1" expect_in stderr "$1" && - test_i18ncmp "$HOME/expected-stderr" "$HOME/stderr" + test_cmp "$HOME/expected-stderr" "$HOME/stderr" } broken_c_unquote () { @@ -865,4 +865,38 @@ test_expect_success 'info/exclude trumps core.excludesfile' ' test_cmp expect actual ' +test_expect_success SYMLINKS 'set up ignore file for symlink tests' ' + echo "*" >ignore && + rm -f .gitignore .git/info/exclude +' + +test_expect_success SYMLINKS 'symlinks respected in core.excludesFile' ' + test_when_finished "rm symlink" && + ln -s ignore symlink && + test_config core.excludesFile "$(pwd)/symlink" && + echo file >expect && + git check-ignore file >actual 2>err && + test_cmp expect actual && + test_must_be_empty err +' + +test_expect_success SYMLINKS 'symlinks respected in info/exclude' ' + test_when_finished "rm .git/info/exclude" && + ln -s ../../ignore .git/info/exclude && + echo file >expect && + git check-ignore file >actual 2>err && + test_cmp expect actual && + test_must_be_empty err +' + +test_expect_success SYMLINKS 'symlinks not respected in-tree' ' + test_when_finished "rm .gitignore" && + ln -s ignore .gitignore && + mkdir subdir && + ln -s ignore subdir/.gitignore && + test_must_fail git check-ignore subdir/file >actual 2>err && + test_must_be_empty actual && + test_i18ngrep "unable to access.*gitignore" err +' + test_done diff --git a/t/t0012-help.sh b/t/t0012-help.sh index e8ef7300ec..5679e29c62 100755 --- a/t/t0012-help.sh +++ b/t/t0012-help.sh @@ -55,7 +55,7 @@ test_expect_success "--help does not work for guides" " git: 'revisions' is not a git command. See 'git --help'. EOF test_must_fail git revisions --help 2>actual && - test_i18ncmp expect actual + test_cmp expect actual " test_expect_success 'git help' ' diff --git a/t/t0017-env-helper.sh b/t/t0017-env-helper.sh index c1ecf6aeac..4a159f99e4 100755 --- a/t/t0017-env-helper.sh +++ b/t/t0017-env-helper.sh @@ -86,14 +86,14 @@ test_expect_success 'env--helper reads config thanks to trace2' ' git config -f home/cycle include.path .gitconfig && test_must_fail \ - env HOME="$(pwd)/home" GIT_TEST_GETTEXT_POISON=false \ + env HOME="$(pwd)/home" \ git config -l 2>err && grep "exceeded maximum include depth" err && test_must_fail \ - env HOME="$(pwd)/home" GIT_TEST_GETTEXT_POISON=true \ - git -C cycle env--helper --type=bool --default=0 --exit-code GIT_TEST_GETTEXT_POISON 2>err && - grep "# GETTEXT POISON #" err + env HOME="$(pwd)/home" GIT_TEST_ENV_HELPER=true \ + git -C cycle env--helper --type=bool --default=0 --exit-code GIT_TEST_ENV_HELPER 2>err && + grep "exceeded maximum include depth" err ' test_done diff --git a/t/t0018-advice.sh b/t/t0018-advice.sh index e03554d2f3..39e5e4b34f 100755 --- a/t/t0018-advice.sh +++ b/t/t0018-advice.sh @@ -10,7 +10,7 @@ test_expect_success 'advice should be printed when config variable is unset' ' hint: Disable this message with "git config advice.nestedTag false" EOF test-tool advise "This is a piece of advice" 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'advice should be printed when config variable is set to true' ' @@ -20,7 +20,7 @@ test_expect_success 'advice should be printed when config variable is set to tru EOF test_config advice.nestedTag true && test-tool advise "This is a piece of advice" 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'advice should not be printed when config variable is set to false' ' diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh index b63ba62e5d..f25ae8b5e1 100755 --- a/t/t0020-crlf.sh +++ b/t/t0020-crlf.sh @@ -2,6 +2,9 @@ test_description='CRLF conversion' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh has_cr() { @@ -84,10 +87,8 @@ test_expect_success 'safecrlf: print warning only once' ' git commit -m "nowarn" && for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >doublewarn && git add doublewarn 2>err && - if test_have_prereq C_LOCALE_OUTPUT - then - test $(grep "CRLF will be replaced by LF" err | wc -l) = 1 - fi + grep "CRLF will be replaced by LF" err >err.warnings && + test_line_count = 1 err.warnings ' @@ -318,8 +319,8 @@ test_expect_success 'checkout with existing .gitattributes' ' git add .gitattributes .file && git commit -m second && - git checkout master~1 && - git checkout master && + git checkout main~1 && + git checkout main && test "$(git diff-files --raw)" = "" ' @@ -331,8 +332,8 @@ test_expect_success 'checkout when deleting .gitattributes' ' git add .file2 && git commit -m third && - git checkout master~1 && - git checkout master && + git checkout main~1 && + git checkout main && has_cr .file2 ' diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh index 630c3ee49e..b5749f327d 100755 --- a/t/t0021-conversion.sh +++ b/t/t0021-conversion.sh @@ -2,6 +2,9 @@ test_description='blob conversion via gitattributes' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh TEST_ROOT="$PWD" @@ -31,7 +34,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. https://lore.kernel.org/git/xmqqshv18i8i.fsf@gitster.mtv.corp.google.com/ test_cmp_count () { expect=$1 actual=$2 @@ -46,7 +49,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. https://lore.kernel.org/git/xmqqshv18i8i.fsf@gitster.mtv.corp.google.com/ test_cmp_exclude_clean () { expect=$1 actual=$2 @@ -254,6 +257,30 @@ test_expect_success 'required filter clean failure' ' test_must_fail git add test.fc ' +test_expect_success 'required filter with absent clean field' ' + test_config filter.absentclean.smudge cat && + test_config filter.absentclean.required true && + + echo "*.ac filter=absentclean" >.gitattributes && + + echo test >test.ac && + test_must_fail git add test.ac 2>stderr && + test_i18ngrep "fatal: test.ac: clean filter .absentclean. failed" stderr +' + +test_expect_success 'required filter with absent smudge field' ' + test_config filter.absentsmudge.clean cat && + test_config filter.absentsmudge.required true && + + echo "*.as filter=absentsmudge" >.gitattributes && + + echo test >test.as && + git add test.as && + rm -f test.as && + test_must_fail git checkout -- test.as 2>stderr && + test_i18ngrep "fatal: test.as: smudge filter absentsmudge failed" stderr +' + test_expect_success 'filtering large input to small output should use little memory' ' test_config filter.devnull.clean "cat >/dev/null" && test_config filter.devnull.required true && @@ -378,8 +405,8 @@ test_expect_success PERL 'required process filter should filter data' ' test_cmp_count expected.log debug.log && git commit -m "test commit 2" && - MASTER=$(git rev-parse --verify master) && - META="ref=refs/heads/master treeish=$MASTER" && + MAIN=$(git rev-parse --verify main) && + META="ref=refs/heads/main treeish=$MAIN" && rm -f test2.r "testsubdir/test3 '\''sq'\'',\$x=.r" && filter_git checkout --quiet --no-progress . && @@ -404,7 +431,7 @@ test_expect_success PERL 'required process filter should filter data' ' EOF test_cmp_exclude_clean expected.log debug.log && - filter_git checkout --quiet --no-progress master && + filter_git checkout --quiet --no-progress main && cat >expected.log <<-EOF && START init handshake complete @@ -436,15 +463,15 @@ test_expect_success PERL 'required process filter should filter data for various M3=$(git hash-object "testsubdir/test3 '\''sq'\'',\$x=.r") && EMPTY=$(git hash-object /dev/null) && - MASTER=$(git rev-parse --verify master) && + MAIN=$(git rev-parse --verify main) && cp "$TEST_ROOT/test.o" test5.r && git add test5.r && git commit -m "test commit 3" && git checkout empty-branch && - filter_git rebase --onto empty-branch master^^ master && - MASTER2=$(git rev-parse --verify master) && - META="ref=refs/heads/master treeish=$MASTER2" && + filter_git rebase --onto empty-branch main^^ main && + MAIN2=$(git rev-parse --verify main) && + META="ref=refs/heads/main treeish=$MAIN2" && cat >expected.log <<-EOF && START init handshake complete @@ -458,8 +485,8 @@ test_expect_success PERL 'required process filter should filter data for various test_cmp_exclude_clean expected.log debug.log && git reset --hard empty-branch && - filter_git reset --hard $MASTER && - META="treeish=$MASTER" && + filter_git reset --hard $MAIN && + META="treeish=$MAIN" && cat >expected.log <<-EOF && START init handshake complete @@ -471,10 +498,10 @@ test_expect_success PERL 'required process filter should filter data for various EOF test_cmp_exclude_clean expected.log debug.log && - git branch old-master $MASTER && + git branch old-main $MAIN && git reset --hard empty-branch && - filter_git reset --hard old-master && - META="ref=refs/heads/old-master treeish=$MASTER" && + filter_git reset --hard old-main && + META="ref=refs/heads/old-main treeish=$MAIN" && cat >expected.log <<-EOF && START init handshake complete @@ -487,9 +514,9 @@ test_expect_success PERL 'required process filter should filter data for various test_cmp_exclude_clean expected.log debug.log && git checkout -b merge empty-branch && - git branch -f master $MASTER2 && - filter_git merge master && - META="treeish=$MASTER2" && + git branch -f main $MAIN2 && + filter_git merge main && + META="treeish=$MAIN2" && cat >expected.log <<-EOF && START init handshake complete @@ -502,8 +529,8 @@ test_expect_success PERL 'required process filter should filter data for various EOF test_cmp_exclude_clean expected.log debug.log && - filter_git archive master >/dev/null && - META="ref=refs/heads/master treeish=$MASTER2" && + filter_git archive main >/dev/null && + META="ref=refs/heads/main treeish=$MAIN2" && cat >expected.log <<-EOF && START init handshake complete @@ -516,7 +543,7 @@ test_expect_success PERL 'required process filter should filter data for various EOF test_cmp_exclude_clean expected.log debug.log && - TREE="$(git rev-parse $MASTER2^{tree})" && + TREE="$(git rev-parse $MAIN2^{tree})" && filter_git archive $TREE >/dev/null && META="treeish=$TREE" && cat >expected.log <<-EOF && @@ -856,8 +883,8 @@ test_expect_success PERL 'delayed checkout in process filter' ' ) && S=$(test_file_size "$TEST_ROOT/test.o") && - PM="ref=refs/heads/master treeish=$(git -C repo rev-parse --verify master) " && - M="${PM}blob=$(git -C repo rev-parse --verify master:test.a)" && + PM="ref=refs/heads/main treeish=$(git -C repo rev-parse --verify main) " && + M="${PM}blob=$(git -C repo rev-parse --verify main:test.a)" && cat >a.exp <<-EOF && START init handshake complete diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh index 9fcd56fab3..4a5c5c602c 100755 --- a/t/t0027-auto-crlf.sh +++ b/t/t0027-auto-crlf.sh @@ -83,7 +83,7 @@ check_warning () { *) echo >&2 "Illegal 1": "$1" ; return false ;; esac grep "will be replaced by" "$2" | sed -e "s/\(.*\) in [^ ]*$/\1/" | uniq >"$2".actual - test_i18ncmp "$2".expect "$2".actual + test_cmp "$2".expect "$2".actual } commit_check_warn () { @@ -368,9 +368,9 @@ test_expect_success 'ls-files --eol -o Text/Binary' ' test_cmp expect actual ' -test_expect_success 'setup master' ' +test_expect_success 'setup main' ' echo >.gitattributes && - git checkout -b master && + git checkout -b main && git add .gitattributes && git commit -m "add .gitattributes" . && printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\nLINETWO\nLINETHREE" >LF && @@ -386,7 +386,9 @@ test_expect_success 'setup master' ' test_tick ' - +# Disable extra chain-linting for the next set of tests. There are many +# auto-generated ones that are not worth checking over and over. +GIT_TEST_CHAIN_LINT_HARDER_DEFAULT=0 warn_LF_CRLF="LF will be replaced by CRLF" warn_CRLF_LF="CRLF will be replaced by LF" @@ -597,6 +599,9 @@ do checkout_files auto "$id" "" false native $NL CRLF CRLF_mix_LF LF_mix_CR LF_nul done +# The rest of the tests are unique; do the usual linting. +unset GIT_TEST_CHAIN_LINT_HARDER_DEFAULT + # Should be the last test case: remove some files from the worktree test_expect_success 'ls-files --eol -d -z' ' rm crlf_false_attr__CRLF.txt crlf_false_attr__CRLF_mix_LF.txt crlf_false_attr__LF.txt .gitattributes && diff --git a/t/t0028-working-tree-encoding.sh b/t/t0028-working-tree-encoding.sh index bfc4fb9af5..82905a2156 100755 --- a/t/t0028-working-tree-encoding.sh +++ b/t/t0028-working-tree-encoding.sh @@ -2,34 +2,14 @@ test_description='working-tree-encoding conversion via gitattributes' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh +. "$TEST_DIRECTORY/lib-encoding.sh" GIT_TRACE_WORKING_TREE_ENCODING=1 && export GIT_TRACE_WORKING_TREE_ENCODING -test_lazy_prereq NO_UTF16_BOM ' - test $(printf abc | iconv -f UTF-8 -t UTF-16 | wc -c) = 6 -' - -test_lazy_prereq NO_UTF32_BOM ' - test $(printf abc | iconv -f UTF-8 -t UTF-32 | wc -c) = 12 -' - -write_utf16 () { - if test_have_prereq NO_UTF16_BOM - then - printf '\376\377' - fi && - iconv -f UTF-8 -t UTF-16 -} - -write_utf32 () { - if test_have_prereq NO_UTF32_BOM - then - printf '\0\0\376\377' - fi && - iconv -f UTF-8 -t UTF-32 -} - test_expect_success 'setup test files' ' git config core.eol lf && @@ -215,7 +195,7 @@ test_expect_success 'error if encoding round trip is not the same during refresh TEST_HASH=$(git hash-object --no-filters -w nonsense.utf16le) && git update-index --add --cacheinfo 100644 $TEST_HASH nonsense.utf16le && COMMIT=$(git commit-tree -p $(git rev-parse HEAD) -m "plain commit" $(git write-tree)) && - git update-ref refs/heads/master $COMMIT && + git update-ref refs/heads/main $COMMIT && test_must_fail git checkout HEAD^ 2>err.out && test_i18ngrep "error: .* overwritten by checkout:" err.out @@ -231,7 +211,7 @@ test_expect_success 'error if encoding garbage is already in Git' ' TEST_HASH=$(git hash-object --no-filters -w nonsense.utf16) && git update-index --add --cacheinfo 100644 $TEST_HASH nonsense.utf16 && COMMIT=$(git commit-tree -p $(git rev-parse HEAD) -m "plain commit" $(git write-tree)) && - git update-ref refs/heads/master $COMMIT && + git update-ref refs/heads/main $COMMIT && git diff 2>err.out && test_i18ngrep "error: BOM is required" err.out diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh index 14cafc138b..ad4746d899 100755 --- a/t/t0040-parse-options.sh +++ b/t/t0040-parse-options.sh @@ -61,7 +61,7 @@ EOF test_expect_success 'test help' ' test_must_fail test-tool parse-options -h >output 2>output.err && test_must_be_empty output.err && - test_i18ncmp expect output + test_cmp expect output ' mv expect expect.err @@ -84,7 +84,7 @@ check_unknown_i18n() { cat expect.err >>expect && test_must_fail test-tool parse-options $* >output 2>output.err && test_must_be_empty output && - test_i18ncmp expect output.err + test_cmp expect output.err } test_expect_success 'OPT_BOOL() #1' 'check boolean: 1 --yes' @@ -250,7 +250,7 @@ EOF test_expect_success 'detect possible typos' ' test_must_fail test-tool parse-options -boolean >output 2>output.err && test_must_be_empty output && - test_i18ncmp typo.err output.err + test_cmp typo.err output.err ' cat >typo.err <<\EOF @@ -260,7 +260,7 @@ EOF test_expect_success 'detect possible typos' ' test_must_fail test-tool parse-options -ambiguous >output 2>output.err && test_must_be_empty output && - test_i18ncmp typo.err output.err + test_cmp typo.err output.err ' test_expect_success 'keep some options as arguments' ' diff --git a/t/t0041-usage.sh b/t/t0041-usage.sh index 5b927b76fe..c4fc34eb18 100755 --- a/t/t0041-usage.sh +++ b/t/t0041-usage.sh @@ -2,6 +2,9 @@ test_description='Test commands behavior when given invalid argument value' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup ' ' @@ -41,8 +44,8 @@ test_expect_success 'tag usage error' ' ' test_expect_success 'branch --contains <existent_commit>' ' - git branch --contains "master" >actual 2>actual.err && - test_i18ngrep "master" actual && + git branch --contains "main" >actual 2>actual.err && + test_i18ngrep "main" actual && test_line_count = 0 actual.err ' @@ -54,7 +57,7 @@ test_expect_success 'branch --contains <inexistent_commit>' ' ' test_expect_success 'branch --no-contains <existent_commit>' ' - git branch --no-contains "master" >actual 2>actual.err && + git branch --no-contains "main" >actual 2>actual.err && test_line_count = 0 actual && test_line_count = 0 actual.err ' @@ -73,7 +76,7 @@ test_expect_success 'branch usage error' ' ' test_expect_success 'for-each-ref --contains <existent_object>' ' - git for-each-ref --contains "master" >actual 2>actual.err && + git for-each-ref --contains "main" >actual 2>actual.err && test_line_count = 2 actual && test_line_count = 0 actual.err ' @@ -86,7 +89,7 @@ test_expect_success 'for-each-ref --contains <inexistent_object>' ' ' test_expect_success 'for-each-ref --no-contains <existent_object>' ' - git for-each-ref --no-contains "master" >actual 2>actual.err && + git for-each-ref --no-contains "main" >actual 2>actual.err && test_line_count = 0 actual && test_line_count = 0 actual.err ' diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index 608673fb77..afc343cf9b 100755 --- a/t/t0050-filesystem.sh +++ b/t/t0050-filesystem.sh @@ -2,6 +2,9 @@ test_description='Various filesystem issues' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh auml=$(printf '\303\244') @@ -65,7 +68,7 @@ test_expect_success "setup case tests" ' git mv camelcase tmp && git mv tmp CamelCase && git commit -m "rename" && - git checkout -f master + git checkout -f main ' test_expect_success 'rename (case change)' ' @@ -118,7 +121,7 @@ test_expect_success "setup unicode normalization tests" ' git mv $aumlcdiar tmp && git mv tmp "$auml" && git commit -m rename && - git checkout -f master + git checkout -f main ' $test_unicode 'rename (silent unicode normalization)' ' @@ -147,7 +150,7 @@ test_expect_success CASE_INSENSITIVE_FS 'checkout with no pathspec and a case in git add gitweb && git commit -m "add gitweb/subdir/file" && - git checkout master + git checkout main ) ' diff --git a/t/t0052-simple-ipc.sh b/t/t0052-simple-ipc.sh new file mode 100755 index 0000000000..ff98be31a5 --- /dev/null +++ b/t/t0052-simple-ipc.sh @@ -0,0 +1,122 @@ +#!/bin/sh + +test_description='simple command server' + +. ./test-lib.sh + +test-tool simple-ipc SUPPORTS_SIMPLE_IPC || { + skip_all='simple IPC not supported on this platform' + test_done +} + +stop_simple_IPC_server () { + test-tool simple-ipc stop-daemon +} + +test_expect_success 'start simple command server' ' + test_atexit stop_simple_IPC_server && + test-tool simple-ipc start-daemon --threads=8 && + test-tool simple-ipc is-active +' + +test_expect_success 'simple command server' ' + test-tool simple-ipc send --token=ping >actual && + echo pong >expect && + test_cmp expect actual +' + +test_expect_success 'servers cannot share the same path' ' + test_must_fail test-tool simple-ipc run-daemon && + test-tool simple-ipc is-active +' + +test_expect_success 'big response' ' + test-tool simple-ipc send --token=big >actual && + test_line_count -ge 10000 actual && + grep -q "big: [0]*9999\$" actual +' + +test_expect_success 'chunk response' ' + test-tool simple-ipc send --token=chunk >actual && + test_line_count -ge 10000 actual && + grep -q "big: [0]*9999\$" actual +' + +test_expect_success 'slow response' ' + test-tool simple-ipc send --token=slow >actual && + test_line_count -ge 100 actual && + grep -q "big: [0]*99\$" actual +' + +# Send an IPC with n=100,000 bytes of ballast. This should be large enough +# to force both the kernel and the pkt-line layer to chunk the message to the +# daemon and for the daemon to receive it in chunks. +# +test_expect_success 'sendbytes' ' + test-tool simple-ipc sendbytes --bytecount=100000 --byte=A >actual && + grep "sent:A00100000 rcvd:A00100000" actual +' + +# Start a series of <threads> client threads that each make <batchsize> +# IPC requests to the server. Each (<threads> * <batchsize>) request +# will open a new connection to the server and randomly bind to a server +# thread. Each client thread exits after completing its batch. So the +# total number of live client threads will be smaller than the total. +# Each request will send a message containing at least <bytecount> bytes +# of ballast. (Responses are small.) +# +# The purpose here is to test threading in the server and responding to +# many concurrent client requests (regardless of whether they come from +# 1 client process or many). And to test that the server side of the +# named pipe/socket is stable. (On Windows this means that the server +# pipe is properly recycled.) +# +# On Windows it also lets us adjust the connection timeout in the +# `ipc_client_send_command()`. +# +# Note it is easy to drive the system into failure by requesting an +# insane number of threads on client or server and/or increasing the +# per-thread batchsize or the per-request bytecount (ballast). +# On Windows these failures look like "pipe is busy" errors. +# So I've chosen fairly conservative values for now. +# +# We expect output of the form "sent:<letter><length> ..." +# With terms (7, 19, 13) we expect: +# <letter> in [A-G] +# <length> in [19+0 .. 19+(13-1)] +# and (7 * 13) successful responses. +# +test_expect_success 'stress test threads' ' + test-tool simple-ipc multiple \ + --threads=7 \ + --bytecount=19 \ + --batchsize=13 \ + >actual && + test_line_count = 92 actual && + grep "good 91" actual && + grep "sent:A" <actual >actual_a && + cat >expect_a <<-EOF && + sent:A00000019 rcvd:A00000019 + sent:A00000020 rcvd:A00000020 + sent:A00000021 rcvd:A00000021 + sent:A00000022 rcvd:A00000022 + sent:A00000023 rcvd:A00000023 + sent:A00000024 rcvd:A00000024 + sent:A00000025 rcvd:A00000025 + sent:A00000026 rcvd:A00000026 + sent:A00000027 rcvd:A00000027 + sent:A00000028 rcvd:A00000028 + sent:A00000029 rcvd:A00000029 + sent:A00000030 rcvd:A00000030 + sent:A00000031 rcvd:A00000031 + EOF + test_cmp expect_a actual_a +' + +test_expect_success 'stop-daemon works' ' + test-tool simple-ipc stop-daemon && + test_must_fail test-tool simple-ipc is-active && + test_must_fail test-tool simple-ipc send --token=ping +' + +test_done diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index 56db5c8aba..de4960783f 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -312,8 +312,8 @@ test_git_path GIT_COMMON_DIR=bar info/sparse-checkout .git/info/sparse-check test_git_path GIT_COMMON_DIR=bar info//sparse-checkout .git/info//sparse-checkout test_git_path GIT_COMMON_DIR=bar remotes/bar bar/remotes/bar test_git_path GIT_COMMON_DIR=bar branches/bar bar/branches/bar -test_git_path GIT_COMMON_DIR=bar logs/refs/heads/master bar/logs/refs/heads/master -test_git_path GIT_COMMON_DIR=bar refs/heads/master bar/refs/heads/master +test_git_path GIT_COMMON_DIR=bar logs/refs/heads/main bar/logs/refs/heads/main +test_git_path GIT_COMMON_DIR=bar refs/heads/main bar/refs/heads/main test_git_path GIT_COMMON_DIR=bar refs/bisect/foo .git/refs/bisect/foo test_git_path GIT_COMMON_DIR=bar hooks/me bar/hooks/me test_git_path GIT_COMMON_DIR=bar config bar/config @@ -468,6 +468,36 @@ test_expect_success 'match .gitmodules' ' .gitmodules,:\$DATA ' +test_expect_success 'match .gitattributes' ' + test-tool path-utils is_dotgitattributes \ + .gitattributes \ + .git${u200c}attributes \ + .Gitattributes \ + .gitattributeS \ + GITATT~1 \ + GI7D29~1 +' + +test_expect_success 'match .gitignore' ' + test-tool path-utils is_dotgitignore \ + .gitignore \ + .git${u200c}ignore \ + .Gitignore \ + .gitignorE \ + GITIGN~1 \ + GI250A~1 +' + +test_expect_success 'match .mailmap' ' + test-tool path-utils is_dotmailmap \ + .mailmap \ + .mail${u200c}map \ + .Mailmap \ + .mailmaP \ + MAILMA~1 \ + MABA30~1 +' + test_expect_success MINGW 'is_valid_path() on Windows' ' test-tool path-utils is_valid_path \ win32 \ diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh index 5a633690bf..9bf66c9e68 100755 --- a/t/t0090-cache-tree.sh +++ b/t/t0090-cache-tree.sh @@ -10,40 +10,36 @@ cache-tree extension. cmp_cache_tree () { test-tool dump-cache-tree | sed -e '/#(ref)/d' >actual && sed "s/$OID_REGEX/SHA/" <actual >filtered && - test_cmp "$1" filtered + test_cmp "$1" filtered && + rm filtered } # We don't bother with actually checking the SHA1: # test-tool dump-cache-tree already verifies that all existing data is # correct. -generate_expected_cache_tree_rec () { - dir="$1${1:+/}" && - 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) && - subtree_count=$(echo "$subtrees"|awk -v c=0 '$1 != "" {++c} END {print c}') && - entries=$(wc -l <files) && - printf "SHA $dir (%d entries, %d subtrees)\n" "$entries" "$subtree_count" && - for subtree in $subtrees - do - cd "$subtree" - generate_expected_cache_tree_rec "$dir$subtree" "$dir" || return 1 - cd .. - done && - dir=$parent -} - generate_expected_cache_tree () { - ( - generate_expected_cache_tree_rec - ) + pathspec="$1" && + dir="$2${2:+/}" && + git ls-tree --name-only HEAD -- "$pathspec" >files && + git ls-tree --name-only -d HEAD -- "$pathspec" >subtrees && + printf "SHA %s (%d entries, %d subtrees)\n" "$dir" $(wc -l <files) $(wc -l <subtrees) && + while read subtree + do + generate_expected_cache_tree "$pathspec/$subtree/" "$subtree" || return 1 + done <subtrees } test_cache_tree () { - generate_expected_cache_tree >expect && - cmp_cache_tree expect + generate_expected_cache_tree "." >expect && + cmp_cache_tree expect && + rm expect actual files subtrees && + git status --porcelain -- ':!status' ':!expected.status' >status && + if test -n "$1" + then + test_cmp "$1" status + else + test_must_be_empty status + fi } test_invalid_cache_tree () { @@ -54,7 +50,7 @@ test_invalid_cache_tree () { } test_no_cache_tree () { - : >expect && + >expect && cmp_cache_tree expect } @@ -83,18 +79,6 @@ test_expect_success 'git-add in subdir invalidates cache-tree' ' test_invalid_cache_tree ' -cat >before <<\EOF -SHA (3 entries, 2 subtrees) -SHA dir1/ (1 entries, 0 subtrees) -SHA dir2/ (1 entries, 0 subtrees) -EOF - -cat >expect <<\EOF -invalid (2 subtrees) -invalid dir1/ (0 subtrees) -SHA dir2/ (1 entries, 0 subtrees) -EOF - test_expect_success 'git-add in subdir does not invalidate sibling cache-tree' ' git tag no-children && test_when_finished "git reset --hard no-children; git read-tree HEAD" && @@ -102,9 +86,20 @@ test_expect_success 'git-add in subdir does not invalidate sibling cache-tree' ' test_commit dir1/a && test_commit dir2/b && echo "I changed this file" >dir1/a && + test_when_finished "rm before" && + cat >before <<-\EOF && + SHA (3 entries, 2 subtrees) + SHA dir1/ (1 entries, 0 subtrees) + SHA dir2/ (1 entries, 0 subtrees) + EOF cmp_cache_tree before && echo "I changed this file" >dir1/a && git add dir1/a && + cat >expect <<-\EOF && + invalid (2 subtrees) + invalid dir1/ (0 subtrees) + SHA dir2/ (1 entries, 0 subtrees) + EOF cmp_cache_tree expect ' @@ -133,6 +128,7 @@ test_expect_success 'second commit has cache-tree' ' ' test_expect_success PERL 'commit --interactive gives cache-tree on partial commit' ' + test_when_finished "git reset --hard" && cat <<-\EOT >foo.c && int foo() { @@ -159,7 +155,10 @@ test_expect_success PERL 'commit --interactive gives cache-tree on partial commi EOT test_write_lines p 1 "" s n y q | git commit --interactive -m foo && - test_cache_tree + cat <<-\EOF >expected.status && + M foo.c + EOF + test_cache_tree expected.status ' test_expect_success PERL 'commit -p with shrinking cache-tree' ' @@ -250,7 +249,10 @@ test_expect_success 'partial commit gives cache-tree' ' git add one.t && echo "some other change" >two.t && git commit two.t -m partial && - test_cache_tree + cat <<-\EOF >expected.status && + M one.t + EOF + test_cache_tree expected.status ' test_expect_success 'no phantom error when switching trees' ' diff --git a/t/t0100-previous.sh b/t/t0100-previous.sh index 58c0b7e9b6..69beb59f62 100755 --- a/t/t0100-previous.sh +++ b/t/t0100-previous.sh @@ -2,13 +2,16 @@ test_description='previous branch syntax @{-n}' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'branch -d @{-1}' ' test_commit A && git checkout -b junk && git checkout - && - test "$(git symbolic-ref HEAD)" = refs/heads/master && + test "$(git symbolic-ref HEAD)" = refs/heads/main && git branch -d @{-1} && test_must_fail git rev-parse --verify refs/heads/junk ' @@ -17,9 +20,9 @@ test_expect_success 'branch -d @{-12} when there is not enough switches yet' ' git reflog expire --expire=now && git checkout -b junk2 && git checkout - && - test "$(git symbolic-ref HEAD)" = refs/heads/master && + test "$(git symbolic-ref HEAD)" = refs/heads/main && test_must_fail git branch -d @{-12} && - git rev-parse --verify refs/heads/master + git rev-parse --verify refs/heads/main ' test_expect_success 'merge @{-1}' ' @@ -28,19 +31,19 @@ test_expect_success 'merge @{-1}' ' git checkout A && test_commit C && test_commit D && - git branch -f master B && + git branch -f main B && git branch -f other && git checkout other && - git checkout master && + git checkout main && git merge @{-1} && git cat-file commit HEAD | grep "Merge branch '\''other'\''" ' test_expect_success 'merge @{-1}~1' ' - git checkout master && + git checkout main && git reset --hard B && git checkout other && - git checkout master && + git checkout main && git merge @{-1}~1 && git cat-file commit HEAD >actual && grep "Merge branch '\''other'\''" actual @@ -48,11 +51,11 @@ test_expect_success 'merge @{-1}~1' ' test_expect_success 'merge @{-100} before checking out that many branches yet' ' git reflog expire --expire=now && - git checkout -f master && + git checkout -f main && git reset --hard B && git branch -f other C && git checkout other && - git checkout master && + git checkout main && test_must_fail git merge @{-100} ' diff --git a/t/t0201-gettext-fallbacks.sh b/t/t0201-gettext-fallbacks.sh index 90da1c7ddc..6c74df0dc6 100755 --- a/t/t0201-gettext-fallbacks.sh +++ b/t/t0201-gettext-fallbacks.sh @@ -18,7 +18,7 @@ test_expect_success 'sanity: $GIT_INTERNAL_GETTEXT_TEST_FALLBACKS is set' ' test -n "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS" ' -test_expect_success C_LOCALE_OUTPUT 'sanity: $GIT_INTERNAL_GETTEXT_SH_SCHEME" is fallthrough' ' +test_expect_success 'sanity: $GIT_INTERNAL_GETTEXT_SH_SCHEME" is fallthrough' ' echo fallthrough >expect && echo $GIT_INTERNAL_GETTEXT_SH_SCHEME >actual && test_cmp expect actual @@ -27,25 +27,25 @@ test_expect_success C_LOCALE_OUTPUT 'sanity: $GIT_INTERNAL_GETTEXT_SH_SCHEME" is test_expect_success 'gettext: our gettext() fallback has pass-through semantics' ' printf "test" >expect && gettext "test" >actual && - test_i18ncmp expect actual && + test_cmp expect actual && printf "test more words" >expect && gettext "test more words" >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'eval_gettext: our eval_gettext() fallback has pass-through semantics' ' printf "test" >expect && eval_gettext "test" >actual && - test_i18ncmp expect actual && + test_cmp expect actual && printf "test more words" >expect && eval_gettext "test more words" >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate variables' ' printf "test YesPlease" >expect && GIT_INTERNAL_GETTEXT_TEST_FALLBACKS=YesPlease eval_gettext "test \$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS" >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate variables with spaces' ' @@ -53,7 +53,7 @@ test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate v export cmdline && printf "When you have resolved this problem, run git am --resolved." >expect && eval_gettext "When you have resolved this problem, run \$cmdline --resolved." >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate variables with spaces and quotes' ' @@ -61,7 +61,7 @@ test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate v export cmdline && printf "When you have resolved this problem, run \"git am --resolved\"." >expect && eval_gettext "When you have resolved this problem, run \"\$cmdline --resolved\"." >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_done diff --git a/t/t0205-gettext-poison.sh b/t/t0205-gettext-poison.sh deleted file mode 100755 index f9fa16ad83..0000000000 --- a/t/t0205-gettext-poison.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2010 Ævar Arnfjörð Bjarmason -# - -test_description='Gettext Shell poison' - -GIT_TEST_GETTEXT_POISON=true -export GIT_TEST_GETTEXT_POISON -. ./lib-gettext.sh - -test_expect_success 'sanity: $GIT_INTERNAL_GETTEXT_SH_SCHEME" is poison' ' - test "$GIT_INTERNAL_GETTEXT_SH_SCHEME" = "poison" -' - -test_expect_success 'gettext: our gettext() fallback has poison semantics' ' - printf "# GETTEXT POISON #" >expect && - gettext "test" >actual && - test_cmp expect actual && - printf "# GETTEXT POISON #" >expect && - gettext "test more words" >actual && - test_cmp expect actual -' - -test_expect_success 'eval_gettext: our eval_gettext() fallback has poison semantics' ' - printf "# GETTEXT POISON #" >expect && - eval_gettext "test" >actual && - test_cmp expect actual && - printf "# GETTEXT POISON #" >expect && - eval_gettext "test more words" >actual && - test_cmp expect actual -' - -test_expect_success "gettext: invalid GIT_TEST_GETTEXT_POISON value doesn't infinitely loop" " - test_must_fail env GIT_TEST_GETTEXT_POISON=xyz git version 2>error && - grep \"fatal: bad numeric config value 'xyz' for 'GIT_TEST_GETTEXT_POISON': invalid unit\" error -" - -test_done diff --git a/t/t0210-trace2-normal.sh b/t/t0210-trace2-normal.sh index ce7574edb1..0cf3a63b75 100755 --- a/t/t0210-trace2-normal.sh +++ b/t/t0210-trace2-normal.sh @@ -147,6 +147,25 @@ test_expect_success 'normal stream, error event' ' test_cmp expect actual ' +# Verb 007bug +# +# Check that BUG writes to trace2 + +test_expect_success 'BUG messages are written to trace2' ' + test_when_finished "rm trace.normal actual expect" && + test_must_fail env GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 007bug && + perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual && + cat >expect <<-EOF && + version $V + start _EXE_ trace2 007bug + cmd_name trace2 (trace2) + error the bug message + exit elapsed:_TIME_ code:99 + atexit elapsed:_TIME_ code:99 + EOF + test_cmp expect actual +' + sane_unset GIT_TRACE2_BRIEF # Now test without environment variables and get all Trace2 settings diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh index a18f8a473b..3485c0534e 100755 --- a/t/t0300-credentials.sh +++ b/t/t0300-credentials.sh @@ -578,7 +578,7 @@ test_expect_success 'helpers can abort the process' ' quit: host=example.com fatal: credential helper '\''quit'\'' told us to quit EOF - test_i18ncmp expect stderr + test_cmp expect stderr ' test_expect_success 'empty helper spec resets helper list' ' @@ -606,7 +606,7 @@ test_expect_success 'url parser rejects embedded newlines' ' warning: url contains a newline in its path 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_cmp expect stderr ' test_expect_success 'host-less URLs are parsed as empty host' ' @@ -633,7 +633,7 @@ test_expect_success 'credential system refuses to work with missing host' ' cat >expect <<-\EOF && fatal: refusing to work with credential missing host field EOF - test_i18ncmp expect stderr + test_cmp expect stderr ' test_expect_success 'credential system refuses to work with missing protocol' ' @@ -643,7 +643,7 @@ test_expect_success 'credential system refuses to work with missing protocol' ' cat >expect <<-\EOF && fatal: refusing to work with credential missing protocol field EOF - test_i18ncmp expect stderr + test_cmp expect stderr ' # usage: check_host_and_path <url> <expected-host> <expected-path> diff --git a/t/t0500-progress-display.sh b/t/t0500-progress-display.sh index 1ed1df351c..22058b503a 100755 --- a/t/t0500-progress-display.sh +++ b/t/t0500-progress-display.sh @@ -29,7 +29,7 @@ test_expect_success 'simple progress display' ' test-tool progress "Working hard" <in 2>stderr && show_cr <stderr >out && - test_i18ncmp expect out + test_cmp expect out ' test_expect_success 'progress display with total' ' @@ -48,7 +48,7 @@ test_expect_success 'progress display with total' ' test-tool progress --total=3 "Working hard" <in 2>stderr && show_cr <stderr >out && - test_i18ncmp expect out + test_cmp expect out ' test_expect_success 'progress display breaks long lines #1' ' @@ -72,7 +72,7 @@ EOF <in 2>stderr && show_cr <stderr >out && - test_i18ncmp expect out + test_cmp expect out ' test_expect_success 'progress display breaks long lines #2' ' @@ -100,7 +100,7 @@ EOF <in 2>stderr && show_cr <stderr >out && - test_i18ncmp expect out + test_cmp expect out ' test_expect_success 'progress display breaks long lines #3 - even the first is too long' ' @@ -126,7 +126,7 @@ EOF <in 2>stderr && show_cr <stderr >out && - test_i18ncmp expect out + test_cmp expect out ' test_expect_success 'progress display breaks long lines #4 - title line matches terminal width' ' @@ -150,7 +150,7 @@ EOF <in 2>stderr && show_cr <stderr >out && - test_i18ncmp expect out + test_cmp expect out ' # Progress counter goes backwards, this should not happen in practice. @@ -172,7 +172,7 @@ test_expect_success 'progress shortens - crazy caller' ' test-tool progress --total=1000 "Working hard" <in 2>stderr && show_cr <stderr >out && - test_i18ncmp expect out + test_cmp expect out ' test_expect_success 'progress display with throughput' ' @@ -201,7 +201,7 @@ test_expect_success 'progress display with throughput' ' test-tool progress "Working hard" <in 2>stderr && show_cr <stderr >out && - test_i18ncmp expect out + test_cmp expect out ' test_expect_success 'progress display with throughput and total' ' @@ -226,7 +226,7 @@ test_expect_success 'progress display with throughput and total' ' test-tool progress --total=40 "Working hard" <in 2>stderr && show_cr <stderr >out && - test_i18ncmp expect out + test_cmp expect out ' test_expect_success 'cover up after throughput shortens' ' @@ -255,7 +255,7 @@ test_expect_success 'cover up after throughput shortens' ' test-tool progress "Working hard" <in 2>stderr && show_cr <stderr >out && - test_i18ncmp expect out + test_cmp expect out ' test_expect_success 'cover up after throughput shortens a lot' ' @@ -280,7 +280,7 @@ test_expect_success 'cover up after throughput shortens a lot' ' test-tool progress "Working hard" <in 2>stderr && show_cr <stderr >out && - test_i18ncmp expect out + test_cmp expect out ' test_expect_success 'progress generates traces' ' @@ -303,8 +303,7 @@ test_expect_success 'progress generates traces' ' "Working hard" <in 2>stderr && # t0212/parse_events.perl intentionally omits regions and data. - grep -e "region_enter" -e "\"category\":\"progress\"" trace.event && - grep -e "region_leave" -e "\"category\":\"progress\"" trace.event && + test_region progress "Working hard" trace.event && grep "\"key\":\"total_objects\",\"value\":\"40\"" trace.event && grep "\"key\":\"total_bytes\",\"value\":\"409600\"" trace.event ' diff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh index 181956b241..11bf10424f 100755 --- a/t/t1004-read-tree-m-u-wf.sh +++ b/t/t1004-read-tree-m-u-wf.sh @@ -2,6 +2,9 @@ test_description='read-tree -m -u checks working tree files' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-read-tree.sh @@ -20,17 +23,17 @@ test_expect_success 'two-way setup' ' git branch side && git tag -f branch-point && - echo file2 is not tracked on the master branch anymore && + echo file2 is not tracked on the main branch anymore && rm -f file2 subdir/file2 && git update-index --remove file2 subdir/file2 && - git commit -a -m "master removes file2 and subdir/file2" + git commit -a -m "main removes file2 and subdir/file2" ' test_expect_success 'two-way not clobbering' ' - echo >file2 master creates untracked file2 && - echo >subdir/file2 master creates untracked subdir/file2 && - if err=$(read_tree_u_must_succeed -m -u master side 2>&1) + echo >file2 main creates untracked file2 && + echo >subdir/file2 main creates untracked subdir/file2 && + if err=$(read_tree_u_must_succeed -m -u main side 2>&1) then echo should have complained false @@ -43,7 +46,7 @@ echo file2 >.gitignore test_expect_success 'two-way with incorrect --exclude-per-directory (1)' ' - if err=$(read_tree_u_must_succeed -m --exclude-per-directory=.gitignore master side 2>&1) + if err=$(read_tree_u_must_succeed -m --exclude-per-directory=.gitignore main side 2>&1) then echo should have complained false @@ -54,7 +57,7 @@ test_expect_success 'two-way with incorrect --exclude-per-directory (1)' ' test_expect_success 'two-way with incorrect --exclude-per-directory (2)' ' - if err=$(read_tree_u_must_succeed -m -u --exclude-per-directory=foo --exclude-per-directory=.gitignore master side 2>&1) + if err=$(read_tree_u_must_succeed -m -u --exclude-per-directory=foo --exclude-per-directory=.gitignore main side 2>&1) then echo should have complained false @@ -65,7 +68,7 @@ test_expect_success 'two-way with incorrect --exclude-per-directory (2)' ' test_expect_success 'two-way clobbering a ignored file' ' - read_tree_u_must_succeed -m -u --exclude-per-directory=.gitignore master side + read_tree_u_must_succeed -m -u --exclude-per-directory=.gitignore main side ' rm -f .gitignore @@ -81,21 +84,21 @@ test_expect_success 'three-way not complaining on an untracked path in both' ' git update-index --add file3 subdir/file3 && git commit -a -m "side adds file3 and removes file2" && - git checkout master && - echo >file2 file two is untracked on the master side && - echo >subdir/file2 file two is untracked on the master side && + git checkout main && + echo >file2 file two is untracked on the main side && + echo >subdir/file2 file two is untracked on the main side && - read_tree_u_must_succeed -m -u branch-point master side + read_tree_u_must_succeed -m -u branch-point main side ' test_expect_success 'three-way not clobbering a working tree file' ' git reset --hard && rm -f file2 subdir/file2 file3 subdir/file3 && - git checkout master && - echo >file3 file three created in master, untracked && - echo >subdir/file3 file three created in master, untracked && - if err=$(read_tree_u_must_succeed -m -u branch-point master side 2>&1) + git checkout main && + echo >file3 file three created in main, untracked && + echo >subdir/file3 file three created in main, untracked && + if err=$(read_tree_u_must_succeed -m -u branch-point main side 2>&1) then echo should have complained false @@ -110,11 +113,11 @@ test_expect_success 'three-way not complaining on an untracked file' ' git reset --hard && rm -f file2 subdir/file2 file3 subdir/file3 && - git checkout master && - echo >file3 file three created in master, untracked && - echo >subdir/file3 file three created in master, untracked && + git checkout main && + echo >file3 file three created in main, untracked && + echo >subdir/file3 file three created in main, untracked && - read_tree_u_must_succeed -m -u --exclude-per-directory=.gitignore branch-point master side + read_tree_u_must_succeed -m -u --exclude-per-directory=.gitignore branch-point main side ' test_expect_success '3-way not overwriting local changes (setup)' ' diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index 2f501d2dc9..5d2dc99b74 100755 --- a/t/t1006-cat-file.sh +++ b/t/t1006-cat-file.sh @@ -166,7 +166,7 @@ tag_content="$tag_header_without_timestamp 0000000000 +0000 $tag_description" -tag_sha1=$(echo_without_newline "$tag_content" | git mktag) +tag_sha1=$(echo_without_newline "$tag_content" | git hash-object -t tag --stdin -w) tag_size=$(strlen "$tag_content") run_tests 'tag' $tag_sha1 $tag_size "$tag_content" "$tag_content" 1 diff --git a/t/t1008-read-tree-overlay.sh b/t/t1008-read-tree-overlay.sh index cf96016844..4512fb0b6e 100755 --- a/t/t1008-read-tree-overlay.sh +++ b/t/t1008-read-tree-overlay.sh @@ -2,6 +2,9 @@ test_description='test multi-tree read-tree without merging' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-read-tree.sh @@ -22,7 +25,7 @@ test_expect_success setup ' ' test_expect_success 'multi-read' ' - read_tree_must_succeed initial master side && + read_tree_must_succeed initial main side && test_write_lines a b/c >expect && git ls-files >actual && test_cmp expect actual diff --git a/t/t1009-read-tree-new-index.sh b/t/t1009-read-tree-new-index.sh index 59b3aa4bc4..2935f68f8d 100755 --- a/t/t1009-read-tree-new-index.sh +++ b/t/t1009-read-tree-new-index.sh @@ -2,6 +2,9 @@ test_description='test read-tree into a fresh index file' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -12,13 +15,13 @@ test_expect_success setup ' test_expect_success 'non-existent index file' ' rm -f new-index && - GIT_INDEX_FILE=new-index git read-tree master + GIT_INDEX_FILE=new-index git read-tree main ' test_expect_success 'empty index file' ' rm -f new-index && > new-index && - GIT_INDEX_FILE=new-index git read-tree master + GIT_INDEX_FILE=new-index git read-tree main ' test_done diff --git a/t/t1011-read-tree-sparse-checkout.sh b/t/t1011-read-tree-sparse-checkout.sh index 140f459977..24092c09a9 100755 --- a/t/t1011-read-tree-sparse-checkout.sh +++ b/t/t1011-read-tree-sparse-checkout.sh @@ -2,7 +2,7 @@ test_description='sparse checkout tests -* (tag: removed, master) removed +* (tag: removed, main) removed | D sub/added * (HEAD, tag: top) modified and added | M init.t @@ -253,7 +253,7 @@ warning: The following paths were already present and thus not updated despite s After fixing the above paths, you may want to run `git sparse-checkout reapply`. EOF - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'checkout without --ignore-skip-worktree-bits' ' diff --git a/t/t1021-rerere-in-workdir.sh b/t/t1021-rerere-in-workdir.sh index 301e071ff7..0b892894eb 100755 --- a/t/t1021-rerere-in-workdir.sh +++ b/t/t1021-rerere-in-workdir.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='rerere run in a workdir' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success SYMLINKS setup ' @@ -19,7 +22,7 @@ test_expect_success SYMLINKS setup ' test_tick && git commit -a -m goodbye && - git checkout master + git checkout main ' test_expect_success SYMLINKS 'rerere in workdir' ' diff --git a/t/t1090-sparse-checkout-scope.sh b/t/t1090-sparse-checkout-scope.sh index f35a73dd20..3deb490187 100755 --- a/t/t1090-sparse-checkout-scope.sh +++ b/t/t1090-sparse-checkout-scope.sh @@ -2,6 +2,9 @@ test_description='sparse checkout scope tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -20,18 +23,18 @@ test_expect_success 'create feature branch' ' git commit -m "modification" ' -test_expect_success 'perform sparse checkout of master' ' +test_expect_success 'perform sparse checkout of main' ' git config --local --bool core.sparsecheckout true && echo "!/*" >.git/info/sparse-checkout && echo "/a" >>.git/info/sparse-checkout && echo "/c" >>.git/info/sparse-checkout && - git checkout master && + git checkout main && test_path_is_file a && test_path_is_missing b && test_path_is_file c ' -test_expect_success 'merge feature branch into sparse checkout of master' ' +test_expect_success 'merge feature branch into sparse checkout of main' ' git merge feature && test_path_is_file a && test_path_is_missing b && @@ -39,10 +42,10 @@ test_expect_success 'merge feature branch into sparse checkout of master' ' test "$(cat c)" = "modified" ' -test_expect_success 'return to full checkout of master' ' +test_expect_success 'return to full checkout of main' ' git checkout feature && echo "/*" >.git/info/sparse-checkout && - git checkout master && + git checkout main && test_path_is_file a && test_path_is_file b && test_path_is_file c && diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh index 84acfc48b6..38fc8340f5 100755 --- a/t/t1091-sparse-checkout-builtin.sh +++ b/t/t1091-sparse-checkout-builtin.sh @@ -2,6 +2,9 @@ test_description='sparse checkout builtin tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh list_files() { @@ -117,7 +120,7 @@ test_expect_success 'interaction with clone --no-checkout (unborn index)' ' test_path_is_missing clone_no_checkout/.git/index && # No branch is checked out until we manually switch to one - git -C clone_no_checkout switch master && + git -C clone_no_checkout switch main && test_path_is_file clone_no_checkout/.git/index && check_files clone_no_checkout a folder1 ' @@ -202,6 +205,19 @@ test_expect_success 'sparse-checkout disable' ' check_files repo a deep folder1 folder2 ' +test_expect_success 'sparse-index enabled and disabled' ' + git -C repo sparse-checkout init --cone --sparse-index && + test_cmp_config -C repo true index.sparse && + test-tool -C repo read-cache --table >cache && + grep " tree " cache && + + git -C repo sparse-checkout disable && + test-tool -C repo read-cache --table >cache && + ! grep " tree " cache && + git -C repo config --list >config && + ! grep index.sparse config +' + test_expect_success 'cone mode: init and set' ' git -C repo sparse-checkout init --cone && git -C repo config --list >config && diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh new file mode 100755 index 0000000000..e9a815ca7a --- /dev/null +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -0,0 +1,416 @@ +#!/bin/sh + +test_description='compare full workdir to sparse workdir' + +GIT_TEST_SPLIT_INDEX=0 +GIT_TEST_SPARSE_INDEX= + +. ./test-lib.sh + +test_expect_success 'setup' ' + git init initial-repo && + ( + GIT_TEST_SPARSE_INDEX=0 && + cd initial-repo && + echo a >a && + echo "after deep" >e && + echo "after folder1" >g && + echo "after x" >z && + mkdir folder1 folder2 deep x && + mkdir deep/deeper1 deep/deeper2 && + mkdir deep/deeper1/deepest && + echo "after deeper1" >deep/e && + echo "after deepest" >deep/deeper1/e && + cp a folder1 && + cp a folder2 && + cp a x && + cp a deep && + cp a deep/deeper1 && + cp a deep/deeper2 && + cp a deep/deeper1/deepest && + cp -r deep/deeper1/deepest deep/deeper2 && + git add . && + git commit -m "initial commit" && + git checkout -b base && + for dir in folder1 folder2 deep + do + git checkout -b update-$dir && + echo "updated $dir" >$dir/a && + git commit -a -m "update $dir" || return 1 + done && + + git checkout -b rename-base base && + echo >folder1/larger-content <<-\EOF && + matching + lines + help + inexact + renames + EOF + cp folder1/larger-content folder2/ && + cp folder1/larger-content deep/deeper1/ && + git add . && + git commit -m "add interesting rename content" && + + git checkout -b rename-out-to-out rename-base && + mv folder1/a folder2/b && + mv folder1/larger-content folder2/edited-content && + echo >>folder2/edited-content && + git add . && + git commit -m "rename folder1/... to folder2/..." && + + git checkout -b rename-out-to-in rename-base && + mv folder1/a deep/deeper1/b && + mv folder1/larger-content deep/deeper1/edited-content && + echo >>deep/deeper1/edited-content && + git add . && + git commit -m "rename folder1/... to deep/deeper1/..." && + + git checkout -b rename-in-to-out rename-base && + mv deep/deeper1/a folder1/b && + mv deep/deeper1/larger-content folder1/edited-content && + echo >>folder1/edited-content && + git add . && + git commit -m "rename deep/deeper1/... to folder1/..." && + + git checkout -b deepest base && + echo "updated deepest" >deep/deeper1/deepest/a && + git commit -a -m "update deepest" && + + git checkout -f base && + git reset --hard + ) +' + +init_repos () { + rm -rf full-checkout sparse-checkout sparse-index && + + # create repos in initial state + cp -r initial-repo full-checkout && + git -C full-checkout reset --hard && + + cp -r initial-repo sparse-checkout && + git -C sparse-checkout reset --hard && + + cp -r initial-repo sparse-index && + git -C sparse-index reset --hard && + + # initialize sparse-checkout definitions + git -C sparse-checkout sparse-checkout init --cone && + git -C sparse-checkout sparse-checkout set deep && + git -C sparse-index sparse-checkout init --cone --sparse-index && + test_cmp_config -C sparse-index true index.sparse && + git -C sparse-index sparse-checkout set deep +} + +run_on_sparse () { + ( + cd sparse-checkout && + GIT_PROGRESS_DELAY=100000 "$@" >../sparse-checkout-out 2>../sparse-checkout-err + ) && + ( + cd sparse-index && + GIT_PROGRESS_DELAY=100000 "$@" >../sparse-index-out 2>../sparse-index-err + ) +} + +run_on_all () { + ( + cd full-checkout && + GIT_PROGRESS_DELAY=100000 "$@" >../full-checkout-out 2>../full-checkout-err + ) && + run_on_sparse "$@" +} + +test_all_match () { + run_on_all "$@" && + test_cmp full-checkout-out sparse-checkout-out && + test_cmp full-checkout-out sparse-index-out && + test_cmp full-checkout-err sparse-checkout-err && + test_cmp full-checkout-err sparse-index-err +} + +test_sparse_match () { + run_on_sparse "$@" && + test_cmp sparse-checkout-out sparse-index-out && + test_cmp sparse-checkout-err sparse-index-err +} + +test_expect_success 'sparse-index contents' ' + init_repos && + + test-tool -C sparse-index read-cache --table >cache && + for dir in folder1 folder2 x + do + TREE=$(git -C sparse-index rev-parse HEAD:$dir) && + grep "040000 tree $TREE $dir/" cache \ + || return 1 + done && + + git -C sparse-index sparse-checkout set folder1 && + + test-tool -C sparse-index read-cache --table >cache && + for dir in deep folder2 x + do + TREE=$(git -C sparse-index rev-parse HEAD:$dir) && + grep "040000 tree $TREE $dir/" cache \ + || return 1 + done && + + git -C sparse-index sparse-checkout set deep/deeper1 && + + test-tool -C sparse-index read-cache --table >cache && + for dir in deep/deeper2 folder1 folder2 x + do + TREE=$(git -C sparse-index rev-parse HEAD:$dir) && + grep "040000 tree $TREE $dir/" cache \ + || return 1 + done && + + # Disabling the sparse-index removes tree entries with full ones + git -C sparse-index sparse-checkout init --no-sparse-index && + + test-tool -C sparse-index read-cache --table >cache && + ! grep "040000 tree" cache && + test_sparse_match test-tool read-cache --table +' + +test_expect_success 'expanded in-memory index matches full index' ' + init_repos && + test_sparse_match test-tool read-cache --expand --table +' + +test_expect_success 'status with options' ' + init_repos && + test_sparse_match ls && + test_all_match git status --porcelain=v2 && + test_all_match git status --porcelain=v2 -z -u && + test_all_match git status --porcelain=v2 -uno && + run_on_all touch README.md && + test_all_match git status --porcelain=v2 && + test_all_match git status --porcelain=v2 -z -u && + test_all_match git status --porcelain=v2 -uno && + test_all_match git add README.md && + test_all_match git status --porcelain=v2 && + test_all_match git status --porcelain=v2 -z -u && + test_all_match git status --porcelain=v2 -uno +' + +test_expect_success 'add, commit, checkout' ' + init_repos && + + write_script edit-contents <<-\EOF && + echo text >>$1 + EOF + run_on_all ../edit-contents README.md && + + test_all_match git add README.md && + test_all_match git status --porcelain=v2 && + test_all_match git commit -m "Add README.md" && + + test_all_match git checkout HEAD~1 && + test_all_match git checkout - && + + run_on_all ../edit-contents README.md && + + test_all_match git add -A && + test_all_match git status --porcelain=v2 && + test_all_match git commit -m "Extend README.md" && + + test_all_match git checkout HEAD~1 && + test_all_match git checkout - && + + run_on_all ../edit-contents deep/newfile && + + test_all_match git status --porcelain=v2 -uno && + test_all_match git status --porcelain=v2 && + test_all_match git add . && + test_all_match git status --porcelain=v2 && + test_all_match git commit -m "add deep/newfile" && + + test_all_match git checkout HEAD~1 && + test_all_match git checkout - +' + +test_expect_success 'checkout and reset --hard' ' + init_repos && + + test_all_match git checkout update-folder1 && + test_all_match git status --porcelain=v2 && + + test_all_match git checkout update-deep && + test_all_match git status --porcelain=v2 && + + test_all_match git checkout -b reset-test && + test_all_match git reset --hard deepest && + test_all_match git reset --hard update-folder1 && + test_all_match git reset --hard update-folder2 +' + +test_expect_success 'diff --staged' ' + init_repos && + + write_script edit-contents <<-\EOF && + echo text >>README.md + EOF + run_on_all ../edit-contents && + + test_all_match git diff && + test_all_match git diff --staged && + test_all_match git add README.md && + test_all_match git diff && + test_all_match git diff --staged +' + +test_expect_success 'diff with renames' ' + init_repos && + + for branch in rename-out-to-out rename-out-to-in rename-in-to-out + do + test_all_match git checkout rename-base && + test_all_match git checkout $branch -- .&& + test_all_match git diff --staged --no-renames && + test_all_match git diff --staged --find-renames || return 1 + done +' + +test_expect_success 'log with pathspec outside sparse definition' ' + init_repos && + + test_all_match git log -- a && + test_all_match git log -- folder1/a && + test_all_match git log -- folder2/a && + test_all_match git log -- deep/a && + test_all_match git log -- deep/deeper1/a && + test_all_match git log -- deep/deeper1/deepest/a && + + test_all_match git checkout update-folder1 && + test_all_match git log -- folder1/a +' + +test_expect_success 'blame with pathspec inside sparse definition' ' + init_repos && + + test_all_match git blame a && + test_all_match git blame deep/a && + test_all_match git blame deep/deeper1/a && + test_all_match git blame deep/deeper1/deepest/a +' + +# TODO: blame currently does not support blaming files outside of the +# sparse definition. It complains that the file doesn't exist locally. +test_expect_failure 'blame with pathspec outside sparse definition' ' + init_repos && + + test_all_match git blame folder1/a && + test_all_match git blame folder2/a && + test_all_match git blame deep/deeper2/a && + test_all_match git blame deep/deeper2/deepest/a +' + +# TODO: reset currently does not behave as expected when in a +# sparse-checkout. +test_expect_failure 'checkout and reset (mixed)' ' + init_repos && + + test_all_match git checkout -b reset-test update-deep && + test_all_match git reset deepest && + test_all_match git reset update-folder1 && + test_all_match git reset update-folder2 +' + +# Ensure that sparse-index behaves identically to +# sparse-checkout with a full index. +test_expect_success 'checkout and reset (mixed) [sparse]' ' + init_repos && + + test_sparse_match git checkout -b reset-test update-deep && + test_sparse_match git reset deepest && + test_sparse_match git reset update-folder1 && + test_sparse_match git reset update-folder2 +' + +test_expect_success 'merge' ' + init_repos && + + test_all_match git checkout -b merge update-deep && + test_all_match git merge -m "folder1" update-folder1 && + test_all_match git rev-parse HEAD^{tree} && + test_all_match git merge -m "folder2" update-folder2 && + test_all_match git rev-parse HEAD^{tree} +' + +test_expect_success 'merge with outside renames' ' + init_repos && + + for type in out-to-out out-to-in in-to-out + do + test_all_match git reset --hard && + test_all_match git checkout -f -b merge-$type update-deep && + test_all_match git merge -m "$type" rename-$type && + test_all_match git rev-parse HEAD^{tree} || return 1 + done +' + +test_expect_success 'clean' ' + init_repos && + + echo bogus >>.gitignore && + run_on_all cp ../.gitignore . && + test_all_match git add .gitignore && + test_all_match git commit -m "ignore bogus files" && + + run_on_sparse mkdir folder1 && + run_on_all touch folder1/bogus && + + test_all_match git status --porcelain=v2 && + test_all_match git clean -f && + test_all_match git status --porcelain=v2 && + test_sparse_match ls && + test_sparse_match ls folder1 && + + test_all_match git clean -xf && + test_all_match git status --porcelain=v2 && + test_sparse_match ls && + test_sparse_match ls folder1 && + + test_all_match git clean -xdf && + test_all_match git status --porcelain=v2 && + test_sparse_match ls && + test_sparse_match ls folder1 && + + test_sparse_match test_path_is_dir folder1 +' + +test_expect_success 'submodule handling' ' + init_repos && + + test_all_match mkdir modules && + test_all_match touch modules/a && + test_all_match git add modules && + test_all_match git commit -m "add modules directory" && + + run_on_all git submodule add "$(pwd)/initial-repo" modules/sub && + test_all_match git commit -m "add submodule" && + + # having a submodule prevents "modules" from collapse + test-tool -C sparse-index read-cache --table >cache && + grep "100644 blob .* modules/a" cache && + grep "160000 commit $(git -C initial-repo rev-parse HEAD) modules/sub" cache +' + +test_expect_success 'sparse-index is expanded and converted back' ' + init_repos && + + GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \ + git -C sparse-index -c core.fsmonitor="" reset --hard && + test_region index convert_to_sparse trace2.txt && + test_region index ensure_full_index trace2.txt && + + rm trace2.txt && + GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \ + git -C sparse-index -c core.fsmonitor="" status -uno && + test_region index ensure_full_index trace2.txt +' + +test_done diff --git a/t/t1300-config.sh b/t/t1300-config.sh index 1a4156c704..9ff46f3b04 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -5,6 +5,9 @@ test_description='Test git config in different settings' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'clear default config' ' @@ -672,6 +675,13 @@ test_expect_success 'invalid unit' ' test_i18ngrep "bad numeric config value .1auto. for .aninvalid.unit. in file .git/config: invalid unit" actual ' +test_expect_success 'invalid unit boolean' ' + git config commit.gpgsign "1true" && + test_cmp_config 1true commit.gpgsign && + test_must_fail git config --bool --get commit.gpgsign 2>actual && + test_i18ngrep "bad boolean config value .1true. for .commit.gpgsign." actual +' + test_expect_success 'line number is reported correctly' ' printf "[bool]\n\tvar\n" >invalid && test_must_fail git config -f invalid --path bool.var 2>actual && @@ -1046,8 +1056,8 @@ test_expect_success 'check split_cmdline return' " echo foo > foo && git add foo && git commit -m 'initial commit' && - git config branch.master.mergeoptions 'echo \"' && - test_must_fail git merge master + git config branch.main.mergeoptions 'echo \"' && + test_must_fail git merge main " test_expect_success 'git -c "key=value" support' ' @@ -1286,6 +1296,58 @@ test_expect_success 'git -c is not confused by empty environment' ' GIT_CONFIG_PARAMETERS="" git -c x.one=1 config --list ' +test_expect_success 'GIT_CONFIG_PARAMETERS handles old-style entries' ' + v="${SQ}key.one=foo${SQ}" && + v="$v ${SQ}key.two=bar${SQ}" && + v="$v ${SQ}key.ambiguous=section.whatever=value${SQ}" && + GIT_CONFIG_PARAMETERS=$v git config --get-regexp "key.*" >actual && + cat >expect <<-EOF && + key.one foo + key.two bar + key.ambiguous section.whatever=value + EOF + test_cmp expect actual +' + +test_expect_success 'GIT_CONFIG_PARAMETERS handles new-style entries' ' + v="${SQ}key.one${SQ}=${SQ}foo${SQ}" && + v="$v ${SQ}key.two${SQ}=${SQ}bar${SQ}" && + v="$v ${SQ}key.ambiguous=section.whatever${SQ}=${SQ}value${SQ}" && + GIT_CONFIG_PARAMETERS=$v git config --get-regexp "key.*" >actual && + cat >expect <<-EOF && + key.one foo + key.two bar + key.ambiguous=section.whatever value + EOF + test_cmp expect actual +' + +test_expect_success 'old and new-style entries can mix' ' + v="${SQ}key.oldone=oldfoo${SQ}" && + v="$v ${SQ}key.newone${SQ}=${SQ}newfoo${SQ}" && + v="$v ${SQ}key.oldtwo=oldbar${SQ}" && + v="$v ${SQ}key.newtwo${SQ}=${SQ}newbar${SQ}" && + GIT_CONFIG_PARAMETERS=$v git config --get-regexp "key.*" >actual && + cat >expect <<-EOF && + key.oldone oldfoo + key.newone newfoo + key.oldtwo oldbar + key.newtwo newbar + EOF + test_cmp expect actual +' + +test_expect_success 'old and new bools with ambiguous subsection' ' + v="${SQ}key.with=equals.oldbool${SQ}" && + v="$v ${SQ}key.with=equals.newbool${SQ}=" && + GIT_CONFIG_PARAMETERS=$v git config --get-regexp "key.*" >actual && + cat >expect <<-EOF && + key.with equals.oldbool + key.with=equals.newbool + EOF + test_cmp expect actual +' + test_expect_success 'detect bogus GIT_CONFIG_PARAMETERS' ' cat >expect <<-\EOF && env.one one @@ -1308,6 +1370,186 @@ test_expect_success 'detect bogus GIT_CONFIG_PARAMETERS' ' git config --get-regexp "env.*" ' +test_expect_success 'git --config-env=key=envvar support' ' + cat >expect <<-\EOF && + value + value + value + value + false + false + EOF + { + ENVVAR=value git --config-env=core.name=ENVVAR config core.name && + ENVVAR=value git --config-env core.name=ENVVAR config core.name && + ENVVAR=value git --config-env=foo.CamelCase=ENVVAR config foo.camelcase && + ENVVAR=value git --config-env foo.CamelCase=ENVVAR config foo.camelcase && + ENVVAR= git --config-env=foo.flag=ENVVAR config --bool foo.flag && + ENVVAR= git --config-env foo.flag=ENVVAR config --bool foo.flag + } >actual && + test_cmp expect actual +' + +test_expect_success 'git --config-env with missing value' ' + test_must_fail env ENVVAR=value git --config-env 2>error && + grep "no config key given for --config-env" error && + test_must_fail env ENVVAR=value git --config-env config core.name 2>error && + grep "invalid config format: config" error +' + +test_expect_success 'git --config-env fails with invalid parameters' ' + test_must_fail git --config-env=foo.flag config --bool foo.flag 2>error && + test_i18ngrep "invalid config format: foo.flag" error && + test_must_fail git --config-env=foo.flag= config --bool foo.flag 2>error && + test_i18ngrep "missing environment variable name for configuration ${SQ}foo.flag${SQ}" error && + sane_unset NONEXISTENT && + test_must_fail git --config-env=foo.flag=NONEXISTENT config --bool foo.flag 2>error && + test_i18ngrep "missing environment variable ${SQ}NONEXISTENT${SQ} for configuration ${SQ}foo.flag${SQ}" error +' + +test_expect_success 'git -c and --config-env work together' ' + cat >expect <<-\EOF && + bar.cmd cmd-value + bar.env env-value + EOF + ENVVAR=env-value git \ + -c bar.cmd=cmd-value \ + --config-env=bar.env=ENVVAR \ + config --get-regexp "^bar.*" >actual && + test_cmp expect actual +' + +test_expect_success 'git -c and --config-env override each other' ' + cat >expect <<-\EOF && + env + cmd + EOF + { + ENVVAR=env git -c bar.bar=cmd --config-env=bar.bar=ENVVAR config bar.bar && + ENVVAR=env git --config-env=bar.bar=ENVVAR -c bar.bar=cmd config bar.bar + } >actual && + test_cmp expect actual +' + +test_expect_success '--config-env handles keys with equals' ' + echo value=with=equals >expect && + ENVVAR=value=with=equals git \ + --config-env=section.subsection=with=equals.key=ENVVAR \ + config section.subsection=with=equals.key >actual && + test_cmp expect actual +' + +test_expect_success 'git config handles environment config pairs' ' + GIT_CONFIG_COUNT=2 \ + GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="foo" \ + GIT_CONFIG_KEY_1="pair.two" GIT_CONFIG_VALUE_1="bar" \ + git config --get-regexp "pair.*" >actual && + cat >expect <<-EOF && + pair.one foo + pair.two bar + EOF + test_cmp expect actual +' + +test_expect_success 'git config ignores pairs without count' ' + test_must_fail env GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \ + git config pair.one 2>error && + test_must_be_empty error +' + +test_expect_success 'git config ignores pairs with zero count' ' + test_must_fail env \ + GIT_CONFIG_COUNT=0 \ + GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \ + git config pair.one +' + +test_expect_success 'git config ignores pairs exceeding count' ' + GIT_CONFIG_COUNT=1 \ + GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \ + GIT_CONFIG_KEY_1="pair.two" GIT_CONFIG_VALUE_1="value" \ + git config --get-regexp "pair.*" >actual && + cat >expect <<-EOF && + pair.one value + EOF + test_cmp expect actual +' + +test_expect_success 'git config ignores pairs with zero count' ' + test_must_fail env \ + GIT_CONFIG_COUNT=0 GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \ + git config pair.one >error && + test_must_be_empty error +' + +test_expect_success 'git config ignores pairs with empty count' ' + test_must_fail env \ + GIT_CONFIG_COUNT= GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \ + git config pair.one >error && + test_must_be_empty error +' + +test_expect_success 'git config fails with invalid count' ' + test_must_fail env GIT_CONFIG_COUNT=10a git config --list 2>error && + test_i18ngrep "bogus count" error && + test_must_fail env GIT_CONFIG_COUNT=9999999999999999 git config --list 2>error && + test_i18ngrep "too many entries" error +' + +test_expect_success 'git config fails with missing config key' ' + test_must_fail env GIT_CONFIG_COUNT=1 GIT_CONFIG_VALUE_0="value" \ + git config --list 2>error && + test_i18ngrep "missing config key" error +' + +test_expect_success 'git config fails with missing config value' ' + test_must_fail env GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="pair.one" \ + git config --list 2>error && + test_i18ngrep "missing config value" error +' + +test_expect_success 'git config fails with invalid config pair key' ' + test_must_fail env GIT_CONFIG_COUNT=1 \ + GIT_CONFIG_KEY_0= GIT_CONFIG_VALUE_0=value \ + git config --list && + test_must_fail env GIT_CONFIG_COUNT=1 \ + GIT_CONFIG_KEY_0=missing-section GIT_CONFIG_VALUE_0=value \ + git config --list +' + +test_expect_success 'environment overrides config file' ' + test_when_finished "rm -f .git/config" && + cat >.git/config <<-EOF && + [pair] + one = value + EOF + GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=pair.one GIT_CONFIG_VALUE_0=override \ + git config pair.one >actual && + cat >expect <<-EOF && + override + EOF + test_cmp expect actual +' + +test_expect_success 'GIT_CONFIG_PARAMETERS overrides environment config' ' + GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=pair.one GIT_CONFIG_VALUE_0=value \ + GIT_CONFIG_PARAMETERS="${SQ}pair.one=override${SQ}" \ + git config pair.one >actual && + cat >expect <<-EOF && + override + EOF + test_cmp expect actual +' + +test_expect_success 'command line overrides environment config' ' + GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=pair.one GIT_CONFIG_VALUE_0=value \ + git -c pair.one=override config pair.one >actual && + cat >expect <<-EOF && + override + EOF + test_cmp expect actual +' + test_expect_success 'git config --edit works' ' git config -f tmp test.value no && echo test.value=yes >expect && @@ -1653,9 +1895,11 @@ test_expect_success '--show-origin with --list' ' 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.environ=true command line: user.cmdline=true EOF - git -c user.cmdline=true config --list --show-origin >output && + GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=user.environ GIT_CONFIG_VALUE_0=true\ + git -c user.cmdline=true config --list --show-origin >output && test_cmp expect output ' @@ -1761,11 +2005,11 @@ test_expect_success '--show-origin blob' ' test_expect_success '--show-origin blob ref' ' cat >expect <<-\EOF && - blob:master:custom.conf user.custom=true + blob:main:custom.conf user.custom=true EOF git add "$CUSTOM_CONFIG_FILE" && git commit -m "new config file" && - git config --blob=master:"$CUSTOM_CONFIG_FILE" --show-origin --list >output && + git config --blob=main:"$CUSTOM_CONFIG_FILE" --show-origin --list >output && test_cmp expect output ' @@ -1828,6 +2072,91 @@ test_expect_success '--show-scope with --show-origin' ' test_cmp expect output ' +test_expect_success 'override global and system config' ' + test_when_finished rm -f "$HOME"/.config/git && + + cat >"$HOME"/.gitconfig <<-EOF && + [home] + config = true + EOF + mkdir -p "$HOME"/.config/git && + cat >"$HOME"/.config/git/config <<-EOF && + [xdg] + config = true + EOF + cat >.git/config <<-EOF && + [local] + config = true + EOF + cat >custom-global-config <<-EOF && + [global] + config = true + EOF + cat >custom-system-config <<-EOF && + [system] + config = true + EOF + + cat >expect <<-EOF && + global xdg.config=true + global home.config=true + local local.config=true + EOF + git config --show-scope --list >output && + test_cmp expect output && + + cat >expect <<-EOF && + system system.config=true + global global.config=true + local local.config=true + EOF + GIT_CONFIG_NOSYSTEM=false GIT_CONFIG_SYSTEM=custom-system-config GIT_CONFIG_GLOBAL=custom-global-config \ + git config --show-scope --list >output && + test_cmp expect output && + + cat >expect <<-EOF && + local local.config=true + EOF + GIT_CONFIG_NOSYSTEM=false GIT_CONFIG_SYSTEM=/dev/null GIT_CONFIG_GLOBAL=/dev/null \ + git config --show-scope --list >output && + test_cmp expect output +' + +test_expect_success 'override global and system config with missing file' ' + test_must_fail env GIT_CONFIG_GLOBAL=does-not-exist GIT_CONFIG_SYSTEM=/dev/null git config --global --list && + test_must_fail env GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=does-not-exist git config --system --list && + GIT_CONFIG_GLOBAL=does-not-exist GIT_CONFIG_SYSTEM=does-not-exist git version +' + +test_expect_success 'system override has no effect with GIT_CONFIG_NOSYSTEM' ' + # `git config --system` has different semantics compared to other + # commands as it ignores GIT_CONFIG_NOSYSTEM. We thus test whether the + # variable has an effect via a different proxy. + cat >alias-config <<-EOF && + [alias] + hello-world = !echo "hello world" + EOF + test_must_fail env GIT_CONFIG_NOSYSTEM=true GIT_CONFIG_SYSTEM=alias-config \ + git hello-world && + GIT_CONFIG_NOSYSTEM=false GIT_CONFIG_SYSTEM=alias-config \ + git hello-world >actual && + echo "hello world" >expect && + test_cmp expect actual +' + +test_expect_success 'write to overridden global and system config' ' + cat >expect <<EOF && +[config] + key = value +EOF + + GIT_CONFIG_GLOBAL=write-to-global git config --global config.key value && + test_cmp expect write-to-global && + + GIT_CONFIG_SYSTEM=write-to-system git config --system config.key value && + test_cmp expect write-to-system +' + for opt in --local --worktree do test_expect_success "$opt requires a repo" ' diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh index 2dc853d1be..ac947bff9f 100755 --- a/t/t1301-shared-repo.sh +++ b/t/t1301-shared-repo.sh @@ -5,6 +5,9 @@ test_description='Test shared repository initialization' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # Remove a default ACL from the test dir if possible. @@ -115,13 +118,13 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' ' umask 077 && git config core.sharedRepository group && git reflog expire --all && - actual="$(ls -l .git/logs/refs/heads/master)" && + actual="$(ls -l .git/logs/refs/heads/main)" && case "$actual" in -rw-rw-*) : happy ;; *) - echo Ooops, .git/logs/refs/heads/master is not 0662 [$actual] + echo Ooops, .git/logs/refs/heads/main is not 0662 [$actual] false ;; esac diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh index f1e1b289f9..ccbb116c01 100755 --- a/t/t1305-config-include.sh +++ b/t/t1305-config-include.sh @@ -312,7 +312,7 @@ test_expect_success SYMLINKS 'conditional include, gitdir matching symlink, icas test_expect_success 'conditional include, onbranch' ' echo "[includeIf \"onbranch:foo-branch\"]path=bar9" >>.git/config && echo "[test]nine=9" >.git/bar9 && - git checkout -b master && + git checkout -b main && test_must_fail git config test.nine && git checkout -b foo-branch && echo 9 >expect && @@ -352,9 +352,7 @@ test_expect_success 'include cycles are detected' ' git init --bare cycle && git -C cycle config include.path cycle && git config -f cycle/cycle include.path config && - test_must_fail \ - env GIT_TEST_GETTEXT_POISON=false \ - git -C cycle config --get-all test.value 2>stderr && + test_must_fail git -C cycle config --get-all test.value 2>stderr && grep "exceeded maximum include depth" stderr ' diff --git a/t/t1306-xdg-files.sh b/t/t1306-xdg-files.sh index dd87b43be1..40d3c42618 100755 --- a/t/t1306-xdg-files.sh +++ b/t/t1306-xdg-files.sh @@ -116,7 +116,7 @@ test_expect_success 'Exclusion in a non-XDG global ignore file' ' test_expect_success 'Checking XDG ignore file when HOME is unset' ' (sane_unset HOME && git config --unset core.excludesfile && - git ls-files --exclude-standard --ignored >actual) && + git ls-files --exclude-standard --ignored --others >actual) && test_must_be_empty actual ' diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh index 3a527e3a84..88b119a0a3 100755 --- a/t/t1308-config-set.sh +++ b/t/t1308-config-set.sh @@ -208,14 +208,14 @@ test_expect_success 'proper error on error in default config files' ' echo "[" >>.git/config && echo "fatal: bad config line 34 in file .git/config" >expect && test_expect_code 128 test-tool config get_value foo.bar 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'proper error on error in custom config files' ' echo "[" >>syntax-error && echo "fatal: bad config line 1 in file syntax-error" >expect && test_expect_code 128 test-tool config configset_get_value foo.bar syntax-error 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'check line errors for malformed values' ' diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 6ee7d216fb..4506cd435b 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -4,6 +4,9 @@ # test_description='Test git update-ref and basic ref logging' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh Z=$ZERO_OID @@ -371,7 +374,7 @@ test_expect_success 'Query "main@{May 25 2005}" (before history)' ' echo "$C" >expect && test_cmp expect o && echo "warning: log for '\''main'\'' only goes back to $ed" >expect && - test_i18ncmp expect e + test_cmp expect e ' test_expect_success 'Query main@{2005-05-25} (before history)' ' test_when_finished "rm -f o e" && @@ -379,7 +382,7 @@ test_expect_success 'Query main@{2005-05-25} (before history)' ' echo "$C" >expect && test_cmp expect o && echo "warning: log for '\''main'\'' only goes back to $ed" >expect && - test_i18ncmp expect e + test_cmp expect e ' test_expect_success 'Query "main@{May 26 2005 23:31:59}" (1 second before history)' ' test_when_finished "rm -f o e" && @@ -387,7 +390,7 @@ test_expect_success 'Query "main@{May 26 2005 23:31:59}" (1 second before histor echo "$C" >expect && test_cmp expect o && echo "warning: log for '\''main'\'' only goes back to $ed" >expect && - test_i18ncmp expect e + test_cmp expect e ' test_expect_success 'Query "main@{May 26 2005 23:32:00}" (exactly history start)' ' test_when_finished "rm -f o e" && @@ -1595,4 +1598,13 @@ test_expect_success 'transaction cannot restart ongoing transaction' ' test_must_fail git show-ref --verify refs/heads/restart ' +test_expect_success 'directory not created deleting packed ref' ' + git branch d1/d2/r1 HEAD && + git pack-refs --all && + test_path_is_missing .git/refs/heads/d1/d2 && + git update-ref -d refs/heads/d1/d2/r1 && + test_path_is_missing .git/refs/heads/d1/d2 && + test_path_is_missing .git/refs/heads/d1 +' + test_done diff --git a/t/t1402-check-ref-format.sh b/t/t1402-check-ref-format.sh index 98e4a8613b..cabc516ae9 100755 --- a/t/t1402-check-ref-format.sh +++ b/t/t1402-check-ref-format.sh @@ -134,18 +134,18 @@ valid_ref !MINGW "$ref" '--refspec-pattern --allow-onelevel --normalize' test_expect_success "check-ref-format --branch @{-1}" ' T=$(git write-tree) && sha1=$(echo A | git commit-tree $T) && - git update-ref refs/heads/master $sha1 && - git update-ref refs/remotes/origin/master $sha1 && - git checkout master && - git checkout origin/master && - git checkout master && + git update-ref refs/heads/main $sha1 && + git update-ref refs/remotes/origin/main $sha1 && + git checkout main && + git checkout origin/main && + git checkout main && refname=$(git check-ref-format --branch @{-1}) && test "$refname" = "$sha1" && refname2=$(git check-ref-format --branch @{-2}) && - test "$refname2" = master' + test "$refname2" = main' -test_expect_success 'check-ref-format --branch -naster' ' - test_must_fail git check-ref-format --branch -naster >actual && +test_expect_success 'check-ref-format --branch -nain' ' + test_must_fail git check-ref-format --branch -nain >actual && test_must_be_empty actual ' @@ -154,11 +154,11 @@ test_expect_success 'check-ref-format --branch from subdir' ' T=$(git write-tree) && sha1=$(echo A | git commit-tree $T) && - git update-ref refs/heads/master $sha1 && - git update-ref refs/remotes/origin/master $sha1 && - git checkout master && - git checkout origin/master && - git checkout master && + git update-ref refs/heads/main $sha1 && + git update-ref refs/remotes/origin/main $sha1 && + git checkout main && + git checkout origin/main && + git checkout main && refname=$( cd subdir && git check-ref-format --branch @{-1} @@ -171,9 +171,9 @@ test_expect_success 'check-ref-format --branch @{-1} from non-repo' ' test_must_be_empty actual ' -test_expect_success 'check-ref-format --branch master from non-repo' ' - echo master >expect && - nongit git check-ref-format --branch master >actual && +test_expect_success 'check-ref-format --branch main from non-repo' ' + echo main >expect && + nongit git check-ref-format --branch main >actual && test_cmp expect actual ' diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh index 5d955c3bff..6ce62f878c 100755 --- a/t/t1403-show-ref.sh +++ b/t/t1403-show-ref.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='show-ref' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -9,7 +12,7 @@ test_expect_success setup ' git checkout -b side && test_commit B && git tag -f -a -m "annotated B" B && - git checkout master && + git checkout main && test_commit C && git branch B A^0 ' @@ -92,23 +95,23 @@ test_expect_success 'show-ref -d' ' git show-ref --verify -d refs/tags/A refs/tags/C >actual && test_cmp expect actual && - echo $(git rev-parse refs/heads/master) refs/heads/master >expect && - git show-ref -d master >actual && + echo $(git rev-parse refs/heads/main) refs/heads/main >expect && + git show-ref -d main >actual && test_cmp expect actual && - git show-ref -d heads/master >actual && + git show-ref -d heads/main >actual && test_cmp expect actual && - git show-ref -d refs/heads/master >actual && + git show-ref -d refs/heads/main >actual && test_cmp expect actual && - git show-ref -d --verify refs/heads/master >actual && + git show-ref -d --verify refs/heads/main >actual && test_cmp expect actual && - test_must_fail git show-ref -d --verify master >actual && + test_must_fail git show-ref -d --verify main >actual && test_must_be_empty actual && - test_must_fail git show-ref -d --verify heads/master >actual && + test_must_fail git show-ref -d --verify heads/main >actual && test_must_be_empty actual && test_must_fail git show-ref --verify -d A C >actual && @@ -120,7 +123,7 @@ test_expect_success 'show-ref -d' ' ' test_expect_success 'show-ref --heads, --tags, --head, pattern' ' - for branch in B master side + for branch in B main side do echo $(git rev-parse refs/heads/$branch) refs/heads/$branch done >expect.heads && diff --git a/t/t1404-update-ref-errors.sh b/t/t1404-update-ref-errors.sh index 2d142e5535..8b51c4efc1 100755 --- a/t/t1404-update-ref-errors.sh +++ b/t/t1404-update-ref-errors.sh @@ -101,7 +101,7 @@ df_test() { printf "%s\n" "delete $delname" "create $addname $D" fi >commands && test_must_fail git update-ref --stdin <commands 2>output.err && - test_i18ncmp expected-err output.err && + test_cmp expected-err output.err && printf "%s\n" "$C $delref" >expected-refs && git for-each-ref --format="%(objectname) %(refname)" $prefix/r >actual-refs && test_cmp expected-refs actual-refs diff --git a/t/t1405-main-ref-store.sh b/t/t1405-main-ref-store.sh index 74af927fba..a237d9880e 100755 --- a/t/t1405-main-ref-store.sh +++ b/t/t1405-main-ref-store.sh @@ -2,6 +2,9 @@ test_description='test main ref store api' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh RUN="test-tool ref-store main" @@ -14,24 +17,18 @@ test_expect_success 'pack_refs(PACK_REFS_ALL | PACK_REFS_PRUNE)' ' N=`find .git/refs -type f | wc -l` ' -test_expect_success 'peel_ref(new-tag)' ' - git rev-parse HEAD >expected && - git tag -a -m new-tag new-tag HEAD && - $RUN peel-ref refs/tags/new-tag >actual && - test_cmp expected actual -' - -test_expect_success 'create_symref(FOO, refs/heads/master)' ' - $RUN create-symref FOO refs/heads/master nothing && - echo refs/heads/master >expected && +test_expect_success 'create_symref(FOO, refs/heads/main)' ' + $RUN create-symref FOO refs/heads/main nothing && + echo refs/heads/main >expected && git symbolic-ref FOO >actual && test_cmp expected actual ' test_expect_success 'delete_refs(FOO, refs/tags/new-tag)' ' + git tag -a -m new-tag new-tag HEAD && git rev-parse FOO -- && git rev-parse refs/tags/new-tag -- && - m=$(git rev-parse master) && + m=$(git rev-parse main) && REF_NO_DEREF=1 && $RUN delete-refs $REF_NO_DEREF nothing FOO refs/tags/new-tag && test_must_fail git rev-parse --symbolic-full-name FOO && @@ -39,19 +36,19 @@ test_expect_success 'delete_refs(FOO, refs/tags/new-tag)' ' test_must_fail git rev-parse refs/tags/new-tag -- ' -test_expect_success 'rename_refs(master, new-master)' ' - git rev-parse master >expected && - $RUN rename-ref refs/heads/master refs/heads/new-master && - git rev-parse new-master >actual && +test_expect_success 'rename_refs(main, new-main)' ' + git rev-parse main >expected && + $RUN rename-ref refs/heads/main refs/heads/new-main && + git rev-parse new-main >actual && test_cmp expected actual && - test_commit recreate-master + test_commit recreate-main ' test_expect_success 'for_each_ref(refs/heads/)' ' $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual && cat >expected <<-\EOF && - master 0x0 - new-master 0x0 + main 0x0 + new-main 0x0 EOF test_cmp expected actual ' @@ -62,23 +59,23 @@ test_expect_success 'for_each_ref() is sorted' ' test_cmp expected actual ' -test_expect_success 'resolve_ref(new-master)' ' - SHA1=`git rev-parse new-master` && - echo "$SHA1 refs/heads/new-master 0x0" >expected && - $RUN resolve-ref refs/heads/new-master 0 >actual && +test_expect_success 'resolve_ref(new-main)' ' + SHA1=`git rev-parse new-main` && + echo "$SHA1 refs/heads/new-main 0x0" >expected && + $RUN resolve-ref refs/heads/new-main 0 >actual && test_cmp expected actual ' -test_expect_success 'verify_ref(new-master)' ' - $RUN verify-ref refs/heads/new-master +test_expect_success 'verify_ref(new-main)' ' + $RUN verify-ref refs/heads/new-main ' test_expect_success 'for_each_reflog()' ' $RUN for-each-reflog | sort -k2 | cut -d" " -f 2- >actual && cat >expected <<-\EOF && HEAD 0x1 - refs/heads/master 0x0 - refs/heads/new-master 0x0 + refs/heads/main 0x0 + refs/heads/new-main 0x0 EOF test_cmp expected actual ' @@ -86,12 +83,12 @@ test_expect_success 'for_each_reflog()' ' test_expect_success 'for_each_reflog_ent()' ' $RUN for-each-reflog-ent HEAD >actual && head -n1 actual | grep one && - tail -n2 actual | head -n1 | grep recreate-master + tail -n2 actual | head -n1 | grep recreate-main ' test_expect_success 'for_each_reflog_ent_reverse()' ' $RUN for-each-reflog-ent-reverse HEAD >actual && - head -n1 actual | grep recreate-master && + head -n1 actual | grep recreate-main && tail -n2 actual | head -n1 | grep one ' diff --git a/t/t1406-submodule-ref-store.sh b/t/t1406-submodule-ref-store.sh index 36b7ef5046..0a87058971 100755 --- a/t/t1406-submodule-ref-store.sh +++ b/t/t1406-submodule-ref-store.sh @@ -2,6 +2,9 @@ test_description='test submodule ref store api' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh RUN="test-tool ref-store submodule:sub" @@ -11,7 +14,8 @@ test_expect_success 'setup' ' ( cd sub && test_commit first && - git checkout -b new-master + git checkout -b new-main && + git tag -a -m new-tag new-tag HEAD ) ' @@ -19,15 +23,8 @@ test_expect_success 'pack_refs() not allowed' ' test_must_fail $RUN pack-refs 3 ' -test_expect_success 'peel_ref(new-tag)' ' - git -C sub rev-parse HEAD >expected && - git -C sub tag -a -m new-tag new-tag HEAD && - $RUN peel-ref refs/tags/new-tag >actual && - test_cmp expected actual -' - test_expect_success 'create_symref() not allowed' ' - test_must_fail $RUN create-symref FOO refs/heads/master nothing + test_must_fail $RUN create-symref FOO refs/heads/main nothing ' test_expect_success 'delete_refs() not allowed' ' @@ -35,14 +32,14 @@ test_expect_success 'delete_refs() not allowed' ' ' test_expect_success 'rename_refs() not allowed' ' - test_must_fail $RUN rename-ref refs/heads/master refs/heads/new-master + test_must_fail $RUN rename-ref refs/heads/main refs/heads/new-main ' test_expect_success 'for_each_ref(refs/heads/)' ' $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual && cat >expected <<-\EOF && - master 0x0 - new-master 0x0 + main 0x0 + new-main 0x0 EOF test_cmp expected actual ' @@ -53,23 +50,23 @@ test_expect_success 'for_each_ref() is sorted' ' test_cmp expected actual ' -test_expect_success 'resolve_ref(master)' ' - SHA1=`git -C sub rev-parse master` && - echo "$SHA1 refs/heads/master 0x0" >expected && - $RUN resolve-ref refs/heads/master 0 >actual && +test_expect_success 'resolve_ref(main)' ' + SHA1=`git -C sub rev-parse main` && + echo "$SHA1 refs/heads/main 0x0" >expected && + $RUN resolve-ref refs/heads/main 0 >actual && test_cmp expected actual ' -test_expect_success 'verify_ref(new-master)' ' - $RUN verify-ref refs/heads/new-master +test_expect_success 'verify_ref(new-main)' ' + $RUN verify-ref refs/heads/new-main ' test_expect_success 'for_each_reflog()' ' $RUN for-each-reflog | sort | cut -d" " -f 2- >actual && cat >expected <<-\EOF && HEAD 0x1 - refs/heads/master 0x0 - refs/heads/new-master 0x0 + refs/heads/main 0x0 + refs/heads/new-main 0x0 EOF test_cmp expected actual ' @@ -77,12 +74,12 @@ test_expect_success 'for_each_reflog()' ' test_expect_success 'for_each_reflog_ent()' ' $RUN for-each-reflog-ent HEAD >actual && head -n1 actual | grep first && - tail -n2 actual | head -n1 | grep master.to.new + tail -n2 actual | head -n1 | grep main.to.new ' test_expect_success 'for_each_reflog_ent_reverse()' ' $RUN for-each-reflog-ent-reverse HEAD >actual && - head -n1 actual | grep master.to.new && + head -n1 actual | grep main.to.new && tail -n2 actual | head -n1 | grep first ' diff --git a/t/t1407-worktree-ref-store.sh b/t/t1407-worktree-ref-store.sh index 9a84858118..d3fe777511 100755 --- a/t/t1407-worktree-ref-store.sh +++ b/t/t1407-worktree-ref-store.sh @@ -2,6 +2,9 @@ test_description='test worktree ref store api' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh RWT="test-tool ref-store worktree:wt" @@ -9,7 +12,7 @@ RMAIN="test-tool ref-store worktree:main" test_expect_success 'setup' ' test_commit first && - git worktree add -b wt-master wt && + git worktree add -b wt-main wt && ( cd wt && test_commit second @@ -17,34 +20,34 @@ test_expect_success 'setup' ' ' test_expect_success 'resolve_ref(<shared-ref>)' ' - SHA1=`git rev-parse master` && - echo "$SHA1 refs/heads/master 0x0" >expected && - $RWT resolve-ref refs/heads/master 0 >actual && + SHA1=`git rev-parse main` && + echo "$SHA1 refs/heads/main 0x0" >expected && + $RWT resolve-ref refs/heads/main 0 >actual && test_cmp expected actual && - $RMAIN resolve-ref refs/heads/master 0 >actual && + $RMAIN resolve-ref refs/heads/main 0 >actual && test_cmp expected actual ' test_expect_success 'resolve_ref(<per-worktree-ref>)' ' SHA1=`git -C wt rev-parse HEAD` && - echo "$SHA1 refs/heads/wt-master 0x1" >expected && + echo "$SHA1 refs/heads/wt-main 0x1" >expected && $RWT resolve-ref HEAD 0 >actual && test_cmp expected actual && SHA1=`git rev-parse HEAD` && - echo "$SHA1 refs/heads/master 0x1" >expected && + echo "$SHA1 refs/heads/main 0x1" >expected && $RMAIN resolve-ref HEAD 0 >actual && test_cmp expected actual ' -test_expect_success 'create_symref(FOO, refs/heads/master)' ' - $RWT create-symref FOO refs/heads/master nothing && - echo refs/heads/master >expected && +test_expect_success 'create_symref(FOO, refs/heads/main)' ' + $RWT create-symref FOO refs/heads/main nothing && + echo refs/heads/main >expected && git -C wt symbolic-ref FOO >actual && test_cmp expected actual && - $RMAIN create-symref FOO refs/heads/wt-master nothing && - echo refs/heads/wt-master >expected && + $RMAIN create-symref FOO refs/heads/wt-main nothing && + echo refs/heads/wt-main >expected && git symbolic-ref FOO >actual && test_cmp expected actual ' @@ -63,8 +66,8 @@ test_expect_success 'for_each_reflog()' ' HEAD 0x1 PSEUDO-WT 0x0 refs/bisect/wt-random 0x0 - refs/heads/master 0x0 - refs/heads/wt-master 0x0 + refs/heads/main 0x0 + refs/heads/wt-main 0x0 EOF test_cmp expected actual && @@ -73,8 +76,8 @@ test_expect_success 'for_each_reflog()' ' HEAD 0x1 PSEUDO-MAIN 0x0 refs/bisect/random 0x0 - refs/heads/master 0x0 - refs/heads/wt-master 0x0 + refs/heads/main 0x0 + refs/heads/wt-main 0x0 EOF test_cmp expected actual ' diff --git a/t/t1408-packed-refs.sh b/t/t1408-packed-refs.sh index 1e44a17eea..41ba1f1d7f 100755 --- a/t/t1408-packed-refs.sh +++ b/t/t1408-packed-refs.sh @@ -2,6 +2,9 @@ test_description='packed-refs entries are covered by loose refs' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -9,32 +12,32 @@ test_expect_success setup ' git commit --allow-empty -m one && one=$(git rev-parse HEAD) && git for-each-ref >actual && - echo "$one commit refs/heads/master" >expect && + echo "$one commit refs/heads/main" >expect && test_cmp expect actual && git pack-refs --all && git for-each-ref >actual && - echo "$one commit refs/heads/master" >expect && + echo "$one commit refs/heads/main" >expect && test_cmp expect actual && git checkout --orphan another && test_tick && git commit --allow-empty -m two && two=$(git rev-parse HEAD) && - git checkout -B master && + git checkout -B main && git branch -D another && git for-each-ref >actual && - echo "$two commit refs/heads/master" >expect && + echo "$two commit refs/heads/main" >expect && test_cmp expect actual && git reflog expire --expire=now --all && git prune && - git tag -m v1.0 v1.0 master + git tag -m v1.0 v1.0 main ' test_expect_success 'no error from stale entry in packed-refs' ' - git describe master >actual 2>&1 && + git describe main >actual 2>&1 && echo "v1.0" >expect && test_cmp expect actual ' diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index 730a43d9dd..27b9080251 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -4,6 +4,9 @@ # test_description='Test prune and reflog expiration' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh check_have () { @@ -99,7 +102,7 @@ test_expect_success setup ' check_fsck && - git reflog refs/heads/master >output && + git reflog refs/heads/main >output && test_line_count = 4 output ' @@ -116,7 +119,7 @@ test_expect_success rewind ' check_have A B C D E F G H I J K L && - git reflog refs/heads/master >output && + git reflog refs/heads/main >output && test_line_count = 5 output ' @@ -135,7 +138,7 @@ test_expect_success 'reflog expire --dry-run should not touch reflog' ' --stale-fix \ --all && - git reflog refs/heads/master >output && + git reflog refs/heads/main >output && test_line_count = 5 output && check_fsck "missing blob $F" @@ -149,12 +152,38 @@ test_expect_success 'reflog expire' ' --stale-fix \ --all && - git reflog refs/heads/master >output && + git reflog refs/heads/main >output && test_line_count = 2 output && check_fsck "dangling commit $K" ' +test_expect_success '--stale-fix handles missing objects generously' ' + git -c core.logAllRefUpdates=false fast-import --date-format=now <<-EOS && + commit refs/heads/stale-fix + mark :1 + committer Author <a@uth.or> now + data <<EOF + start stale fix + EOF + M 100644 inline file + data <<EOF + contents + EOF + commit refs/heads/stale-fix + committer Author <a@uth.or> now + data <<EOF + stale fix branch tip + EOF + from :1 + EOS + + parent_oid=$(git rev-parse stale-fix^) && + test_when_finished "recover $parent_oid" && + corrupt $parent_oid && + git reflog expire --stale-fix +' + test_expect_success 'prune and fsck' ' git prune && @@ -186,29 +215,29 @@ test_expect_success 'delete' ' git commit -m tiger C && HEAD_entry_count=$(git reflog | wc -l) && - master_entry_count=$(git reflog show master | wc -l) && + main_entry_count=$(git reflog show main | wc -l) && test $HEAD_entry_count = 5 && - test $master_entry_count = 5 && + test $main_entry_count = 5 && - git reflog delete master@{1} && - git reflog show master > output && - test_line_count = $(($master_entry_count - 1)) output && + git reflog delete main@{1} && + git reflog show main > output && + test_line_count = $(($main_entry_count - 1)) output && test $HEAD_entry_count = $(git reflog | wc -l) && ! grep ox < output && - master_entry_count=$(wc -l < output) && + main_entry_count=$(wc -l < output) && git reflog delete HEAD@{1} && test $(($HEAD_entry_count -1)) = $(git reflog | wc -l) && - test $master_entry_count = $(git reflog show master | wc -l) && + test $main_entry_count = $(git reflog show main | wc -l) && HEAD_entry_count=$(git reflog | wc -l) && - git reflog delete master@{07.04.2005.15:15:00.-0700} && - git reflog show master > output && - test_line_count = $(($master_entry_count - 1)) output && + git reflog delete main@{07.04.2005.15:15:00.-0700} && + git reflog show main > output && + test_line_count = $(($main_entry_count - 1)) output && ! grep dragon < output ' @@ -216,7 +245,7 @@ test_expect_success 'delete' ' test_expect_success 'rewind2' ' test_tick && git reset --hard HEAD~2 && - git reflog refs/heads/master >output && + git reflog refs/heads/main >output && test_line_count = 4 output ' @@ -226,7 +255,7 @@ test_expect_success '--expire=never' ' --expire=never \ --expire-unreachable=never \ --all && - git reflog refs/heads/master >output && + git reflog refs/heads/main >output && test_line_count = 4 output ' @@ -237,7 +266,7 @@ test_expect_success 'gc.reflogexpire=never' ' git reflog expire --verbose --all >output && test_line_count = 9 output && - git reflog refs/heads/master >output && + git reflog refs/heads/main >output && test_line_count = 4 output ' @@ -246,7 +275,7 @@ test_expect_success 'gc.reflogexpire=false' ' test_config gc.reflogexpireunreachable false && git reflog expire --verbose --all && - git reflog refs/heads/master >output && + git reflog refs/heads/main >output && test_line_count = 4 output ' @@ -255,33 +284,33 @@ test_expect_success 'git reflog expire unknown reference' ' test_config gc.reflogexpire never && test_config gc.reflogexpireunreachable never && - test_must_fail git reflog expire master@{123} 2>stderr && + test_must_fail git reflog expire main@{123} 2>stderr && test_i18ngrep "points nowhere" stderr && test_must_fail git reflog expire does-not-exist 2>stderr && test_i18ngrep "points nowhere" stderr ' test_expect_success 'checkout should not delete log for packed ref' ' - test $(git reflog master | wc -l) = 4 && + test $(git reflog main | wc -l) = 4 && git branch foo && git pack-refs --all && git checkout foo && - test $(git reflog master | wc -l) = 4 + test $(git reflog main | wc -l) = 4 ' test_expect_success 'stale dirs do not cause d/f conflicts (reflogs on)' ' test_when_finished "git branch -d one || git branch -d one/two" && - git branch one/two master && - echo "one/two@{0} branch: Created from master" >expect && + git branch one/two main && + echo "one/two@{0} branch: Created from main" >expect && git log -g --format="%gd %gs" one/two >actual && test_cmp expect actual && git branch -d one/two && # now logs/refs/heads/one is a stale directory, but # we should move it out of the way to create "one" reflog - git branch one master && - echo "one@{0} branch: Created from master" >expect && + git branch one main && + echo "one@{0} branch: Created from main" >expect && git log -g --format="%gd %gs" one >actual && test_cmp expect actual ' @@ -289,15 +318,15 @@ test_expect_success 'stale dirs do not cause d/f conflicts (reflogs on)' ' test_expect_success 'stale dirs do not cause d/f conflicts (reflogs off)' ' test_when_finished "git branch -d one || git branch -d one/two" && - git branch one/two master && - echo "one/two@{0} branch: Created from master" >expect && + git branch one/two main && + echo "one/two@{0} branch: Created from main" >expect && git log -g --format="%gd %gs" one/two >actual && test_cmp expect actual && git branch -d one/two && # same as before, but we only create a reflog for "one" if # it already exists, which it does not - git -c core.logallrefupdates=false branch one master && + git -c core.logallrefupdates=false branch one main && git log -g --format="%gd %gs" one >actual && test_must_be_empty actual ' diff --git a/t/t1411-reflog-show.sh b/t/t1411-reflog-show.sh index 985daf1def..0bb319b944 100755 --- a/t/t1411-reflog-show.sh +++ b/t/t1411-reflog-show.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='Test reflog display routines' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -167,7 +170,7 @@ test_expect_success 'git log -g -p shows diffs vs. parents' ' ' test_expect_success 'reflog exists works' ' - git reflog exists refs/heads/master && + git reflog exists refs/heads/main && ! git reflog exists refs/heads/nonexistent ' diff --git a/t/t1412-reflog-loop.sh b/t/t1412-reflog-loop.sh index 3acd895afb..977603f7f1 100755 --- a/t/t1412-reflog-loop.sh +++ b/t/t1412-reflog-loop.sh @@ -4,11 +4,8 @@ test_description='reflog walk shows repeated commits again' . ./test-lib.sh test_expect_success 'setup commits' ' - test_tick && - echo content >file && git add file && git commit -m one && - git tag one && - echo content >>file && git add file && git commit -m two && - git tag two + test_commit one file content && + test_commit --append two file content ' test_expect_success 'setup reflog with alternating commits' ' diff --git a/t/t1413-reflog-detach.sh b/t/t1413-reflog-detach.sh index c730600d8a..bde05208ae 100755 --- a/t/t1413-reflog-detach.sh +++ b/t/t1413-reflog-detach.sh @@ -1,10 +1,13 @@ #!/bin/sh test_description='Test reflog interaction with detached HEAD' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh reset_state () { - git checkout master && + git checkout main && cp saved_reflog .git/logs/HEAD } @@ -19,14 +22,14 @@ test_expect_success setup ' test_expect_success baseline ' reset_state && - git rev-parse master master^ >expect && + git rev-parse main main^ >expect && git log -g --format=%H >actual && test_cmp expect actual ' test_expect_success 'switch to branch' ' reset_state && - git rev-parse side master master^ >expect && + git rev-parse side main main^ >expect && git checkout side && git log -g --format=%H >actual && test_cmp expect actual @@ -34,34 +37,34 @@ test_expect_success 'switch to branch' ' test_expect_success 'detach to other' ' reset_state && - git rev-parse master side master master^ >expect && + git rev-parse main side main main^ >expect && git checkout side && - git checkout master^0 && + git checkout main^0 && git log -g --format=%H >actual && test_cmp expect actual ' test_expect_success 'detach to self' ' reset_state && - git rev-parse master master master^ >expect && - git checkout master^0 && + git rev-parse main main main^ >expect && + git checkout main^0 && git log -g --format=%H >actual && test_cmp expect actual ' test_expect_success 'attach to self' ' reset_state && - git rev-parse master master master master^ >expect && - git checkout master^0 && - git checkout master && + git rev-parse main main main main^ >expect && + git checkout main^0 && + git checkout main && git log -g --format=%H >actual && test_cmp expect actual ' test_expect_success 'attach to other' ' reset_state && - git rev-parse side master master master^ >expect && - git checkout master^0 && + git rev-parse side main main main^ >expect && + git checkout main^0 && git checkout side && git log -g --format=%H >actual && test_cmp expect actual diff --git a/t/t1414-reflog-walk.sh b/t/t1414-reflog-walk.sh index 1181a9fb28..80d94704d0 100755 --- a/t/t1414-reflog-walk.sh +++ b/t/t1414-reflog-walk.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='various tests of reflog walk (log -g) behavior' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'set up some reflog entries' ' @@ -8,7 +11,7 @@ test_expect_success 'set up some reflog entries' ' test_commit two && git checkout -b side HEAD^ && test_commit three && - git merge --no-commit master && + git merge --no-commit main && echo evil-merge-content >>one.t && test_tick && git commit --no-edit -a @@ -20,9 +23,9 @@ do_walk () { 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}main${SQ} into side HEAD@{1} commit: three - HEAD@{2} checkout: moving from master to side + HEAD@{2} checkout: moving from main to side HEAD@{3} commit: two HEAD@{4} commit (initial): one EOF @@ -73,15 +76,15 @@ test_expect_success 'walking multiple reflogs shows all' ' # sort ignores the bits after the timestamp. # # 2. POSIX leaves undefined whether this is a stable sort or not. So - # we use "-k 1" to ensure that we see HEAD before master before + # we use "-k 1" to ensure that we see HEAD before main before # side when breaking ties. { do_walk --date=unix HEAD && do_walk --date=unix side && - do_walk --date=unix master + do_walk --date=unix main } >expect.raw && sort -t "{" -k 2nr -k 1 <expect.raw >expect && - do_walk --date=unix HEAD master side >actual && + do_walk --date=unix HEAD main side >actual && test_cmp expect actual ' diff --git a/t/t1416-ref-transaction-hooks.sh b/t/t1416-ref-transaction-hooks.sh index f6e741c6c0..6c941027a8 100755 --- a/t/t1416-ref-transaction-hooks.sh +++ b/t/t1416-ref-transaction-hooks.sh @@ -2,6 +2,9 @@ test_description='reference transaction hooks' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -53,11 +56,11 @@ test_expect_success 'hook gets all queued updates in prepared state' ' EOF cat >expect <<-EOF && $ZERO_OID $POST_OID HEAD - $ZERO_OID $POST_OID refs/heads/master + $ZERO_OID $POST_OID refs/heads/main EOF git update-ref HEAD POST <<-EOF && update HEAD $ZERO_OID $POST_OID - update refs/heads/master $ZERO_OID $POST_OID + update refs/heads/main $ZERO_OID $POST_OID EOF test_cmp expect actual ' @@ -76,7 +79,7 @@ test_expect_success 'hook gets all queued updates in committed state' ' EOF cat >expect <<-EOF && $ZERO_OID $POST_OID HEAD - $ZERO_OID $POST_OID refs/heads/master + $ZERO_OID $POST_OID refs/heads/main EOF git update-ref HEAD POST && test_cmp expect actual @@ -96,12 +99,12 @@ test_expect_success 'hook gets all queued updates in aborted state' ' EOF cat >expect <<-EOF && $ZERO_OID $POST_OID HEAD - $ZERO_OID $POST_OID refs/heads/master + $ZERO_OID $POST_OID refs/heads/main EOF git update-ref --stdin <<-EOF && start update HEAD POST $ZERO_OID - update refs/heads/master POST $ZERO_OID + update refs/heads/main POST $ZERO_OID abort EOF test_cmp expect actual diff --git a/t/t1430-bad-ref-name.sh b/t/t1430-bad-ref-name.sh index c7878a60ed..b1839e0877 100755 --- a/t/t1430-bad-ref-name.sh +++ b/t/t1430-bad-ref-name.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='Test handling of ref names that check-ref-format rejects' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -17,7 +20,7 @@ test_expect_success 'fast-import: fail on invalid branch name ".badbranchname"' corrupt COMMIT - from refs/heads/master + from refs/heads/main INPUT_END test_must_fail git fast-import <input @@ -32,14 +35,14 @@ test_expect_success 'fast-import: fail on invalid branch name "bad[branch]name"' corrupt COMMIT - from refs/heads/master + from refs/heads/main INPUT_END test_must_fail git fast-import <input ' test_expect_success 'git branch shows badly named ref as warning' ' - cp .git/refs/heads/master .git/refs/heads/broken...ref && + cp .git/refs/heads/main .git/refs/heads/broken...ref && test_when_finished "rm -f .git/refs/heads/broken...ref" && git branch >output 2>error && test_i18ngrep -e "ignoring ref with broken name refs/heads/broken\.\.\.ref" error && @@ -47,7 +50,7 @@ test_expect_success 'git branch shows badly named ref as warning' ' ' test_expect_success 'branch -d can delete badly named ref' ' - cp .git/refs/heads/master .git/refs/heads/broken...ref && + cp .git/refs/heads/main .git/refs/heads/broken...ref && test_when_finished "rm -f .git/refs/heads/broken...ref" && git branch -d broken...ref && git branch >output 2>error && @@ -56,7 +59,7 @@ test_expect_success 'branch -d can delete badly named ref' ' ' test_expect_success 'branch -D can delete badly named ref' ' - cp .git/refs/heads/master .git/refs/heads/broken...ref && + cp .git/refs/heads/main .git/refs/heads/broken...ref && test_when_finished "rm -f .git/refs/heads/broken...ref" && git branch -D broken...ref && git branch >output 2>error && @@ -98,17 +101,17 @@ test_expect_success 'branch -m cannot rename to a bad ref name' ' test_might_fail git branch -D goodref && git branch goodref && test_must_fail git branch -m goodref broken...ref && - test_cmp_rev master goodref && + test_cmp_rev main goodref && git branch >output 2>error && ! grep -e "broken\.\.\.ref" error && ! grep -e "broken\.\.\.ref" output ' test_expect_failure 'branch -m can rename from a bad ref name' ' - cp .git/refs/heads/master .git/refs/heads/broken...ref && + cp .git/refs/heads/main .git/refs/heads/broken...ref && test_when_finished "rm -f .git/refs/heads/broken...ref" && git branch -m broken...ref renamed && - test_cmp_rev master renamed && + test_cmp_rev main renamed && git branch >output 2>error && ! grep -e "broken\.\.\.ref" error && ! grep -e "broken\.\.\.ref" output @@ -122,7 +125,7 @@ test_expect_success 'push cannot create a badly named ref' ' ! grep -e "broken\.\.\.ref" output ' -test_expect_failure C_LOCALE_OUTPUT 'push --mirror can delete badly named ref' ' +test_expect_failure 'push --mirror can delete badly named ref' ' top=$(pwd) && git init src && git init dest && @@ -135,7 +138,7 @@ test_expect_failure C_LOCALE_OUTPUT 'push --mirror can delete badly named ref' ' cd dest && test_commit two && git checkout --detach && - cp .git/refs/heads/master .git/refs/heads/broken...ref + cp .git/refs/heads/main .git/refs/heads/broken...ref ) && git -C src push --mirror "file://$top/dest" && git -C dest branch >output 2>error && @@ -146,7 +149,7 @@ test_expect_failure C_LOCALE_OUTPUT 'push --mirror can delete badly named ref' ' test_expect_success 'rev-parse skips symref pointing to broken name' ' test_when_finished "rm -f .git/refs/heads/broken...ref" && git branch shadow one && - cp .git/refs/heads/master .git/refs/heads/broken...ref && + cp .git/refs/heads/main .git/refs/heads/broken...ref && printf "ref: refs/heads/broken...ref\n" >.git/refs/tags/shadow && test_when_finished "rm -f .git/refs/tags/shadow" && git rev-parse --verify one >expect && @@ -156,11 +159,11 @@ test_expect_success 'rev-parse skips symref pointing to broken name' ' ' test_expect_success 'for-each-ref emits warnings for broken names' ' - cp .git/refs/heads/master .git/refs/heads/broken...ref && + cp .git/refs/heads/main .git/refs/heads/broken...ref && test_when_finished "rm -f .git/refs/heads/broken...ref" && printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && test_when_finished "rm -f .git/refs/heads/badname" && - printf "ref: refs/heads/master\n" >.git/refs/heads/broken...symref && + printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref && test_when_finished "rm -f .git/refs/heads/broken...symref" && git for-each-ref >output 2>error && ! grep -e "broken\.\.\.ref" output && @@ -172,7 +175,7 @@ test_expect_success 'for-each-ref emits warnings for broken names' ' ' test_expect_success 'update-ref -d can delete broken name' ' - cp .git/refs/heads/master .git/refs/heads/broken...ref && + cp .git/refs/heads/main .git/refs/heads/broken...ref && test_when_finished "rm -f .git/refs/heads/broken...ref" && git update-ref -d refs/heads/broken...ref >output 2>error && test_must_be_empty output && @@ -183,7 +186,7 @@ test_expect_success 'update-ref -d can delete broken name' ' ' test_expect_success 'branch -d can delete broken name' ' - cp .git/refs/heads/master .git/refs/heads/broken...ref && + cp .git/refs/heads/main .git/refs/heads/broken...ref && test_when_finished "rm -f .git/refs/heads/broken...ref" && git branch -d broken...ref >output 2>error && test_i18ngrep "Deleted branch broken...ref (was broken)" output && @@ -194,7 +197,7 @@ test_expect_success 'branch -d can delete broken name' ' ' test_expect_success 'update-ref --no-deref -d can delete symref to broken name' ' - cp .git/refs/heads/master .git/refs/heads/broken...ref && + cp .git/refs/heads/main .git/refs/heads/broken...ref && test_when_finished "rm -f .git/refs/heads/broken...ref" && printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && test_when_finished "rm -f .git/refs/heads/badname" && @@ -205,7 +208,7 @@ test_expect_success 'update-ref --no-deref -d can delete symref to broken name' ' test_expect_success 'branch -d can delete symref to broken name' ' - cp .git/refs/heads/master .git/refs/heads/broken...ref && + cp .git/refs/heads/main .git/refs/heads/broken...ref && test_when_finished "rm -f .git/refs/heads/broken...ref" && printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && test_when_finished "rm -f .git/refs/heads/badname" && @@ -234,7 +237,7 @@ test_expect_success 'branch -d can delete dangling symref to broken name' ' ' test_expect_success 'update-ref -d can delete broken name through symref' ' - cp .git/refs/heads/master .git/refs/heads/broken...ref && + cp .git/refs/heads/main .git/refs/heads/broken...ref && test_when_finished "rm -f .git/refs/heads/broken...ref" && printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && test_when_finished "rm -f .git/refs/heads/badname" && @@ -245,7 +248,7 @@ test_expect_success 'update-ref -d can delete broken name through symref' ' ' test_expect_success 'update-ref --no-deref -d can delete symref with broken name' ' - printf "ref: refs/heads/master\n" >.git/refs/heads/broken...symref && + printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref && test_when_finished "rm -f .git/refs/heads/broken...symref" && git update-ref --no-deref -d refs/heads/broken...symref >output 2>error && test_path_is_missing .git/refs/heads/broken...symref && @@ -254,11 +257,11 @@ test_expect_success 'update-ref --no-deref -d can delete symref with broken name ' test_expect_success 'branch -d can delete symref with broken name' ' - printf "ref: refs/heads/master\n" >.git/refs/heads/broken...symref && + printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref && test_when_finished "rm -f .git/refs/heads/broken...symref" && git branch -d broken...symref >output 2>error && test_path_is_missing .git/refs/heads/broken...symref && - test_i18ngrep "Deleted branch broken...symref (was refs/heads/master)" output && + test_i18ngrep "Deleted branch broken...symref (was refs/heads/main)" output && test_must_be_empty error ' @@ -296,37 +299,37 @@ test_expect_success 'update-ref -d cannot delete absolute path' ' ' test_expect_success 'update-ref --stdin fails create with bad ref name' ' - echo "create ~a refs/heads/master" >stdin && + echo "create ~a refs/heads/main" >stdin && test_must_fail git update-ref --stdin <stdin 2>err && grep "fatal: invalid ref format: ~a" err ' test_expect_success 'update-ref --stdin fails update with bad ref name' ' - echo "update ~a refs/heads/master" >stdin && + echo "update ~a refs/heads/main" >stdin && test_must_fail git update-ref --stdin <stdin 2>err && grep "fatal: invalid ref format: ~a" err ' test_expect_success 'update-ref --stdin fails delete with bad ref name' ' - echo "delete ~a refs/heads/master" >stdin && + echo "delete ~a refs/heads/main" >stdin && test_must_fail git update-ref --stdin <stdin 2>err && grep "fatal: invalid ref format: ~a" err ' test_expect_success 'update-ref --stdin -z fails create with bad ref name' ' - printf "%s\0" "create ~a " refs/heads/master >stdin && + printf "%s\0" "create ~a " refs/heads/main >stdin && test_must_fail git update-ref -z --stdin <stdin 2>err && grep "fatal: invalid ref format: ~a " err ' test_expect_success 'update-ref --stdin -z fails update with bad ref name' ' - printf "%s\0" "update ~a" refs/heads/master "" >stdin && + printf "%s\0" "update ~a" refs/heads/main "" >stdin && test_must_fail git update-ref -z --stdin <stdin 2>err && grep "fatal: invalid ref format: ~a" err ' test_expect_success 'update-ref --stdin -z fails delete with bad ref name' ' - printf "%s\0" "delete ~a" refs/heads/master >stdin && + printf "%s\0" "delete ~a" refs/heads/main >stdin && test_must_fail git update-ref -z --stdin <stdin 2>err && grep "fatal: invalid ref format: ~a" err ' diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index b17f5c21fb..5071ac63a5 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -3,7 +3,7 @@ test_description='git fsck random collection of tests * (HEAD) B -* (master) A +* (main) A ' . ./test-lib.sh @@ -40,17 +40,13 @@ test_expect_success 'HEAD is part of refs, valid objects appear valid' ' # specific corruption you test afterwards, lest a later test trip over # it. -test_expect_success 'setup: helpers for corruption tests' ' - sha1_file() { - remainder=${1#??} && - firsttwo=${1%$remainder} && - echo ".git/objects/$firsttwo/$remainder" - } && +sha1_file () { + git rev-parse --git-path objects/$(test_oid_to_path "$1") +} - remove_object() { - rm "$(sha1_file "$1")" - } -' +remove_object () { + rm "$(sha1_file "$1")" +} test_expect_success 'object with bad sha1' ' sha=$(echo blob | git hash-object -w --stdin) && @@ -380,7 +376,7 @@ test_expect_success 'tag with incorrect tag name & missing tagger' ' warning in tag $tag: badTagName: invalid '\''tag'\'' name: wrong name format warning in tag $tag: missingTaggerEntry: invalid format - expected '\''tagger'\'' line EOF - test_i18ncmp expect out + test_cmp expect out ' test_expect_success 'tag with bad tagger' ' @@ -662,13 +658,15 @@ test_expect_success 'fsck --name-objects' ' git init name-objects && ( cd name-objects && + git config core.logAllRefUpdates false && test_commit julius caesar.t && - test_commit augustus && - test_commit caesar && + test_commit augustus44 && + test_commit caesar && 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 + git tag -d julius && + test_must_fail git fsck --name-objects >out && + test_i18ngrep "$tree (refs/tags/augustus44\\^:" out ) ' @@ -806,7 +804,7 @@ test_expect_success 'fsck notices dangling objects' ' git fsck >actual && # the output order is non-deterministic, as it comes from a hash sort <actual >actual.sorted && - test_i18ncmp expect actual.sorted + test_cmp expect actual.sorted ) ' @@ -816,7 +814,7 @@ test_expect_success 'fsck --connectivity-only notices dangling objects' ' git fsck --connectivity-only >actual && # the output order is non-deterministic, as it comes from a hash sort <actual >actual.sorted && - test_i18ncmp expect actual.sorted + test_cmp expect actual.sorted ) ' diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh index 408b97d5af..1c2df08333 100755 --- a/t/t1500-rev-parse.sh +++ b/t/t1500-rev-parse.sh @@ -1,8 +1,21 @@ #!/bin/sh test_description='test git rev-parse' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh +test_one () { + dir="$1" && + expect="$2" && + shift && + shift && + echo "$expect" >expect && + git -C "$dir" rev-parse "$@" >actual && + test_cmp expect actual +} + # usage: [options] label is-bare is-inside-git is-inside-work prefix git-dir absolute-git-dir test_rev_parse () { d= @@ -60,7 +73,13 @@ ROOT=$(pwd) test_expect_success 'setup' ' mkdir -p sub/dir work && - cp -R .git repo.git + cp -R .git repo.git && + git checkout -B main && + test_commit abc && + git checkout -b side && + test_commit def && + git checkout main && + git worktree add worktree side ' test_rev_parse toplevel false false true '' .git "$ROOT/.git" @@ -88,6 +107,49 @@ test_rev_parse -C work -g ../repo.git -b t 'GIT_DIR=../repo.git, core.bare = tru test_rev_parse -C work -g ../repo.git -b u 'GIT_DIR=../repo.git, core.bare undefined' false false true '' +test_expect_success 'rev-parse --path-format=absolute' ' + test_one "." "$ROOT/.git" --path-format=absolute --git-dir && + test_one "." "$ROOT/.git" --path-format=absolute --git-common-dir && + test_one "sub/dir" "$ROOT/.git" --path-format=absolute --git-dir && + test_one "sub/dir" "$ROOT/.git" --path-format=absolute --git-common-dir && + test_one "worktree" "$ROOT/.git/worktrees/worktree" --path-format=absolute --git-dir && + test_one "worktree" "$ROOT/.git" --path-format=absolute --git-common-dir && + test_one "." "$ROOT" --path-format=absolute --show-toplevel && + test_one "." "$ROOT/.git/objects" --path-format=absolute --git-path objects && + test_one "." "$ROOT/.git/objects/foo/bar/baz" --path-format=absolute --git-path objects/foo/bar/baz +' + +test_expect_success 'rev-parse --path-format=relative' ' + test_one "." ".git" --path-format=relative --git-dir && + test_one "." ".git" --path-format=relative --git-common-dir && + test_one "sub/dir" "../../.git" --path-format=relative --git-dir && + test_one "sub/dir" "../../.git" --path-format=relative --git-common-dir && + test_one "worktree" "../.git/worktrees/worktree" --path-format=relative --git-dir && + test_one "worktree" "../.git" --path-format=relative --git-common-dir && + test_one "." "./" --path-format=relative --show-toplevel && + test_one "." ".git/objects" --path-format=relative --git-path objects && + test_one "." ".git/objects/foo/bar/baz" --path-format=relative --git-path objects/foo/bar/baz +' + +test_expect_success '--path-format=relative does not affect --absolute-git-dir' ' + git rev-parse --path-format=relative --absolute-git-dir >actual && + echo "$ROOT/.git" >expect && + test_cmp expect actual +' + +test_expect_success '--path-format can change in the middle of the command line' ' + git rev-parse --path-format=absolute --git-dir --path-format=relative --git-path objects/foo/bar >actual && + cat >expect <<-EOF && + $ROOT/.git + .git/objects/foo/bar + EOF + test_cmp expect actual +' + +test_expect_success '--path-format does not segfault without an argument' ' + test_must_fail git rev-parse --path-format +' + test_expect_success 'git-common-dir from worktree root' ' echo .git >expect && git rev-parse --git-common-dir >actual && @@ -174,8 +236,8 @@ test_expect_success 'showing the superproject correctly' ' test_commit -C super/dir/sub branch1_commit && git -C super add dir/sub && test_commit -C super branch1_commit && - git -C super checkout -b branch2 master && - git -C super/dir/sub checkout -b branch2 master && + git -C super checkout -b branch2 main && + git -C super/dir/sub checkout -b branch2 main && test_commit -C super/dir/sub branch2_commit && git -C super add dir/sub && test_commit -C super branch2_commit && @@ -185,4 +247,19 @@ test_expect_success 'showing the superproject correctly' ' test_cmp expect out ' +# at least one external project depends on this behavior: +test_expect_success 'rev-parse --since= unsqueezed ordering' ' + x1=--since=1970-01-01T00:00:01Z && + x2=--since=1970-01-01T00:00:02Z && + x3=--since=1970-01-01T00:00:03Z && + git rev-parse $x1 $x1 $x3 $x2 >actual && + cat >expect <<-EOF && + --max-age=1 + --max-age=1 + --max-age=3 + --max-age=2 + EOF + test_cmp expect actual +' + test_done diff --git a/t/t1502-rev-parse-parseopt.sh b/t/t1502-rev-parse-parseopt.sh index a859abedf5..b29563fc99 100755 --- a/t/t1502-rev-parse-parseopt.sh +++ b/t/t1502-rev-parse-parseopt.sh @@ -95,7 +95,7 @@ test_expect_success 'test --parseopt help output' ' |EOF END_EXPECT test_expect_code 129 git rev-parse --parseopt -- -h > output < optionspec && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'test --parseopt help output no switches' ' @@ -108,7 +108,7 @@ test_expect_success 'test --parseopt help output no switches' ' |EOF END_EXPECT test_expect_code 129 git rev-parse --parseopt -- -h > output < optionspec_no_switches && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'test --parseopt help output hidden switches' ' @@ -121,7 +121,7 @@ test_expect_success 'test --parseopt help output hidden switches' ' |EOF END_EXPECT test_expect_code 129 git rev-parse --parseopt -- -h > output < optionspec_only_hidden_switches && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'test --parseopt help-all output hidden switches' ' @@ -136,7 +136,7 @@ test_expect_success 'test --parseopt help-all output hidden switches' ' |EOF END_EXPECT test_expect_code 129 git rev-parse --parseopt -- --help-all > output < optionspec_only_hidden_switches && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'test --parseopt invalid switch help output' ' @@ -176,7 +176,7 @@ test_expect_success 'test --parseopt invalid switch help output' ' | END_EXPECT test_expect_code 129 git rev-parse --parseopt -- --does-not-exist 1>/dev/null 2>output < optionspec && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'setup expect.1' " diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh index dc9fe3cbf1..bf08102391 100755 --- a/t/t1503-rev-parse-verify.sh +++ b/t/t1503-rev-parse-verify.sh @@ -6,6 +6,9 @@ test_description='test git rev-parse --verify' exec </dev/null +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh add_line_into_file() @@ -51,8 +54,8 @@ test_expect_success 'works with one good rev' ' test "$rev_hash3" = "$HASH3" && rev_hash4=$(git rev-parse --verify $HASH4) && test "$rev_hash4" = "$HASH4" && - rev_master=$(git rev-parse --verify master) && - test "$rev_master" = "$HASH4" && + rev_main=$(git rev-parse --verify main) && + test "$rev_main" = "$HASH4" && rev_head=$(git rev-parse --verify HEAD) && test "$rev_head" = "$HASH4" ' @@ -86,8 +89,8 @@ test_expect_success 'fails silently when using -q' ' test_expect_success 'fails silently when using -q with deleted reflogs' ' ref=$(git rev-parse HEAD) && git update-ref --create-reflog -m "message for refs/test" refs/test "$ref" && - git reflog delete --updateref --rewrite refs/test@{0} && - test_must_fail git rev-parse -q --verify refs/test@{0} >error 2>&1 && + git reflog delete --updateref --rewrite refs/test@{1} && + test_must_fail git rev-parse -q --verify refs/test@{1} >error 2>&1 && test_must_be_empty error ' @@ -116,27 +119,27 @@ test_expect_success 'no stdout output on error' ' ' test_expect_success 'use --default' ' - git rev-parse --verify --default master && - git rev-parse --verify --default master HEAD && - git rev-parse --default master --verify && - git rev-parse --default master --verify HEAD && - git rev-parse --verify HEAD --default master && - test_must_fail git rev-parse --verify foo --default master && + git rev-parse --verify --default main && + git rev-parse --verify --default main HEAD && + git rev-parse --default main --verify && + git rev-parse --default main --verify HEAD && + git rev-parse --verify HEAD --default main && + test_must_fail git rev-parse --verify foo --default main && test_must_fail git rev-parse --default HEAD --verify bar && test_must_fail git rev-parse --verify --default HEAD baz && test_must_fail git rev-parse --default foo --verify && test_must_fail git rev-parse --verify --default bar ' -test_expect_success 'master@{n} for various n' ' +test_expect_success 'main@{n} for various n' ' N=$(git reflog | wc -l) && Nm1=$(($N-1)) && Np1=$(($N+1)) && - git rev-parse --verify master@{0} && - git rev-parse --verify master@{1} && - git rev-parse --verify master@{$Nm1} && - test_must_fail git rev-parse --verify master@{$N} && - test_must_fail git rev-parse --verify master@{$Np1} + git rev-parse --verify main@{0} && + git rev-parse --verify main@{1} && + git rev-parse --verify main@{$Nm1} && + test_must_fail git rev-parse --verify main@{$N} && + test_must_fail git rev-parse --verify main@{$Np1} ' test_expect_success SYMLINKS 'ref resolution not confused by broken symlinks' ' diff --git a/t/t1505-rev-parse-last.sh b/t/t1505-rev-parse-last.sh index 4969edb314..2803ca9489 100755 --- a/t/t1505-rev-parse-last.sh +++ b/t/t1505-rev-parse-last.sh @@ -2,6 +2,9 @@ test_description='test @{-N} syntax' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh @@ -20,12 +23,12 @@ test_expect_success 'setup' ' make_commit 3 && git checkout side && make_commit 4 && - git merge master && - git checkout master + git merge main && + git checkout main ' -# 1 -- 2 -- 3 master +# 1 -- 2 -- 3 main # \ \ # \ \ # --- 4 --- 5 side @@ -49,7 +52,7 @@ test_expect_success '@{-1}@{1} works' ' ' test_expect_success '@{-2} works' ' - test_cmp_rev master @{-2} + test_cmp_rev main @{-2} ' test_expect_success '@{-3} fails' ' diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh index e2ae15a2cf..65a154a8a2 100755 --- a/t/t1506-rev-parse-diagnosis.sh +++ b/t/t1506-rev-parse-diagnosis.sh @@ -4,6 +4,9 @@ test_description='test git rev-parse diagnosis for invalid argument' exec </dev/null +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_did_you_mean () @@ -12,7 +15,7 @@ test_did_you_mean () fatal: path '$2$3' $4, but not ${5:-$SQ$3$SQ} hint: Did you mean '$1:$2$3'${2:+ aka $SQ$1:./$3$SQ}? EOF - test_i18ncmp expected error + test_cmp expected error } HASH_file= @@ -137,10 +140,10 @@ test_expect_success 'incorrect file in :path and :N:path' ' ' test_expect_success 'invalid @{n} reference' ' - test_must_fail git rev-parse master@{99999} >output 2>error && + test_must_fail git rev-parse main@{99999} >output 2>error && test_must_be_empty output && test_i18ngrep "log for [^ ]* only has [0-9][0-9]* entries" error && - test_must_fail git rev-parse --verify master@{99999} >output 2>error && + test_must_fail git rev-parse --verify main@{99999} >output 2>error && test_must_be_empty output && test_i18ngrep "log for [^ ]* only has [0-9][0-9]* entries" error ' diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh index dfc0d96d8a..c34714ffe3 100755 --- a/t/t1507-rev-parse-upstream.sh +++ b/t/t1507-rev-parse-upstream.sh @@ -2,6 +2,9 @@ test_description='test <branch>@{upstream} syntax' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh @@ -10,20 +13,20 @@ test_expect_success 'setup' ' test_commit 1 && git checkout -b side && test_commit 2 && - git checkout master && + git checkout main && git clone . clone && test_commit 3 && (cd clone && test_commit 4 && git branch --track my-side origin/side && - git branch --track local-master master && + git branch --track local-main main && git branch --track fun@ny origin/side && git branch --track @funny origin/side && git branch --track funny@ origin/side && - git remote add -t master master-only .. && - git fetch master-only && + git remote add -t main main-only .. && + git fetch main-only && git branch bad-upstream && - git config branch.bad-upstream.remote master-only && + git config branch.bad-upstream.remote main-only && git config branch.bad-upstream.merge refs/heads/side ) ' @@ -39,7 +42,7 @@ error_message () { } test_expect_success '@{upstream} resolves to correct full name' ' - echo refs/remotes/origin/master >expect && + echo refs/remotes/origin/main >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 && @@ -49,7 +52,7 @@ test_expect_success '@{upstream} resolves to correct full name' ' ' test_expect_success '@{u} resolves to correct full name' ' - echo refs/remotes/origin/master >expect && + echo refs/remotes/origin/main >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 && @@ -132,7 +135,7 @@ test_expect_success 'checkout -b new my-side@{u} forks from the same' ' test_expect_success 'merge my-side@{u} records the correct name' ' ( cd clone && - git checkout master && + git checkout main && test_might_fail git branch -D new && git branch -t new my-side@{u} && git merge -s ours new@{u} && @@ -143,24 +146,24 @@ test_expect_success 'merge my-side@{u} records the correct name' ' ' test_expect_success 'branch -d other@{u}' ' - git checkout -t -b other master && + git checkout -t -b other main && git branch -d @{u} && - git for-each-ref refs/heads/master >actual && + git for-each-ref refs/heads/main >actual && test_must_be_empty actual ' test_expect_success 'checkout other@{u}' ' - git branch -f master HEAD && - git checkout -t -b another master && + git branch -f main HEAD && + git checkout -t -b another main && git checkout @{u} && git symbolic-ref HEAD >actual && - echo refs/heads/master >expect && + echo refs/heads/main >expect && test_cmp expect actual ' 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 && + echo refs/heads/main >expect && + git -C clone rev-parse --symbolic-full-name local-main@{u} >actual && test_cmp expect actual ' @@ -169,15 +172,15 @@ test_expect_success 'branch@{u} error message when no upstream' ' fatal: no upstream configured for branch ${SQ}non-tracking${SQ} EOF error_message non-tracking@{u} && - test_i18ncmp expect error + test_cmp expect error ' 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}main${SQ} EOF test_must_fail git rev-parse --verify @{u} 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'branch@{u} error message with misspelt branch' ' @@ -185,7 +188,7 @@ test_expect_success 'branch@{u} error message with misspelt branch' ' fatal: no such branch: ${SQ}no-such-branch${SQ} EOF error_message no-such-branch@{u} && - test_i18ncmp expect error + test_cmp expect error ' test_expect_success '@{u} error message when not on a branch' ' @@ -194,7 +197,7 @@ test_expect_success '@{u} error message when not on a branch' ' EOF git checkout HEAD^0 && test_must_fail git rev-parse --verify @{u} 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'branch@{u} error message if upstream branch not fetched' ' @@ -202,20 +205,20 @@ test_expect_success 'branch@{u} error message if upstream branch not fetched' ' 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 + test_cmp expect error ' test_expect_success 'pull works when tracking a local branch' ' ( cd clone && - git checkout local-master && + git checkout local-main && git pull ) ' # makes sense if the previous one succeeded test_expect_success '@{u} works when tracking a local branch' ' - echo refs/heads/master >expect && + echo refs/heads/main >expect && git -C clone rev-parse --symbolic-full-name @{u} >actual && test_cmp expect actual ' @@ -224,7 +227,7 @@ 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: main@{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 @@ -239,7 +242,7 @@ 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: main@{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 diff --git a/t/t1508-at-combinations.sh b/t/t1508-at-combinations.sh index 4a9964e9dc..87a4286414 100755 --- a/t/t1508-at-combinations.sh +++ b/t/t1508-at-combinations.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='test various @{X} syntax combinations together' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh check() { @@ -30,8 +33,8 @@ fail() { } test_expect_success 'setup' ' - test_commit master-one && - test_commit master-two && + test_commit main-one && + test_commit main-two && git checkout -b upstream-branch && test_commit upstream-one && test_commit upstream-two && @@ -47,7 +50,7 @@ test_expect_success 'setup' ' git checkout -b new-branch && test_commit new-one && test_commit new-two && - git branch -u master old-branch && + git branch -u main old-branch && git branch -u upstream-branch new-branch ' @@ -62,8 +65,8 @@ check "@{-1}@{1}" commit old-one check "@{u}" ref refs/heads/upstream-branch check "HEAD@{u}" ref refs/heads/upstream-branch check "@{u}@{1}" commit upstream-one -check "@{-1}@{u}" ref refs/heads/master -check "@{-1}@{u}@{1}" commit master-one +check "@{-1}@{u}" ref refs/heads/main +check "@{-1}@{u}@{1}" commit main-one check "@" commit new-two check "@@{u}" ref refs/heads/upstream-branch check "@@/at-test" ref refs/heads/@@/at-test @@ -99,4 +102,17 @@ test_expect_success 'create path with @' ' check "@:normal" blob content check "@:fun@ny" blob content +test_expect_success '@{1} works with only one reflog entry' ' + git checkout -B newbranch main && + git reflog expire --expire=now refs/heads/newbranch && + git commit --allow-empty -m "first after expiration" && + test_cmp_rev newbranch~ newbranch@{1} +' + +test_expect_success '@{0} works with empty reflog' ' + git checkout -B newbranch main && + git reflog expire --expire=now refs/heads/newbranch && + test_cmp_rev newbranch newbranch@{0} +' + test_done diff --git a/t/t1509-root-work-tree.sh b/t/t1509-root-work-tree.sh index fd2f7abf1c..553a3f601b 100755 --- a/t/t1509-root-work-tree.sh +++ b/t/t1509-root-work-tree.sh @@ -221,7 +221,7 @@ test_expect_success 'setup' ' rm -rf /.git && echo "Initialized empty Git repository in /.git/" > expected && git init > result && - test_i18ncmp expected result + test_cmp expected result ' test_vars 'auto gitdir, root' ".git" "/" "" @@ -246,7 +246,7 @@ test_expect_success 'setup' ' cd / && echo "Initialized empty Git repository in /" > expected && git init --bare > result && - test_i18ncmp expected result + test_cmp expected result ' test_vars 'auto gitdir, root' "." "" "" diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh index e0a49a651f..6ecfed86bc 100755 --- a/t/t1511-rev-parse-caret.sh +++ b/t/t1511-rev-parse-caret.sh @@ -2,6 +2,9 @@ test_description='tests for ref^{stuff}' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -15,7 +18,7 @@ test_expect_success 'setup' ' git commit -m Initial && git tag -a -m commit commit-tag && git branch ref && - git checkout master && + git checkout main && echo modified >>a-blob && git add -u && git commit -m Modified && @@ -73,52 +76,52 @@ test_expect_success 'ref^{tag}' ' ' test_expect_success 'ref^{/.}' ' - git rev-parse master >expected && - git rev-parse master^{/.} >actual && + git rev-parse main >expected && + git rev-parse main^{/.} >actual && test_cmp expected actual ' test_expect_success 'ref^{/non-existent}' ' - test_must_fail git rev-parse master^{/non-existent} + test_must_fail git rev-parse main^{/non-existent} ' test_expect_success 'ref^{/Initial}' ' git rev-parse ref >expected && - git rev-parse master^{/Initial} >actual && + git rev-parse main^{/Initial} >actual && test_cmp expected actual ' test_expect_success 'ref^{/!Exp}' ' - test_must_fail git rev-parse master^{/!Exp} + test_must_fail git rev-parse main^{/!Exp} ' test_expect_success 'ref^{/!}' ' - test_must_fail git rev-parse master^{/!} + test_must_fail git rev-parse main^{/!} ' test_expect_success 'ref^{/!!Exp}' ' git rev-parse expref >expected && - git rev-parse master^{/!!Exp} >actual && + git rev-parse main^{/!!Exp} >actual && test_cmp expected actual ' test_expect_success 'ref^{/!-}' ' - test_must_fail git rev-parse master^{/!-} + test_must_fail git rev-parse main^{/!-} ' test_expect_success 'ref^{/!-.}' ' - test_must_fail git rev-parse master^{/!-.} + test_must_fail git rev-parse main^{/!-.} ' test_expect_success 'ref^{/!-non-existent}' ' - git rev-parse master >expected && - git rev-parse master^{/!-non-existent} >actual && + git rev-parse main >expected && + git rev-parse main^{/!-non-existent} >actual && test_cmp expected actual ' test_expect_success 'ref^{/!-Changed}' ' git rev-parse expref >expected && - git rev-parse master^{/!-Changed} >actual && + git rev-parse main^{/!-Changed} >actual && test_cmp expected actual ' diff --git a/t/t1512-rev-parse-disambiguation.sh b/t/t1512-rev-parse-disambiguation.sh index 18fa6cf40d..7891a6becf 100755 --- a/t/t1512-rev-parse-disambiguation.sh +++ b/t/t1512-rev-parse-disambiguation.sh @@ -20,6 +20,9 @@ one tagged as v1.0.0. They all have one regular file each. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh if ! test_have_prereq SHA1 @@ -48,7 +51,7 @@ test_expect_success 'blob and tree' ' test_expect_success 'warn ambiguity when no candidate matches type hint' ' test_must_fail git rev-parse --verify 000000000^{commit} 2>actual && - test_i18ngrep "short SHA1 000000000 is ambiguous" actual + test_i18ngrep "short object ID 000000000 is ambiguous" actual ' test_expect_success 'disambiguate tree-ish' ' @@ -212,7 +215,7 @@ test_expect_success 'more history' ' side=$(git rev-parse HEAD) && # commit 000000000066 - git checkout master && + git checkout main && # If you use recursive, merge will fail and you will need to # clean up a0blgqsjc as well. If you use resolve, merge will @@ -311,39 +314,39 @@ test_expect_success 'ambiguous short sha1 ref' ' grep "refname.*${REF}.*ambiguous" err ' -test_expect_success C_LOCALE_OUTPUT 'ambiguity errors are not repeated (raw)' ' +test_expect_success 'ambiguity errors are not repeated (raw)' ' test_must_fail git rev-parse 00000 2>stderr && grep "is ambiguous" stderr >errors && test_line_count = 1 errors ' -test_expect_success C_LOCALE_OUTPUT 'ambiguity errors are not repeated (treeish)' ' +test_expect_success 'ambiguity errors are not repeated (treeish)' ' test_must_fail git rev-parse 00000:foo 2>stderr && grep "is ambiguous" stderr >errors && test_line_count = 1 errors ' -test_expect_success C_LOCALE_OUTPUT 'ambiguity errors are not repeated (peel)' ' +test_expect_success 'ambiguity errors are not repeated (peel)' ' test_must_fail git rev-parse 00000^{commit} 2>stderr && grep "is ambiguous" stderr >errors && test_line_count = 1 errors ' -test_expect_success C_LOCALE_OUTPUT 'ambiguity hints' ' +test_expect_success 'ambiguity hints' ' test_must_fail git rev-parse 000000000 2>stderr && grep ^hint: stderr >hints && # 16 candidates, plus one intro line test_line_count = 17 hints ' -test_expect_success C_LOCALE_OUTPUT 'ambiguity hints respect type' ' +test_expect_success '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 test_line_count = 7 hints ' -test_expect_success C_LOCALE_OUTPUT 'failed type-selector still shows hint' ' +test_expect_success 'failed type-selector still shows hint' ' # these two blobs share the same prefix "ee3d", but neither # will pass for a commit echo 851 | git hash-object --stdin -w && @@ -367,7 +370,7 @@ test_expect_success 'core.disambiguate does not override context' ' git -c core.disambiguate=committish rev-parse $sha1^{tree} ' -test_expect_success C_LOCALE_OUTPUT 'ambiguous commits are printed by type first, then hash order' ' +test_expect_success 'ambiguous commits are printed by type first, then hash order' ' test_must_fail git rev-parse 0000 2>stderr && grep ^hint: stderr >hints && grep 0000 hints >objects && diff --git a/t/t1513-rev-parse-prefix.sh b/t/t1513-rev-parse-prefix.sh index 87ec3ae714..5f437be8c9 100755 --- a/t/t1513-rev-parse-prefix.sh +++ b/t/t1513-rev-parse-prefix.sh @@ -2,6 +2,9 @@ test_description='Tests for rev-parse --prefix' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -76,9 +79,9 @@ test_expect_success 'disambiguate path with valid prefix' ' ' test_expect_success 'file and refs with prefix' ' - git rev-parse --prefix sub1/ master file1 >actual && + git rev-parse --prefix sub1/ main file1 >actual && cat <<-EOF >expected && - $(git rev-parse master) + $(git rev-parse main) sub1/file1 EOF test_cmp expected actual diff --git a/t/t1514-rev-parse-push.sh b/t/t1514-rev-parse-push.sh index 788cc91e45..d868a08110 100755 --- a/t/t1514-rev-parse-push.sh +++ b/t/t1514-rev-parse-push.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='test <branch>@{push} syntax' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh resolve () { @@ -16,24 +19,24 @@ test_expect_success 'setup' ' git remote add other other.git && test_commit base && git push origin HEAD && - git branch --set-upstream-to=origin/master master && - git branch --track topic origin/master && + git branch --set-upstream-to=origin/main main && + git branch --track topic origin/main && git push origin topic && git push other topic ' test_expect_success '@{push} with default=nothing' ' test_config push.default nothing && - test_must_fail git rev-parse master@{push} && - test_must_fail git rev-parse master@{PUSH} && - test_must_fail git rev-parse master@{PuSH} + test_must_fail git rev-parse main@{push} && + test_must_fail git rev-parse main@{PUSH} && + test_must_fail git rev-parse main@{PuSH} ' test_expect_success '@{push} with default=simple' ' test_config push.default simple && - resolve master@{push} refs/remotes/origin/master && - resolve master@{PUSH} refs/remotes/origin/master && - resolve master@{pUSh} refs/remotes/origin/master + resolve main@{push} refs/remotes/origin/main && + resolve main@{PUSH} refs/remotes/origin/main && + resolve main@{pUSh} refs/remotes/origin/main ' test_expect_success 'triangular @{push} fails with default=simple' ' diff --git a/t/t1600-index.sh b/t/t1600-index.sh index b7c31aa86a..c9b9e718b8 100755 --- a/t/t1600-index.sh +++ b/t/t1600-index.sh @@ -18,7 +18,7 @@ test_expect_success 'bogus GIT_INDEX_VERSION issues warning' ' warning: GIT_INDEX_VERSION set, but the value is invalid. Using version Z EOF - test_i18ncmp expect.err actual.err + test_cmp expect.err actual.err ) ' @@ -32,7 +32,7 @@ test_expect_success 'out of bounds GIT_INDEX_VERSION issues warning' ' warning: GIT_INDEX_VERSION set, but the value is invalid. Using version Z EOF - test_i18ncmp expect.err actual.err + test_cmp expect.err actual.err ) ' @@ -55,7 +55,7 @@ test_expect_success 'out of bounds index.version issues warning' ' warning: index.version set, but the value is invalid. Using version Z EOF - test_i18ncmp expect.err actual.err + test_cmp expect.err actual.err ) ' diff --git a/t/t1700-split-index.sh b/t/t1700-split-index.sh index 12a5568844..986baa612e 100755 --- a/t/t1700-split-index.sh +++ b/t/t1700-split-index.sh @@ -2,6 +2,9 @@ test_description='split index mode tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # We need total control of index splitting here @@ -496,7 +499,7 @@ test_expect_success 'do not refresh null base index' ' test_commit initial && git checkout -b side-branch && test_commit extra && - git checkout master && + git checkout main && git update-index --split-index && test_commit more && # must not write a new shareindex, or we wont catch the problem diff --git a/t/t2006-checkout-index-basic.sh b/t/t2006-checkout-index-basic.sh index 7b25a3572e..7705e3a317 100755 --- a/t/t2006-checkout-index-basic.sh +++ b/t/t2006-checkout-index-basic.sh @@ -77,4 +77,27 @@ do ' done +test_expect_success 'checkout-index --temp correctly reports error on missing blobs' ' + test_when_finished git reset --hard && + missing_blob=$(echo "no such blob here" | git hash-object --stdin) && + cat >objs <<-EOF && + 100644 $missing_blob file + 120000 $missing_blob symlink + EOF + git update-index --index-info <objs && + + test_must_fail git checkout-index --temp symlink file 2>stderr && + test_i18ngrep "unable to read sha1 file of file ($missing_blob)" stderr && + test_i18ngrep "unable to read sha1 file of symlink ($missing_blob)" stderr +' + +test_expect_success 'checkout-index --temp correctly reports error for submodules' ' + git init sub && + test_commit -C sub file && + git submodule add ./sub && + git commit -m sub && + test_must_fail git checkout-index --temp sub 2>stderr && + test_i18ngrep "cannot create temporary submodule sub" stderr +' + test_done diff --git a/t/t2007-checkout-symlink.sh b/t/t2007-checkout-symlink.sh index fc9aad530e..6f0b90ce12 100755 --- a/t/t2007-checkout-symlink.sh +++ b/t/t2007-checkout-symlink.sh @@ -4,6 +4,9 @@ test_description='git checkout to switch between branches with symlink<->dir' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -12,14 +15,14 @@ test_expect_success setup ' echo hello >frotz/filfre && git add frotz/filfre && test_tick && - git commit -m "master has file frotz/filfre" && + git commit -m "main has file frotz/filfre" && git branch side && echo goodbye >nitfol && git add nitfol && test_tick && - git commit -m "master adds file nitfol" && + git commit -m "main adds file nitfol" && git checkout side && @@ -34,13 +37,13 @@ test_expect_success setup ' test_expect_success 'switch from symlink to dir' ' - git checkout master + git checkout main ' -test_expect_success 'Remove temporary directories & switch to master' ' +test_expect_success 'Remove temporary directories & switch to main' ' rm -fr frotz xyzzy nitfol && - git checkout -f master + git checkout -f main ' test_expect_success 'switch from dir to symlink' ' diff --git a/t/t2009-checkout-statinfo.sh b/t/t2009-checkout-statinfo.sh index f3c2152087..b0540636ae 100755 --- a/t/t2009-checkout-statinfo.sh +++ b/t/t2009-checkout-statinfo.sh @@ -2,6 +2,9 @@ test_description='checkout should leave clean stat info' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -21,13 +24,13 @@ test_expect_success 'branch switching' ' git reset --hard && test "$(git diff-files --raw)" = "" && - git checkout master && + git checkout main && test "$(git diff-files --raw)" = "" && git checkout side && test "$(git diff-files --raw)" = "" && - git checkout master && + git checkout main && test "$(git diff-files --raw)" = "" ' @@ -37,13 +40,13 @@ test_expect_success 'path checkout' ' git reset --hard && test "$(git diff-files --raw)" = "" && - git checkout master world && + git checkout main world && test "$(git diff-files --raw)" = "" && git checkout side world && test "$(git diff-files --raw)" = "" && - git checkout master world && + git checkout main world && test "$(git diff-files --raw)" = "" ' diff --git a/t/t2010-checkout-ambiguous.sh b/t/t2010-checkout-ambiguous.sh index 2e47fe01cf..6e8757387d 100755 --- a/t/t2010-checkout-ambiguous.sh +++ b/t/t2010-checkout-ambiguous.sh @@ -2,6 +2,9 @@ test_description='checkout and pathspecs/refspecs ambiguities' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -17,7 +20,7 @@ test_expect_success 'reference must be a tree' ' ' test_expect_success 'branch switching' ' - test "refs/heads/master" = "$(git symbolic-ref HEAD)" && + test "refs/heads/main" = "$(git symbolic-ref HEAD)" && git checkout world -- && test "refs/heads/world" = "$(git symbolic-ref HEAD)" ' @@ -57,7 +60,7 @@ test_expect_success 'disambiguate checking out from a tree-ish' ' ' test_expect_success 'accurate error message with more than one ref' ' - test_must_fail git checkout HEAD master -- 2>actual && + test_must_fail git checkout HEAD main -- 2>actual && test_i18ngrep 2 actual && test_i18ngrep "one reference expected, 2 given" actual ' diff --git a/t/t2011-checkout-invalid-head.sh b/t/t2011-checkout-invalid-head.sh index 0e8d56aa76..e52022e152 100755 --- a/t/t2011-checkout-invalid-head.sh +++ b/t/t2011-checkout-invalid-head.sh @@ -2,6 +2,9 @@ test_description='checkout switching away from an invalid branch' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -11,12 +14,12 @@ test_expect_success 'setup' ' ' test_expect_success 'checkout should not start branch from a tree' ' - test_must_fail git checkout -b newbranch master^{tree} + test_must_fail git checkout -b newbranch main^{tree} ' -test_expect_success 'checkout master from invalid HEAD' ' +test_expect_success 'checkout main from invalid HEAD' ' echo $ZERO_OID >.git/HEAD && - git checkout master -- + git checkout main -- ' test_expect_success 'checkout notices failure to lock HEAD' ' @@ -26,7 +29,7 @@ test_expect_success 'checkout notices failure to lock HEAD' ' ' test_expect_success 'create ref directory/file conflict scenario' ' - git update-ref refs/heads/outer/inner master && + git update-ref refs/heads/outer/inner main && # do not rely on symbolic-ref to get a known state, # as it may use the same code we are testing @@ -37,12 +40,12 @@ test_expect_success 'create ref directory/file conflict scenario' ' test_expect_success 'checkout away from d/f HEAD (unpacked, to branch)' ' reset_to_df && - git checkout master + git checkout main ' test_expect_success 'checkout away from d/f HEAD (unpacked, to detached)' ' reset_to_df && - git checkout --detach master + git checkout --detach main ' test_expect_success 'pack refs' ' @@ -51,11 +54,11 @@ test_expect_success 'pack refs' ' test_expect_success 'checkout away from d/f HEAD (packed, to branch)' ' reset_to_df && - git checkout master + git checkout main ' test_expect_success 'checkout away from d/f HEAD (packed, to detached)' ' reset_to_df && - git checkout --detach master + git checkout --detach main ' test_done diff --git a/t/t2012-checkout-last.sh b/t/t2012-checkout-last.sh index e7ba8c505f..0e7d47ab31 100755 --- a/t/t2012-checkout-last.sh +++ b/t/t2012-checkout-last.sh @@ -2,16 +2,15 @@ test_description='checkout can switch to last branch and merge base' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' - echo hello >world && - git add world && - git commit -m initial && + test_commit initial world hello && git branch other && - echo "hello again" >>world && - git add world && - git commit -m second + test_commit --append second world "hello again" ' test_expect_success '"checkout -" does not work initially' ' @@ -24,7 +23,7 @@ test_expect_success 'first branch switch' ' test_expect_success '"checkout -" switches back' ' git checkout - && - test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master" + test "z$(git symbolic-ref HEAD)" = "zrefs/heads/main" ' test_expect_success '"checkout -" switches forth' ' @@ -93,61 +92,59 @@ test_expect_success 'switch to twelfth from the last' ' test_expect_success 'merge base test setup' ' git checkout -b another other && - echo "hello again" >>world && - git add world && - git commit -m third + test_commit --append third world "hello again" ' -test_expect_success 'another...master' ' +test_expect_success 'another...main' ' git checkout another && - git checkout another...master && - test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify master^)" + git checkout another...main && + test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify main^)" ' -test_expect_success '...master' ' +test_expect_success '...main' ' git checkout another && - git checkout ...master && - test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify master^)" + git checkout ...main && + test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify main^)" ' -test_expect_success 'master...' ' +test_expect_success 'main...' ' git checkout another && - git checkout master... && - test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify master^)" + git checkout main... && + test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify main^)" ' test_expect_success '"checkout -" works after a rebase A' ' - git checkout master && + git checkout main && git checkout other && - git rebase master && + git rebase main && git checkout - && - test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master" + test "z$(git symbolic-ref HEAD)" = "zrefs/heads/main" ' test_expect_success '"checkout -" works after a rebase A B' ' - git branch moodle master~1 && - git checkout master && + git branch moodle main~1 && + git checkout main && git checkout other && - git rebase master moodle && + git rebase main moodle && git checkout - && - test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master" + test "z$(git symbolic-ref HEAD)" = "zrefs/heads/main" ' test_expect_success '"checkout -" works after a rebase -i A' ' - git checkout master && + git checkout main && git checkout other && - git rebase -i master && + git rebase -i main && git checkout - && - test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master" + test "z$(git symbolic-ref HEAD)" = "zrefs/heads/main" ' test_expect_success '"checkout -" works after a rebase -i A B' ' - git branch foodle master~1 && - git checkout master && + git branch foodle main~1 && + git checkout main && git checkout other && - git rebase master foodle && + git rebase main foodle && git checkout - && - test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master" + test "z$(git symbolic-ref HEAD)" = "zrefs/heads/main" ' test_done diff --git a/t/t2015-checkout-unborn.sh b/t/t2015-checkout-unborn.sh index 37bdcedcc9..a9721215fa 100755 --- a/t/t2015-checkout-unborn.sh +++ b/t/t2015-checkout-unborn.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='checkout from unborn branch' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -11,7 +14,7 @@ test_expect_success 'setup' ' git add file && git commit -m base ) && - git fetch parent master:origin + git fetch parent main:origin ' test_expect_success 'checkout from unborn preserves untracked files' ' diff --git a/t/t2017-checkout-orphan.sh b/t/t2017-checkout-orphan.sh index 655f278c5f..c7adbdd39a 100755 --- a/t/t2017-checkout-orphan.sh +++ b/t/t2017-checkout-orphan.sh @@ -7,6 +7,9 @@ test_description='git checkout --orphan Main Tests for --orphan functionality.' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh TEST_FILE=foo @@ -29,34 +32,34 @@ test_expect_success '--orphan creates a new orphan branch from HEAD' ' test_tick && git commit -m "Third Commit" && test_must_fail git rev-parse --verify HEAD^ && - git diff-tree --quiet master alpha + git diff-tree --quiet main alpha ' test_expect_success '--orphan creates a new orphan branch from <start_point>' ' - git checkout master && - git checkout --orphan beta master^ && + git checkout main && + git checkout --orphan beta main^ && test_must_fail git rev-parse --verify HEAD && test "refs/heads/beta" = "$(git symbolic-ref HEAD)" && test_tick && git commit -m "Fourth Commit" && test_must_fail git rev-parse --verify HEAD^ && - git diff-tree --quiet master^ beta + git diff-tree --quiet main^ beta ' test_expect_success '--orphan must be rejected with -b' ' - git checkout master && + git checkout main && test_must_fail git checkout --orphan new -b newer && - test refs/heads/master = "$(git symbolic-ref HEAD)" + test refs/heads/main = "$(git symbolic-ref HEAD)" ' test_expect_success '--orphan must be rejected with -t' ' - git checkout master && - test_must_fail git checkout --orphan new -t master && - test refs/heads/master = "$(git symbolic-ref HEAD)" + git checkout main && + test_must_fail git checkout --orphan new -t main && + test refs/heads/main = "$(git symbolic-ref HEAD)" ' test_expect_success '--orphan ignores branch.autosetupmerge' ' - git checkout master && + git checkout main && git config branch.autosetupmerge always && git checkout --orphan gamma && test -z "$(git config branch.gamma.merge)" && @@ -65,7 +68,7 @@ test_expect_success '--orphan ignores branch.autosetupmerge' ' ' test_expect_success '--orphan makes reflog by default' ' - git checkout master && + git checkout main && git config --unset core.logAllRefUpdates && git checkout --orphan delta && test_must_fail git rev-parse --verify delta@{0} && @@ -74,7 +77,7 @@ test_expect_success '--orphan makes reflog by default' ' ' test_expect_success '--orphan does not make reflog when core.logAllRefUpdates = false' ' - git checkout master && + git checkout main && git config core.logAllRefUpdates false && git checkout --orphan epsilon && test_must_fail git rev-parse --verify epsilon@{0} && @@ -83,7 +86,7 @@ test_expect_success '--orphan does not make reflog when core.logAllRefUpdates = ' test_expect_success '--orphan with -l makes reflog when core.logAllRefUpdates = false' ' - git checkout master && + git checkout main && git checkout -l --orphan zeta && test_must_fail git rev-parse --verify zeta@{0} && git commit -m Zeta && @@ -91,33 +94,33 @@ test_expect_success '--orphan with -l makes reflog when core.logAllRefUpdates = ' test_expect_success 'giving up --orphan not committed when -l and core.logAllRefUpdates = false deletes reflog' ' - git checkout master && + git checkout main && git checkout -l --orphan eta && test_must_fail git rev-parse --verify eta@{0} && - git checkout master && + git checkout main && test_must_fail git rev-parse --verify eta@{0} ' test_expect_success '--orphan is rejected with an existing name' ' - git checkout master && - test_must_fail git checkout --orphan master && - test refs/heads/master = "$(git symbolic-ref HEAD)" + git checkout main && + test_must_fail git checkout --orphan main && + test refs/heads/main = "$(git symbolic-ref HEAD)" ' test_expect_success '--orphan refuses to switch if a merge is needed' ' - git checkout master && + git checkout main && git reset --hard && echo local >>"$TEST_FILE" && cat "$TEST_FILE" >"$TEST_FILE.saved" && - test_must_fail git checkout --orphan new master^ && - test refs/heads/master = "$(git symbolic-ref HEAD)" && + test_must_fail git checkout --orphan new main^ && + test refs/heads/main = "$(git symbolic-ref HEAD)" && test_cmp "$TEST_FILE" "$TEST_FILE.saved" && git diff-index --quiet --cached HEAD && git reset --hard ' test_expect_success 'cannot --detach on an unborn branch' ' - git checkout master && + git checkout main && git checkout --orphan new && test_must_fail git checkout --detach ' diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh index 5f761bc616..93be1c0eae 100755 --- a/t/t2018-checkout-branch.sh +++ b/t/t2018-checkout-branch.sh @@ -150,7 +150,7 @@ test_expect_success 'checkout -b to @{-1} fails with the right branch name' ' git checkout branch2 && echo >expect "fatal: A branch named '\''branch1'\'' already exists." && test_must_fail git checkout -b @{-1} 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'checkout -B to an existing branch resets branch to HEAD' ' diff --git a/t/t2020-checkout-detach.sh b/t/t2020-checkout-detach.sh index b748db9946..bc46713a43 100755 --- a/t/t2020-checkout-detach.sh +++ b/t/t2020-checkout-detach.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='checkout into detached HEAD state' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh check_detached () { @@ -22,7 +25,7 @@ check_no_orphan_warning() { } reset () { - git checkout master && + git checkout main && check_not_detached } @@ -85,7 +88,7 @@ test_expect_success 'checkout --detach errors out for non-commit' ' test_expect_success 'checkout --detach errors out for extra argument' ' reset && - git checkout master && + git checkout main && test_must_fail git checkout --detach tag one.t && check_not_detached ' @@ -113,7 +116,7 @@ test_expect_success 'checkout warns on orphan commits' ' echo new content >orphan && git commit -a -m orphan2 && orphan2=$(git rev-parse HEAD) && - git checkout master 2>stderr + git checkout main 2>stderr ' test_expect_success 'checkout warns on orphan commits: output' ' @@ -132,7 +135,7 @@ test_expect_success 'checkout warns orphaning 1 of 2 commits: output' ' test_expect_success 'checkout does not warn leaving ref tip' ' reset && git checkout --detach two && - git checkout master 2>stderr + git checkout main 2>stderr ' test_expect_success 'checkout does not warn leaving ref tip' ' @@ -142,7 +145,7 @@ test_expect_success 'checkout does not warn leaving ref tip' ' test_expect_success 'checkout does not warn leaving reachable commit' ' reset && git checkout --detach HEAD^ && - git checkout master 2>stderr + git checkout main 2>stderr ' test_expect_success 'checkout does not warn leaving reachable commit' ' @@ -150,17 +153,17 @@ test_expect_success 'checkout does not warn leaving reachable commit' ' ' cat >expect <<'EOF' -Your branch is behind 'master' by 1 commit, and can be fast-forwarded. +Your branch is behind 'main' by 1 commit, and can be fast-forwarded. (use "git pull" to update your local branch) EOF test_expect_success 'tracking count is accurate after orphan check' ' reset && - git branch child master^ && + git branch child main^ && git config branch.child.remote . && - git config branch.child.merge refs/heads/master && + git config branch.child.merge refs/heads/main && git checkout child^ && git checkout child >stdout && - test_i18ncmp expect stdout + test_cmp expect stdout ' test_expect_success 'no advice given for explicit detached head state' ' @@ -189,9 +192,9 @@ test_expect_success 'no advice given for explicit detached head state' ' # Detached HEAD tests for GIT_PRINT_SHA1_ELLIPSIS (new format) test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not asked to' " - commit=$(git rev-parse --short=12 master^) && - commit2=$(git rev-parse --short=12 master~2) && - commit3=$(git rev-parse --short=12 master~3) && + commit=$(git rev-parse --short=12 main^) && + commit2=$(git rev-parse --short=12 main~2) && + commit3=$(git rev-parse --short=12 main~3) && # The first detach operation is more chatty than the following ones. cat >1st_detach <<-EOF && @@ -234,15 +237,15 @@ test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not as sane_unset GIT_PRINT_SHA1_ELLIPSIS && git -c 'core.abbrev=12' checkout HEAD^ >actual 2>&1 && check_detached && - test_i18ncmp 1st_detach actual && + test_cmp 1st_detach actual && GIT_PRINT_SHA1_ELLIPSIS="no" git -c 'core.abbrev=12' checkout HEAD^ >actual 2>&1 && check_detached && - test_i18ncmp 2nd_detach actual && + test_cmp 2nd_detach actual && GIT_PRINT_SHA1_ELLIPSIS= git -c 'core.abbrev=12' checkout HEAD^ >actual 2>&1 && check_detached && - test_i18ncmp 3rd_detach actual && + test_cmp 3rd_detach actual && sane_unset GIT_PRINT_SHA1_ELLIPSIS && @@ -253,17 +256,17 @@ test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not as # Make no mention of the env var at all git -c 'core.abbrev=12' checkout HEAD^ >actual 2>&1 && check_detached && - test_i18ncmp 1st_detach actual && + test_cmp 1st_detach actual && GIT_PRINT_SHA1_ELLIPSIS='nope' && git -c 'core.abbrev=12' checkout HEAD^ >actual 2>&1 && check_detached && - test_i18ncmp 2nd_detach actual && + test_cmp 2nd_detach actual && GIT_PRINT_SHA1_ELLIPSIS=nein && git -c 'core.abbrev=12' checkout HEAD^ >actual 2>&1 && check_detached && - test_i18ncmp 3rd_detach actual && + test_cmp 3rd_detach actual && true " @@ -271,9 +274,9 @@ test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not as # Detached HEAD tests for GIT_PRINT_SHA1_ELLIPSIS (old format) test_expect_success 'describe_detached_head does print SHA-1 ellipsis when asked to' " - commit=$(git rev-parse --short=12 master^) && - commit2=$(git rev-parse --short=12 master~2) && - commit3=$(git rev-parse --short=12 master~3) && + commit=$(git rev-parse --short=12 main^) && + commit2=$(git rev-parse --short=12 main~2) && + commit3=$(git rev-parse --short=12 main~3) && # The first detach operation is more chatty than the following ones. cat >1st_detach <<-EOF && @@ -316,15 +319,15 @@ test_expect_success 'describe_detached_head does print SHA-1 ellipsis when asked GIT_PRINT_SHA1_ELLIPSIS=yes git -c 'core.abbrev=12' checkout HEAD^ >actual 2>&1 && check_detached && - test_i18ncmp 1st_detach actual && + test_cmp 1st_detach actual && GIT_PRINT_SHA1_ELLIPSIS=Yes git -c 'core.abbrev=12' checkout HEAD^ >actual 2>&1 && check_detached && - test_i18ncmp 2nd_detach actual && + test_cmp 2nd_detach actual && GIT_PRINT_SHA1_ELLIPSIS=YES git -c 'core.abbrev=12' checkout HEAD^ >actual 2>&1 && check_detached && - test_i18ncmp 3rd_detach actual && + test_cmp 3rd_detach actual && true " diff --git a/t/t2021-checkout-overwrite.sh b/t/t2021-checkout-overwrite.sh index c2ada7de37..70d69263e6 100755 --- a/t/t2021-checkout-overwrite.sh +++ b/t/t2021-checkout-overwrite.sh @@ -51,4 +51,16 @@ test_expect_success SYMLINKS 'the symlink remained' ' test -h a/b ' +test_expect_success SYMLINKS 'checkout -f must not follow symlinks when removing entries' ' + git checkout -f start && + mkdir dir && + >dir/f && + git add dir/f && + git commit -m "add dir/f" && + mv dir untracked && + ln -s untracked dir && + git checkout -f HEAD~ && + test_path_is_file untracked/f +' + test_done diff --git a/t/t2022-checkout-paths.sh b/t/t2022-checkout-paths.sh index 6844afafc0..c49ba7f9bd 100755 --- a/t/t2022-checkout-paths.sh +++ b/t/t2022-checkout-paths.sh @@ -1,19 +1,22 @@ #!/bin/sh test_description='checkout $tree -- $paths' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' mkdir dir && - >dir/master && + >dir/main && echo common >dir/common && - git add dir/master dir/common && - test_tick && git commit -m "master has dir/master" && + git add dir/main dir/common && + test_tick && git commit -m "main has dir/main" && git checkout -b next && - git mv dir/master dir/next0 && + git mv dir/main dir/next0 && echo next >dir/next1 && git add dir && - test_tick && git commit -m "next has dir/next but not dir/master" + test_tick && git commit -m "next has dir/next but not dir/main" ' test_expect_success 'checking out paths out of a tree does not clobber unrelated paths' ' @@ -26,11 +29,11 @@ test_expect_success 'checking out paths out of a tree does not clobber unrelated echo untracked >expect.next2 && cat expect.next2 >dir/next2 && - git checkout master dir && + git checkout main dir && test_cmp expect.common dir/common && - test_path_is_file dir/master && - git diff --exit-code master dir/master && + test_path_is_file dir/main && + git diff --exit-code main dir/main && test_path_is_missing dir/next0 && test_cmp expect.next1 dir/next1 && @@ -52,11 +55,11 @@ test_expect_success 'do not touch unmerged entries matching $path but not in $tr EOF git update-index --index-info <expect.next0 && - git checkout master dir && + git checkout main dir && test_cmp expect.common dir/common && - test_path_is_file dir/master && - git diff --exit-code master dir/master && + test_path_is_file dir/main && + git diff --exit-code main dir/main && git ls-files -s dir/next0 >actual.next0 && test_cmp expect.next0 actual.next0 ' diff --git a/t/t2023-checkout-m.sh b/t/t2023-checkout-m.sh index fca3f85824..7b327b7544 100755 --- a/t/t2023-checkout-m.sh +++ b/t/t2023-checkout-m.sh @@ -4,21 +4,24 @@ test_description='checkout -m -- <conflicted path> Ensures that checkout -m on a resolved file restores the conflicted file' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' test_tick && test_commit both.txt both.txt initial && git branch topic && - test_commit modified_in_master both.txt in_master && - test_commit added_in_master each.txt in_master && + test_commit modified_in_main both.txt in_main && + test_commit added_in_main each.txt in_main && git checkout topic && test_commit modified_in_topic both.txt in_topic && test_commit added_in_topic each.txt in_topic ' -test_expect_success 'git merge master' ' - test_must_fail git merge master +test_expect_success 'git merge main' ' + test_must_fail git merge main ' clean_branchnames () { @@ -61,7 +64,7 @@ test_expect_success 'force checkout a conflict file creates stage zero entry' ' git checkout topic && echo c >a && C_OBJ=$(git hash-object a) && - git checkout -m master && + git checkout -m main && test_cmp_rev :1:a $A_OBJ && test_cmp_rev :2:a $B_OBJ && test_cmp_rev :3:a $C_OBJ && diff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh index a4f8d3a67e..4a1c901456 100755 --- a/t/t2024-checkout-dwim.sh +++ b/t/t2024-checkout-dwim.sh @@ -29,11 +29,11 @@ status_uno_is_clean () { } test_expect_success 'setup' ' - test_commit my_master && + test_commit my_main && git init repo_a && ( cd repo_a && - test_commit a_master && + test_commit a_main && git checkout -b foo && test_commit a_foo && git checkout -b bar && @@ -44,7 +44,7 @@ test_expect_success 'setup' ' git init repo_b && ( cd repo_b && - test_commit b_master && + test_commit b_main && git checkout -b foo && test_commit b_foo && git checkout -b baz && @@ -60,23 +60,23 @@ test_expect_success 'setup' ' ' test_expect_success 'checkout of non-existing branch fails' ' - git checkout -B master && + git checkout -B main && test_might_fail git branch -D xyzzy && test_must_fail git checkout xyzzy && status_uno_is_clean && test_must_fail git rev-parse --verify refs/heads/xyzzy && - test_branch master + test_branch main ' test_expect_success 'checkout of branch from multiple remotes fails #1' ' - git checkout -B master && + git checkout -B main && test_might_fail git branch -D foo && test_must_fail git checkout foo && status_uno_is_clean && test_must_fail git rev-parse --verify refs/heads/foo && - test_branch master + test_branch main ' test_expect_success 'when arg matches multiple remotes, do not fallback to interpreting as pathspec' ' @@ -100,21 +100,21 @@ test_expect_success 'when arg matches multiple remotes, do not fallback to inter ' test_expect_success 'checkout of branch from multiple remotes fails with advice' ' - git checkout -B master && + git checkout -B main && test_might_fail git branch -D foo && test_must_fail git checkout foo 2>stderr && - test_branch master && + test_branch main && status_uno_is_clean && test_i18ngrep "^hint: " stderr && test_must_fail git -c advice.checkoutAmbiguousRemoteBranchName=false \ checkout foo 2>stderr && - test_branch master && + test_branch main && status_uno_is_clean && test_i18ngrep ! "^hint: " stderr ' test_expect_success PERL 'checkout -p with multiple remotes does not print advice' ' - git checkout -B master && + git checkout -B main && test_might_fail git branch -D foo && git checkout -p foo 2>stderr && @@ -123,7 +123,7 @@ test_expect_success PERL 'checkout -p with multiple remotes does not print advic ' test_expect_success 'checkout of branch from multiple remotes succeeds with checkout.defaultRemote #1' ' - git checkout -B master && + git checkout -B main && status_uno_is_clean && test_might_fail git branch -D foo && @@ -135,7 +135,7 @@ test_expect_success 'checkout of branch from multiple remotes succeeds with chec ' test_expect_success 'checkout of branch from a single remote succeeds #1' ' - git checkout -B master && + git checkout -B main && test_might_fail git branch -D bar && git checkout bar && @@ -146,7 +146,7 @@ test_expect_success 'checkout of branch from a single remote succeeds #1' ' ' test_expect_success 'checkout of branch from a single remote succeeds #2' ' - git checkout -B master && + git checkout -B main && test_might_fail git branch -D baz && git checkout baz && @@ -157,33 +157,33 @@ test_expect_success 'checkout of branch from a single remote succeeds #2' ' ' test_expect_success '--no-guess suppresses branch auto-vivification' ' - git checkout -B master && + git checkout -B main && status_uno_is_clean && test_might_fail git branch -D bar && test_must_fail git checkout --no-guess bar && test_must_fail git rev-parse --verify refs/heads/bar && - test_branch master + test_branch main ' test_expect_success 'checkout.guess = false suppresses branch auto-vivification' ' - git checkout -B master && + git checkout -B main && status_uno_is_clean && test_might_fail git branch -D bar && test_config checkout.guess false && test_must_fail git checkout bar && test_must_fail git rev-parse --verify refs/heads/bar && - test_branch master + test_branch main ' test_expect_success 'setup more remotes with unconventional refspecs' ' - git checkout -B master && + git checkout -B main && status_uno_is_clean && git init repo_c && ( cd repo_c && - test_commit c_master && + test_commit c_main && git checkout -b bar && test_commit c_bar && git checkout -b spam && @@ -192,7 +192,7 @@ test_expect_success 'setup more remotes with unconventional refspecs' ' git init repo_d && ( cd repo_d && - test_commit d_master && + test_commit d_main && git checkout -b baz && test_commit d_baz && git checkout -b eggs && @@ -208,29 +208,29 @@ test_expect_success 'setup more remotes with unconventional refspecs' ' ' test_expect_success 'checkout of branch from multiple remotes fails #2' ' - git checkout -B master && + git checkout -B main && status_uno_is_clean && test_might_fail git branch -D bar && test_must_fail git checkout bar && status_uno_is_clean && test_must_fail git rev-parse --verify refs/heads/bar && - test_branch master + test_branch main ' test_expect_success 'checkout of branch from multiple remotes fails #3' ' - git checkout -B master && + git checkout -B main && status_uno_is_clean && test_might_fail git branch -D baz && test_must_fail git checkout baz && status_uno_is_clean && test_must_fail git rev-parse --verify refs/heads/baz && - test_branch master + test_branch main ' test_expect_success 'checkout of branch from a single remote succeeds #3' ' - git checkout -B master && + git checkout -B main && status_uno_is_clean && test_might_fail git branch -D spam && @@ -242,7 +242,7 @@ test_expect_success 'checkout of branch from a single remote succeeds #3' ' ' test_expect_success 'checkout of branch from a single remote succeeds #4' ' - git checkout -B master && + git checkout -B main && status_uno_is_clean && test_might_fail git branch -D eggs && @@ -254,7 +254,7 @@ test_expect_success 'checkout of branch from a single remote succeeds #4' ' ' test_expect_success 'checkout of branch with a file having the same name fails' ' - git checkout -B master && + git checkout -B main && status_uno_is_clean && test_might_fail git branch -D spam && @@ -262,11 +262,11 @@ test_expect_success 'checkout of branch with a file having the same name fails' test_must_fail git checkout spam && status_uno_is_clean && test_must_fail git rev-parse --verify refs/heads/spam && - test_branch master + test_branch main ' test_expect_success 'checkout of branch with a file in subdir having the same name fails' ' - git checkout -B master && + git checkout -B main && status_uno_is_clean && test_might_fail git branch -D spam && @@ -276,11 +276,11 @@ test_expect_success 'checkout of branch with a file in subdir having the same na test_must_fail git -C sub checkout spam && status_uno_is_clean && test_must_fail git rev-parse --verify refs/heads/spam && - test_branch master + test_branch main ' test_expect_success 'checkout <branch> -- succeeds, even if a file with the same name exists' ' - git checkout -B master && + git checkout -B main && status_uno_is_clean && test_might_fail git branch -D spam && @@ -294,7 +294,7 @@ test_expect_success 'checkout <branch> -- succeeds, even if a file with the same test_expect_success 'loosely defined local base branch is reported correctly' ' - git checkout master && + git checkout main && status_uno_is_clean && git branch strict && git branch loose && @@ -302,8 +302,8 @@ test_expect_success 'loosely defined local base branch is reported correctly' ' test_config branch.strict.remote . && test_config branch.loose.remote . && - test_config branch.strict.merge refs/heads/master && - test_config branch.loose.merge master && + test_config branch.strict.merge refs/heads/main && + test_config branch.loose.merge main && git checkout strict | sed -e "s/strict/BRANCHNAME/g" >expect && status_uno_is_clean && diff --git a/t/t2027-checkout-track.sh b/t/t2027-checkout-track.sh index bcba1bf90c..4453741b96 100755 --- a/t/t2027-checkout-track.sh +++ b/t/t2027-checkout-track.sh @@ -2,6 +2,9 @@ test_description='tests for git branch --track' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -10,14 +13,14 @@ test_expect_success 'setup' ' ' test_expect_success 'checkout --track -b creates a new tracking branch' ' - git checkout --track -b branch1 master && + git checkout --track -b branch1 main && test $(git rev-parse --abbrev-ref HEAD) = branch1 && test $(git config --get branch.branch1.remote) = . && - test $(git config --get branch.branch1.merge) = refs/heads/master + test $(git config --get branch.branch1.merge) = refs/heads/main ' test_expect_success 'checkout --track -b rejects an extra path argument' ' - test_must_fail git checkout --track -b branch2 master one.t 2>err && + test_must_fail git checkout --track -b branch2 main one.t 2>err && test_i18ngrep "cannot be used with updating paths" err ' diff --git a/t/t2030-unresolve-info.sh b/t/t2030-unresolve-info.sh index 309199bca2..be6c84c52a 100755 --- a/t/t2030-unresolve-info.sh +++ b/t/t2030-unresolve-info.sh @@ -2,6 +2,9 @@ test_description='undoing resolution' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh check_resolve_undo () { @@ -59,7 +62,7 @@ test_expect_success setup ' test_commit fourth fi/le fourth && git checkout add-add && test_commit fifth add-differently && - git checkout master + git checkout main ' test_expect_success 'add records switch clears' ' @@ -183,8 +186,8 @@ test_expect_success 'rerere forget (binary)' ' ' test_expect_success 'rerere forget (add-add conflict)' ' - git checkout -f master && - echo master >add-differently && + git checkout -f main && + echo main >add-differently && git add add-differently && git commit -m "add differently" && test_must_fail git merge fifth && diff --git a/t/t2060-switch.sh b/t/t2060-switch.sh index 68c9101b02..9bc6a3aa5c 100755 --- a/t/t2060-switch.sh +++ b/t/t2060-switch.sh @@ -2,6 +2,9 @@ test_description='switch basic functionality' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -23,41 +26,41 @@ test_expect_success 'switch branch' ' ' test_expect_success 'switch and detach' ' - test_when_finished git switch master && - test_must_fail git switch master^{commit} && - git switch --detach master^{commit} && + test_when_finished git switch main && + test_must_fail git switch main^{commit} && + git switch --detach main^{commit} && test_must_fail git symbolic-ref HEAD ' test_expect_success 'switch and detach current branch' ' - test_when_finished git switch master && - git switch master && + test_when_finished git switch main && + git switch main && git switch --detach && test_must_fail git symbolic-ref HEAD ' test_expect_success 'switch and create branch' ' - test_when_finished git switch master && - git switch -c temp master^ && - test_cmp_rev master^ refs/heads/temp && + test_when_finished git switch main && + git switch -c temp main^ && + test_cmp_rev main^ refs/heads/temp && echo refs/heads/temp >expected-branch && git symbolic-ref HEAD >actual-branch && test_cmp expected-branch actual-branch ' test_expect_success 'force create branch from HEAD' ' - test_when_finished git switch master && - git switch --detach master && + test_when_finished git switch main && + git switch --detach main && test_must_fail git switch -c temp && git switch -C temp && - test_cmp_rev master refs/heads/temp && + test_cmp_rev main refs/heads/temp && echo refs/heads/temp >expected-branch && git symbolic-ref HEAD >actual-branch && test_cmp expected-branch actual-branch ' test_expect_success 'new orphan branch from empty' ' - test_when_finished git switch master && + test_when_finished git switch main && test_must_fail git switch --orphan new-orphan HEAD && git switch --orphan new-orphan && test_commit orphan && @@ -69,7 +72,7 @@ test_expect_success 'new orphan branch from empty' ' ' test_expect_success 'orphan branch works with --discard-changes' ' - test_when_finished git switch master && + test_when_finished git switch main && echo foo >foo.txt && git switch --discard-changes --orphan new-orphan2 && git ls-files >tracked-files && @@ -77,7 +80,7 @@ test_expect_success 'orphan branch works with --discard-changes' ' ' test_expect_success 'switching ignores file of same branch name' ' - test_when_finished git switch master && + test_when_finished git switch main && : >first-branch && git switch first-branch && echo refs/heads/first-branch >expected && @@ -86,7 +89,7 @@ test_expect_success 'switching ignores file of same branch name' ' ' test_expect_success 'guess and create branch' ' - test_when_finished git switch master && + test_when_finished git switch main && test_must_fail git switch --no-guess foo && test_config checkout.guess false && test_must_fail git switch foo && diff --git a/t/t2070-restore.sh b/t/t2070-restore.sh index 89e5a142c9..7c43ddf1d9 100755 --- a/t/t2070-restore.sh +++ b/t/t2070-restore.sh @@ -2,6 +2,9 @@ test_description='restore basic functionality' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -15,7 +18,7 @@ test_expect_success 'setup' ' echo ignored >ignored && echo /ignored >.gitignore && git add one two .gitignore && - git update-ref refs/heads/one master + git update-ref refs/heads/one main ' test_expect_success 'restore without pathspec is not ok' ' @@ -91,7 +94,7 @@ test_expect_success 'restore --ignore-unmerged ignores unmerged entries' ' git switch -c first && echo first >unmerged && git commit -am first && - git switch -c second master && + git switch -c second main && echo second >unmerged && git commit -am second && test_must_fail git merge first && diff --git a/t/t2080-parallel-checkout-basics.sh b/t/t2080-parallel-checkout-basics.sh new file mode 100755 index 0000000000..3e0f8c675f --- /dev/null +++ b/t/t2080-parallel-checkout-basics.sh @@ -0,0 +1,229 @@ +#!/bin/sh + +test_description='parallel-checkout basics + +Ensure that parallel-checkout basically works on clone and checkout, spawning +the required number of workers and correctly populating both the index and the +working tree. +' + +TEST_NO_CREATE_REPO=1 +. ./test-lib.sh +. "$TEST_DIRECTORY/lib-parallel-checkout.sh" + +# Test parallel-checkout with a branch switch containing a variety of file +# creations, deletions, and modifications, involving different entry types. +# The branches B1 and B2 have the following paths: +# +# B1 B2 +# a/a (file) a (file) +# b (file) b/b (file) +# +# c/c (file) c (symlink) +# d (symlink) d/d (file) +# +# e/e (file) e (submodule) +# f (submodule) f/f (file) +# +# g (submodule) g (symlink) +# h (symlink) h (submodule) +# +# Additionally, the following paths are present on both branches, but with +# different contents: +# +# i (file) i (file) +# j (symlink) j (symlink) +# k (submodule) k (submodule) +# +# And the following paths are only present in one of the branches: +# +# l/l (file) - +# - m/m (file) +# +test_expect_success 'setup repo for checkout with various types of changes' ' + git init sub && + ( + cd sub && + git checkout -b B2 && + echo B2 >file && + git add file && + git commit -m file && + + git checkout -b B1 && + echo B1 >file && + git add file && + git commit -m file + ) && + + git init various && + ( + cd various && + + git checkout -b B1 && + mkdir a c e && + echo a/a >a/a && + echo b >b && + echo c/c >c/c && + test_ln_s_add c d && + echo e/e >e/e && + git submodule add ../sub f && + git submodule add ../sub g && + test_ln_s_add c h && + + echo "B1 i" >i && + test_ln_s_add c j && + git submodule add -b B1 ../sub k && + mkdir l && + echo l/l >l/l && + + git add . && + git commit -m B1 && + + git checkout -b B2 && + git rm -rf :^.gitmodules :^k && + mkdir b d f && + echo a >a && + echo b/b >b/b && + test_ln_s_add b c && + echo d/d >d/d && + git submodule add ../sub e && + echo f/f >f/f && + test_ln_s_add b g && + git submodule add ../sub h && + + echo "B2 i" >i && + test_ln_s_add b j && + git -C k checkout B2 && + mkdir m && + echo m/m >m/m && + + git add . && + git commit -m B2 && + + git checkout --recurse-submodules B1 + ) +' + +for mode in sequential parallel sequential-fallback +do + case $mode in + sequential) workers=1 threshold=0 expected_workers=0 ;; + parallel) workers=2 threshold=0 expected_workers=2 ;; + sequential-fallback) workers=2 threshold=100 expected_workers=0 ;; + esac + + test_expect_success "$mode checkout" ' + repo=various_$mode && + cp -R -P various $repo && + + # The just copied files have more recent timestamps than their + # associated index entries. So refresh the cached timestamps + # to avoid an "entry not up-to-date" error from `git checkout`. + # We only have to do this for the submodules as `git checkout` + # will already refresh the superproject index before performing + # the up-to-date check. + # + git -C $repo submodule foreach "git update-index --refresh" && + + set_checkout_config $workers $threshold && + test_checkout_workers $expected_workers \ + git -C $repo checkout --recurse-submodules B2 && + verify_checkout $repo + ' +done + +for mode in parallel sequential-fallback +do + case $mode in + parallel) workers=2 threshold=0 expected_workers=2 ;; + sequential-fallback) workers=2 threshold=100 expected_workers=0 ;; + esac + + test_expect_success "$mode checkout on clone" ' + repo=various_${mode}_clone && + set_checkout_config $workers $threshold && + test_checkout_workers $expected_workers \ + git clone --recurse-submodules --branch B2 various $repo && + verify_checkout $repo + ' +done + +# Just to be paranoid, actually compare the working trees' contents directly. +test_expect_success 'compare the working trees' ' + rm -rf various_*/.git && + rm -rf various_*/*/.git && + + # We use `git diff` instead of `diff -r` because the latter would + # follow symlinks, and not all `diff` implementations support the + # `--no-dereference` option. + # + git diff --no-index various_sequential various_parallel && + git diff --no-index various_sequential various_parallel_clone && + git diff --no-index various_sequential various_sequential-fallback && + git diff --no-index various_sequential various_sequential-fallback_clone +' + +# Currently, each submodule is checked out in a separated child process, but +# these subprocesses must also be able to use parallel checkout workers to +# write the submodules' entries. +test_expect_success 'submodules can use parallel checkout' ' + set_checkout_config 2 0 && + git init super && + ( + cd super && + git init sub && + test_commit -C sub A && + test_commit -C sub B && + git submodule add ./sub && + git commit -m sub && + rm sub/* && + test_checkout_workers 2 git checkout --recurse-submodules . + ) +' + +test_expect_success 'parallel checkout respects --[no]-force' ' + set_checkout_config 2 0 && + git init dirty && + ( + cd dirty && + mkdir D && + test_commit D/F && + test_commit F && + + rm -rf D && + echo changed >D && + echo changed >F.t && + + # We expect 0 workers because there is nothing to be done + test_checkout_workers 0 git checkout HEAD && + test_path_is_file D && + grep changed D && + grep changed F.t && + + test_checkout_workers 2 git checkout --force HEAD && + test_path_is_dir D && + grep D/F D/F.t && + grep F F.t + ) +' + +test_expect_success SYMLINKS 'parallel checkout checks for symlinks in leading dirs' ' + set_checkout_config 2 0 && + git init symlinks && + ( + cd symlinks && + mkdir D untracked && + # Commit 2 files to have enough work for 2 parallel workers + test_commit D/A && + test_commit D/B && + rm -rf D && + ln -s untracked D && + + test_checkout_workers 2 git checkout --force HEAD && + ! test -h D && + grep D/A D/A.t && + grep D/B D/B.t + ) +' + +test_done diff --git a/t/t2081-parallel-checkout-collisions.sh b/t/t2081-parallel-checkout-collisions.sh new file mode 100755 index 0000000000..f6fcfc0c1e --- /dev/null +++ b/t/t2081-parallel-checkout-collisions.sh @@ -0,0 +1,162 @@ +#!/bin/sh + +test_description="path collisions during parallel checkout + +Parallel checkout must detect path collisions to: + +1) Avoid racily writing to different paths that represent the same file on disk. +2) Report the colliding entries on clone. + +The tests in this file exercise parallel checkout's collision detection code in +both these mechanics. +" + +. ./test-lib.sh +. "$TEST_DIRECTORY/lib-parallel-checkout.sh" + +TEST_ROOT="$PWD" + +test_expect_success CASE_INSENSITIVE_FS 'setup' ' + empty_oid=$(git hash-object -w --stdin </dev/null) && + cat >objs <<-EOF && + 100644 $empty_oid FILE_X + 100644 $empty_oid FILE_x + 100644 $empty_oid file_X + 100644 $empty_oid file_x + EOF + git update-index --index-info <objs && + git commit -m "colliding files" && + git tag basename_collision && + + write_script "$TEST_ROOT"/logger_script <<-\EOF + echo "$@" >>filter.log + EOF +' + +test_workers_in_event_trace () +{ + test $1 -eq $(grep ".event.:.child_start..*checkout--worker" $2 | wc -l) +} + +test_expect_success CASE_INSENSITIVE_FS 'worker detects basename collision' ' + GIT_TRACE2_EVENT="$(pwd)/trace" git \ + -c checkout.workers=2 -c checkout.thresholdForParallelism=0 \ + checkout . && + + test_workers_in_event_trace 2 trace && + collisions=$(grep -i "category.:.pcheckout.,.key.:.collision/basename.,.value.:.file_x.}" trace | wc -l) && + test $collisions -eq 3 +' + +test_expect_success CASE_INSENSITIVE_FS 'worker detects dirname collision' ' + test_config filter.logger.smudge "\"$TEST_ROOT/logger_script\" %f" && + empty_oid=$(git hash-object -w --stdin </dev/null) && + + # By setting a filter command to "a", we make it ineligible for parallel + # checkout, and thus it is checked out *first*. This way we can ensure + # that "A/B" and "A/C" will both collide with the regular file "a". + # + attr_oid=$(echo "a filter=logger" | git hash-object -w --stdin) && + + cat >objs <<-EOF && + 100644 $empty_oid A/B + 100644 $empty_oid A/C + 100644 $empty_oid a + 100644 $attr_oid .gitattributes + EOF + git rm -rf . && + git update-index --index-info <objs && + + rm -f trace filter.log && + GIT_TRACE2_EVENT="$(pwd)/trace" git \ + -c checkout.workers=2 -c checkout.thresholdForParallelism=0 \ + checkout . && + + # Check that "a" (and only "a") was filtered + echo a >expected.log && + test_cmp filter.log expected.log && + + # Check that it used the right number of workers and detected the collisions + test_workers_in_event_trace 2 trace && + grep "category.:.pcheckout.,.key.:.collision/dirname.,.value.:.A/B.}" trace && + grep "category.:.pcheckout.,.key.:.collision/dirname.,.value.:.A/C.}" trace +' + +test_expect_success SYMLINKS,CASE_INSENSITIVE_FS 'do not follow symlinks colliding with leading dir' ' + empty_oid=$(git hash-object -w --stdin </dev/null) && + symlink_oid=$(echo "./e" | git hash-object -w --stdin) && + mkdir e && + + cat >objs <<-EOF && + 120000 $symlink_oid D + 100644 $empty_oid d/x + 100644 $empty_oid e/y + EOF + git rm -rf . && + git update-index --index-info <objs && + + set_checkout_config 2 0 && + test_checkout_workers 2 git checkout . && + test_path_is_dir e && + test_path_is_missing e/x +' + +# The two following tests check that parallel checkout correctly reports +# colliding entries on clone. The sequential code detects a collision by +# calling lstat() before trying to open(O_CREAT) a file. (Note that this only +# works for clone.) Then, to find the pair of a colliding item k, it searches +# cache_entry[0, k-1]. This is not sufficient in parallel checkout because: +# +# - A colliding file may be created between the lstat() and open() calls; +# - A colliding entry might appear in the second half of the cache_entry array. +# +test_expect_success CASE_INSENSITIVE_FS 'collision report on clone (w/ racy file creation)' ' + git reset --hard basename_collision && + set_checkout_config 2 0 && + test_checkout_workers 2 git clone . clone-repo 2>stderr && + + grep FILE_X stderr && + grep FILE_x stderr && + grep file_X stderr && + grep file_x stderr && + grep "the following paths have collided" stderr +' + +# This test ensures that the collision report code is correctly looking for +# colliding peers in the second half of the cache_entry array. This is done by +# defining a smudge command for the *last* array entry, which makes it +# non-eligible for parallel-checkout. Thus, it is checked out *first*, before +# spawning the workers. +# +# Note: this test doesn't work on Windows because, on this system, the +# collision report code uses strcmp() to find the colliding pairs when +# core.ignoreCase is false. And we need this setting for this test so that only +# 'file_x' matches the pattern of the filter attribute. But the test works on +# OSX, where the colliding pairs are found using inode. +# +test_expect_success CASE_INSENSITIVE_FS,!MINGW,!CYGWIN \ + 'collision report on clone (w/ colliding peer after the detected entry)' ' + + test_config_global filter.logger.smudge "\"$TEST_ROOT/logger_script\" %f" && + git reset --hard basename_collision && + echo "file_x filter=logger" >.gitattributes && + git add .gitattributes && + git commit -m "filter for file_x" && + + rm -rf clone-repo && + set_checkout_config 2 0 && + test_checkout_workers 2 \ + git -c core.ignoreCase=false clone . clone-repo 2>stderr && + + grep FILE_X stderr && + grep FILE_x stderr && + grep file_X stderr && + grep file_x stderr && + grep "the following paths have collided" stderr && + + # Check that only "file_x" was filtered + echo file_x >expected.log && + test_cmp clone-repo/filter.log expected.log +' + +test_done diff --git a/t/t2082-parallel-checkout-attributes.sh b/t/t2082-parallel-checkout-attributes.sh new file mode 100755 index 0000000000..2525457961 --- /dev/null +++ b/t/t2082-parallel-checkout-attributes.sh @@ -0,0 +1,194 @@ +#!/bin/sh + +test_description='parallel-checkout: attributes + +Verify that parallel-checkout correctly creates files that require +conversions, as specified in .gitattributes. The main point here is +to check that the conv_attr data is correctly sent to the workers +and that it contains sufficient information to smudge files +properly (without access to the index or attribute stack). +' + +TEST_NO_CREATE_REPO=1 +. ./test-lib.sh +. "$TEST_DIRECTORY/lib-parallel-checkout.sh" +. "$TEST_DIRECTORY/lib-encoding.sh" + +test_expect_success 'parallel-checkout with ident' ' + set_checkout_config 2 0 && + git init ident && + ( + cd ident && + echo "A ident" >.gitattributes && + echo "\$Id\$" >A && + echo "\$Id\$" >B && + git add -A && + git commit -m id && + + rm A B && + test_checkout_workers 2 git reset --hard && + hexsz=$(test_oid hexsz) && + grep -E "\\\$Id: [0-9a-f]{$hexsz} \\\$" A && + grep "\\\$Id\\\$" B + ) +' + +test_expect_success 'parallel-checkout with re-encoding' ' + set_checkout_config 2 0 && + git init encoding && + ( + cd encoding && + echo text >utf8-text && + write_utf16 <utf8-text >utf16-text && + + echo "A working-tree-encoding=UTF-16" >.gitattributes && + cp utf16-text A && + cp utf8-text B && + git add A B .gitattributes && + git commit -m encoding && + + # Check that A is stored in UTF-8 + git cat-file -p :A >A.internal && + test_cmp_bin utf8-text A.internal && + + rm A B && + test_checkout_workers 2 git checkout A B && + + # Check that A (and only A) is re-encoded during checkout + test_cmp_bin utf16-text A && + test_cmp_bin utf8-text B + ) +' + +test_expect_success 'parallel-checkout with eol conversions' ' + set_checkout_config 2 0 && + git init eol && + ( + cd eol && + printf "multi\r\nline\r\ntext" >crlf-text && + printf "multi\nline\ntext" >lf-text && + + git config core.autocrlf false && + echo "A eol=crlf" >.gitattributes && + cp crlf-text A && + cp lf-text B && + git add A B .gitattributes && + git commit -m eol && + + # Check that A is stored with LF format + git cat-file -p :A >A.internal && + test_cmp_bin lf-text A.internal && + + rm A B && + test_checkout_workers 2 git checkout A B && + + # Check that A (and only A) is converted to CRLF during checkout + test_cmp_bin crlf-text A && + test_cmp_bin lf-text B + ) +' + +# Entries that require an external filter are not eligible for parallel +# checkout. Check that both the parallel-eligible and non-eligible entries are +# properly writen in a single checkout operation. +# +test_expect_success 'parallel-checkout and external filter' ' + set_checkout_config 2 0 && + git init filter && + ( + cd filter && + write_script <<-\EOF rot13.sh && + tr \ + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" \ + "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM" + EOF + + git config filter.rot13.clean "\"$(pwd)/rot13.sh\"" && + git config filter.rot13.smudge "\"$(pwd)/rot13.sh\"" && + git config filter.rot13.required true && + + echo abcd >original && + echo nopq >rot13 && + + echo "A filter=rot13" >.gitattributes && + cp original A && + cp original B && + cp original C && + git add A B C .gitattributes && + git commit -m filter && + + # Check that A (and only A) was cleaned + git cat-file -p :A >A.internal && + test_cmp rot13 A.internal && + git cat-file -p :B >B.internal && + test_cmp original B.internal && + git cat-file -p :C >C.internal && + test_cmp original C.internal && + + rm A B C *.internal && + test_checkout_workers 2 git checkout A B C && + + # Check that A (and only A) was smudged during checkout + test_cmp original A && + test_cmp original B && + test_cmp original C + ) +' + +# The delayed queue is independent from the parallel queue, and they should be +# able to work together in the same checkout process. +# +test_expect_success PERL 'parallel-checkout and delayed checkout' ' + write_script rot13-filter.pl "$PERL_PATH" \ + <"$TEST_DIRECTORY"/t0021/rot13-filter.pl && + + test_config_global filter.delay.process \ + "\"$(pwd)/rot13-filter.pl\" --always-delay \"$(pwd)/delayed.log\" clean smudge delay" && + test_config_global filter.delay.required true && + + echo "abcd" >original && + echo "nopq" >rot13 && + + git init delayed && + ( + cd delayed && + echo "*.d filter=delay" >.gitattributes && + cp ../original W.d && + cp ../original X.d && + cp ../original Y && + cp ../original Z && + git add -A && + git commit -m delayed && + + # Check that *.d files were cleaned + git cat-file -p :W.d >W.d.internal && + test_cmp W.d.internal ../rot13 && + git cat-file -p :X.d >X.d.internal && + test_cmp X.d.internal ../rot13 && + git cat-file -p :Y >Y.internal && + test_cmp Y.internal ../original && + git cat-file -p :Z >Z.internal && + test_cmp Z.internal ../original && + + rm * + ) && + + set_checkout_config 2 0 && + test_checkout_workers 2 git -C delayed checkout -f && + verify_checkout delayed && + + # Check that the *.d files got to the delay queue and were filtered + grep "smudge W.d .* \[DELAYED\]" delayed.log && + grep "smudge X.d .* \[DELAYED\]" delayed.log && + test_cmp delayed/W.d original && + test_cmp delayed/X.d original && + + # Check that the parallel-eligible entries went to the right queue and + # were not filtered + ! grep "smudge Y .* \[DELAYED\]" delayed.log && + ! grep "smudge Z .* \[DELAYED\]" delayed.log && + test_cmp delayed/Y original && + test_cmp delayed/Z original +' + +test_done diff --git a/t/t2104-update-index-skip-worktree.sh b/t/t2104-update-index-skip-worktree.sh index 7e2e7dd4ae..30666fc70d 100755 --- a/t/t2104-update-index-skip-worktree.sh +++ b/t/t2104-update-index-skip-worktree.sh @@ -9,6 +9,11 @@ test_description='skip-worktree bit test' sane_unset GIT_TEST_SPLIT_INDEX +test_set_index_version () { + GIT_INDEX_VERSION="$1" + export GIT_INDEX_VERSION +} + test_set_index_version 3 cat >expect.full <<EOF diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 7cb7a70382..45ca35d60a 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -135,7 +135,7 @@ test_expect_success 'add -n -u should not add but just report' ' after=$(git ls-files -s check top) && test "$before" = "$after" && - test_i18ncmp expect actual + test_cmp expect actual ' diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh index 5a7495474a..96dfca1554 100755 --- a/t/t2400-worktree-add.sh +++ b/t/t2400-worktree-add.sh @@ -2,6 +2,9 @@ test_description='test git worktree add' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh @@ -12,12 +15,12 @@ test_expect_success 'setup' ' test_expect_success '"add" an existing worktree' ' mkdir -p existing/subtree && - test_must_fail git worktree add --detach existing master + test_must_fail git worktree add --detach existing main ' test_expect_success '"add" an existing empty worktree' ' mkdir existing_empty && - git worktree add --detach existing_empty master + git worktree add --detach existing_empty main ' test_expect_success '"add" using shorthand - fails when no previous branch' ' @@ -29,7 +32,7 @@ test_expect_success '"add" using - shorthand' ' echo hello >myworld && git add myworld && git commit -m myworld && - git checkout master && + git checkout main && git worktree add short-hand - && echo refs/heads/newbranch >expect && git -C short-hand rev-parse --symbolic-full-name HEAD >actual && @@ -37,7 +40,7 @@ test_expect_success '"add" using - shorthand' ' ' test_expect_success '"add" refuses to checkout locked branch' ' - test_must_fail git worktree add zere master && + test_must_fail git worktree add zere main && ! test -d zere && ! test -d .git/worktrees/zere ' @@ -46,13 +49,13 @@ test_expect_success 'checking out paths not complaining about linked checkouts' ( cd existing_empty && echo dirty >>init.t && - git checkout master -- init.t + git checkout main -- init.t ) ' test_expect_success '"add" worktree' ' git rev-parse HEAD >expect && - git worktree add --detach here master && + git worktree add --detach here main && ( cd here && test_cmp ../init.t init.t && @@ -65,7 +68,7 @@ test_expect_success '"add" worktree' ' test_expect_success '"add" worktree with lock' ' git rev-parse HEAD >expect && - git worktree add --detach --lock here-with-lock master && + git worktree add --detach --lock here-with-lock main && test -f .git/worktrees/here-with-lock/locked ' @@ -73,7 +76,7 @@ test_expect_success '"add" worktree from a subdir' ' ( mkdir sub && cd sub && - git worktree add --detach here master && + git worktree add --detach here main && cd here && test_cmp ../../init.t init.t ) @@ -82,19 +85,19 @@ test_expect_success '"add" worktree from a subdir' ' test_expect_success '"add" from a linked checkout' ' ( cd here && - git worktree add --detach nested-here master && + git worktree add --detach nested-here main && cd nested-here && git fsck ) ' test_expect_success '"add" worktree creating new branch' ' - git worktree add -b newmaster there master && + git worktree add -b newmain there main && ( cd there && test_cmp ../init.t init.t && git symbolic-ref HEAD >actual && - echo refs/heads/newmaster >expect && + echo refs/heads/newmain >expect && test_cmp expect actual && git fsck ) @@ -103,7 +106,7 @@ test_expect_success '"add" worktree creating new branch' ' test_expect_success 'die the same branch is already checked out' ' ( cd here && - test_must_fail git checkout newmaster + test_must_fail git checkout newmain ) ' @@ -112,20 +115,20 @@ test_expect_success SYMLINKS 'die the same branch is already checked out (symlin ref=$(git -C there symbolic-ref HEAD) && rm "$head" && ln -s "$ref" "$head" && - test_must_fail git -C here checkout newmaster + test_must_fail git -C here checkout newmain ' test_expect_success 'not die the same branch is already checked out' ' ( cd here && - git worktree add --force anothernewmaster newmaster + git worktree add --force anothernewmain newmain ) ' test_expect_success 'not die on re-checking out current branch' ' ( cd there && - git checkout newmaster + git checkout newmain ) ' @@ -133,14 +136,14 @@ test_expect_success '"add" from a bare repo' ' ( git clone --bare . bare && cd bare && - git worktree add -b bare-master ../there2 master + git worktree add -b bare-main ../there2 main ) ' test_expect_success 'checkout from a bare repo without "add"' ' ( cd bare && - test_must_fail git checkout master + test_must_fail git checkout main ) ' @@ -148,7 +151,7 @@ test_expect_success '"add" default branch of a bare repo' ' ( git clone --bare . bare2 && cd bare2 && - git worktree add ../there3 master + git worktree add ../there3 main ) ' @@ -165,7 +168,7 @@ test_expect_success 'checkout with grafts' ' EOF git log --format=%s -2 >actual && test_cmp expected actual && - git worktree add --detach grafted master && + git worktree add --detach grafted main && git --git-dir=grafted/.git log --format=%s -2 >actual && test_cmp expected actual ' @@ -226,34 +229,34 @@ test_expect_success '"add" no auto-vivify with --detach and <branch> omitted' ' ' test_expect_success '"add" -b/-B mutually exclusive' ' - test_must_fail git worktree add -b poodle -B poodle bamboo master + test_must_fail git worktree add -b poodle -B poodle bamboo main ' test_expect_success '"add" -b/--detach mutually exclusive' ' - test_must_fail git worktree add -b poodle --detach bamboo master + test_must_fail git worktree add -b poodle --detach bamboo main ' test_expect_success '"add" -B/--detach mutually exclusive' ' - test_must_fail git worktree add -B poodle --detach bamboo master + test_must_fail git worktree add -B poodle --detach bamboo main ' test_expect_success '"add -B" fails if the branch is checked out' ' - git rev-parse newmaster >before && - test_must_fail git worktree add -B newmaster bamboo master && - git rev-parse newmaster >after && + git rev-parse newmain >before && + test_must_fail git worktree add -B newmain bamboo main && + git rev-parse newmain >after && test_cmp before after ' test_expect_success 'add -B' ' - git worktree add -B poodle bamboo2 master^ && + git worktree add -B poodle bamboo2 main^ && git -C bamboo2 symbolic-ref HEAD >actual && echo refs/heads/poodle >expected && test_cmp expected actual && - test_cmp_rev master^ poodle + test_cmp_rev main^ poodle ' test_expect_success 'add --quiet' ' - git worktree add --quiet another-worktree master 2>actual && + git worktree add --quiet another-worktree main 2>actual && test_must_be_empty actual ' @@ -348,24 +351,24 @@ test_branch_upstream () { test_expect_success '--track sets up tracking' ' test_when_finished rm -rf track && - git worktree add --track -b track track master && - test_branch_upstream track . master + git worktree add --track -b track track main && + test_branch_upstream track . main ' # setup remote repository $1 and repository $2 with $1 set up as -# remote. The remote has two branches, master and foo. +# remote. The remote has two branches, main and foo. setup_remote_repo () { git init $1 && ( cd $1 && - test_commit $1_master && + test_commit $1_main && git checkout -b foo && test_commit upstream_foo ) && git init $2 && ( cd $2 && - test_commit $2_master && + test_commit $2_main && git remote add $1 ../$1 && git config remote.$1.fetch \ "refs/heads/*:refs/remotes/$1/*" && diff --git a/t/t2401-worktree-prune.sh b/t/t2401-worktree-prune.sh index a6ce7f590b..a615d3b483 100755 --- a/t/t2401-worktree-prune.sh +++ b/t/t2401-worktree-prune.sh @@ -2,6 +2,9 @@ test_description='prune $GIT_DIR/worktrees' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success initialize ' @@ -20,7 +23,7 @@ test_expect_success 'prune files inside $GIT_DIR/worktrees' ' cat >expect <<EOF && Removing worktrees/abc: not a valid directory EOF - test_i18ncmp expect actual && + test_cmp expect actual && ! test -f .git/worktrees/abc && ! test -d .git/worktrees ' @@ -32,7 +35,7 @@ test_expect_success 'prune directories without gitdir' ' Removing worktrees/def: gitdir file does not exist EOF git worktree prune --verbose >actual && - test_i18ncmp expect actual && + test_cmp expect actual && ! test -d .git/worktrees/def && ! test -d .git/worktrees ' @@ -87,7 +90,7 @@ test_expect_success 'not prune recent checkouts' ' test_expect_success 'not prune proper checkouts' ' test_when_finished rm -r .git/worktrees && - git worktree add --detach "$PWD/nop" master && + git worktree add --detach "$PWD/nop" main && git worktree prune && test -d .git/worktrees/nop ' diff --git a/t/t2402-worktree-list.sh b/t/t2402-worktree-list.sh index 795ddca2e4..fedcefe8de 100755 --- a/t/t2402-worktree-list.sh +++ b/t/t2402-worktree-list.sh @@ -2,6 +2,9 @@ test_description='test git worktree list' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -21,7 +24,7 @@ test_expect_success 'rev-parse --git-common-dir on main worktree' ' test_expect_success 'rev-parse --git-path objects linked worktree' ' echo "$(git rev-parse --show-toplevel)/.git/objects" >expect && test_when_finished "rm -rf linked-tree actual expect && git worktree prune" && - git worktree add --detach linked-tree master && + git worktree add --detach linked-tree main && git -C linked-tree rev-parse --git-path objects >actual && test_cmp expect actual ' @@ -29,7 +32,7 @@ test_expect_success 'rev-parse --git-path objects linked worktree' ' test_expect_success '"list" all worktrees from main' ' echo "$(git rev-parse --show-toplevel) $(git rev-parse --short HEAD) [$(git symbolic-ref --short HEAD)]" >expect && test_when_finished "rm -rf here out actual expect && git worktree prune" && - git worktree add --detach here master && + git worktree add --detach here main && echo "$(git -C here rev-parse --show-toplevel) $(git rev-parse --short HEAD) (detached HEAD)" >>expect && git worktree list >out && sed "s/ */ /g" <out >actual && @@ -39,7 +42,7 @@ test_expect_success '"list" all worktrees from main' ' test_expect_success '"list" all worktrees from linked' ' echo "$(git rev-parse --show-toplevel) $(git rev-parse --short HEAD) [$(git symbolic-ref --short HEAD)]" >expect && test_when_finished "rm -rf here out actual expect && git worktree prune" && - git worktree add --detach here master && + git worktree add --detach here main && echo "$(git -C here rev-parse --show-toplevel) $(git rev-parse --short HEAD) (detached HEAD)" >>expect && git -C here worktree list >out && sed "s/ */ /g" <out >actual && @@ -52,7 +55,7 @@ test_expect_success '"list" all worktrees --porcelain' ' echo "branch $(git symbolic-ref HEAD)" >>expect && echo >>expect && test_when_finished "rm -rf here actual expect && git worktree prune" && - git worktree add --detach here master && + git worktree add --detach here main && echo "worktree $(git -C here rev-parse --show-toplevel)" >>expect && echo "HEAD $(git rev-parse HEAD)" >>expect && echo "detached" >>expect && @@ -63,26 +66,122 @@ test_expect_success '"list" all worktrees --porcelain' ' test_expect_success '"list" all worktrees with locked annotation' ' test_when_finished "rm -rf locked unlocked out && git worktree prune" && - git worktree add --detach locked master && - git worktree add --detach unlocked master && + git worktree add --detach locked main && + git worktree add --detach unlocked main && git worktree lock locked && + test_when_finished "git worktree unlock locked" && git worktree list >out && grep "/locked *[0-9a-f].* locked$" out && ! grep "/unlocked *[0-9a-f].* locked$" out ' +test_expect_success '"list" all worktrees --porcelain with locked' ' + test_when_finished "rm -rf locked1 locked2 unlocked out actual expect && git worktree prune" && + echo "locked" >expect && + echo "locked with reason" >>expect && + git worktree add --detach locked1 && + git worktree add --detach locked2 && + # unlocked worktree should not be annotated with "locked" + git worktree add --detach unlocked && + git worktree lock locked1 && + test_when_finished "git worktree unlock locked1" && + git worktree lock locked2 --reason "with reason" && + test_when_finished "git worktree unlock locked2" && + git worktree list --porcelain >out && + grep "^locked" out >actual && + test_cmp expect actual +' + +test_expect_success '"list" all worktrees --porcelain with locked reason newline escaped' ' + test_when_finished "rm -rf locked_lf locked_crlf out actual expect && git worktree prune" && + printf "locked \"locked\\\\r\\\\nreason\"\n" >expect && + printf "locked \"locked\\\\nreason\"\n" >>expect && + git worktree add --detach locked_lf && + git worktree add --detach locked_crlf && + git worktree lock locked_lf --reason "$(printf "locked\nreason")" && + test_when_finished "git worktree unlock locked_lf" && + git worktree lock locked_crlf --reason "$(printf "locked\r\nreason")" && + test_when_finished "git worktree unlock locked_crlf" && + git worktree list --porcelain >out && + grep "^locked" out >actual && + test_cmp expect actual +' + +test_expect_success '"list" all worktrees with prunable annotation' ' + test_when_finished "rm -rf prunable unprunable out && git worktree prune" && + git worktree add --detach prunable && + git worktree add --detach unprunable && + rm -rf prunable && + git worktree list >out && + grep "/prunable *[0-9a-f].* prunable$" out && + ! grep "/unprunable *[0-9a-f].* prunable$" +' + +test_expect_success '"list" all worktrees --porcelain with prunable' ' + test_when_finished "rm -rf prunable out && git worktree prune" && + git worktree add --detach prunable && + rm -rf prunable && + git worktree list --porcelain >out && + sed -n "/^worktree .*\/prunable$/,/^$/p" <out >only_prunable && + test_i18ngrep "^prunable gitdir file points to non-existent location$" only_prunable +' + +test_expect_success '"list" all worktrees with prunable consistent with "prune"' ' + test_when_finished "rm -rf prunable unprunable out && git worktree prune" && + git worktree add --detach prunable && + git worktree add --detach unprunable && + rm -rf prunable && + git worktree list >out && + grep "/prunable *[0-9a-f].* prunable$" out && + ! grep "/unprunable *[0-9a-f].* unprunable$" out && + git worktree prune --verbose >out && + test_i18ngrep "^Removing worktrees/prunable" out && + test_i18ngrep ! "^Removing worktrees/unprunable" out +' + +test_expect_success '"list" --verbose and --porcelain mutually exclusive' ' + test_must_fail git worktree list --verbose --porcelain +' + +test_expect_success '"list" all worktrees --verbose with locked' ' + test_when_finished "rm -rf locked1 locked2 out actual expect && git worktree prune" && + git worktree add locked1 --detach && + git worktree add locked2 --detach && + git worktree lock locked1 && + test_when_finished "git worktree unlock locked1" && + git worktree lock locked2 --reason "with reason" && + test_when_finished "git worktree unlock locked2" && + echo "$(git -C locked2 rev-parse --show-toplevel) $(git rev-parse --short HEAD) (detached HEAD)" >expect && + printf "\tlocked: with reason\n" >>expect && + git worktree list --verbose >out && + grep "/locked1 *[0-9a-f].* locked$" out && + sed -n "s/ */ /g;/\/locked2 *[0-9a-f].*$/,/locked: .*$/p" <out >actual && + test_cmp actual expect +' + +test_expect_success '"list" all worktrees --verbose with prunable' ' + test_when_finished "rm -rf prunable out actual expect && git worktree prune" && + git worktree add prunable --detach && + echo "$(git -C prunable rev-parse --show-toplevel) $(git rev-parse --short HEAD) (detached HEAD)" >expect && + printf "\tprunable: gitdir file points to non-existent location\n" >>expect && + rm -rf prunable && + git worktree list --verbose >out && + sed -n "s/ */ /g;/\/prunable *[0-9a-f].*$/,/prunable: .*$/p" <out >actual && + test_cmp actual expect +' + test_expect_success 'bare repo setup' ' git init --bare bare1 && echo "data" >file1 && git add file1 && git commit -m"File1: add data" && - git push bare1 master && + git push bare1 main && git reset --hard HEAD^ ' test_expect_success '"list" all worktrees from bare main' ' test_when_finished "rm -rf there out actual expect && git -C bare1 worktree prune" && - git -C bare1 worktree add --detach ../there master && + git -C bare1 worktree add --detach ../there main && echo "$(pwd)/bare1 (bare)" >expect && echo "$(git -C there rev-parse --show-toplevel) $(git -C there rev-parse --short HEAD) (detached HEAD)" >>expect && git -C bare1 worktree list >out && @@ -92,7 +191,7 @@ test_expect_success '"list" all worktrees from bare main' ' test_expect_success '"list" all worktrees --porcelain from bare main' ' test_when_finished "rm -rf there actual expect && git -C bare1 worktree prune" && - git -C bare1 worktree add --detach ../there master && + git -C bare1 worktree add --detach ../there main && echo "worktree $(pwd)/bare1" >expect && echo "bare" >>expect && echo >>expect && @@ -106,7 +205,7 @@ test_expect_success '"list" all worktrees --porcelain from bare main' ' test_expect_success '"list" all worktrees from linked with a bare main' ' test_when_finished "rm -rf there out actual expect && git -C bare1 worktree prune" && - git -C bare1 worktree add --detach ../there master && + git -C bare1 worktree add --detach ../there main && echo "$(pwd)/bare1 (bare)" >expect && echo "$(git -C there rev-parse --show-toplevel) $(git -C there rev-parse --short HEAD) (detached HEAD)" >>expect && git -C there worktree list >out && diff --git a/t/t2405-worktree-submodule.sh b/t/t2405-worktree-submodule.sh index e1b2bfd87e..b172c26ca4 100755 --- a/t/t2405-worktree-submodule.sh +++ b/t/t2405-worktree-submodule.sh @@ -2,6 +2,9 @@ test_description='Combination of submodules and multiple worktrees' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh base_path=$(pwd -P) @@ -31,7 +34,7 @@ test_expect_success 'add superproject worktree' ' ' test_expect_failure 'submodule is checked out just after worktree add' ' - git -C worktree diff --submodule master"^!" >out && + git -C worktree diff --submodule main"^!" >out && grep "file1 updated" out ' @@ -41,7 +44,7 @@ test_expect_success 'add superproject worktree and initialize submodules' ' ' test_expect_success 'submodule is checked out just after submodule update in linked worktree' ' - git -C worktree-submodule-update diff --submodule master"^!" >out && + git -C worktree-submodule-update diff --submodule main"^!" >out && grep "file1 updated" out ' @@ -51,7 +54,7 @@ test_expect_success 'add superproject worktree and manually add submodule worktr ' test_expect_success 'submodule is checked out after manually adding submodule worktree' ' - git -C linked_submodule diff --submodule master"^!" >out && + git -C linked_submodule diff --submodule main"^!" >out && grep "file1 updated" out ' diff --git a/t/t2406-worktree-repair.sh b/t/t2406-worktree-repair.sh index 1fe468bfe8..f73741886b 100755 --- a/t/t2406-worktree-repair.sh +++ b/t/t2406-worktree-repair.sh @@ -104,6 +104,16 @@ test_expect_success 'repo not found; .git not file' ' test_i18ngrep ".git is not a file" err ' +test_expect_success 'repo not found; .git not referencing repo' ' + test_when_finished "rm -rf side not-a-repo && git worktree prune" && + git worktree add --detach side && + sed s,\.git/worktrees/side$,not-a-repo, side/.git >side/.newgit && + mv side/.newgit side/.git && + mkdir not-a-repo && + test_must_fail git worktree repair side 2>err && + test_i18ngrep ".git file does not reference a repository" err +' + test_expect_success 'repo not found; .git file broken' ' test_when_finished "rm -rf orig moved && git worktree prune" && git worktree add --detach orig && @@ -176,4 +186,20 @@ test_expect_success 'repair multiple gitdir files' ' test_must_be_empty err ' +test_expect_success 'repair moved main and linked worktrees' ' + test_when_finished "rm -rf main side mainmoved sidemoved" && + test_create_repo main && + test_commit -C main init && + git -C main worktree add --detach ../side && + sed "s,side/\.git$,sidemoved/.git," \ + main/.git/worktrees/side/gitdir >expect-gitdir && + sed "s,main/.git/worktrees/side$,mainmoved/.git/worktrees/side," \ + side/.git >expect-gitfile && + mv main mainmoved && + mv side sidemoved && + git -C mainmoved worktree repair ../sidemoved && + test_cmp expect-gitdir mainmoved/.git/worktrees/side/gitdir && + test_cmp expect-gitfile sidemoved/.git +' + test_done diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index 1ec7cb57c7..516c95ea0e 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -292,6 +292,11 @@ EOF test_cmp expect actual ' +test_expect_success 'ls-files with "**" patterns and --directory' ' + # Expectation same as previous test + git ls-files --directory -o -i --exclude "**/a.1" >actual && + test_cmp expect actual +' test_expect_success 'ls-files with "**" patterns and no slashes' ' git ls-files -o -i --exclude "one**a.1" >actual && diff --git a/t/t3003-ls-files-exclude.sh b/t/t3003-ls-files-exclude.sh index d5ec333131..c41c4f046a 100755 --- a/t/t3003-ls-files-exclude.sh +++ b/t/t3003-ls-files-exclude.sh @@ -29,11 +29,11 @@ test_expect_success 'add file to gitignore' ' ' check_all_output -test_expect_success 'ls-files -i lists only tracked-but-ignored files' ' +test_expect_success 'ls-files -i -c lists only tracked-but-ignored files' ' echo content >other-file && git add other-file && echo file >expect && - git ls-files -i --exclude-standard >output && + git ls-files -i -c --exclude-standard >output && test_cmp expect output ' diff --git a/t/t3005-ls-files-relative.sh b/t/t3005-ls-files-relative.sh index 2ec69a8a26..727e9ae1a4 100755 --- a/t/t3005-ls-files-relative.sh +++ b/t/t3005-ls-files-relative.sh @@ -46,7 +46,7 @@ test_expect_success 'ls-files -c' ' 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 && - test_i18ncmp expect.err actual.err + test_cmp expect.err actual.err ) ' @@ -61,7 +61,7 @@ test_expect_success 'ls-files -o' ' 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 && - test_i18ncmp expect.err actual.err + test_cmp expect.err actual.err ) ' diff --git a/t/t3012-ls-files-dedup.sh b/t/t3012-ls-files-dedup.sh new file mode 100755 index 0000000000..2682b1f43a --- /dev/null +++ b/t/t3012-ls-files-dedup.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +test_description='git ls-files --deduplicate test' + +. ./test-lib.sh + +test_expect_success 'setup' ' + >a.txt && + >b.txt && + >delete.txt && + git add a.txt b.txt delete.txt && + git commit -m base && + echo a >a.txt && + echo b >b.txt && + echo delete >delete.txt && + git add a.txt b.txt delete.txt && + git commit -m tip && + git tag tip && + git reset --hard HEAD^ && + echo change >a.txt && + git commit -a -m side && + git tag side +' + +test_expect_success 'git ls-files --deduplicate to show unique unmerged path' ' + test_must_fail git merge tip && + git ls-files --deduplicate >actual && + cat >expect <<-\EOF && + a.txt + b.txt + delete.txt + EOF + test_cmp expect actual && + git merge --abort +' + +test_expect_success 'git ls-files -d -m --deduplicate with different display options' ' + git reset --hard side && + test_must_fail git merge tip && + rm delete.txt && + git ls-files -d -m --deduplicate >actual && + cat >expect <<-\EOF && + a.txt + delete.txt + EOF + test_cmp expect actual && + git ls-files -d -m -t --deduplicate >actual && + cat >expect <<-\EOF && + C a.txt + C a.txt + C a.txt + R delete.txt + C delete.txt + EOF + test_cmp expect actual && + git ls-files -d -m -c --deduplicate >actual && + cat >expect <<-\EOF && + a.txt + b.txt + delete.txt + EOF + test_cmp expect actual && + git merge --abort +' + +test_done diff --git a/t/t3060-ls-files-with-tree.sh b/t/t3060-ls-files-with-tree.sh index 52ed665fcd..b257c792a4 100755 --- a/t/t3060-ls-files-with-tree.sh +++ b/t/t3060-ls-files-with-tree.sh @@ -47,6 +47,12 @@ test_expect_success setup ' git add . ' +test_expect_success 'usage' ' + test_expect_code 128 git ls-files --with-tree=HEAD -u && + test_expect_code 128 git ls-files --with-tree=HEAD -s && + test_expect_code 128 git ls-files --recurse-submodules --with-tree=HEAD +' + 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 @@ -60,4 +66,39 @@ test_expect_success \ 'git ls-files --with-tree should add entries from named tree.' \ 'test_cmp expected output' +test_expect_success 'no duplicates in --with-tree output' ' + git ls-files --with-tree=HEAD >actual && + sort -u actual >expected && + test_cmp expected actual +' + +test_expect_success 'setup: output in a conflict' ' + test_create_repo conflict && + test_commit -C conflict BASE file && + test_commit -C conflict A file foo && + git -C conflict reset --hard BASE && + test_commit -C conflict B file bar +' + +test_expect_success 'output in a conflict' ' + test_must_fail git -C conflict merge A B && + cat >expected <<-\EOF && + file + file + file + file + EOF + git -C conflict ls-files --with-tree=HEAD >actual && + test_cmp expected actual +' + +test_expect_success 'output with removed .git/index' ' + cat >expected <<-\EOF && + file + EOF + rm conflict/.git/index && + git -C conflict ls-files --with-tree=HEAD >actual && + test_cmp expected actual +' + test_done diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh index 891d4d7cb9..56ea4bda13 100755 --- a/t/t3070-wildmatch.sh +++ b/t/t3070-wildmatch.sh @@ -4,6 +4,11 @@ test_description='wildmatch tests' . ./test-lib.sh +# Disable expensive chain-lint tests; all of the tests in this script +# are variants of a few trivial test-tool invocations, and there are a lot of +# them. +GIT_TEST_CHAIN_LINT_HARDER_DEFAULT=0 + should_create_test_file() { file=$1 diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 3ec3e1d730..cc4b10236e 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -5,6 +5,9 @@ test_description='git branch assorted tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh @@ -306,7 +309,9 @@ test_expect_success 'git branch --list -v with --abbrev' ' git branch -v --list --no-abbrev t >actual.noabbrev && git branch -v --list --abbrev=0 t >actual.0abbrev && + git -c core.abbrev=no branch -v --list t >actual.noabbrev-conf && test_cmp actual.noabbrev actual.0abbrev && + test_cmp actual.noabbrev actual.noabbrev-conf && git branch -v --list --abbrev=36 t >actual.36abbrev && # how many hexdigits are used? @@ -690,7 +695,7 @@ test_expect_success 'deleting a symref' ' git branch -d symref >actual && test_path_is_file .git/refs/heads/target && test_path_is_missing .git/refs/heads/symref && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'deleting a dangling symref' ' @@ -699,7 +704,7 @@ test_expect_success 'deleting a dangling symref' ' echo "Deleted branch dangling-symref (was nowhere)." >expect && git branch -d dangling-symref >actual && test_path_is_missing .git/refs/heads/dangling-symref && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'deleting a self-referential symref' ' @@ -708,7 +713,7 @@ test_expect_success 'deleting a self-referential symref' ' echo "Deleted branch self-reference (was refs/heads/self-reference)." >expect && git branch -d self-reference >actual && test_path_is_missing .git/refs/heads/self-reference && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'renaming a symref is not allowed' ' @@ -803,7 +808,7 @@ test_expect_success 'test deleting branch without config' ' sha1=$(git rev-parse my7 | cut -c 1-7) && echo "Deleted branch my7 (was $sha1)." >expect && git branch -d my7 >actual 2>&1 && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'deleting currently checked out branch fails' ' @@ -838,7 +843,7 @@ test_expect_success 'branch from tag w/--track causes failure' ' test_expect_success '--set-upstream-to fails on multiple branches' ' echo "fatal: too many arguments to set new upstream" >expect && test_must_fail git branch --set-upstream-to main a b c 2>err && - test_i18ncmp expect err + test_cmp expect err ' test_expect_success '--set-upstream-to fails on detached HEAD' ' @@ -846,13 +851,13 @@ test_expect_success '--set-upstream-to fails on detached HEAD' ' test_when_finished git checkout - && echo "fatal: could not set upstream of HEAD to main when it does not point to any branch." >expect && test_must_fail git branch --set-upstream-to main 2>err && - test_i18ncmp expect err + test_cmp expect err ' test_expect_success '--set-upstream-to fails on a missing dst branch' ' echo "fatal: branch '"'"'does-not-exist'"'"' does not exist" >expect && test_must_fail git branch --set-upstream-to main does-not-exist 2>err && - test_i18ncmp expect err + test_cmp expect err ' test_expect_success '--set-upstream-to fails on a missing src branch' ' @@ -863,7 +868,7 @@ test_expect_success '--set-upstream-to fails on a missing src branch' ' test_expect_success '--set-upstream-to fails on a non-ref' ' echo "fatal: Cannot setup tracking information; starting point '"'"'HEAD^{}'"'"' is not a branch." >expect && test_must_fail git branch --set-upstream-to HEAD^{} 2>err && - test_i18ncmp expect err + test_cmp expect err ' test_expect_success '--set-upstream-to fails on locked config' ' @@ -894,7 +899,7 @@ test_expect_success 'use --set-upstream-to modify a particular branch' ' test_expect_success '--unset-upstream should fail if given a non-existent branch' ' echo "fatal: Branch '"'"'i-dont-exist'"'"' has no upstream information" >expect && test_must_fail git branch --unset-upstream i-dont-exist 2>err && - test_i18ncmp expect err + test_cmp expect err ' test_expect_success '--unset-upstream should fail if config is locked' ' @@ -916,13 +921,13 @@ test_expect_success 'test --unset-upstream on HEAD' ' # fail for a branch without upstream set echo "fatal: Branch '"'"'main'"'"' has no upstream information" >expect && test_must_fail git branch --unset-upstream 2>err && - test_i18ncmp expect err + test_cmp expect err ' test_expect_success '--unset-upstream should fail on multiple branches' ' echo "fatal: too many arguments to unset upstream" >expect && test_must_fail git branch --unset-upstream a b c 2>err && - test_i18ncmp expect err + test_cmp expect err ' test_expect_success '--unset-upstream should fail on detached HEAD' ' @@ -930,7 +935,7 @@ test_expect_success '--unset-upstream should fail on detached HEAD' ' test_when_finished git checkout - && echo "fatal: could not unset upstream of HEAD when it does not point to any branch." >expect && test_must_fail git branch --unset-upstream 2>err && - test_i18ncmp expect err + test_cmp expect err ' test_expect_success 'test --unset-upstream on a particular branch' ' @@ -952,7 +957,7 @@ test_expect_success '--set-upstream-to notices an error to set branch as own ups EOF test_expect_code 1 git config branch.my13.remote && test_expect_code 1 git config branch.my13.merge && - test_i18ncmp expect actual + test_cmp expect actual ' # Keep this test last, as it changes the current branch diff --git a/t/t3201-branch-contains.sh b/t/t3201-branch-contains.sh index 6c1ab69ca6..349a810cee 100755 --- a/t/t3201-branch-contains.sh +++ b/t/t3201-branch-contains.sh @@ -2,6 +2,9 @@ test_description='branch --contains <commit>, --no-contains <commit> --merged, and --no-merged' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -261,7 +264,7 @@ test_expect_success 'branch --merged with --verbose' ' * topic $(git rev-parse --short topic ) [ahead 1] foo zzz $(git rev-parse --short zzz ) second on main EOF - test_i18ncmp expect actual + test_cmp expect actual ' test_done diff --git a/t/t3202-show-branch-octopus.sh b/t/t3202-show-branch-octopus.sh index 6adf47869c..5cb0126cfe 100755 --- a/t/t3202-show-branch-octopus.sh +++ b/t/t3202-show-branch-octopus.sh @@ -2,6 +2,9 @@ test_description='test show-branch with more than 8 heads' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh numbers="1 2 3 4 5 6 7 8 9 10" @@ -15,7 +18,7 @@ test_expect_success 'setup' ' for i in $numbers do - git checkout -b branch$i master && + git checkout -b branch$i main && > file$i && git add file$i && test_tick && diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh index 5e0577d5c7..5325b9f67a 100755 --- a/t/t3203-branch-output.sh +++ b/t/t3203-branch-output.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='git branch display tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-terminal.sh @@ -157,7 +160,7 @@ test_expect_success 'git branch shows detached HEAD properly' ' EOF git checkout HEAD^0 && git branch >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'git branch shows detached HEAD properly after checkout --detach' ' @@ -170,7 +173,7 @@ test_expect_success 'git branch shows detached HEAD properly after checkout --de EOF git checkout --detach && git branch >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'git branch shows detached HEAD properly after moving' ' @@ -182,7 +185,7 @@ test_expect_success 'git branch shows detached HEAD properly after moving' ' EOF git reset --hard HEAD^1 && git branch >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'git branch shows detached HEAD properly from tag' ' @@ -195,7 +198,7 @@ EOF git tag fromtag main && git checkout fromtag && git branch >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'git branch shows detached HEAD properly after moving from tag' ' @@ -207,7 +210,7 @@ test_expect_success 'git branch shows detached HEAD properly after moving from t EOF git reset --hard HEAD^1 && git branch >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'git branch `--sort=[-]objectsize` option' ' @@ -218,7 +221,7 @@ test_expect_success 'git branch `--sort=[-]objectsize` option' ' main EOF git branch --sort=objectsize >actual && - test_i18ncmp expect actual && + test_cmp expect actual && cat >expect <<-\EOF && * (HEAD detached from fromtag) @@ -227,7 +230,7 @@ test_expect_success 'git branch `--sort=[-]objectsize` option' ' branch-two EOF git branch --sort=-objectsize >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'git branch `--sort=[-]type` option' ' @@ -238,7 +241,7 @@ test_expect_success 'git branch `--sort=[-]type` option' ' main EOF git branch --sort=type >actual && - test_i18ncmp expect actual && + test_cmp expect actual && cat >expect <<-\EOF && * (HEAD detached from fromtag) @@ -247,7 +250,7 @@ test_expect_success 'git branch `--sort=[-]type` option' ' main EOF git branch --sort=-type >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'git branch `--sort=[-]version:refname` option' ' @@ -258,7 +261,7 @@ test_expect_success 'git branch `--sort=[-]version:refname` option' ' main EOF git branch --sort=version:refname >actual && - test_i18ncmp expect actual && + test_cmp expect actual && cat >expect <<-\EOF && * (HEAD detached from fromtag) @@ -267,7 +270,7 @@ test_expect_success 'git branch `--sort=[-]version:refname` option' ' branch-one EOF git branch --sort=-version:refname >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'git branch --points-at option' ' @@ -334,7 +337,7 @@ test_expect_success 'git branch --format option' ' Refname is refs/heads/ref-to-remote EOF git branch --format="Refname is %(refname)" >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'worktree colors correct' ' @@ -352,7 +355,7 @@ test_expect_success 'worktree colors correct' ' rm -r worktree_dir && git worktree prune && test_decode_color <actual.raw >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success "set up color tests" ' @@ -395,7 +398,7 @@ test_expect_success 'verbose output lists worktree path' ' git branch -vv >actual && rm -r worktree_dir && git worktree prune && - test_i18ncmp expect actual + test_cmp expect actual ' test_done diff --git a/t/t3204-branch-name-interpretation.sh b/t/t3204-branch-name-interpretation.sh index 698d9cc4f3..993a6b5eff 100755 --- a/t/t3204-branch-name-interpretation.sh +++ b/t/t3204-branch-name-interpretation.sh @@ -6,6 +6,9 @@ Branch name arguments are usually names which are taken to be inside of refs/heads/, but we interpret some magic syntax like @{-1}, @{upstream}, etc. This script aims to check the behavior of those corner cases. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh expect_branch() { @@ -28,7 +31,7 @@ test_expect_success 'update branch via @{-1}' ' git branch previous one && git checkout previous && - git checkout master && + git checkout main && git branch -f @{-1} two && expect_branch previous two @@ -58,7 +61,7 @@ test_expect_success 'delete branch via @{-1}' ' git branch previous-del && git checkout previous-del && - git checkout master && + git checkout main && git branch -D @{-1} && expect_deleted previous-del @@ -98,7 +101,7 @@ test_expect_success 'disallow deleting remote branch via @{-1}' ' git update-ref refs/remotes/origin/previous one && git checkout -b origin/previous two && - git checkout master && + git checkout main && test_must_fail git branch -r -D @{-1} && expect_branch refs/remotes/origin/previous one && diff --git a/t/t3205-branch-color.sh b/t/t3205-branch-color.sh index da1c202fa7..08bd906173 100755 --- a/t/t3205-branch-color.sh +++ b/t/t3205-branch-color.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='basic branch output coloring' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'set up some sample branches' ' diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh index 6eb344be03..e30bc48a29 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -2,6 +2,9 @@ test_description='range-diff tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # Note that because of the range-diff's heuristics, test_commit does more @@ -127,7 +130,7 @@ test_expect_success 'setup' ' ' test_expect_success 'simple A..B A..C (unmodified)' ' - git range-diff --no-color master..topic master..unmodified \ + git range-diff --no-color main..topic main..unmodified \ >actual && cat >expect <<-EOF && 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ @@ -145,13 +148,26 @@ test_expect_success 'simple B...C (unmodified)' ' ' test_expect_success 'simple A B C (unmodified)' ' - git range-diff --no-color master topic unmodified >actual && + git range-diff --no-color main topic unmodified >actual && # same "expect" as above test_cmp expect actual ' +test_expect_success 'A^! and A^-<n> (unmodified)' ' + git range-diff --no-color topic^! unmodified^-1 >actual && + cat >expect <<-EOF && + 1: $(test_oid t4) = 1: $(test_oid u4) s/12/B/ + EOF + test_cmp expect actual +' + +test_expect_success 'A^{/..} is not mistaken for a range' ' + test_must_fail git range-diff topic^.. topic^{/..} 2>error && + test_i18ngrep "not a commit range" error +' + test_expect_success 'trivial reordering' ' - git range-diff --no-color master topic reordered >actual && + git range-diff --no-color main 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/ @@ -162,7 +178,7 @@ test_expect_success 'trivial reordering' ' ' test_expect_success 'removed a commit' ' - git range-diff --no-color master topic removed >actual && + git range-diff --no-color main 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/ @@ -173,7 +189,7 @@ test_expect_success 'removed a commit' ' ' test_expect_success 'added a commit' ' - git range-diff --no-color master topic added >actual && + git range-diff --no-color main 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/ @@ -185,7 +201,7 @@ test_expect_success 'added a commit' ' ' test_expect_success 'new base, A B C' ' - git range-diff --no-color master topic rebased >actual && + git range-diff --no-color main 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/ @@ -196,7 +212,7 @@ test_expect_success 'new base, A B C' ' ' test_expect_success 'new base, B...C' ' - # this syntax includes the commits from master! + # this syntax includes the commits from main! git range-diff --no-color topic...rebased >actual && cat >expect <<-EOF && -: $(test_oid __) > 1: $(test_oid b5) unrelated @@ -420,7 +436,7 @@ test_expect_success 'file added and later removed' ' test_expect_success 'no commits on one side' ' git commit --amend -m "new message" && - git range-diff master HEAD@{1} HEAD + git range-diff main HEAD@{1} HEAD ' test_expect_success 'changed message' ' @@ -482,11 +498,11 @@ test_expect_success 'dual-coloring' ' test_cmp expect actual ' -for prev in topic master..topic +for prev in topic main..topic do test_expect_success "format-patch --range-diff=$prev" ' git format-patch --cover-letter --range-diff=$prev \ - master..unmodified >actual && + main..unmodified >actual && test_when_finished "rm 000?-*" && test_line_count = 5 actual && test_i18ngrep "^Range-diff:$" 0000-* && @@ -505,25 +521,49 @@ test_expect_success 'format-patch --range-diff as commentary' ' grep "> 1: .* new message" 0001-* ' +test_expect_success 'format-patch --range-diff reroll-count with a non-integer' ' + git format-patch --range-diff=HEAD~1 -v2.9 HEAD~1 >actual && + test_when_finished "rm v2.9-0001-*" && + test_line_count = 1 actual && + test_i18ngrep "^Range-diff:$" v2.9-0001-* && + grep "> 1: .* new message" v2.9-0001-* +' + +test_expect_success 'format-patch --range-diff reroll-count with a integer' ' + git format-patch --range-diff=HEAD~1 -v2 HEAD~1 >actual && + test_when_finished "rm v2-0001-*" && + test_line_count = 1 actual && + test_i18ngrep "^Range-diff ..* v1:$" v2-0001-* && + grep "> 1: .* new message" v2-0001-* +' + +test_expect_success 'format-patch --range-diff with v0' ' + git format-patch --range-diff=HEAD~1 -v0 HEAD~1 >actual && + test_when_finished "rm v0-0001-*" && + test_line_count = 1 actual && + test_i18ngrep "^Range-diff:$" v0-0001-* && + grep "> 1: .* new message" v0-0001-* +' + test_expect_success 'range-diff overrides diff.noprefix internally' ' git -c diff.noprefix=true range-diff HEAD^... ' test_expect_success 'basic with modified format.pretty with suffix' ' git -c format.pretty="format:commit %H%d%n" range-diff \ - master..topic master..unmodified + main..topic main..unmodified ' test_expect_success 'basic with modified format.pretty without "commit "' ' git -c format.pretty="format:%H%n" range-diff \ - master..topic master..unmodified + main..topic main..unmodified ' 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 \ + git range-diff --no-color main..topic main..unmodified \ >actual && sed s/Z/\ /g >expect <<-EOF && 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ @@ -547,7 +587,7 @@ 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 \ + git range-diff --no-color --no-notes main..topic main..unmodified \ >actual && cat >expect <<-EOF && 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ @@ -565,7 +605,7 @@ test_expect_success 'range-diff with multiple --notes' ' 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 \ + git range-diff --no-color --notes=note1 --notes=note2 main..topic main..unmodified \ >actual && sed s/Z/\ /g >expect <<-EOF && 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ @@ -595,7 +635,7 @@ test_expect_success 'format-patch --range-diff does not compare notes by default 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 && + main..unmodified >actual && test_when_finished "rm 000?-*" && test_line_count = 5 actual && test_i18ngrep "^Range-diff:$" 0000-* && @@ -612,7 +652,7 @@ test_expect_success 'format-patch --range-diff with --no-notes' ' 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 && + main..unmodified >actual && test_when_finished "rm 000?-*" && test_line_count = 5 actual && test_i18ngrep "^Range-diff:$" 0000-* && @@ -629,7 +669,7 @@ test_expect_success 'format-patch --range-diff with --notes' ' 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 && + main..unmodified >actual && test_when_finished "rm 000?-*" && test_line_count = 5 actual && test_i18ngrep "^Range-diff:$" 0000-* && @@ -658,7 +698,7 @@ test_expect_success 'format-patch --range-diff with format.notes config' ' test_when_finished git notes remove topic unmodified && test_config format.notes true && git format-patch --cover-letter --range-diff=$prev \ - master..unmodified >actual && + main..unmodified >actual && test_when_finished "rm 000?-*" && test_line_count = 5 actual && test_i18ngrep "^Range-diff:$" 0000-* && @@ -689,7 +729,7 @@ test_expect_success 'format-patch --range-diff with multiple notes' ' 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 && + main..unmodified >actual && test_when_finished "rm 000?-*" && test_line_count = 5 actual && test_i18ngrep "^Range-diff:$" 0000-* && @@ -717,4 +757,19 @@ test_expect_success 'format-patch --range-diff with multiple notes' ' test_cmp expect actual ' +test_expect_success '--left-only/--right-only' ' + git switch --orphan left-right && + test_commit first && + test_commit unmatched && + test_commit common && + git switch -C left-right first && + git cherry-pick common && + + git range-diff -s --left-only ...common >actual && + head_oid=$(git rev-parse --short HEAD) && + common_oid=$(git rev-parse --short common) && + echo "1: $head_oid = 2: $common_oid common" >expect && + test_cmp expect actual +' + test_done diff --git a/t/t3206/history.export b/t/t3206/history.export index 4c808e5b3b..4485adc37b 100644 --- a/t/t3206/history.export +++ b/t/t3206/history.export @@ -168,7 +168,7 @@ mark :11 data 10 unrelated -commit refs/heads/master +commit refs/heads/main mark :12 author Thomas Rast <trast@inf.ethz.ch> 1374485127 +0200 committer Thomas Rast <trast@inf.ethz.ch> 1374485127 +0200 diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh index f41b2afb99..3b7cdc56ec 100755 --- a/t/t3210-pack-refs.sh +++ b/t/t3210-pack-refs.sh @@ -9,6 +9,9 @@ test_description='git pack-refs should not change the branch semantic This test runs git pack-refs and git show-ref and checks that the branch semantic is still the same. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'enable reflogs' ' @@ -135,7 +138,7 @@ test_expect_success 'delete ref with dangling packed version' ' git commit --allow-empty -m "future garbage" && git pack-refs --all && git reset --hard HEAD^ && - git checkout master && + git checkout main && git reflog expire --expire=all --all && git prune --expire=all && git branch -d lamb 2>result && @@ -240,7 +243,7 @@ test_expect_success 'retry acquiring packed-refs.lock' ' test_expect_success SYMLINKS 'pack symlinked packed-refs' ' # First make sure that symlinking works when reading: - git update-ref refs/heads/lossy refs/heads/master && + git update-ref refs/heads/lossy refs/heads/main && git for-each-ref >all-refs-before && mv .git/packed-refs .git/my-deviant-packed-refs && ln -s my-deviant-packed-refs .git/packed-refs && diff --git a/t/t3211-peel-ref.sh b/t/t3211-peel-ref.sh index 3b7caca421..37b9d26f4b 100755 --- a/t/t3211-peel-ref.sh +++ b/t/t3211-peel-ref.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='tests for the peel_ref optimization of packed-refs' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'create annotated tag in refs/tags' ' @@ -19,7 +22,7 @@ print_ref() { test_expect_success 'set up expected show-ref output' ' { - print_ref "refs/heads/master" && + print_ref "refs/heads/main" && print_ref "refs/outside/foo" && print_ref "refs/outside/foo^{}" && print_ref "refs/tags/base" && @@ -47,7 +50,7 @@ test_expect_success 'create old-style pack-refs without fully-peeled' ' # know we are emulating exactly what an older git would have written. { echo "# pack-refs with: peeled " && - print_ref "refs/heads/master" && + print_ref "refs/heads/main" && print_ref "refs/outside/foo" && print_ref "refs/tags/base" && print_ref "refs/tags/foo" && diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh index 04de03cad0..f5bf16abcd 100755 --- a/t/t3300-funny-names.sh +++ b/t/t3300-funny-names.sh @@ -181,7 +181,7 @@ test_expect_success 'diffstat for rename quotes funny filename' ' git diff-index -M -p $t0 >diff && git apply --stat <diff >diffstat && sed -e "s/|.*//" -e "s/ *\$//" <diffstat >current && - test_i18ncmp expected current + test_cmp expected current ' test_expect_success 'numstat for rename quotes funny filename' ' diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh index ca60faf480..d742be8840 100755 --- a/t/t3301-notes.sh +++ b/t/t3301-notes.sh @@ -1293,18 +1293,18 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' ' grep "replacement note 3" actual ' -test_expect_success 'git notes copy diagnoses too many or too few parameters' ' +test_expect_success 'git notes copy diagnoses too many or too few arguments' ' test_must_fail git notes copy 2>error && - test_i18ngrep "too few parameters" error && + test_i18ngrep "too few arguments" error && test_must_fail git notes copy one two three 2>error && - test_i18ngrep "too many parameters" error + test_i18ngrep "too many arguments" error ' -test_expect_success 'git notes get-ref expands refs/heads/master to refs/notes/refs/heads/master' ' +test_expect_success 'git notes get-ref expands refs/heads/main to refs/notes/refs/heads/main' ' test_unconfig core.notesRef && sane_unset GIT_NOTES_REF && - echo refs/notes/refs/heads/master >expect && - git notes --ref=refs/heads/master get-ref >actual && + echo refs/notes/refs/heads/main >expect && + git notes --ref=refs/heads/main get-ref >actual && test_cmp expect actual ' diff --git a/t/t3302-notes-index-expensive.sh b/t/t3302-notes-index-expensive.sh index 7217c5e222..ef8b63952e 100755 --- a/t/t3302-notes-index-expensive.sh +++ b/t/t3302-notes-index-expensive.sh @@ -5,6 +5,9 @@ test_description='Test commit notes index (expensive!)' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh create_repo () { @@ -20,7 +23,7 @@ create_repo () { notemark=$(($mark+1)) test_tick && cat <<-INPUT_END && - commit refs/heads/master + commit refs/heads/main mark :$mark committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <<COMMIT diff --git a/t/t3303-notes-subtrees.sh b/t/t3303-notes-subtrees.sh index 704aee81ef..d47ce00f69 100755 --- a/t/t3303-notes-subtrees.sh +++ b/t/t3303-notes-subtrees.sh @@ -2,6 +2,9 @@ test_description='Test commit notes organized in subtrees' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh number_of_commits=100 @@ -40,7 +43,7 @@ test_expect_success "setup: create $number_of_commits commits" ' nr=$(($nr+1)) && test_tick && cat <<INPUT_END -commit refs/heads/master +commit refs/heads/main committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <<COMMIT commit #$nr @@ -75,7 +78,7 @@ test_sha1_based () { ( start_note_commit && nr=$number_of_commits && - git rev-list refs/heads/master | + git rev-list refs/heads/main | while read sha1; do note_path=$(echo "$sha1" | sed "$1") cat <<INPUT_END && @@ -105,7 +108,7 @@ test_same_notes () { ( start_note_commit && nr=$number_of_commits && - git rev-list refs/heads/master | + git rev-list refs/heads/main | while read sha1; do first_note_path=$(echo "$sha1" | sed "$1") second_note_path=$(echo "$sha1" | sed "$2") @@ -144,7 +147,7 @@ test_concatenated_notes () { ( start_note_commit && nr=$number_of_commits && - git rev-list refs/heads/master | + git rev-list refs/heads/main | while read sha1; do first_note_path=$(echo "$sha1" | sed "$1") second_note_path=$(echo "$sha1" | sed "$2") diff --git a/t/t3304-notes-mixed.sh b/t/t3304-notes-mixed.sh index 1709e8c00b..03dfcd3954 100755 --- a/t/t3304-notes-mixed.sh +++ b/t/t3304-notes-mixed.sh @@ -2,6 +2,9 @@ test_description='Test notes trees that also contain non-notes' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh number_of_commits=100 @@ -36,7 +39,7 @@ test_expect_success "setup: create a couple of commits" ' test_tick && cat <<INPUT_END >input && -commit refs/heads/master +commit refs/heads/main committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <<COMMIT commit #1 @@ -51,7 +54,7 @@ INPUT_END test_tick && cat <<INPUT_END >>input && -commit refs/heads/master +commit refs/heads/main committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <<COMMIT commit #2 @@ -68,8 +71,8 @@ INPUT_END test_expect_success "create a notes tree with both notes and non-notes" ' - commit1=$(git rev-parse refs/heads/master^) && - commit2=$(git rev-parse refs/heads/master) && + commit1=$(git rev-parse refs/heads/main^) && + commit2=$(git rev-parse refs/heads/main) && test_tick && cat <<INPUT_END >input && commit refs/notes/commits diff --git a/t/t3308-notes-merge.sh b/t/t3308-notes-merge.sh index d69c84c640..202702be1a 100755 --- a/t/t3308-notes-merge.sh +++ b/t/t3308-notes-merge.sh @@ -108,7 +108,7 @@ test_expect_success 'fail to merge into various non-notes refs' ' git update-ref refs/notes/dir/foo HEAD && test_must_fail git -c "core.notesRef=refs/notes/dir" notes merge x && test_must_fail git -c "core.notesRef=refs/notes/dir/" notes merge x && - test_must_fail git -c "core.notesRef=refs/heads/master" notes merge x && + test_must_fail git -c "core.notesRef=refs/heads/main" notes merge x && test_must_fail git -c "core.notesRef=refs/notes/y:" notes merge x && test_must_fail git -c "core.notesRef=refs/notes/y:foo" notes merge x && test_must_fail git -c "core.notesRef=refs/notes/foo^{bar" notes merge x diff --git a/t/t3320-notes-merge-worktrees.sh b/t/t3320-notes-merge-worktrees.sh index 823fdbda1f..052516e6c6 100755 --- a/t/t3320-notes-merge-worktrees.sh +++ b/t/t3320-notes-merge-worktrees.sh @@ -5,6 +5,9 @@ test_description='Test merging of notes trees in multiple worktrees' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup commit' ' @@ -36,8 +39,8 @@ test_expect_success 'modify notes ref ourselves (x)' ' ' test_expect_success 'create some new worktrees' ' - git worktree add -b newbranch worktree master && - git worktree add -b newbranch2 worktree2 master + git worktree add -b newbranch worktree main && + git worktree add -b newbranch2 worktree2 main ' test_expect_success 'merge z into y fails and sets NOTES_MERGE_REF' ' diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index 40d2975995..0bb88aa982 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -8,6 +8,9 @@ test_description='git rebase assorted tests This test runs git rebase and checks that the author information is not lost among other things. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh GIT_AUTHOR_NAME=author@name @@ -24,15 +27,15 @@ test_expect_success 'prepare repository with topic branches' ' git update-index --add Y && git commit -m "Add Y." && git checkout -b filemove && - git reset --soft master && + git reset --soft main && mkdir D && git mv A D/A && git commit -m "Move A." && - git checkout -b my-topic-branch master && + git checkout -b my-topic-branch main && echo Second >B && git update-index --add B && git commit -m "Add B." && - git checkout -f master && + git checkout -f main && echo Third >>A && git update-index A && git commit -m "Modify A." && @@ -46,23 +49,23 @@ test_expect_success 'prepare repository with topic branches' ' test_expect_success 'rebase on dirty worktree' ' echo dirty >>A && - test_must_fail git rebase master + test_must_fail git rebase main ' test_expect_success 'rebase on dirty cache' ' git add A && - test_must_fail git rebase master + test_must_fail git rebase main ' -test_expect_success 'rebase against master' ' +test_expect_success 'rebase against main' ' git reset --hard HEAD && - git rebase master + git rebase main ' test_expect_success 'rebase sets ORIG_HEAD to pre-rebase state' ' git checkout -b orig-head topic && pre="$(git rev-parse --verify HEAD)" && - git rebase master && + git rebase main && test_cmp_rev "$pre" ORIG_HEAD && test_cmp_rev ! "$pre" HEAD ' @@ -93,28 +96,28 @@ test_expect_success 'HEAD was detached during rebase' ' test_expect_success 'rebase from ambiguous branch name' ' git checkout -b topic side && - git rebase master + git rebase main ' test_expect_success 'rebase off of the previous branch using "-"' ' - git checkout master && + git checkout main && git checkout HEAD^ && git rebase @{-1} >expect.messages && - git merge-base master HEAD >expect.forkpoint && + git merge-base main HEAD >expect.forkpoint && - git checkout master && + git checkout main && git checkout HEAD^ && git rebase - >actual.messages && - git merge-base master HEAD >actual.forkpoint && + git merge-base main HEAD >actual.forkpoint && test_cmp expect.forkpoint actual.forkpoint && # the next one is dubious---we may want to say "-", # instead of @{-1}, in the message - test_i18ncmp expect.messages actual.messages + test_cmp expect.messages actual.messages ' test_expect_success 'rebase a single mode change' ' - git checkout master && + git checkout main && git branch -D topic && echo 1 >X && git add X && @@ -126,7 +129,7 @@ test_expect_success 'rebase a single mode change' ' test_chmod +x A && test_tick && git commit -m modechange && - GIT_TRACE=1 git rebase master + GIT_TRACE=1 git rebase main ' test_expect_success 'rebase is not broken by diff.renames' ' @@ -162,11 +165,11 @@ test_expect_success 'fail when upstream arg is missing and not configured' ' test_expect_success 'rebase works with format.useAutoBase' ' test_config format.useAutoBase true && git checkout topic && - git rebase master + git rebase main ' test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg (--merge)' ' - git checkout -b default-base master && + git checkout -b default-base main && git checkout -b default topic && git config branch.default.remote . && git config branch.default.merge refs/heads/default-base && @@ -184,7 +187,7 @@ test_expect_success 'default to common base in @{upstream}s reflog if no upstrea ' test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg (--apply)' ' - git checkout -B default-base master && + git checkout -B default-base main && git checkout -B default topic && git config branch.default.remote . && git config branch.default.merge refs/heads/default-base && @@ -226,13 +229,13 @@ test_expect_success 'cherry-picked commits and fork-point work together' ' test_expect_success 'rebase --apply -q is quiet' ' git checkout -b quiet topic && - git rebase --apply -q master >output.out 2>&1 && + git rebase --apply -q main >output.out 2>&1 && test_must_be_empty output.out ' test_expect_success 'rebase --merge -q is quiet' ' git checkout -B quiet topic && - git rebase --merge -q master >output.out 2>&1 && + git rebase --merge -q main >output.out 2>&1 && test_must_be_empty output.out ' @@ -294,7 +297,7 @@ test_expect_success 'rebase commit with an ancient timestamp' ' ' test_expect_success 'rebase with "From " line in commit message' ' - git checkout -b preserve-from master~1 && + git checkout -b preserve-from main~1 && cat >From_.msg <<EOF && Somebody embedded an mbox in a commit message @@ -310,7 +313,7 @@ EOF >From_ && git add From_ && git commit -F From_.msg && - git rebase master && + git rebase main && git log -1 --pretty=format:%B >out && test_cmp From_.msg out ' @@ -357,12 +360,12 @@ test_expect_success 'rebase --apply and .gitattributes' ' git cherry-pick test && git checkout test && - git rebase master && + git rebase main && grep "smudged" a.txt && git checkout removal && git reset --hard && - git rebase master && + git rebase main && grep "clean" a.txt ) ' @@ -385,37 +388,21 @@ test_expect_success 'rebase--merge.sh and --show-current-patch' ' ) ' -test_expect_success 'rebase -c rebase.useBuiltin=false warning' ' - expected="rebase.useBuiltin support has been removed" && - - # Only warn when the legacy rebase is requested... - test_must_fail git -c rebase.useBuiltin=false rebase 2>err && - test_i18ngrep "$expected" err && - test_must_fail env GIT_TEST_REBASE_USE_BUILTIN=false git rebase 2>err && - test_i18ngrep "$expected" err && - - # ...not when we would have used the built-in anyway - test_must_fail git -c rebase.useBuiltin=true rebase 2>err && - test_must_be_empty err && - test_must_fail env GIT_TEST_REBASE_USE_BUILTIN=true git rebase 2>err && - test_must_be_empty err -' - test_expect_success 'switch to branch checked out here' ' - git checkout master && - git rebase master master + git checkout main && + git rebase main main ' test_expect_success 'switch to branch not checked out' ' - git checkout master && + git checkout main && git branch other && - git rebase master other + git rebase main other ' test_expect_success 'refuse to switch to branch checked out elsewhere' ' - git checkout master && + git checkout main && git worktree add wt && - test_must_fail git -C wt rebase master master 2>err && + test_must_fail git -C wt rebase main main 2>err && test_i18ngrep "already checked out" err ' diff --git a/t/t3402-rebase-merge.sh b/t/t3402-rebase-merge.sh index 6e032716a6..cfde68f193 100755 --- a/t/t3402-rebase-merge.sh +++ b/t/t3402-rebase-merge.sh @@ -5,6 +5,9 @@ test_description='git rebase --merge test' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh T="A quick brown fox @@ -19,10 +22,10 @@ test_expect_success setup ' git commit -m"initial" && git branch side && echo "11 $T" >>original && - git commit -a -m"master updates a bit." && + git commit -a -m"main updates a bit." && echo "12 $T" >>original && - git commit -a -m"master updates a bit more." && + git commit -a -m"main updates a bit more." && git checkout side && (echo "0 $T" && cat original) >renamed && @@ -47,13 +50,13 @@ test_expect_success setup ' ' test_expect_success 'reference merge' ' - git merge -s recursive -m "reference merge" master + git merge -s recursive -m "reference merge" main ' PRE_REBASE=$(git rev-parse test-rebase) test_expect_success rebase ' git checkout test-rebase && - GIT_TRACE=1 git rebase --merge master + GIT_TRACE=1 git rebase --merge main ' test_expect_success 'test-rebase@{1} is pre rebase' ' @@ -72,24 +75,24 @@ test_expect_success 'merge and rebase should match' ' ' test_expect_success 'rebase the other way' ' - git reset --hard master && + git reset --hard main && git rebase --merge side ' test_expect_success 'rebase -Xtheirs' ' - git checkout -b conflicting master~2 && + git checkout -b conflicting main~2 && echo "AB $T" >> original && git commit -mconflicting original && - git rebase -Xtheirs master && + git rebase -Xtheirs main && grep AB original && ! grep 11 original ' test_expect_success 'rebase -Xtheirs from orphan' ' - git checkout --orphan orphan-conflicting master~2 && + git checkout --orphan orphan-conflicting main~2 && echo "AB $T" >> original && git commit -morphan-conflicting original && - git rebase -Xtheirs master && + git rebase -Xtheirs main && grep AB original && ! grep 11 original ' @@ -107,9 +110,9 @@ test_expect_success 'merge and rebase should match' ' test_expect_success 'picking rebase' ' git reset --hard side && - git rebase --merge --onto master side^^ && - mb=$(git merge-base master HEAD) && - if test "$mb" = "$(git rev-parse master)" + git rebase --merge --onto main side^^ && + mb=$(git merge-base main HEAD) && + if test "$mb" = "$(git rev-parse main)" then echo happy else @@ -140,11 +143,11 @@ test_expect_success 'rebase -s funny -Xopt' ' EOF chmod +x test-bin/git-merge-funny && git reset --hard && - git checkout -b test-funny master^ && + git checkout -b test-funny main^ && test_commit funny && ( PATH=./test-bin:$PATH && - git rebase -s funny -Xopt master + git rebase -s funny -Xopt main ) && test -f funny.was.run ' @@ -165,7 +168,7 @@ test_expect_success 'rebase --skip works with two conflicts in a row' ' test_expect_success '--reapply-cherry-picks' ' git init repo && - # O(1-10) -- O(1-11) -- O(0-10) master + # O(1-10) -- O(1-11) -- O(0-10) main # \ # -- O(1-11) -- O(1-12) otherbranch @@ -187,18 +190,18 @@ test_expect_success '--reapply-cherry-picks' ' git -C repo commit -a -m "add 12 in another branch" && # Regular rebase fails, because the 1-11 commit is deduplicated - test_must_fail git -C repo rebase --merge master 2> err && + test_must_fail git -C repo rebase --merge main 2> err && test_i18ngrep "error: could not apply.*add 12 in another branch" err && git -C repo rebase --abort && # With --reapply-cherry-picks, it works - git -C repo rebase --merge --reapply-cherry-picks master + git -C repo rebase --merge --reapply-cherry-picks main ' test_expect_success '--reapply-cherry-picks refrains from reading unneeded blobs' ' git init server && - # O(1-10) -- O(1-11) -- O(1-12) master + # O(1-10) -- O(1-11) -- O(1-12) main # \ # -- O(0-10) otherbranch @@ -220,18 +223,18 @@ test_expect_success '--reapply-cherry-picks refrains from reading unneeded blobs test_config -C server uploadpack.allowanysha1inwant 1 && git clone --filter=blob:none "file://$(pwd)/server" client && - git -C client checkout origin/master && + git -C client checkout origin/main && git -C client checkout origin/otherbranch && # Sanity check to ensure that the blobs from the merge base and "add # 11" are missing git -C client rev-list --objects --all --missing=print >missing_list && - MERGE_BASE_BLOB=$(git -C server rev-parse master^^:file.txt) && - ADD_11_BLOB=$(git -C server rev-parse master^:file.txt) && + MERGE_BASE_BLOB=$(git -C server rev-parse main^^:file.txt) && + ADD_11_BLOB=$(git -C server rev-parse main^:file.txt) && grep "[?]$MERGE_BASE_BLOB" missing_list && grep "[?]$ADD_11_BLOB" missing_list && - git -C client rebase --merge --reapply-cherry-picks origin/master && + git -C client rebase --merge --reapply-cherry-picks origin/main && # The blob from the merge base had to be fetched, but not "add 11" git -C client rev-list --objects --all --missing=print >missing_list && diff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh index a927774910..e26762d0b2 100755 --- a/t/t3403-rebase-skip.sh +++ b/t/t3403-rebase-skip.sh @@ -5,6 +5,9 @@ test_description='git rebase --merge --skip tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh @@ -48,7 +51,7 @@ test_expect_success setup ' ' test_expect_success 'rebase with git am -3 (default)' ' - test_must_fail git rebase master + test_must_fail git rebase main ' test_expect_success 'rebase --skip can not be used with other options' ' @@ -64,7 +67,7 @@ test_expect_success 'rebase moves back to skip-reference' ' test refs/heads/skip-reference = $(git symbolic-ref HEAD) && git branch post-rebase && git reset --hard pre-rebase && - test_must_fail git rebase master && + test_must_fail git rebase main && echo "hello" > hello && git add hello && git rebase --continue && @@ -75,7 +78,7 @@ test_expect_success 'rebase moves back to skip-reference' ' test_expect_success 'checkout skip-merge' 'git checkout -f skip-merge' test_expect_success 'rebase with --merge' ' - test_must_fail git rebase --merge master + test_must_fail git rebase --merge main ' test_expect_success 'rebase --skip with --merge' ' diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index b06fc36159..66bcbbf952 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -25,6 +25,9 @@ Initial setup: where A, B, D and G all touch file1, and one, two, three, four all touch file "conflict". ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh @@ -83,7 +86,7 @@ test_expect_success 'rebase -i with empty todo list' ' git rebase -i HEAD^ >output 2>&1 ) && tail -n 1 output >actual && # Ignore output about changing todo list - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'rebase -i with the exec command' ' @@ -98,7 +101,8 @@ test_expect_success 'rebase -i with the exec command' ' ) && test_path_is_file touch-one && test_path_is_file touch-two && - test_path_is_missing touch-three " (should have stopped before)" && + # Missing because we should have stopped by now. + test_path_is_missing touch-three && test_cmp_rev C HEAD && git rebase --continue && test_path_is_file touch-three && @@ -155,9 +159,9 @@ test_expect_success 'rebase -x with empty command fails' ' test_when_finished "git rebase --abort ||:" && test_must_fail env git rebase -x "" @ 2>actual && test_write_lines "error: empty exec command" >expected && - test_i18ncmp expected actual && + test_cmp expected actual && test_must_fail env git rebase -x " " @ 2>actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'rebase -x with newline in command fails' ' @@ -165,7 +169,7 @@ test_expect_success 'rebase -x with newline in command fails' ' test_must_fail env git rebase -x "a${LF}b" @ 2>actual && test_write_lines "error: exec commands cannot contain newlines" \ >expected && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'rebase -i with exec of inexistent command' ' @@ -447,7 +451,7 @@ test_expect_success 'verbose flag is heeded, even after --continue' ' grep "^ file1 | 2 +-$" output ' -test_expect_success C_LOCALE_OUTPUT 'multi-squash only fires up editor once' ' +test_expect_success 'multi-squash only fires up editor once' ' base=$(git rev-parse HEAD~4) && ( set_fake_editor && @@ -460,7 +464,7 @@ test_expect_success C_LOCALE_OUTPUT 'multi-squash only fires up editor once' ' test 1 = $(git show | grep ONCE | wc -l) ' -test_expect_success C_LOCALE_OUTPUT 'multi-fixup does not fire up editor' ' +test_expect_success 'multi-fixup does not fire up editor' ' git checkout -b multi-fixup E && base=$(git rev-parse HEAD~4) && ( @@ -511,7 +515,7 @@ test_expect_success 'commit message retained after conflict' ' git branch -D conflict-squash ' -test_expect_success C_LOCALE_OUTPUT 'squash and fixup generate correct log messages' ' +test_expect_success 'squash and fixup generate correct log messages' ' cat >expect-squash-fixup <<-\EOF && B @@ -538,7 +542,7 @@ test_expect_success C_LOCALE_OUTPUT 'squash and fixup generate correct log messa git branch -D squash-fixup ' -test_expect_success C_LOCALE_OUTPUT 'squash ignores comments' ' +test_expect_success 'squash ignores comments' ' git checkout -b skip-comments E && base=$(git rev-parse HEAD~4) && ( @@ -554,7 +558,7 @@ test_expect_success C_LOCALE_OUTPUT 'squash ignores comments' ' git branch -D skip-comments ' -test_expect_success C_LOCALE_OUTPUT 'squash ignores blank lines' ' +test_expect_success 'squash ignores blank lines' ' git checkout -b skip-blank-lines E && base=$(git rev-parse HEAD~4) && ( @@ -992,7 +996,7 @@ test_expect_success 'rebase -ix with several instances of --exec' ' test_cmp expected actual ' -test_expect_success C_LOCALE_OUTPUT 'rebase -ix with --autosquash' ' +test_expect_success 'rebase -ix with --autosquash' ' git reset --hard execute && git checkout -b autosquash && echo second >second.txt && @@ -1133,7 +1137,7 @@ test_expect_success 'rebase -i --root reword root when root has untracked file c test "$(git rev-list --count HEAD)" = 2 ' -test_expect_success C_LOCALE_OUTPUT 'rebase --edit-todo does not work on non-interactive rebase' ' +test_expect_success 'rebase --edit-todo does not work on non-interactive rebase' ' git checkout reword-original-root-branch && git reset --hard && git checkout conflict-branch && @@ -1462,7 +1466,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' ' FAKE_LINES="1 2 3 4" git rebase -i --root 2>actual.2 ) && head -n4 actual.2 >actual && - test_i18ncmp expect actual && + test_cmp expect actual && test D = $(git cat-file commit HEAD | sed -ne \$p) ' @@ -1486,7 +1490,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' ' set_fake_editor && test_must_fail env FAKE_LINES="1 2 4" \ git rebase -i --root 2>actual && - test_i18ncmp expect actual && + test_cmp expect actual && cp .git/rebase-merge/git-rebase-todo.backup \ .git/rebase-merge/git-rebase-todo && FAKE_LINES="1 2 drop 3 4 drop 5" git rebase --edit-todo @@ -1532,11 +1536,11 @@ test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = wa cp .git/rebase-merge/git-rebase-todo.backup orig && FAKE_LINES="2 3 4" git rebase --edit-todo 2>actual.2 && head -n6 actual.2 >actual && - test_i18ncmp expect actual && + test_cmp expect actual && cp orig .git/rebase-merge/git-rebase-todo && FAKE_LINES="1 2 3 4" git rebase --edit-todo 2>actual.2 && head -n4 actual.2 >actual && - test_i18ncmp expect.3 actual && + test_cmp expect.3 actual && git rebase --continue 2>actual ) && test D = $(git cat-file commit HEAD | sed -ne \$p) && @@ -1572,16 +1576,16 @@ test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = er cp .git/rebase-merge/git-rebase-todo.backup orig && test_must_fail env FAKE_LINES="2 3 4" \ git rebase --edit-todo 2>actual && - test_i18ncmp expect actual && + test_cmp expect actual && test_must_fail git rebase --continue 2>actual && - test_i18ncmp expect.2 actual && + test_cmp expect.2 actual && test_must_fail git rebase --edit-todo && cp orig .git/rebase-merge/git-rebase-todo && test_must_fail env FAKE_LINES="1 2 3 4" \ git rebase --edit-todo 2>actual && - test_i18ncmp expect.3 actual && + test_cmp expect.3 actual && test_must_fail git rebase --continue 2>actual && - test_i18ncmp expect.3 actual && + test_cmp expect.3 actual && cp orig .git/rebase-merge/git-rebase-todo && FAKE_LINES="1 2 3 4 drop 5" git rebase --edit-todo && git rebase --continue 2>actual diff --git a/t/t3405-rebase-malformed.sh b/t/t3405-rebase-malformed.sh index 860e63e444..2524331861 100755 --- a/t/t3405-rebase-malformed.sh +++ b/t/t3405-rebase-malformed.sh @@ -2,6 +2,9 @@ test_description='rebase should handle arbitrary git message' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh @@ -52,7 +55,7 @@ test_expect_success setup ' git add file3 && git commit --allow-empty-message -m "" && - git checkout master && + git checkout main && echo One >file1 && test_tick && @@ -62,7 +65,7 @@ test_expect_success setup ' test_expect_success 'rebase commit with multi-line subject' ' - git rebase master multi-line-subject && + git rebase main multi-line-subject && git cat-file commit HEAD | sed -e "1,/^\$/d" >F1 && test_cmp F0 F1 && @@ -70,14 +73,14 @@ test_expect_success 'rebase commit with multi-line subject' ' ' test_expect_success 'rebase commit with diff in message' ' - git rebase master diff-in-message && + git rebase main diff-in-message && git cat-file commit HEAD | sed -e "1,/^$/d" >G1 && test_cmp G0 G1 && test_cmp G G0 ' test_expect_success 'rebase -m commit with empty message' ' - git rebase -m master empty-message-merge + git rebase -m main empty-message-merge ' test_expect_success 'rebase -i commit with empty message' ' diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh index 4afc528165..77a313f62e 100755 --- a/t/t3406-rebase-message.sh +++ b/t/t3406-rebase-message.sh @@ -2,6 +2,9 @@ test_description='messages from rebase operation' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -18,27 +21,27 @@ test_expect_success 'setup' ' ' test_expect_success 'rebase -m' ' - git rebase -m master >actual && + git rebase -m main >actual && test_must_be_empty actual ' -test_expect_success 'rebase against master twice' ' - git rebase --apply master >out && +test_expect_success 'rebase against main twice' ' + git rebase --apply main >out && test_i18ngrep "Current branch topic is up to date" out ' -test_expect_success 'rebase against master twice with --force' ' - git rebase --force-rebase --apply master >out && +test_expect_success 'rebase against main twice with --force' ' + git rebase --force-rebase --apply main >out && test_i18ngrep "Current branch topic is up to date, rebase forced" out ' -test_expect_success 'rebase against master twice from another branch' ' +test_expect_success 'rebase against main twice from another branch' ' git checkout topic^ && - git rebase --apply master topic >out && + git rebase --apply main topic >out && test_i18ngrep "Current branch topic is up to date" out ' -test_expect_success 'rebase fast-forward to master' ' +test_expect_success 'rebase fast-forward to main' ' git checkout topic^ && git rebase --apply topic >out && test_i18ngrep "Fast-forwarded HEAD to topic" out @@ -46,31 +49,24 @@ test_expect_success 'rebase fast-forward to master' ' test_expect_success 'rebase --stat' ' git reset --hard start && - git rebase --stat master >diffstat.txt && + git rebase --stat main >diffstat.txt && grep "^ fileX | *1 +$" diffstat.txt ' test_expect_success 'rebase w/config rebase.stat' ' git reset --hard start && git config rebase.stat true && - git rebase master >diffstat.txt && + git rebase main >diffstat.txt && grep "^ fileX | *1 +$" diffstat.txt ' test_expect_success 'rebase -n overrides config rebase.stat config' ' git reset --hard start && git config rebase.stat true && - git rebase -n master >diffstat.txt && + git rebase -n main >diffstat.txt && ! grep "^ fileX | *1 +$" diffstat.txt ' -# Output to stderr: -# -# "Does not point to a valid commit: invalid-ref" -# -# NEEDSWORK: This "grep" is fine in real non-C locales, but -# GIT_TEST_GETTEXT_POISON poisons the refname along with the enclosing -# error message. test_expect_success 'rebase --onto outputs the invalid ref' ' test_must_fail git rebase --onto invalid-ref HEAD HEAD 2>err && test_i18ngrep "invalid-ref" err @@ -113,7 +109,7 @@ test_expect_success 'rebase -i onto unrelated history' ' git init unrelated && test_commit -C unrelated 1 && git -C unrelated remote add -f origin "$PWD" && - git -C unrelated branch --set-upstream-to=origin/master && + git -C unrelated branch --set-upstream-to=origin/main && git -C unrelated -c core.editor=true rebase -i -v --stat >actual && test_i18ngrep "Changes to " actual && test_i18ngrep "5 files changed" actual diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh index 97efea0f56..7c381fbc89 100755 --- a/t/t3407-rebase-abort.sh +++ b/t/t3407-rebase-abort.sh @@ -2,6 +2,9 @@ test_description='git rebase --abort tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh ### Test that we handle space characters properly @@ -37,7 +40,7 @@ testrebase() { cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && - test_must_fail git rebase$type master && + test_must_fail git rebase$type main && test_path_is_dir "$dotest" && git rebase --abort && test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && @@ -48,10 +51,10 @@ testrebase() { cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && - test_must_fail git rebase$type master && + test_must_fail git rebase$type main && test_path_is_dir "$dotest" && test_must_fail git rebase --skip && - test $(git rev-parse HEAD) = $(git rev-parse master) && + test $(git rev-parse HEAD) = $(git rev-parse main) && git rebase --abort && test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && test ! -d "$dotest" @@ -61,13 +64,13 @@ testrebase() { cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && - test_must_fail git rebase$type master && + test_must_fail git rebase$type main && test_path_is_dir "$dotest" && echo c > a && echo d >> a && git add a && test_must_fail git rebase --continue && - test $(git rev-parse HEAD) != $(git rev-parse master) && + test $(git rev-parse HEAD) != $(git rev-parse main) && git rebase --abort && test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && test ! -d "$dotest" @@ -78,7 +81,7 @@ testrebase() { # Clean up the state from the previous one git reset --hard pre-rebase && git reflog show to-rebase > reflog_before && - test_must_fail git rebase$type master && + test_must_fail git rebase$type main && git rebase --abort && git reflog show to-rebase > reflog_after && test_cmp reflog_before reflog_after && @@ -89,7 +92,7 @@ testrebase() { cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && - test_must_fail git rebase$type master && + test_must_fail git rebase$type main && test_must_fail git rebase -v --abort && test_must_fail git rebase --abort -v && git rebase --abort @@ -103,7 +106,7 @@ test_expect_success 'rebase --apply --quit' ' cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && - test_must_fail git rebase --apply master && + test_must_fail git rebase --apply main && test_path_is_dir .git/rebase-apply && head_before=$(git rev-parse HEAD) && git rebase --quit && @@ -115,7 +118,7 @@ test_expect_success 'rebase --merge --quit' ' cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && - test_must_fail git rebase --merge master && + test_must_fail git rebase --merge main && test_path_is_dir .git/rebase-merge && head_before=$(git rev-parse HEAD) && git rebase --quit && diff --git a/t/t3408-rebase-multi-line.sh b/t/t3408-rebase-multi-line.sh index d2bd7c17b0..ab0960e6d9 100755 --- a/t/t3408-rebase-multi-line.sh +++ b/t/t3408-rebase-multi-line.sh @@ -2,6 +2,9 @@ test_description='rebasing a commit with multi-line first paragraph.' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -46,7 +49,7 @@ But otherwise with a sane description." side2 && test_expect_success rebase ' git checkout side && - git rebase master && + git rebase main && git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && git cat-file commit side@{1} | sed -e "1,/^\$/d" >expect && test_cmp expect actual diff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh index 3b340f1ece..ec8062a66a 100755 --- a/t/t3409-rebase-preserve-merges.sh +++ b/t/t3409-rebase-preserve-merges.sh @@ -6,6 +6,9 @@ test_description='git rebase -p should preserve merges Run "git rebase -p" and check that merges are properly carried along ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh if ! test_have_prereq REBASE_P; then @@ -18,7 +21,7 @@ export GIT_AUTHOR_EMAIL # Clone 2 (conflicting merge): # -# A1--A2--B3 <-- origin/master +# A1--A2--B3 <-- origin/main # \ \ # B1------M <-- topic # \ @@ -26,7 +29,7 @@ export GIT_AUTHOR_EMAIL # # Clone 3 (no-ff merge): # -# A1--A2--B3 <-- origin/master +# A1--A2--B3 <-- origin/main # \ # B1------M <-- topic # \ / @@ -44,7 +47,7 @@ test_expect_success 'setup for merge-preserving rebase' \ echo Second > B && git add B && git commit -m "Add B1" && - git checkout -f master && + git checkout -f main && echo Third >> A && git commit -a -m "Modify A2" && echo Fifth > B && @@ -55,10 +58,10 @@ test_expect_success 'setup for merge-preserving rebase' \ ( cd clone2 && git checkout -b topic origin/topic && - test_must_fail git merge origin/master && + test_must_fail git merge origin/main && echo Resolved >B && git add B && - git commit -m "Merge origin/master into topic" + git commit -m "Merge origin/main into topic" ) && git clone ./. clone3 && diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh index 21632a984e..fda62c65bd 100755 --- a/t/t3412-rebase-root.sh +++ b/t/t3412-rebase-root.sh @@ -4,6 +4,9 @@ test_description='git rebase --root Tests if git rebase --root --onto <newparent> can rebase the root commit. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh log_with_names () { @@ -24,7 +27,7 @@ test_expect_success 'prepare repository' ' test_expect_success 'rebase --root fails with too many args' ' git checkout -B fail other && - test_must_fail git rebase --onto master --root fail fail + test_must_fail git rebase --onto main --root fail fail ' test_expect_success 'setup pre-rebase hook' ' @@ -44,7 +47,7 @@ EOF test_expect_success 'rebase --root --onto <newbase>' ' git checkout -b work other && - git rebase --root --onto master && + git rebase --root --onto main && git log --pretty=tformat:"%s" > rebased && test_cmp expect rebased ' @@ -55,7 +58,7 @@ test_expect_success 'pre-rebase got correct input (1)' ' test_expect_success 'rebase --root --onto <newbase> <branch>' ' git branch work2 other && - git rebase --root --onto master work2 && + git rebase --root --onto main work2 && git log --pretty=tformat:"%s" > rebased2 && test_cmp expect rebased2 ' @@ -66,7 +69,7 @@ test_expect_success 'pre-rebase got correct input (2)' ' test_expect_success 'rebase -i --root --onto <newbase>' ' git checkout -b work3 other && - git rebase -i --root --onto master && + git rebase -i --root --onto main && git log --pretty=tformat:"%s" > rebased3 && test_cmp expect rebased3 ' @@ -77,7 +80,7 @@ test_expect_success 'pre-rebase got correct input (3)' ' test_expect_success 'rebase -i --root --onto <newbase> <branch>' ' git branch work4 other && - git rebase -i --root --onto master work4 && + git rebase -i --root --onto main work4 && git log --pretty=tformat:"%s" > rebased4 && test_cmp expect rebased4 ' @@ -88,7 +91,7 @@ test_expect_success 'pre-rebase got correct input (4)' ' test_expect_success REBASE_P 'rebase -i -p with linear history' ' git checkout -b work5 other && - git rebase -i -p --root --onto master && + git rebase -i -p --root --onto main && git log --pretty=tformat:"%s" > rebased5 && test_cmp expect rebased5 ' @@ -122,7 +125,7 @@ EOF test_expect_success REBASE_P 'rebase -i -p with merge' ' git checkout -b work6 other && - git rebase -i -p --root --onto master && + git rebase -i -p --root --onto main && log_with_names work6 > rebased6 && test_cmp expect-side rebased6 ' @@ -157,7 +160,7 @@ EOF test_expect_success REBASE_P 'rebase -i -p with two roots' ' git checkout -b work7 other && - git rebase -i -p --root --onto master && + git rebase -i -p --root --onto main && log_with_names work7 > rebased7 && test_cmp expect-third rebased7 ' @@ -173,14 +176,14 @@ EOF test_expect_success 'pre-rebase hook stops rebase' ' git checkout -b stops1 other && - test_must_fail git rebase --root --onto master && + test_must_fail git rebase --root --onto main && test "z$(git symbolic-ref HEAD)" = zrefs/heads/stops1 && test 0 = $(git rev-list other...stops1 | wc -l) ' test_expect_success 'pre-rebase hook stops rebase -i' ' git checkout -b stops2 other && - test_must_fail git rebase --root --onto master && + test_must_fail git rebase --root --onto main && test "z$(git symbolic-ref HEAD)" = zrefs/heads/stops2 && test 0 = $(git rev-list other...stops2 | wc -l) ' @@ -190,7 +193,7 @@ test_expect_success 'remove pre-rebase hook' ' ' test_expect_success 'set up a conflict' ' - git checkout master && + git checkout main && echo conflict > B && git add B && git commit -m conflict @@ -198,7 +201,7 @@ test_expect_success 'set up a conflict' ' test_expect_success 'rebase --root with conflict (first part)' ' git checkout -b conflict1 other && - test_must_fail git rebase --root --onto master && + test_must_fail git rebase --root --onto main && git ls-files -u | grep "B$" ' @@ -225,7 +228,7 @@ test_expect_success 'rebase --root with conflict (second part)' ' test_expect_success 'rebase -i --root with conflict (first part)' ' git checkout -b conflict2 other && - test_must_fail git rebase -i --root --onto master && + test_must_fail git rebase -i --root --onto main && git ls-files -u | grep "B$" ' @@ -263,7 +266,7 @@ EOF test_expect_success REBASE_P 'rebase -i -p --root with conflict (first part)' ' git checkout -b conflict3 other && - test_must_fail git rebase -i -p --root --onto master && + test_must_fail git rebase -i -p --root --onto main && git ls-files -u | grep "B$" ' diff --git a/t/t3413-rebase-hook.sh b/t/t3413-rebase-hook.sh index b6833e9a5f..b4acb3be5c 100755 --- a/t/t3413-rebase-hook.sh +++ b/t/t3413-rebase-hook.sh @@ -2,6 +2,9 @@ test_description='git rebase with its hook(s)' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -18,7 +21,7 @@ test_expect_success setup ' git add git && test_tick && git commit -m side && - git checkout master && + git checkout main && git log --pretty=oneline --abbrev-commit --graph --all && git branch test side ' @@ -26,14 +29,14 @@ test_expect_success setup ' test_expect_success 'rebase' ' git checkout test && git reset --hard side && - git rebase master && + git rebase main && test "z$(cat git)" = zworld ' test_expect_success 'rebase -i' ' git checkout test && git reset --hard side && - EDITOR=true git rebase -i master && + EDITOR=true git rebase -i main && test "z$(cat git)" = zworld ' @@ -49,53 +52,53 @@ EOF test_expect_success 'pre-rebase hook gets correct input (1)' ' git checkout test && git reset --hard side && - git rebase master && + git rebase main && test "z$(cat git)" = zworld && - test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster, + test "z$(cat .git/PRE-REBASE-INPUT)" = zmain, ' test_expect_success 'pre-rebase hook gets correct input (2)' ' git checkout test && git reset --hard side && - git rebase master test && + git rebase main test && test "z$(cat git)" = zworld && - test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test + test "z$(cat .git/PRE-REBASE-INPUT)" = zmain,test ' test_expect_success 'pre-rebase hook gets correct input (3)' ' git checkout test && git reset --hard side && - git checkout master && - git rebase master test && + git checkout main && + git rebase main test && test "z$(cat git)" = zworld && - test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test + test "z$(cat .git/PRE-REBASE-INPUT)" = zmain,test ' test_expect_success 'pre-rebase hook gets correct input (4)' ' git checkout test && git reset --hard side && - EDITOR=true git rebase -i master && + EDITOR=true git rebase -i main && test "z$(cat git)" = zworld && - test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster, + test "z$(cat .git/PRE-REBASE-INPUT)" = zmain, ' test_expect_success 'pre-rebase hook gets correct input (5)' ' git checkout test && git reset --hard side && - EDITOR=true git rebase -i master test && + EDITOR=true git rebase -i main test && test "z$(cat git)" = zworld && - test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test + test "z$(cat .git/PRE-REBASE-INPUT)" = zmain,test ' test_expect_success 'pre-rebase hook gets correct input (6)' ' git checkout test && git reset --hard side && - git checkout master && - EDITOR=true git rebase -i master test && + git checkout main && + EDITOR=true git rebase -i main test && test "z$(cat git)" = zworld && - test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test + test "z$(cat .git/PRE-REBASE-INPUT)" = zmain,test ' test_expect_success 'setup pre-rebase hook that fails' ' @@ -110,7 +113,7 @@ EOF test_expect_success 'pre-rebase hook stops rebase (1)' ' git checkout test && git reset --hard side && - test_must_fail git rebase master && + test_must_fail git rebase main && test "z$(git symbolic-ref HEAD)" = zrefs/heads/test && test 0 = $(git rev-list HEAD...side | wc -l) ' @@ -118,7 +121,7 @@ test_expect_success 'pre-rebase hook stops rebase (1)' ' test_expect_success 'pre-rebase hook stops rebase (2)' ' git checkout test && git reset --hard side && - test_must_fail env EDITOR=: git rebase -i master && + test_must_fail env EDITOR=: git rebase -i main && test "z$(git symbolic-ref HEAD)" = zrefs/heads/test && test 0 = $(git rev-list HEAD...side | wc -l) ' @@ -126,7 +129,7 @@ test_expect_success 'pre-rebase hook stops rebase (2)' ' test_expect_success 'rebase --no-verify overrides pre-rebase (1)' ' git checkout test && git reset --hard side && - git rebase --no-verify master && + git rebase --no-verify main && test "z$(git symbolic-ref HEAD)" = zrefs/heads/test && test "z$(cat git)" = zworld ' @@ -134,7 +137,7 @@ test_expect_success 'rebase --no-verify overrides pre-rebase (1)' ' test_expect_success 'rebase --no-verify overrides pre-rebase (2)' ' git checkout test && git reset --hard side && - EDITOR=true git rebase --no-verify -i master && + EDITOR=true git rebase --no-verify -i main && test "z$(git symbolic-ref HEAD)" = zrefs/heads/test && test "z$(cat git)" = zworld ' diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh index 7bab6000dc..78c27496d6 100755 --- a/t/t3415-rebase-autosquash.sh +++ b/t/t3415-rebase-autosquash.sh @@ -2,6 +2,9 @@ test_description='auto squash' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh @@ -81,8 +84,7 @@ test_auto_squash () { echo 1 >file1 && git add -u && test_tick && - git commit -m "squash! first" && - + git commit -m "squash! first" -m "extra para for first" && git tag $1 && test_tick && git rebase $2 -i HEAD^^^ && @@ -139,7 +141,7 @@ test_expect_success 'auto squash that matches 2 commits' ' echo 1 >file1 && git add -u && test_tick && - git commit -m "squash! first" && + git commit -m "squash! first" -m "extra para for first" && git tag final-multisquash && test_tick && git rebase --autosquash -i HEAD~4 && @@ -192,7 +194,7 @@ test_expect_success 'auto squash that matches a sha1' ' git add -u && test_tick && oid=$(git rev-parse --short HEAD^) && - git commit -m "squash! $oid" && + git commit -m "squash! $oid" -m "extra para" && git tag final-shasquash && test_tick && git rebase --autosquash -i HEAD^^^ && @@ -203,7 +205,8 @@ test_expect_success 'auto squash that matches a sha1' ' git cat-file blob HEAD^:file1 >actual && test_cmp expect actual && git cat-file commit HEAD^ >commit && - grep squash commit >actual && + ! grep "squash" commit && + grep "^extra para" commit >actual && test_line_count = 1 actual ' @@ -213,7 +216,7 @@ test_expect_success 'auto squash that matches longer sha1' ' git add -u && test_tick && oid=$(git rev-parse --short=11 HEAD^) && - git commit -m "squash! $oid" && + git commit -m "squash! $oid" -m "extra para" && git tag final-longshasquash && test_tick && git rebase --autosquash -i HEAD^^^ && @@ -224,7 +227,8 @@ test_expect_success 'auto squash that matches longer sha1' ' git cat-file blob HEAD^:file1 >actual && test_cmp expect actual && git cat-file commit HEAD^ >commit && - grep squash commit >actual && + ! grep "squash" commit && + grep "^extra para" commit >actual && test_line_count = 1 actual ' @@ -233,7 +237,7 @@ test_auto_commit_flags () { echo 1 >file1 && git add -u && test_tick && - git commit --$1 first-commit && + git commit --$1 first-commit -m "extra para for first" && git tag final-commit-$1 && test_tick && git rebase --autosquash -i HEAD^^^ && @@ -261,11 +265,11 @@ test_auto_fixup_fixup () { echo 1 >file1 && git add -u && test_tick && - git commit -m "$1! first" && + git commit -m "$1! first" -m "extra para for first" && echo 2 >file1 && git add -u && test_tick && - git commit -m "$1! $2! first" && + git commit -m "$1! $2! first" -m "second extra para for first" && git tag "final-$1-$2" && test_tick && ( @@ -303,35 +307,35 @@ test_auto_fixup_fixup () { fi } -test_expect_success C_LOCALE_OUTPUT 'fixup! fixup!' ' +test_expect_success 'fixup! fixup!' ' test_auto_fixup_fixup fixup fixup ' -test_expect_success C_LOCALE_OUTPUT 'fixup! squash!' ' +test_expect_success 'fixup! squash!' ' test_auto_fixup_fixup fixup squash ' -test_expect_success C_LOCALE_OUTPUT 'squash! squash!' ' +test_expect_success 'squash! squash!' ' test_auto_fixup_fixup squash squash ' -test_expect_success C_LOCALE_OUTPUT 'squash! fixup!' ' +test_expect_success 'squash! fixup!' ' test_auto_fixup_fixup squash fixup ' -test_expect_success C_LOCALE_OUTPUT 'autosquash with custom inst format' ' +test_expect_success 'autosquash with custom inst format' ' git reset --hard base && git config --add rebase.instructionFormat "[%an @ %ar] %s" && echo 2 >file1 && git add -u && test_tick && oid=$(git rev-parse --short HEAD^) && - git commit -m "squash! $oid" && + git commit -m "squash! $oid" -m "extra para for first" && echo 1 >file1 && git add -u && test_tick && subject=$(git log -n 1 --format=%s HEAD~2) && - git commit -m "squash! $subject" && + git commit -m "squash! $subject" -m "second extra para for first" && git tag final-squash-instFmt && test_tick && git rebase --autosquash -i HEAD~4 && @@ -342,8 +346,9 @@ test_expect_success C_LOCALE_OUTPUT 'autosquash with custom inst format' ' git cat-file blob HEAD^:file1 >actual && test_cmp expect actual && git cat-file commit HEAD^ >commit && - grep squash commit >actual && - test_line_count = 2 actual + ! grep "squash" commit && + grep first commit >actual && + test_line_count = 3 actual ' test_expect_success 'autosquash with empty custom instructionFormat' ' @@ -407,7 +412,7 @@ test_expect_success 'wrapped original subject' ' test_expect_success 'abort last squash' ' test_when_finished "test_might_fail git rebase --abort" && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && git checkout -b some-squashes && git commit --allow-empty -m first && @@ -440,4 +445,12 @@ test_expect_success 'fixup a fixup' ' test XZWY = $(git show | tr -cd W-Z) ' +test_expect_success 'fixup does not clean up commit message' ' + oneline="#818" && + git commit --allow-empty -m "$oneline" && + git commit --fixup HEAD --allow-empty && + git -c commit.cleanup=strip rebase -ki --autosquash HEAD~2 && + test "$oneline" = "$(git show -s --format=%s)" +' + test_done diff --git a/t/t3416-rebase-onto-threedots.sh b/t/t3416-rebase-onto-threedots.sh index 9c2548423b..3716a42e81 100755 --- a/t/t3416-rebase-onto-threedots.sh +++ b/t/t3416-rebase-onto-threedots.sh @@ -2,17 +2,20 @@ test_description='git rebase --onto A...B' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY/lib-rebase.sh" -# Rebase only the tip commit of "topic" on merge base between "master" -# and "topic". Cannot do this for "side" with "master" because there +# Rebase only the tip commit of "topic" on merge base between "main" +# and "topic". Cannot do this for "side" with "main" because there # is no single merge base. # # # F---G topic G' # / / -# A---B---C---D---E master --> A---B---C---D---E +# A---B---C---D---E main --> A---B---C---D---E # \ \ / # \ x # \ / \ @@ -26,7 +29,7 @@ test_expect_success setup ' git branch topic && git checkout side && test_commit H && - git checkout master && + git checkout main && test_tick && git merge H && git tag D && @@ -42,83 +45,83 @@ test_expect_success setup ' test_commit K ' -test_expect_success 'rebase --onto master...topic' ' +test_expect_success 'rebase --onto main...topic' ' git reset --hard && git checkout topic && git reset --hard G && - git rebase --onto master...topic F && + git rebase --onto main...topic F && git rev-parse HEAD^1 >actual && git rev-parse C^0 >expect && test_cmp expect actual ' -test_expect_success 'rebase --onto master...' ' +test_expect_success 'rebase --onto main...' ' git reset --hard && git checkout topic && git reset --hard G && - git rebase --onto master... F && + git rebase --onto main... F && git rev-parse HEAD^1 >actual && git rev-parse C^0 >expect && test_cmp expect actual ' -test_expect_success 'rebase --onto master...side' ' +test_expect_success 'rebase --onto main...side' ' git reset --hard && git checkout side && git reset --hard K && - test_must_fail git rebase --onto master...side J + test_must_fail git rebase --onto main...side J ' -test_expect_success 'rebase -i --onto master...topic' ' +test_expect_success 'rebase -i --onto main...topic' ' git reset --hard && git checkout topic && git reset --hard G && set_fake_editor && - EXPECT_COUNT=1 git rebase -i --onto master...topic F && + EXPECT_COUNT=1 git rebase -i --onto main...topic F && git rev-parse HEAD^1 >actual && git rev-parse C^0 >expect && test_cmp expect actual ' -test_expect_success 'rebase -i --onto master...' ' +test_expect_success 'rebase -i --onto main...' ' git reset --hard && git checkout topic && git reset --hard G && set_fake_editor && - EXPECT_COUNT=1 git rebase -i --onto master... F && + EXPECT_COUNT=1 git rebase -i --onto main... F && git rev-parse HEAD^1 >actual && git rev-parse C^0 >expect && test_cmp expect actual ' -test_expect_success 'rebase -i --onto master...side' ' +test_expect_success 'rebase -i --onto main...side' ' git reset --hard && git checkout side && git reset --hard K && set_fake_editor && - test_must_fail git rebase -i --onto master...side J + test_must_fail git rebase -i --onto main...side J ' test_expect_success 'rebase --keep-base --onto incompatible' ' - test_must_fail git rebase --keep-base --onto master... + test_must_fail git rebase --keep-base --onto main... ' test_expect_success 'rebase --keep-base --root incompatible' ' test_must_fail git rebase --keep-base --root ' -test_expect_success 'rebase --keep-base master from topic' ' +test_expect_success 'rebase --keep-base main from topic' ' git reset --hard && git checkout topic && git reset --hard G && - git rebase --keep-base master && + git rebase --keep-base main && git rev-parse C >base.expect && - git merge-base master HEAD >base.actual && + git merge-base main HEAD >base.actual && test_cmp base.expect base.actual && git rev-parse HEAD~2 >actual && @@ -126,23 +129,23 @@ test_expect_success 'rebase --keep-base master from topic' ' test_cmp expect actual ' -test_expect_success 'rebase --keep-base master from side' ' +test_expect_success 'rebase --keep-base main from side' ' git reset --hard && git checkout side && git reset --hard K && - test_must_fail git rebase --keep-base master + test_must_fail git rebase --keep-base main ' -test_expect_success 'rebase -i --keep-base master from topic' ' +test_expect_success 'rebase -i --keep-base main from topic' ' git reset --hard && git checkout topic && git reset --hard G && set_fake_editor && - EXPECT_COUNT=2 git rebase -i --keep-base master && + EXPECT_COUNT=2 git rebase -i --keep-base main && git rev-parse C >base.expect && - git merge-base master HEAD >base.actual && + git merge-base main HEAD >base.actual && test_cmp base.expect base.actual && git rev-parse HEAD~2 >actual && @@ -150,13 +153,13 @@ test_expect_success 'rebase -i --keep-base master from topic' ' test_cmp expect actual ' -test_expect_success 'rebase -i --keep-base master from side' ' +test_expect_success 'rebase -i --keep-base main from side' ' git reset --hard && git checkout side && git reset --hard K && set_fake_editor && - test_must_fail git rebase -i --keep-base master + test_must_fail git rebase -i --keep-base main ' test_done diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index 7a2da972fd..f4c2ee02bc 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -2,6 +2,9 @@ test_description='git rebase --continue tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh @@ -15,13 +18,13 @@ test_expect_success 'setup' ' git checkout -b topic HEAD^ && test_commit "commit-new-file-F2-on-topic-branch" F2 22 && - git checkout master + git checkout main ' test_expect_success 'interactive rebase --continue works with touched file' ' rm -fr .git/rebase-* && git reset --hard && - git checkout master && + git checkout main && FAKE_LINES="edit 1" git rebase -i HEAD^ && test-tool chmtime =-60 F1 && @@ -31,9 +34,9 @@ test_expect_success 'interactive rebase --continue works with touched file' ' test_expect_success 'non-interactive rebase --continue works with touched file' ' rm -fr .git/rebase-* && git reset --hard && - git checkout master && + git checkout main && - test_must_fail git rebase --onto master master topic && + test_must_fail git rebase --onto main main topic && echo "Resolved" >F2 && git add F2 && test-tool chmtime =-60 F1 && @@ -61,7 +64,7 @@ test_expect_success 'rebase --continue remembers merge strategy and options' ' chmod +x test-bin/git-merge-funny && ( PATH=./test-bin:$PATH && - test_must_fail git rebase -s funny -Xopt master topic + test_must_fail git rebase -s funny -Xopt main topic ) && test -f funny.was.run && rm funny.was.run && @@ -93,7 +96,7 @@ test_expect_success 'rebase -i --continue handles merge strategy and options' ' chmod +x test-bin/git-merge-funny && ( PATH=./test-bin:$PATH && - test_must_fail git rebase -i -s funny -Xopt -Xfoo master topic + test_must_fail git rebase -i -s funny -Xopt -Xfoo main topic ) && test -f funny.was.run && rm funny.was.run && @@ -188,11 +191,11 @@ test_expect_success '--skip after failed fixup cleans commit message' ' test_expect_success 'setup rerere database' ' rm -fr .git/rebase-* && git reset --hard commit-new-file-F3-on-topic-branch && - git checkout master && + git checkout main && test_commit "commit-new-file-F3" F3 3 && test_config rerere.enabled true && git update-ref refs/heads/topic commit-new-file-F3-on-topic-branch && - test_must_fail git rebase -m master topic && + test_must_fail git rebase -m main topic && echo "Resolved" >F2 && cp F2 expected-F2 && git add F2 && @@ -207,7 +210,7 @@ test_expect_success 'setup rerere database' ' prepare () { rm -fr .git/rebase-* && git reset --hard commit-new-file-F3-on-topic-branch && - git checkout master && + git checkout main && test_config rerere.enabled true } @@ -215,7 +218,7 @@ test_rerere_autoupdate () { action=$1 && test_expect_success "rebase $action --continue remembers --rerere-autoupdate" ' prepare && - test_must_fail git rebase $action --rerere-autoupdate master topic && + test_must_fail git rebase $action --rerere-autoupdate main topic && test_cmp expected-F2 F2 && git diff-files --quiet && test_must_fail git rebase --continue && @@ -227,7 +230,7 @@ test_rerere_autoupdate () { test_expect_success "rebase $action --continue honors rerere.autoUpdate" ' prepare && test_config rerere.autoupdate true && - test_must_fail git rebase $action master topic && + test_must_fail git rebase $action main topic && test_cmp expected-F2 F2 && git diff-files --quiet && test_must_fail git rebase --continue && @@ -239,7 +242,7 @@ test_rerere_autoupdate () { test_expect_success "rebase $action --continue remembers --no-rerere-autoupdate" ' prepare && test_config rerere.autoupdate true && - test_must_fail git rebase $action --no-rerere-autoupdate master topic && + test_must_fail git rebase $action --no-rerere-autoupdate main topic && test_cmp expected-F2 F2 && test_must_fail git diff-files --quiet && git add F2 && @@ -279,12 +282,35 @@ test_expect_success '--reschedule-failed-exec' ' test_i18ngrep "has been rescheduled" err ' -test_expect_success 'rebase.reschedulefailedexec only affects `rebase -i`' ' - test_config rebase.reschedulefailedexec true && +test_expect_success 'rebase.rescheduleFailedExec only affects `rebase -i`' ' + test_config rebase.rescheduleFailedExec true && test_must_fail git rebase -x false HEAD^ && grep "^exec false" .git/rebase-merge/git-rebase-todo && git rebase --abort && git rebase HEAD^ ' +test_expect_success 'rebase.rescheduleFailedExec=true & --no-reschedule-failed-exec' ' + test_when_finished "git rebase --abort" && + test_config rebase.rescheduleFailedExec true && + test_must_fail git rebase -x false --no-reschedule-failed-exec HEAD~2 && + test_must_fail git rebase --continue 2>err && + ! grep "has been rescheduled" err +' + +test_expect_success 'new rebase.rescheduleFailedExec=true setting in an ongoing rebase is ignored' ' + test_when_finished "git rebase --abort" && + test_must_fail git rebase -x false HEAD~2 && + test_config rebase.rescheduleFailedExec true && + test_must_fail git rebase --continue 2>err && + ! grep "has been rescheduled" err +' + +test_expect_success 'there is no --no-reschedule-failed-exec in an ongoing rebase' ' + test_when_finished "git rebase --abort" && + test_must_fail git rebase -x false HEAD~2 && + test_expect_code 129 git rebase --continue --no-reschedule-failed-exec && + test_expect_code 129 git rebase --edit-todo --no-reschedule-failed-exec +' + test_done diff --git a/t/t3419-rebase-patch-id.sh b/t/t3419-rebase-patch-id.sh index 1f32faa4a4..295040f2fe 100755 --- a/t/t3419-rebase-patch-id.sh +++ b/t/t3419-rebase-patch-id.sh @@ -2,6 +2,9 @@ test_description='git rebase - test patch id computation' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh scramble () { @@ -24,7 +27,7 @@ test_expect_success 'setup' ' test_expect_success 'setup: 500 lines' ' rm -f .gitattributes && - git checkout -q -f master && + git checkout -q -f main && git reset --hard root && test_seq 500 >file && git add file && @@ -40,7 +43,7 @@ test_expect_success 'setup: 500 lines' ' git add newfile && git commit -q -m "add small file" && - git cherry-pick master >/dev/null 2>&1 + git cherry-pick main >/dev/null 2>&1 ' test_expect_success 'setup attributes' ' @@ -48,18 +51,18 @@ test_expect_success 'setup attributes' ' ' test_expect_success 'detect upstream patch' ' - git checkout -q master && + git checkout -q main && scramble file && git add file && git commit -q -m "change big file again" && git checkout -q other^{} && - git rebase master && - git rev-list master...HEAD~ >revs && + git rebase main && + git rev-list main...HEAD~ >revs && test_must_be_empty revs ' test_expect_success 'do not drop patch' ' - git branch -f squashed master && + git branch -f squashed main && git checkout -q -f squashed && git reset -q --soft HEAD~2 && git commit -q -m squashed && diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh index ca331733fb..43fcb68f27 100755 --- a/t/t3420-rebase-autostash.sh +++ b/t/t3420-rebase-autostash.sh @@ -4,6 +4,9 @@ # test_description='git rebase --autostash tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -21,12 +24,12 @@ test_expect_success setup ' git add . && test_tick && git commit -m "third commit" && - git checkout -b unrelated-onto-branch master && + git checkout -b unrelated-onto-branch main && echo unrelated >file4 && git add . && test_tick && git commit -m "unrelated commit" && - git checkout -b related-onto-branch master && + git checkout -b related-onto-branch main && echo conflicting-change >file2 && git add . && test_tick && @@ -107,7 +110,7 @@ testrebase () { fi && create_expected_success_$suffix && sed "$remove_progress_re" <actual >actual2 && - test_i18ncmp expected actual2 + test_cmp expected actual2 ' test_expect_success "rebase$type: dirty index, non-conflicting rebase" ' @@ -228,7 +231,7 @@ testrebase () { fi && create_expected_failure_$suffix && sed "$remove_progress_re" <actual >actual2 && - test_i18ncmp expected actual2 + test_cmp expected actual2 ' } @@ -305,7 +308,7 @@ test_expect_success 'autostash is saved on editor failure with conflict' ' ' test_expect_success 'autostash with dirty submodules' ' - test_when_finished "git reset --hard && git checkout master" && + test_when_finished "git reset --hard && git checkout main" && git checkout -b with-submodule && git submodule add ./ sub && test_tick && @@ -324,7 +327,7 @@ test_expect_success 'branch is left alone when possible' ' test_expect_success 'never change active branch' ' git checkout -b not-the-feature-branch unrelated-onto-branch && - test_when_finished "git reset --hard && git checkout master" && + test_when_finished "git reset --hard && git checkout main" && echo changed >file0 && git rebase --autostash not-the-feature-branch feature-branch && test_cmp_rev not-the-feature-branch unrelated-onto-branch diff --git a/t/t3423-rebase-reword.sh b/t/t3423-rebase-reword.sh index 6963750794..4859bb8f72 100755 --- a/t/t3423-rebase-reword.sh +++ b/t/t3423-rebase-reword.sh @@ -7,7 +7,7 @@ test_description='git rebase interactive with rewording' . "$TEST_DIRECTORY"/lib-rebase.sh test_expect_success 'setup' ' - test_commit master file-1 test && + test_commit main file-1 test && git checkout -b stuff && @@ -22,7 +22,7 @@ test_expect_success 'reword without issues functions as intended' ' set_fake_editor && FAKE_LINES="pick 1 reword 2" FAKE_COMMIT_MESSAGE="feature_b_reworded" \ - git rebase -i -v master && + git rebase -i -v main && test "$(git log -1 --format=%B)" = "feature_b_reworded" && test $(git rev-list --count HEAD) = 3 @@ -35,7 +35,7 @@ test_expect_success 'reword after a conflict preserves commit' ' set_fake_editor && test_must_fail env FAKE_LINES="reword 2" \ - git rebase -i -v master && + git rebase -i -v main && git checkout --theirs file-2 && git add file-2 && diff --git a/t/t3427-rebase-subtree.sh b/t/t3427-rebase-subtree.sh index 5839719ba1..e78c7e3796 100755 --- a/t/t3427-rebase-subtree.sh +++ b/t/t3427-rebase-subtree.sh @@ -4,6 +4,9 @@ test_description='git rebase tests for -Xsubtree This test runs git rebase and tests the subtree strategy. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh @@ -17,7 +20,7 @@ commit_message() { # # topic_1 - topic_2 - topic_3 # \ -# README ---------------------- Add subproject master - topic_4 - files_subtree/topic_5 +# README ---------------------- Add subproject main - topic_4 - files_subtree/topic_5 # # Where the merge moves the files topic_[123].t into the subdirectory # files_subtree/ and topic_4 as well as files_subtree/topic_5 add files to that @@ -28,7 +31,7 @@ commit_message() { # an empty commit is added on top. The pre-rebase commit history looks like # this: # -# Add subproject master - topic_4 - files_subtree/topic_5 - Empty commit +# Add subproject main - topic_4 - files_subtree/topic_5 - Empty commit # # where the root commit adds three files: topic_1.t, topic_2.t and topic_3.t. # @@ -48,11 +51,11 @@ test_expect_success 'setup' ' test_commit -C files topic_3 && : perform subtree merge into files_subtree/ && - git fetch files refs/heads/master:refs/heads/files-master && + git fetch files refs/heads/main:refs/heads/files-main && git merge -s ours --no-commit --allow-unrelated-histories \ - files-master && - git read-tree --prefix=files_subtree -u files-master && - git commit -m "Add subproject master" && + files-main && + git read-tree --prefix=files_subtree -u files-main && + git commit -m "Add subproject main" && : add two extra commits to rebase && test_commit -C files_subtree topic_4 && @@ -70,7 +73,7 @@ test_expect_success 'setup' ' test_expect_failure REBASE_P 'Rebase -Xsubtree --preserve-merges --onto commit' ' reset_rebase && git checkout -b rebase-preserve-merges to-rebase && - git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master && + git rebase -Xsubtree=files_subtree --preserve-merges --onto files-main main && verbose test "$(commit_message HEAD~)" = "topic_4" && verbose test "$(commit_message HEAD)" = "files_subtree/topic_5" ' @@ -79,7 +82,7 @@ test_expect_failure REBASE_P 'Rebase -Xsubtree --preserve-merges --onto commit' test_expect_failure REBASE_P 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit' ' reset_rebase && git checkout -b rebase-keep-empty to-rebase && - git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master && + git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-main main && verbose test "$(commit_message HEAD~2)" = "topic_4" && verbose test "$(commit_message HEAD~)" = "files_subtree/topic_5" && verbose test "$(commit_message HEAD)" = "Empty commit" @@ -88,7 +91,7 @@ test_expect_failure REBASE_P 'Rebase -Xsubtree --keep-empty --preserve-merges -- test_expect_success 'Rebase -Xsubtree --empty=ask --onto commit' ' reset_rebase && git checkout -b rebase-onto to-rebase && - test_must_fail git rebase -Xsubtree=files_subtree --empty=ask --onto files-master master && + test_must_fail git rebase -Xsubtree=files_subtree --empty=ask --onto files-main main && : first pick results in no changes && git rebase --skip && verbose test "$(commit_message HEAD~2)" = "topic_4" && @@ -99,7 +102,7 @@ test_expect_success 'Rebase -Xsubtree --empty=ask --onto commit' ' test_expect_success 'Rebase -Xsubtree --empty=ask --rebase-merges --onto commit' ' reset_rebase && git checkout -b rebase-merges-onto to-rebase && - test_must_fail git rebase -Xsubtree=files_subtree --empty=ask --rebase-merges --onto files-master --root && + test_must_fail git rebase -Xsubtree=files_subtree --empty=ask --rebase-merges --onto files-main --root && : first pick results in no changes && git rebase --skip && verbose test "$(commit_message HEAD~2)" = "topic_4" && diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh index b454f400eb..6748070df5 100755 --- a/t/t3430-rebase-merges.sh +++ b/t/t3430-rebase-merges.sh @@ -12,12 +12,15 @@ Initial setup: -- B -- (first) / \ - A - C - D - E - H (master) + A - C - D - E - H (main) \ \ / \ F - G (second) \ Conflicting-G ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh . "$TEST_DIRECTORY"/lib-log-graph.sh @@ -37,7 +40,7 @@ test_expect_success 'setup' ' git checkout -b first && test_commit B && b=$(git rev-parse --short HEAD) && - git checkout master && + git checkout main && test_commit C && c=$(git rev-parse --short HEAD) && test_commit D && @@ -52,7 +55,7 @@ test_expect_success 'setup' ' f=$(git rev-parse --short HEAD) && test_commit G && g=$(git rev-parse --short HEAD) && - git checkout master && + git checkout main && git merge --no-commit G && test_tick && git commit -m H && @@ -82,7 +85,7 @@ test_expect_success 'create completely different structure' ' EOF test_config sequence.editor \""$PWD"/replace-editor.sh\" && test_tick && - git rebase -i -r A master && + git rebase -i -r A main && test_cmp_graph <<-\EOF * Merge the topic branch '\''onebranch'\'' |\ @@ -183,7 +186,7 @@ test_expect_success 'fast-forward merge -c still rewords' ' ' test_expect_success 'with a branch tip that was cherry-picked already' ' - git checkout -b already-upstream master && + git checkout -b already-upstream main && base="$(git rev-parse --verify HEAD)" && test_commit A1 && @@ -211,7 +214,7 @@ test_expect_success 'with a branch tip that was cherry-picked already' ' ' test_expect_success 'do not rebase cousins unless asked for' ' - git checkout -b cousins master && + git checkout -b cousins main && before="$(git rev-parse --verify HEAD)" && test_tick && git rebase -r HEAD^ && @@ -340,7 +343,7 @@ test_expect_success 'a "merge" into a root commit is a fast-forward' ' test_expect_success 'A root commit can be a cousin, treat it that way' ' git checkout --orphan khnum && test_commit yama && - git checkout -b asherah master && + git checkout -b asherah main && test_commit shamkat && git merge --allow-unrelated-histories khnum && test_tick && @@ -367,7 +370,7 @@ test_expect_success 'labels that are object IDs are rewritten' ' git checkout -b third B && test_commit I && third=$(git rev-parse HEAD) && - git checkout -b labels master && + git checkout -b labels main && git merge --no-commit third && test_tick && git commit -m "Merge commit '\''$third'\'' into labels" && diff --git a/t/t3431-rebase-fork-point.sh b/t/t3431-rebase-fork-point.sh index 172562789e..4c98d99e7e 100755 --- a/t/t3431-rebase-fork-point.sh +++ b/t/t3431-rebase-fork-point.sh @@ -5,13 +5,16 @@ test_description='git rebase --fork-point test' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh -# A---B---D---E (master) +# A---B---D---E (main) # \ # C*---F---G (side) # -# C was formerly part of master but master was rewound to remove C +# C was formerly part of main but main was rewound to remove C # test_expect_success setup ' test_commit A && @@ -26,19 +29,23 @@ test_expect_success setup ' test_commit G ' +do_test_rebase () { + expected="$1" && + shift && + git checkout main && + git reset --hard E && + git checkout side && + git reset --hard G && + git rebase $* && + test_write_lines $expected >expect && + git log --pretty=%s >actual && + test_cmp expect actual +} + test_rebase () { expected="$1" && shift && - test_expect_success "git rebase $*" " - git checkout master && - git reset --hard E && - git checkout side && - git reset --hard G && - git rebase $* && - test_write_lines $expected >expect && - git log --pretty=%s >actual && - test_cmp expect actual - " + test_expect_success "git rebase $*" "do_test_rebase '$expected' $*" } test_rebase 'G F E D B A' @@ -48,30 +55,61 @@ test_rebase 'G F C E D B A' --no-fork-point test_rebase 'G F C D B A' --no-fork-point --onto D test_rebase 'G F C B A' --no-fork-point --keep-base -test_rebase 'G F E D B A' --fork-point refs/heads/master -test_rebase 'G F E D B A' --fork-point master +test_rebase 'G F E D B A' --fork-point refs/heads/main +test_rebase 'G F E D B A' --fork-point main -test_rebase 'G F D B A' --fork-point --onto D refs/heads/master -test_rebase 'G F D B A' --fork-point --onto D master +test_rebase 'G F D B A' --fork-point --onto D refs/heads/main +test_rebase 'G F D B A' --fork-point --onto D main -test_rebase 'G F B A' --fork-point --keep-base refs/heads/master -test_rebase 'G F B A' --fork-point --keep-base master +test_rebase 'G F B A' --fork-point --keep-base refs/heads/main +test_rebase 'G F B A' --fork-point --keep-base main -test_rebase 'G F C E D B A' refs/heads/master -test_rebase 'G F C E D B A' master +test_rebase 'G F C E D B A' refs/heads/main +test_rebase 'G F C E D B A' main -test_rebase 'G F C D B A' --onto D refs/heads/master -test_rebase 'G F C D B A' --onto D master +test_rebase 'G F C D B A' --onto D refs/heads/main +test_rebase 'G F C D B A' --onto D main -test_rebase 'G F C B A' --keep-base refs/heads/master -test_rebase 'G F C B A' --keep-base master +test_rebase 'G F C B A' --keep-base refs/heads/main +test_rebase 'G F C B A' --keep-base main test_expect_success 'git rebase --fork-point with ambigous refname' ' - git checkout master && + git checkout main && git checkout -b one && git checkout side && git tag one && test_must_fail git rebase --fork-point --onto D one ' +test_expect_success '--fork-point and --root both given' ' + test_must_fail git rebase --fork-point --root 2>err && + test_i18ngrep "cannot combine" err +' + +test_expect_success 'rebase.forkPoint set to false' ' + test_config rebase.forkPoint false && + do_test_rebase "G F C E D B A" +' + +test_expect_success 'rebase.forkPoint set to false and then to true' ' + test_config_global rebase.forkPoint false && + test_config rebase.forkPoint true && + do_test_rebase "G F E D B A" +' + +test_expect_success 'rebase.forkPoint set to false and command line says --fork-point' ' + test_config rebase.forkPoint false && + do_test_rebase "G F E D B A" --fork-point +' + +test_expect_success 'rebase.forkPoint set to true and command line says --no-fork-point' ' + test_config rebase.forkPoint true && + do_test_rebase "G F C E D B A" --no-fork-point +' + +test_expect_success 'rebase.forkPoint set to true and --root given' ' + test_config rebase.forkPoint true && + git rebase --root +' + test_done diff --git a/t/t3432-rebase-fast-forward.sh b/t/t3432-rebase-fast-forward.sh index a29eda87e9..5086e14c02 100755 --- a/t/t3432-rebase-fast-forward.sh +++ b/t/t3432-rebase-fast-forward.sh @@ -5,6 +5,9 @@ test_description='ensure rebase fast-forwards commits when possible' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -84,19 +87,19 @@ test_rebase_same_head_ () { changes='no changes' test_rebase_same_head success noop same success work same -test_rebase_same_head success noop same success work same master +test_rebase_same_head success noop same success work same main test_rebase_same_head success noop same success work diff --onto B B test_rebase_same_head success noop same success work diff --onto B... B -test_rebase_same_head success noop same success work same --onto master... master -test_rebase_same_head success noop same success work same --keep-base master +test_rebase_same_head success noop same success work same --onto main... main +test_rebase_same_head success noop same success work same --keep-base main test_rebase_same_head success noop same success work same --keep-base test_rebase_same_head success noop same success work same --no-fork-point test_rebase_same_head success noop same success work same --keep-base --no-fork-point -test_rebase_same_head success noop same success work same --fork-point master +test_rebase_same_head success noop same success work same --fork-point main test_rebase_same_head success noop same success work diff --fork-point --onto B B test_rebase_same_head success noop same success work diff --fork-point --onto B... B -test_rebase_same_head success noop same success work same --fork-point --onto master... master -test_rebase_same_head success noop same success work same --keep-base --keep-base master +test_rebase_same_head success noop same success work same --fork-point --onto main... main +test_rebase_same_head success noop same success work same --keep-base --keep-base main test_expect_success 'add work same to side' ' test_commit E @@ -104,22 +107,22 @@ test_expect_success 'add work same to side' ' changes='our changes' test_rebase_same_head success noop same success work same -test_rebase_same_head success noop same success work same master +test_rebase_same_head success noop same success work same main test_rebase_same_head success noop same success work diff --onto B B test_rebase_same_head success noop same success work diff --onto B... B -test_rebase_same_head success noop same success work same --onto master... master -test_rebase_same_head success noop same success work same --keep-base master +test_rebase_same_head success noop same success work same --onto main... main +test_rebase_same_head success noop same success work same --keep-base main test_rebase_same_head success noop same success work same --keep-base test_rebase_same_head success noop same success work same --no-fork-point test_rebase_same_head success noop same success work same --keep-base --no-fork-point -test_rebase_same_head success noop same success work same --fork-point master +test_rebase_same_head success noop same success work same --fork-point main test_rebase_same_head success noop same success work diff --fork-point --onto B B test_rebase_same_head success noop same success work diff --fork-point --onto B... B -test_rebase_same_head success noop same success work same --fork-point --onto master... master -test_rebase_same_head success noop same success work same --fork-point --keep-base master +test_rebase_same_head success noop same success work same --fork-point --onto main... main +test_rebase_same_head success noop same success work same --fork-point --keep-base main test_expect_success 'add work same to upstream' ' - git checkout master && + git checkout main && test_commit F && git checkout side ' @@ -127,12 +130,12 @@ test_expect_success 'add work same to upstream' ' changes='our and their changes' test_rebase_same_head success noop same success work diff --onto B B test_rebase_same_head success noop same success work diff --onto B... B -test_rebase_same_head success noop same success work diff --onto master... master -test_rebase_same_head success noop same success work diff --keep-base master +test_rebase_same_head success noop same success work diff --onto main... main +test_rebase_same_head success noop same success work diff --keep-base main test_rebase_same_head success noop same success work diff --keep-base test_rebase_same_head failure work same success work diff --fork-point --onto B B test_rebase_same_head failure work same success work diff --fork-point --onto B... B -test_rebase_same_head success noop same success work diff --fork-point --onto master... master -test_rebase_same_head success noop same success work diff --fork-point --keep-base master +test_rebase_same_head success noop same success work diff --fork-point --onto main... main +test_rebase_same_head success noop same success work diff --fork-point --keep-base main test_done diff --git a/t/t3434-rebase-i18n.sh b/t/t3434-rebase-i18n.sh index c7c835cde9..e6fef696bb 100755 --- a/t/t3434-rebase-i18n.sh +++ b/t/t3434-rebase-i18n.sh @@ -7,13 +7,16 @@ test_description='rebase with changing encoding Initial setup: -1 - 2 master +1 - 2 main \ 3 - 4 first \ 5 - 6 second ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh compare_msg () { @@ -41,7 +44,7 @@ test_expect_success 'rebase --rebase-merges update encoding eucJP to UTF-8' ' git config i18n.commitencoding eucJP && git merge -F "$TEST_DIRECTORY/t3434/eucJP.txt" second && git config i18n.commitencoding UTF-8 && - git rebase --rebase-merges master && + git rebase --rebase-merges main && compare_msg eucJP.txt eucJP UTF-8 ' @@ -50,7 +53,7 @@ test_expect_success 'rebase --rebase-merges update encoding eucJP to ISO-2022-JP git config i18n.commitencoding eucJP && git merge -F "$TEST_DIRECTORY/t3434/eucJP.txt" second && git config i18n.commitencoding ISO-2022-JP && - git rebase --rebase-merges master && + git rebase --rebase-merges main && compare_msg eucJP.txt eucJP ISO-2022-JP ' @@ -66,7 +69,7 @@ test_rebase_continue_update_encode () { git config i18n.commitencoding $old && git commit -F "$TEST_DIRECTORY/t3434/$msgfile" && git config i18n.commitencoding $new && - test_must_fail git rebase -m master && + test_must_fail git rebase -m main && test -f .git/rebase-merge/message && git stripspace <.git/rebase-merge/message >two.t && git add two.t && diff --git a/t/t3435-rebase-gpg-sign.sh b/t/t3435-rebase-gpg-sign.sh index 54120b09d6..ec10766858 100755 --- a/t/t3435-rebase-gpg-sign.sh +++ b/t/t3435-rebase-gpg-sign.sh @@ -5,6 +5,9 @@ test_description='test rebase --[no-]gpg-sign' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY/lib-rebase.sh" . "$TEST_DIRECTORY/lib-gpg.sh" @@ -46,7 +49,7 @@ test_expect_success 'setup: merge commit' ' test_commit fork-point && git switch -c side && test_commit three && - git switch master && + git switch main && git merge --no-ff side && git tag merged ' @@ -64,7 +67,7 @@ test_rebase_gpg_sign false -i --no-gpg-sign --gpg-sign test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' ' git reset --hard merged && git config commit.gpgsign true && - git rebase -p --no-gpg-sign --onto=one fork-point master && + git rebase -p --no-gpg-sign --onto=one fork-point main && test_must_fail git verify-commit HEAD ' diff --git a/t/t3436-rebase-more-options.sh b/t/t3436-rebase-more-options.sh index eaaf4c8d1d..4d106642ba 100755 --- a/t/t3436-rebase-more-options.sh +++ b/t/t3436-rebase-more-options.sh @@ -28,7 +28,7 @@ test_expect_success 'setup' ' test_commit commit2 foo foo2 && test_commit commit3 foo foo3 && - git checkout --orphan master && + git checkout --orphan main && rm foo && test_write_lines "line 1" " line 2" "line 3" >file && git commit -am "add file" && diff --git a/t/t3437-rebase-fixup-options.sh b/t/t3437-rebase-fixup-options.sh new file mode 100755 index 0000000000..c023fefd68 --- /dev/null +++ b/t/t3437-rebase-fixup-options.sh @@ -0,0 +1,211 @@ +#!/bin/sh +# +# Copyright (c) 2018 Phillip Wood +# + +test_description='git rebase interactive fixup options + +This test checks the "fixup [-C|-c]" command of rebase interactive. +In addition to amending the contents of the commit, "fixup -C" +replaces the original commit message with the message of the fixup +commit. "fixup -c" also replaces the original message, but opens the +editor to allow the user to edit the message before committing. Similar +to the "fixup" command that works with "fixup!", "fixup -C" works with +"amend!" upon --autosquash. +' + +. ./test-lib.sh + +. "$TEST_DIRECTORY"/lib-rebase.sh + +EMPTY="" + +# test_commit_message <rev> -m <msg> +# test_commit_message <rev> <path> +# Verify that the commit message of <rev> matches +# <msg> or the content of <path>. +test_commit_message () { + git show --no-patch --pretty=format:%B "$1" >actual && + case "$2" in + -m) + echo "$3" >expect && + test_cmp expect actual ;; + *) + test_cmp "$2" actual ;; + esac +} + +get_author () { + rev="$1" && + git log -1 --pretty=format:"%an %ae %at" "$rev" +} + +test_expect_success 'setup' ' + cat >message <<-EOF && + amend! B + $EMPTY + new subject + $EMPTY + new + body + EOF + + test_commit A A && + test_commit B B && + get_author HEAD >expected-author && + ORIG_AUTHOR_NAME="$GIT_AUTHOR_NAME" && + ORIG_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" && + GIT_AUTHOR_NAME="Amend Author" && + GIT_AUTHOR_EMAIL="amend@example.com" && + test_commit "$(cat message)" A A1 A1 && + test_commit A2 A && + test_commit A3 A && + GIT_AUTHOR_NAME="$ORIG_AUTHOR_NAME" && + GIT_AUTHOR_EMAIL="$ORIG_AUTHOR_EMAIL" && + git checkout -b conflicts-branch A && + test_commit conflicts A && + + set_fake_editor && + git checkout -b branch B && + echo B1 >B && + test_tick && + git commit --fixup=HEAD -a && + git tag B1 && + test_tick && + FAKE_COMMIT_AMEND="edited 1" git commit --fixup=reword:B && + test_tick && + FAKE_COMMIT_AMEND="edited 2" git commit --fixup=reword:HEAD && + echo B2 >B && + test_tick && + FAKE_COMMIT_AMEND="edited squash" git commit --squash=HEAD -a && + git tag B2 && + echo B3 >B && + test_tick && + FAKE_COMMIT_AMEND="edited 3" git commit -a --fixup=amend:HEAD^ && + git tag B3 && + + GIT_AUTHOR_NAME="Rebase Author" && + GIT_AUTHOR_EMAIL="rebase.author@example.com" && + GIT_COMMITTER_NAME="Rebase Committer" && + GIT_COMMITTER_EMAIL="rebase.committer@example.com" +' + +test_expect_success 'simple fixup -C works' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout --detach A2 && + FAKE_LINES="1 fixup_-C 2" git rebase -i B && + test_cmp_rev HEAD^ B && + test_cmp_rev HEAD^{tree} A2^{tree} && + test_commit_message HEAD -m "A2" +' + +test_expect_success 'simple fixup -c works' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout --detach A2 && + git log -1 --pretty=format:%B >expected-fixup-message && + test_write_lines "" "Modified A2" >>expected-fixup-message && + FAKE_LINES="1 fixup_-c 2" \ + FAKE_COMMIT_AMEND="Modified A2" \ + git rebase -i B && + test_cmp_rev HEAD^ B && + test_cmp_rev HEAD^{tree} A2^{tree} && + test_commit_message HEAD expected-fixup-message +' + +test_expect_success 'fixup -C removes amend! from message' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout --detach A1 && + git log -1 --pretty=format:%b >expected-message && + FAKE_LINES="1 fixup_-C 2" git rebase -i A && + test_cmp_rev HEAD^ A && + test_cmp_rev HEAD^{tree} A1^{tree} && + test_commit_message HEAD expected-message && + get_author HEAD >actual-author && + test_cmp expected-author actual-author +' + +test_expect_success 'fixup -C with conflicts gives correct message' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout --detach A1 && + git log -1 --pretty=format:%b >expected-message && + test_write_lines "" "edited" >>expected-message && + test_must_fail env FAKE_LINES="1 fixup_-C 2" git rebase -i conflicts && + git checkout --theirs -- A && + git add A && + FAKE_COMMIT_AMEND=edited git rebase --continue && + test_cmp_rev HEAD^ conflicts && + test_cmp_rev HEAD^{tree} A1^{tree} && + test_commit_message HEAD expected-message && + get_author HEAD >actual-author && + test_cmp expected-author actual-author +' + +test_expect_success 'skipping fixup -C after fixup gives correct message' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout --detach A3 && + test_must_fail env FAKE_LINES="1 fixup 2 fixup_-C 4" git rebase -i A && + git reset --hard && + FAKE_COMMIT_AMEND=edited git rebase --continue && + test_commit_message HEAD -m "B" +' + +test_expect_success 'sequence of fixup, fixup -C & squash --signoff works' ' + git checkout --detach B3 && + FAKE_LINES="1 fixup 2 fixup_-C 3 fixup_-C 4 squash 5 fixup_-C 6" \ + FAKE_COMMIT_AMEND=squashed \ + FAKE_MESSAGE_COPY=actual-squash-message \ + git -c commit.status=false rebase -ik --signoff A && + git diff-tree --exit-code --patch HEAD B3 -- && + test_cmp_rev HEAD^ A && + test_cmp "$TEST_DIRECTORY/t3437/expected-squash-message" \ + actual-squash-message +' + +test_expect_success 'first fixup -C commented out in sequence fixup fixup -C fixup -C' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout --detach B2~ && + git log -1 --pretty=format:%b >expected-message && + FAKE_LINES="1 fixup 2 fixup_-C 3 fixup_-C 4" git rebase -i A && + test_cmp_rev HEAD^ A && + test_commit_message HEAD expected-message +' + +test_expect_success 'multiple fixup -c opens editor once' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout --detach A3 && + git log -1 --pretty=format:%B >expected-message && + test_write_lines "" "Modified-A3" >>expected-message && + FAKE_COMMIT_AMEND="Modified-A3" \ + FAKE_LINES="1 fixup_-C 2 fixup_-c 3 fixup_-c 4" \ + EXPECT_HEADER_COUNT=4 \ + git rebase -i A && + test_cmp_rev HEAD^ A && + get_author HEAD >actual-author && + test_cmp expected-author actual-author && + test_commit_message HEAD expected-message +' + +test_expect_success 'sequence squash, fixup & fixup -c gives combined message' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout --detach A3 && + FAKE_LINES="1 squash 2 fixup 3 fixup_-c 4" \ + FAKE_MESSAGE_COPY=actual-combined-message \ + git -c commit.status=false rebase -i A && + test_cmp "$TEST_DIRECTORY/t3437/expected-combined-message" \ + actual-combined-message && + test_cmp_rev HEAD^ A +' + +test_expect_success 'fixup -C works upon --autosquash with amend!' ' + git checkout --detach B3 && + FAKE_COMMIT_AMEND=squashed \ + FAKE_MESSAGE_COPY=actual-squash-message \ + git -c commit.status=false rebase -ik --autosquash \ + --signoff A && + git diff-tree --exit-code --patch HEAD B3 -- && + test_cmp_rev HEAD^ A && + test_cmp "$TEST_DIRECTORY/t3437/expected-squash-message" \ + actual-squash-message +' + +test_done diff --git a/t/t3437/expected-combined-message b/t/t3437/expected-combined-message new file mode 100644 index 0000000000..a26cfb2fa9 --- /dev/null +++ b/t/t3437/expected-combined-message @@ -0,0 +1,21 @@ +# This is a combination of 4 commits. +# This is the 1st commit message: + +B + +# This is the commit message #2: + +# amend! B + +new subject + +new +body + +# The commit message #3 will be skipped: + +# A2 + +# This is the commit message #4: + +A3 diff --git a/t/t3437/expected-squash-message b/t/t3437/expected-squash-message new file mode 100644 index 0000000000..ab2434f90e --- /dev/null +++ b/t/t3437/expected-squash-message @@ -0,0 +1,51 @@ +# This is a combination of 6 commits. +# The 1st commit message will be skipped: + +# B +# +# Signed-off-by: Rebase Committer <rebase.committer@example.com> + +# The commit message #2 will be skipped: + +# fixup! B + +# The commit message #3 will be skipped: + +# amend! B +# +# B +# +# edited 1 +# +# Signed-off-by: Rebase Committer <rebase.committer@example.com> + +# This is the commit message #4: + +# amend! amend! B + +B + +edited 1 + +edited 2 + +Signed-off-by: Rebase Committer <rebase.committer@example.com> + +# This is the commit message #5: + +# squash! amend! amend! B + +edited squash + +# This is the commit message #6: + +# amend! amend! amend! B + +B + +edited 1 + +edited 2 + +edited 3 +squashed diff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh index 2b8d9cb38e..0458a58b4b 100755 --- a/t/t3500-cherry.sh +++ b/t/t3500-cherry.sh @@ -5,9 +5,12 @@ test_description='git cherry should detect patches integrated upstream -This test cherry-picks one local change of two into master branch, and +This test cherry-picks one local change of two into main branch, and checks that git cherry only returns the second patch in the local branch ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh GIT_AUTHOR_EMAIL=bogus_email_address @@ -32,7 +35,7 @@ test_expect_success \ test_tick && git commit -m "Add C." && - git checkout -f master && + git checkout -f main && rm -f B C && echo Third >> A && @@ -40,19 +43,19 @@ test_expect_success \ test_tick && git commit -m "Modify A." && - expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* + .*" + expr "$(echo $(git cherry main my-topic-branch) )" : "+ [^ ]* + .*" ' test_expect_success \ 'check that cherry with limit returns only the top patch'\ - 'expr "$(echo $(git cherry master my-topic-branch my-topic-branch^1) )" : "+ [^ ]*" + 'expr "$(echo $(git cherry main my-topic-branch my-topic-branch^1) )" : "+ [^ ]*" ' test_expect_success \ 'cherry-pick one of the 2 patches, and check cherry recognized one and only one as new' \ 'git cherry-pick my-topic-branch^0 && - echo $(git cherry master my-topic-branch) && - expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* - .*" + echo $(git cherry main my-topic-branch) && + expr "$(echo $(git cherry main my-topic-branch) )" : "+ [^ ]* - .*" ' test_expect_success 'cherry ignores whitespace' ' diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh index 3669dfb1be..9d100cd188 100755 --- a/t/t3501-revert-cherry-pick.sh +++ b/t/t3501-revert-cherry-pick.sh @@ -10,6 +10,9 @@ test_description='test cherry-pick and revert with renames ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -112,7 +115,7 @@ test_expect_success 'cherry-pick on unborn branch' ' test_expect_success 'cherry-pick "-" to pick from previous branch' ' git checkout unborn && test_commit to-pick actual content && - git checkout master && + git checkout main && git cherry-pick - && echo content >expect && test_cmp expect actual @@ -132,7 +135,7 @@ test_expect_success 'cherry-pick "-" is meaningless without checkout' ' test_expect_success 'cherry-pick "-" works with arguments' ' git checkout -b side-branch && test_commit change actual change && - git checkout master && + git checkout main && git cherry-pick -s - && echo "Signed-off-by: C O Mitter <committer@example.com>" >expect && git cat-file commit HEAD | grep ^Signed-off-by: >signoff && diff --git a/t/t3502-cherry-pick-merge.sh b/t/t3502-cherry-pick-merge.sh index 8b635a196d..5495eacfec 100755 --- a/t/t3502-cherry-pick-merge.sh +++ b/t/t3502-cherry-pick-merge.sh @@ -8,6 +8,9 @@ test_description='cherry picking and reverting a merge ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -25,7 +28,7 @@ test_expect_success setup ' echo new line >B && git commit -m "add line to B" B && git tag b && - git checkout master && + git checkout main && git merge side && git tag c diff --git a/t/t3503-cherry-pick-root.sh b/t/t3503-cherry-pick-root.sh index e27f39d1e5..95fe4feaee 100755 --- a/t/t3503-cherry-pick-root.sh +++ b/t/t3503-cherry-pick-root.sh @@ -2,6 +2,9 @@ test_description='test cherry-picking (and reverting) a root commit' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -30,7 +33,7 @@ test_expect_success setup ' test_expect_success 'cherry-pick a root commit' ' git checkout second^0 && - git cherry-pick master && + git cherry-pick main && echo first >expect && test_cmp expect file1 @@ -38,14 +41,14 @@ test_expect_success 'cherry-pick a root commit' ' test_expect_success 'revert a root commit' ' - git revert master && + git revert main && test_path_is_missing file1 ' test_expect_success 'cherry-pick a root commit with an external strategy' ' - git cherry-pick --strategy=resolve master && + git cherry-pick --strategy=resolve main && echo first >expect && test_cmp expect file1 @@ -53,7 +56,7 @@ test_expect_success 'cherry-pick a root commit with an external strategy' ' test_expect_success 'revert a root commit with an external strategy' ' - git revert --strategy=resolve master && + git revert --strategy=resolve main && test_path_is_missing file1 ' @@ -65,7 +68,7 @@ test_expect_success 'cherry-pick two root commits' ' echo third >expect.file3 && git checkout second^0 && - git cherry-pick master third && + git cherry-pick main third && test_cmp expect.file1 file1 && test_cmp expect.file2 file2 && diff --git a/t/t3504-cherry-pick-rerere.sh b/t/t3504-cherry-pick-rerere.sh index 80a0d08706..4581ae98b8 100755 --- a/t/t3504-cherry-pick-rerere.sh +++ b/t/t3504-cherry-pick-rerere.sh @@ -2,12 +2,15 @@ test_description='cherry-pick should rerere for conflicts' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' test_commit foo && - test_commit foo-master foo && - test_commit bar-master bar && + test_commit foo-main foo && + test_commit bar-main bar && git checkout -b dev foo && test_commit foo-dev foo && @@ -16,7 +19,7 @@ test_expect_success setup ' ' test_expect_success 'conflicting merge' ' - test_must_fail git merge master + test_must_fail git merge main ' test_expect_success 'fixup' ' @@ -29,7 +32,7 @@ test_expect_success 'fixup' ' ' test_expect_success 'cherry-pick conflict with --rerere-autoupdate' ' - test_must_fail git cherry-pick --rerere-autoupdate foo..bar-master && + test_must_fail git cherry-pick --rerere-autoupdate foo..bar-main && test_cmp foo-expect foo && git diff-files --quiet && test_must_fail git cherry-pick --continue && @@ -41,7 +44,7 @@ test_expect_success 'cherry-pick conflict with --rerere-autoupdate' ' test_expect_success 'cherry-pick conflict repsects rerere.autoUpdate' ' test_config rerere.autoUpdate true && - test_must_fail git cherry-pick foo..bar-master && + test_must_fail git cherry-pick foo..bar-main && test_cmp foo-expect foo && git diff-files --quiet && test_must_fail git cherry-pick --continue && @@ -53,7 +56,7 @@ test_expect_success 'cherry-pick conflict repsects rerere.autoUpdate' ' test_expect_success 'cherry-pick conflict with --no-rerere-autoupdate' ' test_config rerere.autoUpdate true && - test_must_fail git cherry-pick --no-rerere-autoupdate foo..bar-master && + test_must_fail git cherry-pick --no-rerere-autoupdate foo..bar-main && test_cmp foo-expect foo && test_must_fail git diff-files --quiet && git add foo && @@ -66,38 +69,38 @@ test_expect_success 'cherry-pick conflict with --no-rerere-autoupdate' ' ' test_expect_success 'cherry-pick --continue rejects --rerere-autoupdate' ' - test_must_fail git cherry-pick --rerere-autoupdate foo..bar-master && + test_must_fail git cherry-pick --rerere-autoupdate foo..bar-main && test_cmp foo-expect foo && git diff-files --quiet && test_must_fail git cherry-pick --continue --rerere-autoupdate >actual 2>&1 && echo "fatal: cherry-pick: --rerere-autoupdate cannot be used with --continue" >expect && - test_i18ncmp expect actual && + test_cmp expect actual && test_must_fail git cherry-pick --continue --no-rerere-autoupdate >actual 2>&1 && echo "fatal: cherry-pick: --no-rerere-autoupdate cannot be used with --continue" >expect && - test_i18ncmp expect actual && + test_cmp expect actual && git cherry-pick --abort ' test_expect_success 'cherry-pick --rerere-autoupdate more than once' ' - test_must_fail git cherry-pick --rerere-autoupdate --rerere-autoupdate foo..bar-master && + test_must_fail git cherry-pick --rerere-autoupdate --rerere-autoupdate foo..bar-main && test_cmp foo-expect foo && git diff-files --quiet && git cherry-pick --abort && - test_must_fail git cherry-pick --rerere-autoupdate --no-rerere-autoupdate --rerere-autoupdate foo..bar-master && + test_must_fail git cherry-pick --rerere-autoupdate --no-rerere-autoupdate --rerere-autoupdate foo..bar-main && test_cmp foo-expect foo && git diff-files --quiet && git cherry-pick --abort && - test_must_fail git cherry-pick --rerere-autoupdate --no-rerere-autoupdate foo..bar-master && + test_must_fail git cherry-pick --rerere-autoupdate --no-rerere-autoupdate foo..bar-main && test_must_fail git diff-files --quiet && git cherry-pick --abort ' test_expect_success 'cherry-pick conflict without rerere' ' test_config rerere.enabled false && - test_must_fail git cherry-pick foo-master && + test_must_fail git cherry-pick foo-main && grep ===== foo && grep foo-dev foo && - grep foo-master foo + grep foo-main foo ' test_done diff --git a/t/t3505-cherry-pick-empty.sh b/t/t3505-cherry-pick-empty.sh index 5f911bb529..eba3c38d5a 100755 --- a/t/t3505-cherry-pick-empty.sh +++ b/t/t3505-cherry-pick-empty.sh @@ -2,6 +2,9 @@ test_description='test cherry-picking an empty commit' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -17,7 +20,7 @@ test_expect_success setup ' test_tick && git commit --allow-empty-message -m "" && - git checkout master && + git checkout main && git checkout -b empty-change-branch && test_tick && git commit --allow-empty -m "empty" @@ -25,7 +28,7 @@ test_expect_success setup ' ' test_expect_success 'cherry-pick an empty commit' ' - git checkout master && + git checkout main && test_expect_code 1 git cherry-pick empty-change-branch ' @@ -35,7 +38,7 @@ test_expect_success 'index lockfile was removed' ' test_expect_success 'cherry-pick a commit with an empty message' ' test_when_finished "git reset --hard empty-message-branch~1" && - git checkout master && + git checkout main && git cherry-pick empty-message-branch ' @@ -44,12 +47,12 @@ test_expect_success 'index lockfile was removed' ' ' test_expect_success 'cherry-pick a commit with an empty message with --allow-empty-message' ' - git checkout -f master && + git checkout -f main && git cherry-pick --allow-empty-message empty-message-branch ' test_expect_success 'cherry pick an empty non-ff commit without --allow-empty' ' - git checkout master && + git checkout main && echo fourth >>file2 && git add file2 && git commit -m "fourth" && @@ -57,22 +60,22 @@ test_expect_success 'cherry pick an empty non-ff commit without --allow-empty' ' ' test_expect_success 'cherry pick an empty non-ff commit with --allow-empty' ' - git checkout master && + git checkout main && git cherry-pick --allow-empty empty-change-branch ' test_expect_success 'cherry pick with --keep-redundant-commits' ' - git checkout master && + git checkout main && git cherry-pick --keep-redundant-commits HEAD^ ' test_expect_success 'cherry-pick a commit that becomes no-op (prep)' ' - git checkout master && + git checkout main && git branch fork && echo foo >file2 && git add file2 && test_tick && - git commit -m "add file2 on master" && + git commit -m "add file2 on main" && git checkout fork && echo foo >file2 && @@ -84,15 +87,15 @@ test_expect_success 'cherry-pick a commit that becomes no-op (prep)' ' test_expect_success 'cherry-pick a no-op without --keep-redundant' ' git reset --hard && git checkout fork^0 && - test_must_fail git cherry-pick master + test_must_fail git cherry-pick main ' test_expect_success 'cherry-pick a no-op with --keep-redundant' ' git reset --hard && git checkout fork^0 && - git cherry-pick --keep-redundant-commits master && + git cherry-pick --keep-redundant-commits main && git show -s --format=%s >actual && - echo "add file2 on master" >expect && + echo "add file2 on main" >expect && test_cmp expect actual ' diff --git a/t/t3506-cherry-pick-ff.sh b/t/t3506-cherry-pick-ff.sh index 9d5adbc130..7e11bd4a4c 100755 --- a/t/t3506-cherry-pick-ff.sh +++ b/t/t3506-cherry-pick-ff.sh @@ -2,6 +2,9 @@ test_description='test cherry-picking with --ff option' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -24,7 +27,7 @@ test_expect_success setup ' ' test_expect_success 'cherry-pick using --ff fast forwards' ' - git checkout master && + git checkout main && git reset --hard first && test_tick && git cherry-pick --ff second && @@ -32,7 +35,7 @@ test_expect_success 'cherry-pick using --ff fast forwards' ' ' test_expect_success 'cherry-pick not using --ff does not fast forwards' ' - git checkout master && + git checkout main && git reset --hard first && test_tick && git cherry-pick second && @@ -49,7 +52,7 @@ test_expect_success 'cherry-pick not using --ff does not fast forwards' ' # (This has been taken from t3502-cherry-pick-merge.sh) # test_expect_success 'merge setup' ' - git checkout master && + git checkout main && git reset --hard first && echo new line >A && git add A && @@ -62,7 +65,7 @@ test_expect_success 'merge setup' ' test_tick && git commit -m "add line to B" B && git tag B && - git checkout master && + git checkout main && git merge side && git tag C && git checkout -b new A diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh index a21adcf0e4..014001b8f3 100755 --- a/t/t3507-cherry-pick-conflict.sh +++ b/t/t3507-cherry-pick-conflict.sh @@ -9,6 +9,9 @@ test_description='test cherry-pick and revert with conflicts ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh pristine_detach () { @@ -29,7 +32,7 @@ test_expect_success setup ' test_commit redundant-pick foo c redundant && git commit --allow-empty --allow-empty-message && git tag empty && - git checkout master && + git checkout main && git config advice.detachedhead false ' @@ -56,7 +59,7 @@ test_expect_success 'advice from failed cherry-pick' " EOF test_must_fail git cherry-pick picked 2>actual && - test_i18ncmp expected actual + test_cmp expected actual " test_expect_success 'advice from failed cherry-pick --no-commit' " @@ -70,7 +73,7 @@ test_expect_success 'advice from failed cherry-pick --no-commit' " EOF test_must_fail git cherry-pick --no-commit picked 2>actual && - test_i18ncmp expected actual + test_cmp expected actual " test_expect_success 'failed cherry-pick sets CHERRY_PICK_HEAD' ' @@ -253,7 +256,7 @@ test_expect_success \ test_must_fail git cherry-pick picked && - test_i18ncmp expected .git/MERGE_MSG + test_cmp expected .git/MERGE_MSG ' test_expect_success \ @@ -273,7 +276,7 @@ test_expect_success \ test_must_fail git cherry-pick --cleanup=scissors picked && - test_i18ncmp expected .git/MERGE_MSG + test_cmp expected .git/MERGE_MSG ' test_expect_success 'failed cherry-pick describes conflict in work tree' ' @@ -462,7 +465,7 @@ test_expect_success \ test_must_fail git revert picked && sed "s/$OID_REGEX/OBJID/" .git/MERGE_MSG >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success \ @@ -485,7 +488,7 @@ test_expect_success \ test_must_fail git revert --cleanup=scissors picked && sed "s/$OID_REGEX/OBJID/" .git/MERGE_MSG >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'failed cherry-pick does not forget -s' ' diff --git a/t/t3508-cherry-pick-many-commits.sh b/t/t3508-cherry-pick-many-commits.sh index 23070a7b73..e8375d1c97 100755 --- a/t/t3508-cherry-pick-many-commits.sh +++ b/t/t3508-cherry-pick-many-commits.sh @@ -2,6 +2,9 @@ test_description='test cherry-picking many commits' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh check_head_differs_from() { @@ -31,7 +34,7 @@ test_expect_success setup ' ' test_expect_success 'cherry-pick first..fourth works' ' - git checkout -f master && + git checkout -f main && git reset --hard first && test_tick && git cherry-pick first..fourth && @@ -45,7 +48,7 @@ test_expect_success 'cherry-pick three one two works' ' test_commit one && test_commit two && test_commit three && - git checkout -f master && + git checkout -f main && git reset --hard first && git cherry-pick three one two && git diff --quiet three && @@ -56,38 +59,38 @@ two" ' test_expect_success 'cherry-pick three one two: fails' ' - git checkout -f master && + git checkout -f main && git reset --hard first && test_must_fail git cherry-pick three one two: ' test_expect_success 'output to keep user entertained during multi-pick' ' cat <<-\EOF >expected && - [master OBJID] second + [main OBJID] second Author: A U Thor <author@example.com> Date: Thu Apr 7 15:14:13 2005 -0700 1 file changed, 1 insertion(+) - [master OBJID] third + [main OBJID] third Author: A U Thor <author@example.com> Date: Thu Apr 7 15:15:13 2005 -0700 1 file changed, 1 insertion(+) - [master OBJID] fourth + [main OBJID] fourth Author: A U Thor <author@example.com> Date: Thu Apr 7 15:16:13 2005 -0700 1 file changed, 1 insertion(+) EOF - git checkout -f master && + git checkout -f main && git reset --hard first && test_tick && git cherry-pick first..fourth >actual && sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy && test_line_count -ge 3 actual.fuzzy && - test_i18ncmp expected actual.fuzzy + test_cmp expected actual.fuzzy ' test_expect_success 'cherry-pick --strategy resolve first..fourth works' ' - git checkout -f master && + git checkout -f main && git reset --hard first && test_tick && git cherry-pick --strategy resolve first..fourth && @@ -99,32 +102,32 @@ test_expect_success 'cherry-pick --strategy resolve first..fourth works' ' test_expect_success 'output during multi-pick indicates merge strategy' ' cat <<-\EOF >expected && Trying simple merge. - [master OBJID] second + [main OBJID] second Author: A U Thor <author@example.com> Date: Thu Apr 7 15:14:13 2005 -0700 1 file changed, 1 insertion(+) Trying simple merge. - [master OBJID] third + [main OBJID] third Author: A U Thor <author@example.com> Date: Thu Apr 7 15:15:13 2005 -0700 1 file changed, 1 insertion(+) Trying simple merge. - [master OBJID] fourth + [main OBJID] fourth Author: A U Thor <author@example.com> Date: Thu Apr 7 15:16:13 2005 -0700 1 file changed, 1 insertion(+) EOF - git checkout -f master && + git checkout -f main && git reset --hard first && test_tick && git cherry-pick --strategy resolve first..fourth >actual && sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy && - test_i18ncmp expected actual.fuzzy + test_cmp expected actual.fuzzy ' test_expect_success 'cherry-pick --ff first..fourth works' ' - git checkout -f master && + git checkout -f main && git reset --hard first && test_tick && git cherry-pick --ff first..fourth && @@ -134,7 +137,7 @@ test_expect_success 'cherry-pick --ff first..fourth works' ' ' test_expect_success 'cherry-pick -n first..fourth works' ' - git checkout -f master && + git checkout -f main && git reset --hard first && test_tick && git cherry-pick -n first..fourth && @@ -144,7 +147,7 @@ test_expect_success 'cherry-pick -n first..fourth works' ' ' test_expect_success 'revert first..fourth works' ' - git checkout -f master && + git checkout -f main && git reset --hard fourth && test_tick && git revert first..fourth && @@ -154,7 +157,7 @@ test_expect_success 'revert first..fourth works' ' ' test_expect_success 'revert ^first fourth works' ' - git checkout -f master && + git checkout -f main && git reset --hard fourth && test_tick && git revert ^first fourth && @@ -164,7 +167,7 @@ test_expect_success 'revert ^first fourth works' ' ' test_expect_success 'revert fourth fourth~1 fourth~2 works' ' - git checkout -f master && + git checkout -f main && git reset --hard fourth && test_tick && git revert fourth fourth~1 fourth~2 && @@ -174,7 +177,7 @@ test_expect_success 'revert fourth fourth~1 fourth~2 works' ' ' test_expect_success 'cherry-pick -3 fourth works' ' - git checkout -f master && + git checkout -f main && git reset --hard first && test_tick && git cherry-pick -3 fourth && @@ -184,7 +187,7 @@ test_expect_success 'cherry-pick -3 fourth works' ' ' test_expect_success 'cherry-pick --stdin works' ' - git checkout -f master && + git checkout -f main && git reset --hard first && test_tick && git rev-list --reverse first..fourth | git cherry-pick --stdin && diff --git a/t/t3509-cherry-pick-merge-df.sh b/t/t3509-cherry-pick-merge-df.sh index 1e5b3948df..f4159246e1 100755 --- a/t/t3509-cherry-pick-merge-df.sh +++ b/t/t3509-cherry-pick-merge-df.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='Test cherry-pick with directory/file conflicts' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'Initialize repository' ' @@ -28,7 +31,7 @@ test_expect_success 'Setup rename across paths each below D/F conflicts' ' test_expect_success 'Cherry-pick succeeds with rename across D/F conflicts' ' git reset --hard && - git checkout master^0 && + git checkout main^0 && git cherry-pick branch ' diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh index 5b94fdaa67..49010aa946 100755 --- a/t/t3510-cherry-pick-sequence.sh +++ b/t/t3510-cherry-pick-sequence.sh @@ -65,7 +65,7 @@ test_expect_success 'cherry-pick persists opts correctly' ' # gets interrupted, use a high-enough number that is larger # than the number of parents of any commit we have created mainline=4 && - test_expect_code 128 git cherry-pick -s -m $mainline --strategy=recursive -X patience -X ours initial..anotherpick && + test_expect_code 128 git cherry-pick -s -m $mainline --strategy=recursive -X patience -X ours --edit initial..anotherpick && test_path_is_dir .git/sequencer && test_path_is_file .git/sequencer/head && test_path_is_file .git/sequencer/todo && @@ -84,6 +84,36 @@ test_expect_success 'cherry-pick persists opts correctly' ' ours EOF git config --file=.git/sequencer/opts --get-all options.strategy-option >actual && + test_cmp expect actual && + echo "true" >expect && + git config --file=.git/sequencer/opts --get-all options.edit >actual && + test_cmp expect actual +' + +test_expect_success 'revert persists opts correctly' ' + pristine_detach initial && + # to make sure that the session to revert a sequence + # gets interrupted, revert commits that are not in the history + # of HEAD. + test_expect_code 1 git revert -s --strategy=recursive -X patience -X ours --no-edit picked yetanotherpick && + test_path_is_dir .git/sequencer && + test_path_is_file .git/sequencer/head && + test_path_is_file .git/sequencer/todo && + test_path_is_file .git/sequencer/opts && + echo "true" >expect && + git config --file=.git/sequencer/opts --get-all options.signoff >actual && + test_cmp expect actual && + echo "recursive" >expect && + git config --file=.git/sequencer/opts --get-all options.strategy >actual && + test_cmp expect actual && + cat >expect <<-\EOF && + patience + ours + EOF + git config --file=.git/sequencer/opts --get-all options.strategy-option >actual && + test_cmp expect actual && + echo "false" >expect && + git config --file=.git/sequencer/opts --get-all options.edit >actual && test_cmp expect actual ' @@ -170,7 +200,7 @@ test_expect_success 'check advice when we move HEAD by committing' ' git commit -a && test_path_is_missing .git/CHERRY_PICK_HEAD && test_must_fail git cherry-pick --skip 2>advice && - test_i18ncmp expect advice + test_cmp expect advice ' test_expect_success 'selectively advise --skip while launching another sequence' ' @@ -182,7 +212,7 @@ test_expect_success 'selectively advise --skip while launching another sequence' EOF test_must_fail git cherry-pick picked..yetanotherpick && test_must_fail git cherry-pick picked..yetanotherpick 2>advice && - test_i18ncmp expect advice && + test_cmp expect advice && cat >expect <<-EOF && error: cherry-pick is already in progress hint: try "git cherry-pick (--continue | --abort | --quit)" @@ -190,7 +220,7 @@ test_expect_success 'selectively advise --skip while launching another sequence' EOF git reset --merge && test_must_fail git cherry-pick picked..yetanotherpick 2>advice && - test_i18ncmp expect advice + test_cmp expect advice ' test_expect_success 'allow skipping commit but not abort for a new history' ' @@ -204,7 +234,7 @@ test_expect_success 'allow skipping commit but not abort for a new history' ' test_must_fail git cherry-pick anotherpick && test_must_fail git cherry-pick --abort 2>advice && git cherry-pick --skip && - test_i18ncmp expect advice + test_cmp expect advice ' test_expect_success 'allow skipping stopped cherry-pick because of untracked file modifications' ' diff --git a/t/t3512-cherry-pick-submodule.sh b/t/t3512-cherry-pick-submodule.sh index 6ece1d8573..c657840db3 100755 --- a/t/t3512-cherry-pick-submodule.sh +++ b/t/t3512-cherry-pick-submodule.sh @@ -2,11 +2,17 @@ test_description='cherry-pick can handle submodules' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-submodule-update.sh -KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 -KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1 +if test "$GIT_TEST_MERGE_ALGORITHM" != ort +then + KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 + KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1 +fi test_submodule_switch "cherry-pick" test_expect_success 'unrelated submodule/file conflict is ignored' ' @@ -35,7 +41,7 @@ test_expect_success 'unrelated submodule/file conflict is ignored' ' git add a_file && git commit -m "modify a file" && - git checkout master && + git checkout main && git submodule add ../sub sub && git submodule update sub && diff --git a/t/t3513-revert-submodule.sh b/t/t3513-revert-submodule.sh index a759f12cbb..74cd96e582 100755 --- a/t/t3513-revert-submodule.sh +++ b/t/t3513-revert-submodule.sh @@ -30,7 +30,10 @@ git_revert () { git revert HEAD } -KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 +if test "$GIT_TEST_MERGE_ALGORITHM" != ort +then + KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 +fi test_submodule_switch_func "git_revert" test_done diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index efec8d13b6..bb9ef35dac 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -5,6 +5,9 @@ test_description='Test of the various options to git rm.' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # Setup some files to be removed, some with funny characters @@ -240,7 +243,7 @@ test_expect_success 'refresh index before checking if it is up-to-date' ' test_path_is_missing frotz/nitfol ' -test_expect_success 'choking "git rm" should not let it die with cruft' ' +choke_git_rm_setup() { git reset -q --hard && test_when_finished "rm -f .git/index.lock && git reset -q --hard" && i=0 && @@ -249,12 +252,24 @@ test_expect_success 'choking "git rm" should not let it die with cruft' ' do echo "100644 $hash 0 some-file-$i" i=$(( $i + 1 )) - done | git update-index --index-info && + done | git update-index --index-info +} + +test_expect_success 'choking "git rm" should not let it die with cruft (induce SIGPIPE)' ' + choke_git_rm_setup && # git command is intentionally placed upstream of pipe to induce SIGPIPE git rm -n "some-file-*" | : && test_path_is_missing .git/index.lock ' + +test_expect_success !MINGW 'choking "git rm" should not let it die with cruft (induce and check SIGPIPE)' ' + choke_git_rm_setup && + OUT=$( ((trap "" PIPE; git rm -n "some-file-*"; echo $? 1>&3) | :) 3>&1 ) && + test_match_signal 13 "$OUT" && + test_path_is_missing .git/index.lock +' + test_expect_success 'Resolving by removal is not a warning-worthy event' ' git reset -q --hard && test_when_finished "rm -f .git/index.lock msg && git reset -q --hard" && @@ -439,7 +454,7 @@ test_expect_success 'rm issues a warning when section is not found in .gitmodule git add .gitmodules && echo "warning: Could not find section in .gitmodules where path=submod" >expect.err && git rm submod >actual 2>actual.err && - test_i18ncmp expect.err actual.err && + test_cmp expect.err actual.err && test_path_is_missing submod && test_path_is_missing submod/.git && git status -s -uno >actual && @@ -483,16 +498,16 @@ test_expect_success 'setup submodule conflict' ' echo 1 >nitfol && git add nitfol && git commit -m "added nitfol 1" && - git checkout -b branch2 master && + git checkout -b branch2 main && echo 2 >nitfol && git add nitfol && git commit -m "added nitfol 2" && - git checkout -b conflict1 master && + git checkout -b conflict1 main && git -C submod fetch && git -C submod checkout branch1 && git add submod && git commit -m "submod 1" && - git checkout -b conflict2 master && + git checkout -b conflict2 main && git -C submod checkout branch2 && git add submod && git commit -m "submod 2" @@ -604,7 +619,7 @@ test_expect_success 'rm of a conflicted unpopulated submodule succeeds' ' ' test_expect_success 'rm of a populated submodule with a .git directory migrates git dir' ' - git checkout -f master && + git checkout -f main && git reset --hard && git submodule update && ( @@ -717,7 +732,7 @@ test_expect_success 'checking out a commit after submodule removal needs manual git checkout HEAD^ && git submodule update && git checkout -q HEAD^ && - git checkout -q master 2>actual && + git checkout -q main 2>actual && test_i18ngrep "^warning: unable to rmdir '\''submod'\'':" actual && git status -s submod >actual && echo "?? submod/" >expected && @@ -809,7 +824,7 @@ test_expect_success 'rm files with different staged content' ' echo content1 >foo.txt && echo content1 >bar.txt && test_must_fail git rm foo.txt bar.txt 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'rm files with different staged content without hints' ' @@ -822,7 +837,7 @@ test_expect_success 'rm files with different staged content without hints' ' echo content2 >foo.txt && echo content2 >bar.txt && test_must_fail git -c advice.rmhints=false rm foo.txt bar.txt 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'rm file with local modification' ' @@ -834,7 +849,7 @@ test_expect_success 'rm file with local modification' ' git commit -m "testing rm 3" && echo content3 >foo.txt && test_must_fail git rm foo.txt 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'rm file with local modification without hints' ' @@ -844,7 +859,7 @@ test_expect_success 'rm file with local modification without hints' ' EOF echo content4 >bar.txt && test_must_fail git -c advice.rmhints=false rm bar.txt 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'rm file with changes in the index' ' @@ -857,7 +872,7 @@ test_expect_success 'rm file with changes in the index' ' echo content5 >foo.txt && git add foo.txt && test_must_fail git rm foo.txt 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'rm file with changes in the index without hints' ' @@ -866,7 +881,7 @@ test_expect_success 'rm file with changes in the index without hints' ' foo.txt EOF test_must_fail git -c advice.rmhints=false rm foo.txt 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'rm files with two different errors' ' @@ -885,7 +900,7 @@ test_expect_success 'rm files with two different errors' ' echo content6 >bar1.txt && git add bar1.txt && test_must_fail git rm bar1.txt foo1.txt 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'rm empty string should fail' ' diff --git a/t/t3602-rm-sparse-checkout.sh b/t/t3602-rm-sparse-checkout.sh new file mode 100755 index 0000000000..e9e9a15c74 --- /dev/null +++ b/t/t3602-rm-sparse-checkout.sh @@ -0,0 +1,78 @@ +#!/bin/sh + +test_description='git rm in sparse checked out working trees' + +. ./test-lib.sh + +test_expect_success 'setup' " + mkdir -p sub/dir && + touch a b c sub/d sub/dir/e && + git add -A && + git commit -m files && + + cat >sparse_error_header <<-EOF && + The following pathspecs didn't match any eligible path, but they do match index + entries outside the current sparse checkout: + EOF + + cat >sparse_hint <<-EOF && + hint: Disable or modify the sparsity rules if you intend to update such entries. + hint: Disable this message with \"git config advice.updateSparsePath false\" + EOF + + echo b | cat sparse_error_header - >sparse_entry_b_error && + cat sparse_entry_b_error sparse_hint >b_error_and_hint +" + +for opt in "" -f --dry-run +do + test_expect_success "rm${opt:+ $opt} does not remove sparse entries" ' + git sparse-checkout set a && + test_must_fail git rm $opt b 2>stderr && + test_cmp b_error_and_hint stderr && + git ls-files --error-unmatch b + ' +done + +test_expect_success 'recursive rm does not remove sparse entries' ' + git reset --hard && + git sparse-checkout set sub/dir && + git rm -r sub && + git status --porcelain -uno >actual && + echo "D sub/dir/e" >expected && + test_cmp expected actual +' + +test_expect_success 'rm obeys advice.updateSparsePath' ' + git reset --hard && + git sparse-checkout set a && + test_must_fail git -c advice.updateSparsePath=false rm b 2>stderr && + test_cmp sparse_entry_b_error stderr +' + +test_expect_success 'do not advice about sparse entries when they do not match the pathspec' ' + git reset --hard && + git sparse-checkout set a && + test_must_fail git rm nonexistent 2>stderr && + grep "fatal: pathspec .nonexistent. did not match any files" stderr && + ! grep -F -f sparse_error_header stderr +' + +test_expect_success 'do not warn about sparse entries when pathspec matches dense entries' ' + git reset --hard && + git sparse-checkout set a && + git rm "[ba]" 2>stderr && + test_must_be_empty stderr && + git ls-files --error-unmatch b && + test_must_fail git ls-files --error-unmatch a +' + +test_expect_success 'do not warn about sparse entries with --ignore-unmatch' ' + git reset --hard && + git sparse-checkout set a && + git rm --ignore-unmatch b 2>stderr && + test_must_be_empty stderr && + git ls-files --error-unmatch b +' + +test_done diff --git a/t/t3700-add.sh b/t/t3700-add.sh index b7d4ba608c..4086e1ebbc 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -196,6 +196,12 @@ test_expect_success 'git add --refresh with pathspec' ' grep baz actual ' +test_expect_success 'git add --refresh correctly reports no match error' " + echo \"fatal: pathspec ':(icase)nonexistent' did not match any files\" >expect && + test_must_fail git add --refresh ':(icase)nonexistent' 2>actual && + test_cmp expect actual +" + test_expect_success POSIXPERM,SANITY 'git add should fail atomically upon an unreadable file' ' git reset --hard && date >foo1 && @@ -304,7 +310,7 @@ test_expect_success 'error on a repository with no commits' ' error: '"'empty/'"' does not have a commit checked out fatal: adding files failed EOF - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'git add --dry-run of existing changed file' " @@ -320,7 +326,7 @@ test_expect_success 'git add --dry-run of non-existing file' " test_expect_success 'git add --dry-run of an existing file output' " echo \"fatal: pathspec 'ignored-file' did not match any files\" >expect && - test_i18ncmp expect actual + test_cmp expect actual " cat >expect.err <<\EOF @@ -339,8 +345,12 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file' ' ' test_expect_success 'git add --dry-run --ignore-missing of non-existing file output' ' - test_i18ncmp expect.out actual.out && - test_i18ncmp expect.err actual.err + test_cmp expect.out actual.out && + test_cmp expect.err actual.err +' + +test_expect_success 'git add --dry-run --interactive should fail' ' + test_must_fail git add --dry-run --interactive ' test_expect_success 'git add empty string should fail' ' @@ -386,6 +396,36 @@ test_expect_success POSIXPERM 'git add --chmod=[+-]x does not change the working ! test -x foo4 ' +test_expect_success 'git add --chmod fails with non regular files (but updates the other paths)' ' + git reset --hard && + test_ln_s_add foo foo3 && + touch foo4 && + test_must_fail git add --chmod=+x foo3 foo4 2>stderr && + test_i18ngrep "cannot chmod +x .foo3." stderr && + test_mode_in_index 120000 foo3 && + test_mode_in_index 100755 foo4 +' + +test_expect_success 'git add --chmod honors --dry-run' ' + git reset --hard && + echo foo >foo4 && + git add foo4 && + git add --chmod=+x --dry-run foo4 && + test_mode_in_index 100644 foo4 +' + +test_expect_success 'git add --chmod --dry-run reports error for non regular files' ' + git reset --hard && + test_ln_s_add foo foo4 && + test_must_fail git add --chmod=+x --dry-run foo4 2>stderr && + test_i18ngrep "cannot chmod +x .foo4." stderr +' + +test_expect_success 'git add --chmod --dry-run reports error for unmatched pathspec' ' + test_must_fail git add --chmod=+x --dry-run nonexistent 2>stderr && + test_i18ngrep "pathspec .nonexistent. did not match any files" stderr +' + test_expect_success 'no file status change if no pathspec is given' ' >foo5 && >foo6 && @@ -409,11 +449,17 @@ test_expect_success 'no file status change if no pathspec is given in subdir' ' ' test_expect_success 'all statuses changed in folder if . is given' ' - rm -fr empty && - git add --chmod=+x . && - test $(git ls-files --stage | grep ^100644 | wc -l) -eq 0 && - git add --chmod=-x . && - test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0 + git init repo && + ( + cd repo && + mkdir -p sub/dir && + touch x y z sub/a sub/dir/b && + git add -A && + git add --chmod=+x . && + test $(git ls-files --stage | grep ^100644 | wc -l) -eq 0 && + git add --chmod=-x . && + test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0 + ) ' test_expect_success CASE_INSENSITIVE_FS 'path is case-insensitive' ' diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index cc3f434a97..207714655f 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='add -i basic tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-terminal.sh @@ -367,7 +370,7 @@ test_expect_success 'setup expected' ' ' # Test splitting the first patch, then adding both -test_expect_success C_LOCALE_OUTPUT 'add first line works' ' +test_expect_success 'add first line works' ' git commit -am "clear local changes" && git apply patch && printf "%s\n" s y y | git add -p file 2>error | @@ -549,8 +552,8 @@ test_expect_success 'patch mode ignores unmerged entries' ' test_commit non-conflict && git checkout -b side && test_commit side conflict.t && - git checkout master && - test_commit master conflict.t && + git checkout main && + test_commit main conflict.t && test_must_fail git merge side && echo changed >non-conflict.t && echo y | git add -p >output && @@ -849,6 +852,12 @@ test_expect_success 'setup different kinds of dirty submodules' ' cat >expected <<-\EOF && dirty-both-ways dirty-head + EOF + test_cmp expected actual && + git -C for-submodules diff-files --name-only --ignore-submodules=none >actual && + cat >expected <<-\EOF && + dirty-both-ways + dirty-head dirty-otherwise EOF test_cmp expected actual && @@ -965,7 +974,7 @@ test_expect_success 'show help from add--helper' ' EOF test_write_lines h | force_color git add -i >actual.colored && test_decode_color <actual.colored >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_done diff --git a/t/t3705-add-sparse-checkout.sh b/t/t3705-add-sparse-checkout.sh new file mode 100755 index 0000000000..2b1fd0d0ee --- /dev/null +++ b/t/t3705-add-sparse-checkout.sh @@ -0,0 +1,155 @@ +#!/bin/sh + +test_description='git add in sparse checked out working trees' + +. ./test-lib.sh + +SPARSE_ENTRY_BLOB="" + +# Optionally take a printf format string to write to the sparse_entry file +setup_sparse_entry () { + # 'sparse_entry' might already be in the index with the skip-worktree + # bit set. Remove it so that the subsequent git add can update it. + git update-index --force-remove sparse_entry && + if test $# -eq 1 + then + printf "$1" >sparse_entry + else + >sparse_entry + fi && + git add sparse_entry && + git update-index --skip-worktree sparse_entry && + SPARSE_ENTRY_BLOB=$(git rev-parse :sparse_entry) +} + +test_sparse_entry_unchanged () { + echo "100644 $SPARSE_ENTRY_BLOB 0 sparse_entry" >expected && + git ls-files --stage sparse_entry >actual && + test_cmp expected actual +} + +setup_gitignore () { + test_when_finished rm -f .gitignore && + cat >.gitignore <<-EOF + * + !/sparse_entry + EOF +} + +test_expect_success 'setup' " + cat >sparse_error_header <<-EOF && + The following pathspecs didn't match any eligible path, but they do match index + entries outside the current sparse checkout: + EOF + + cat >sparse_hint <<-EOF && + hint: Disable or modify the sparsity rules if you intend to update such entries. + hint: Disable this message with \"git config advice.updateSparsePath false\" + EOF + + echo sparse_entry | cat sparse_error_header - >sparse_entry_error && + cat sparse_entry_error sparse_hint >error_and_hint +" + +test_expect_success 'git add does not remove sparse entries' ' + setup_sparse_entry && + rm sparse_entry && + test_must_fail git add sparse_entry 2>stderr && + test_cmp error_and_hint stderr && + test_sparse_entry_unchanged +' + +test_expect_success 'git add -A does not remove sparse entries' ' + setup_sparse_entry && + rm sparse_entry && + setup_gitignore && + git add -A 2>stderr && + test_must_be_empty stderr && + test_sparse_entry_unchanged +' + +test_expect_success 'git add . does not remove sparse entries' ' + setup_sparse_entry && + rm sparse_entry && + setup_gitignore && + test_must_fail git add . 2>stderr && + + cat sparse_error_header >expect && + echo . >>expect && + cat sparse_hint >>expect && + + test_cmp expect stderr && + test_sparse_entry_unchanged +' + +for opt in "" -f -u --ignore-removal --dry-run +do + test_expect_success "git add${opt:+ $opt} does not update sparse entries" ' + setup_sparse_entry && + echo modified >sparse_entry && + test_must_fail git add $opt sparse_entry 2>stderr && + test_cmp error_and_hint stderr && + test_sparse_entry_unchanged + ' +done + +test_expect_success 'git add --refresh does not update sparse entries' ' + setup_sparse_entry && + git ls-files --debug sparse_entry | grep mtime >before && + test-tool chmtime -60 sparse_entry && + test_must_fail git add --refresh sparse_entry 2>stderr && + test_cmp error_and_hint stderr && + git ls-files --debug sparse_entry | grep mtime >after && + test_cmp before after +' + +test_expect_success 'git add --chmod does not update sparse entries' ' + setup_sparse_entry && + test_must_fail git add --chmod=+x sparse_entry 2>stderr && + test_cmp error_and_hint stderr && + test_sparse_entry_unchanged && + ! test -x sparse_entry +' + +test_expect_success 'git add --renormalize does not update sparse entries' ' + test_config core.autocrlf false && + setup_sparse_entry "LINEONE\r\nLINETWO\r\n" && + echo "sparse_entry text=auto" >.gitattributes && + test_must_fail git add --renormalize sparse_entry 2>stderr && + test_cmp error_and_hint stderr && + test_sparse_entry_unchanged +' + +test_expect_success 'git add --dry-run --ignore-missing warn on sparse path' ' + setup_sparse_entry && + rm sparse_entry && + test_must_fail git add --dry-run --ignore-missing sparse_entry 2>stderr && + test_cmp error_and_hint stderr && + test_sparse_entry_unchanged +' + +test_expect_success 'do not advice about sparse entries when they do not match the pathspec' ' + setup_sparse_entry && + test_must_fail git add nonexistent 2>stderr && + grep "fatal: pathspec .nonexistent. did not match any files" stderr && + ! grep -F -f sparse_error_header stderr +' + +test_expect_success 'do not warn when pathspec matches dense entries' ' + setup_sparse_entry && + echo modified >sparse_entry && + >dense_entry && + git add "*_entry" 2>stderr && + test_must_be_empty stderr && + test_sparse_entry_unchanged && + git ls-files --error-unmatch dense_entry +' + +test_expect_success 'add obeys advice.updateSparsePath' ' + setup_sparse_entry && + test_must_fail git -c advice.updateSparsePath=false add sparse_entry 2>stderr && + test_cmp sparse_entry_error stderr + +' + +test_done diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index d696aa4e52..6275c98523 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -12,10 +12,27 @@ test_description='git mktag: tag object verify test' # given in the expect.pat file. check_verify_failure () { - expect="$2" + test_expect_success "$1" " + test_must_fail git mktag <tag.sig 2>message && + grep '$2' message && + if test '$3' != '--no-strict' + then + test_must_fail git mktag --no-strict <tag.sig 2>message.no-strict && + grep '$2' message.no-strict + fi + " +} + +test_expect_mktag_success() { test_expect_success "$1" ' - ( test_must_fail git mktag <tag.sig 2>message ) && - grep "$expect" message + git hash-object -t tag -w --stdin <tag.sig >expected && + git fsck --strict && + + git mktag <tag.sig >hash && + test_cmp expected hash && + test_when_finished "git update-ref -d refs/tags/mytag $(cat hash)" && + git update-ref refs/tags/mytag $(cat hash) $(test_oid zero) && + git fsck --strict ' } @@ -23,10 +40,24 @@ check_verify_failure () { # first create a commit, so we have a valid object/type # for the tag. test_expect_success 'setup' ' - echo Hello >A && - git update-index --add A && - git commit -m "Initial commit" && - head=$(git rev-parse --verify HEAD) + test_commit A && + test_commit B && + head=$(git rev-parse --verify HEAD) && + head_parent=$(git rev-parse --verify HEAD~) && + tree=$(git rev-parse HEAD^{tree}) && + blob=$(git rev-parse --verify HEAD:B.t) +' + +test_expect_success 'basic usage' ' + cat >tag.sig <<-EOF && + object $head + type commit + tag mytag + tagger T A Gger <tagger@example.com> 1206478233 -0500 + EOF + git mktag <tag.sig && + git mktag --end-of-options <tag.sig && + test_expect_code 129 git mktag --unknown-option ' ############################################################ @@ -37,33 +68,33 @@ too short for a tag EOF check_verify_failure 'Tag object length check' \ - '^error: .*size wrong.*$' + '^error:.* missingObject:' 'strict' ############################################################ # 2. object line label check cat >tag.sig <<EOF -xxxxxx 139e9b33986b1c2670fff52c5067603117b3e895 +xxxxxx $head type tag tag mytag tagger . <> 0 +0000 EOF -check_verify_failure '"object" line label check' '^error: char0: .*"object "$' +check_verify_failure '"object" line label check' '^error:.* missingObject:' ############################################################ -# 3. object line SHA1 check +# 3. object line hash check cat >tag.sig <<EOF -object zz9e9b33986b1c2670fff52c5067603117b3e895 +object $(echo $head | tr 0-9a-f z) type tag tag mytag tagger . <> 0 +0000 EOF -check_verify_failure '"object" line SHA1 check' '^error: char7: .*SHA1 hash$' +check_verify_failure '"object" line check' '^error:.* badObjectSha1:' ############################################################ # 4. type line label check @@ -76,7 +107,7 @@ tagger . <> 0 +0000 EOF -check_verify_failure '"type" line label check' '^error: char.*: .*"\\ntype "$' +check_verify_failure '"type" line label check' '^error:.* missingTypeEntry:' ############################################################ # 5. type line eol check @@ -84,7 +115,7 @@ check_verify_failure '"type" line label check' '^error: char.*: .*"\\ntype "$' echo "object $head" >tag.sig printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig -check_verify_failure '"type" line eol check' '^error: char.*: .*"\\n"$' +check_verify_failure '"type" line eol check' '^error:.* unterminatedHeader:' ############################################################ # 6. tag line label check #1 @@ -98,7 +129,7 @@ tagger . <> 0 +0000 EOF check_verify_failure '"tag" line label check #1' \ - '^error: char.*: no "tag " found$' + '^error:.* missingTagEntry:' ############################################################ # 7. tag line label check #2 @@ -110,7 +141,7 @@ tag EOF check_verify_failure '"tag" line label check #2' \ - '^error: char.*: no "tag " found$' + '^error:.* badType:' ############################################################ # 8. type line type-name length check @@ -122,21 +153,83 @@ tag mytag EOF check_verify_failure '"type" line type-name length check' \ - '^error: char.*: type too long$' + '^error:.* badType:' ############################################################ -# 9. verify object (SHA1/type) check +# 9. verify object (hash/type) check cat >tag.sig <<EOF object $(test_oid deadbeef) +type tag +tag mytag +tagger . <> 0 +0000 + +EOF + +check_verify_failure 'verify object (hash/type) check -- correct type, nonexisting object' \ + '^fatal: could not read tagged object' + +cat >tag.sig <<EOF +object $head type tagggg tag mytag tagger . <> 0 +0000 EOF -check_verify_failure 'verify object (SHA1/type) check' \ - '^error: char7: could not verify object.*$' +check_verify_failure 'verify object (hash/type) check -- made-up type, valid object' \ + '^error:.* badType:' + +cat >tag.sig <<EOF +object $(test_oid deadbeef) +type tagggg +tag mytag +tagger . <> 0 +0000 + +EOF + +check_verify_failure 'verify object (hash/type) check -- made-up type, nonexisting object' \ + '^error:.* badType:' + +cat >tag.sig <<EOF +object $head +type tree +tag mytag +tagger . <> 0 +0000 + +EOF + +check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \ + '^fatal: object.*tagged as.*tree.*but is.*commit' + +############################################################ +# 9.5. verify object (hash/type) check -- replacement + +test_expect_success 'setup replacement of commit -> commit and tree -> blob' ' + git replace $head_parent $head && + git replace -f $tree $blob +' + +cat >tag.sig <<EOF +object $head_parent +type commit +tag mytag +tagger . <> 0 +0000 + +EOF + +test_expect_mktag_success 'tag to a commit replaced by another commit' + +cat >tag.sig <<EOF +object $tree +type tree +tag mytag +tagger . <> 0 +0000 + +EOF + +check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \ + '^fatal: object.*tagged as.*tree.*but is.*blob' ############################################################ # 10. verify tag-name check @@ -150,7 +243,7 @@ tagger . <> 0 +0000 EOF check_verify_failure 'verify tag-name check' \ - '^error: char.*: could not verify tag name$' + '^error:.* badTagName:' '--no-strict' ############################################################ # 11. tagger line label check #1 @@ -164,7 +257,7 @@ This is filler EOF check_verify_failure '"tagger" line label check #1' \ - '^error: char.*: could not find "tagger "$' + '^error:.* missingTaggerEntry:' '--no-strict' ############################################################ # 12. tagger line label check #2 @@ -179,10 +272,10 @@ This is filler EOF check_verify_failure '"tagger" line label check #2' \ - '^error: char.*: could not find "tagger "$' + '^error:.* missingTaggerEntry:' '--no-strict' ############################################################ -# 13. disallow missing tag author name +# 13. allow missing tag author name like fsck cat >tag.sig <<EOF object $head @@ -193,8 +286,7 @@ tagger <> 0 +0000 This is filler EOF -check_verify_failure 'disallow missing tag author name' \ - '^error: char.*: missing tagger name$' +test_expect_mktag_success 'allow missing tag author name' ############################################################ # 14. disallow missing tag author name @@ -209,7 +301,7 @@ tagger T A Gger < EOF check_verify_failure 'disallow malformed tagger' \ - '^error: char.*: malformed tagger field$' + '^error:.* badEmail:' '--no-strict' ############################################################ # 15. allow empty tag email @@ -222,12 +314,10 @@ tagger T A Gger <> 0 +0000 EOF -test_expect_success \ - 'allow empty tag email' \ - 'git mktag <tag.sig >.git/refs/tags/mytag 2>message' +test_expect_mktag_success 'allow empty tag email' ############################################################ -# 16. disallow spaces in tag email +# 16. allow spaces in tag email like fsck cat >tag.sig <<EOF object $head @@ -237,8 +327,7 @@ tagger T A Gger <tag ger@example.com> 0 +0000 EOF -check_verify_failure 'disallow spaces in tag email' \ - '^error: char.*: malformed tagger field$' +test_expect_mktag_success 'allow spaces in tag email like fsck' ############################################################ # 17. disallow missing tag timestamp @@ -252,7 +341,7 @@ tagger T A Gger <tagger@example.com>__ EOF check_verify_failure 'disallow missing tag timestamp' \ - '^error: char.*: missing tag timestamp$' + '^error:.* badDate:' ############################################################ # 18. detect invalid tag timestamp1 @@ -266,7 +355,7 @@ tagger T A Gger <tagger@example.com> Tue Mar 25 15:47:44 2008 EOF check_verify_failure 'detect invalid tag timestamp1' \ - '^error: char.*: missing tag timestamp$' + '^error:.* badDate:' ############################################################ # 19. detect invalid tag timestamp2 @@ -280,7 +369,7 @@ tagger T A Gger <tagger@example.com> 2008-03-31T12:20:15-0500 EOF check_verify_failure 'detect invalid tag timestamp2' \ - '^error: char.*: malformed tag timestamp$' + '^error:.* badDate:' ############################################################ # 20. detect invalid tag timezone1 @@ -294,7 +383,7 @@ tagger T A Gger <tagger@example.com> 1206478233 GMT EOF check_verify_failure 'detect invalid tag timezone1' \ - '^error: char.*: malformed tag timezone$' + '^error:.* badTimezone:' ############################################################ # 21. detect invalid tag timezone2 @@ -308,10 +397,10 @@ tagger T A Gger <tagger@example.com> 1206478233 + 30 EOF check_verify_failure 'detect invalid tag timezone2' \ - '^error: char.*: malformed tag timezone$' + '^error:.* badTimezone:' ############################################################ -# 22. detect invalid tag timezone3 +# 22. allow invalid tag timezone3 (the maximum is -1200/+1400) cat >tag.sig <<EOF object $head @@ -321,8 +410,7 @@ tagger T A Gger <tagger@example.com> 1206478233 -1430 EOF -check_verify_failure 'detect invalid tag timezone3' \ - '^error: char.*: malformed tag timezone$' +test_expect_mktag_success 'allow invalid tag timezone' ############################################################ # 23. detect invalid header entry @@ -337,10 +425,39 @@ this line should not be here EOF check_verify_failure 'detect invalid header entry' \ - '^error: char.*: trailing garbage in tag header$' + '^error:.* extraHeaderEntry:' '--no-strict' -############################################################ -# 24. create valid tag +test_expect_success 'invalid header entry config & fsck' ' + test_must_fail git mktag <tag.sig && + git mktag --no-strict <tag.sig && + + test_must_fail git -c fsck.extraHeaderEntry=error mktag <tag.sig && + test_must_fail git -c fsck.extraHeaderEntry=error mktag --no-strict <tag.sig && + + test_must_fail git -c fsck.extraHeaderEntry=warn mktag <tag.sig && + git -c fsck.extraHeaderEntry=warn mktag --no-strict <tag.sig && + + git -c fsck.extraHeaderEntry=ignore mktag <tag.sig && + git -c fsck.extraHeaderEntry=ignore mktag --no-strict <tag.sig && + + git fsck && + git -c fsck.extraHeaderEntry=warn fsck 2>err && + grep "warning .*extraHeaderEntry:" err && + test_must_fail git -c fsck.extraHeaderEntry=error 2>err fsck && + grep "error .* extraHeaderEntry:" err +' + +cat >tag.sig <<EOF +object $head +type commit +tag mytag +tagger T A Gger <tagger@example.com> 1206478233 -0500 + + +this line comes after an extra newline +EOF + +test_expect_mktag_success 'allow extra newlines at start of body' cat >tag.sig <<EOF object $head @@ -350,16 +467,27 @@ tagger T A Gger <tagger@example.com> 1206478233 -0500 EOF -test_expect_success \ - 'create valid tag' \ - 'git mktag <tag.sig >.git/refs/tags/mytag 2>message' +test_expect_mktag_success 'allow a blank line before an empty body (1)' + +cat >tag.sig <<EOF +object $head +type commit +tag mytag +tagger T A Gger <tagger@example.com> 1206478233 -0500 +EOF + +test_expect_mktag_success 'allow no blank line before an empty body (2)' ############################################################ -# 25. check mytag +# 24. create valid tag -test_expect_success \ - 'check mytag' \ - 'git tag -l | grep mytag' +cat >tag.sig <<EOF +object $head +type commit +tag mytag +tagger T A Gger <tagger@example.com> 1206478233 -0500 +EOF +test_expect_mktag_success 'create valid tag object' test_done diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh index d277a9f4b7..bfab245eb3 100755 --- a/t/t3900-i18n-commit.sh +++ b/t/t3900-i18n-commit.sh @@ -226,10 +226,6 @@ test_commit_autosquash_multi_encoding () { git rev-list HEAD >actual && test_line_count = 3 actual && iconv -f $old -t UTF-8 "$TEST_DIRECTORY"/t3900/$msg >expect && - if test $flag = squash; then - subject="$(head -1 expect)" && - printf "\nsquash! %s\n" "$subject" >>expect - fi && git cat-file commit HEAD^ >raw && (sed "1,/^$/d" raw | iconv -f $new -t utf-8) >actual && test_cmp expect actual diff --git a/t/t3901-i18n-patch.sh b/t/t3901-i18n-patch.sh index 923eb01f0e..4f16a735d9 100755 --- a/t/t3901-i18n-patch.sh +++ b/t/t3901-i18n-patch.sh @@ -5,6 +5,9 @@ test_description='i18n settings and format-patch | am pipe' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh check_encoding () { @@ -45,7 +48,7 @@ test_expect_success setup ' # the first commit on the side branch is UTF-8 test_tick && - git checkout -b side master^ && + git checkout -b side main^ && echo Another file >yours && git add yours && git commit -s -m "Second on side" && @@ -69,7 +72,7 @@ test_expect_success setup ' test_expect_success 'format-patch output (ISO-8859-1)' ' git config i18n.logoutputencoding ISO8859-1 && - git format-patch --stdout master..HEAD^ >out-l1 && + git format-patch --stdout main..HEAD^ >out-l1 && git format-patch --stdout HEAD^ >out-l2 && grep "^Content-Type: text/plain; charset=ISO8859-1" out-l1 && grep "^From: =?ISO8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l1 && @@ -80,7 +83,7 @@ test_expect_success 'format-patch output (ISO-8859-1)' ' test_expect_success 'format-patch output (UTF-8)' ' git config i18n.logoutputencoding UTF-8 && - git format-patch --stdout master..HEAD^ >out-u1 && + git format-patch --stdout main..HEAD^ >out-u1 && git format-patch --stdout HEAD^ >out-u2 && grep "^Content-Type: text/plain; charset=UTF-8" out-u1 && grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u1 && @@ -102,7 +105,7 @@ test_expect_success 'rebase (U/U)' ' # we want UTF-8 encoded name. . "$TEST_DIRECTORY"/t3901/utf8.txt && git checkout -b test && - git rebase master && + git rebase main && check_encoding 2 ' @@ -113,7 +116,7 @@ test_expect_success 'rebase (U/L)' ' . "$TEST_DIRECTORY"/t3901/utf8.txt && git reset --hard side && - git rebase master && + git rebase main && check_encoding 2 ' @@ -125,7 +128,7 @@ test_expect_success !MINGW 'rebase (L/L)' ' . "$TEST_DIRECTORY"/t3901/8859-1.txt && git reset --hard side && - git rebase master && + git rebase main && check_encoding 2 8859 ' @@ -138,7 +141,7 @@ test_expect_success !MINGW 'rebase (L/U)' ' . "$TEST_DIRECTORY"/t3901/8859-1.txt && git reset --hard side && - git rebase master && + git rebase main && check_encoding 2 8859 ' @@ -150,7 +153,7 @@ test_expect_success 'cherry-pick(U/U)' ' git config i18n.logoutputencoding UTF-8 && . "$TEST_DIRECTORY"/t3901/utf8.txt && - git reset --hard master && + git reset --hard main && git cherry-pick side^ && git cherry-pick side && git revert HEAD && @@ -165,7 +168,7 @@ test_expect_success !MINGW 'cherry-pick(L/L)' ' git config i18n.logoutputencoding ISO8859-1 && . "$TEST_DIRECTORY"/t3901/8859-1.txt && - git reset --hard master && + git reset --hard main && git cherry-pick side^ && git cherry-pick side && git revert HEAD && @@ -180,7 +183,7 @@ test_expect_success 'cherry-pick(U/L)' ' git config i18n.logoutputencoding ISO8859-1 && . "$TEST_DIRECTORY"/t3901/utf8.txt && - git reset --hard master && + git reset --hard main && git cherry-pick side^ && git cherry-pick side && git revert HEAD && @@ -196,7 +199,7 @@ test_expect_success !MINGW 'cherry-pick(L/U)' ' git config i18n.logoutputencoding UTF-8 && . "$TEST_DIRECTORY"/t3901/8859-1.txt && - git reset --hard master && + git reset --hard main && git cherry-pick side^ && git cherry-pick side && git revert HEAD && @@ -210,7 +213,7 @@ test_expect_success 'rebase --merge (U/U)' ' . "$TEST_DIRECTORY"/t3901/utf8.txt && git reset --hard side && - git rebase --merge master && + git rebase --merge main && check_encoding 2 ' @@ -221,7 +224,7 @@ test_expect_success 'rebase --merge (U/L)' ' . "$TEST_DIRECTORY"/t3901/utf8.txt && git reset --hard side && - git rebase --merge master && + git rebase --merge main && check_encoding 2 ' @@ -233,7 +236,7 @@ test_expect_success 'rebase --merge (L/L)' ' . "$TEST_DIRECTORY"/t3901/8859-1.txt && git reset --hard side && - git rebase --merge master && + git rebase --merge main && check_encoding 2 8859 ' @@ -246,7 +249,7 @@ test_expect_success 'rebase --merge (L/U)' ' . "$TEST_DIRECTORY"/t3901/8859-1.txt && git reset --hard side && - git rebase --merge master && + git rebase --merge main && check_encoding 2 8859 ' @@ -256,7 +259,7 @@ test_expect_success 'am (U/U)' ' git config i18n.commitencoding UTF-8 && . "$TEST_DIRECTORY"/t3901/utf8.txt && - git reset --hard master && + git reset --hard main && git am out-u1 out-u2 && check_encoding 2 @@ -267,7 +270,7 @@ test_expect_success !MINGW 'am (L/L)' ' git config i18n.commitencoding ISO8859-1 && . "$TEST_DIRECTORY"/t3901/8859-1.txt && - git reset --hard master && + git reset --hard main && git am out-l1 out-l2 && check_encoding 2 8859 @@ -277,7 +280,7 @@ test_expect_success 'am (U/L)' ' # Apply ISO-8859-1 patches with UTF-8 commitencoding git config i18n.commitencoding UTF-8 && . "$TEST_DIRECTORY"/t3901/utf8.txt && - git reset --hard master && + git reset --hard main && # am specifies --utf8 by default. git am out-l1 out-l2 && @@ -290,7 +293,7 @@ test_expect_success 'am --no-utf8 (U/L)' ' git config i18n.commitencoding UTF-8 && . "$TEST_DIRECTORY"/t3901/utf8.txt && - git reset --hard master && + git reset --hard main && git am --no-utf8 out-l1 out-l2 2>err && # commit-tree will warn that the commit message does not contain valid UTF-8 @@ -305,7 +308,7 @@ test_expect_success !MINGW 'am (L/U)' ' git config i18n.commitencoding ISO8859-1 && . "$TEST_DIRECTORY"/t3901/8859-1.txt && - git reset --hard master && + git reset --hard main && # mailinfo will re-code the commit message to the charset specified by # i18n.commitencoding git am out-u1 out-u2 && diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 9f7ca98967..5f282ecf61 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -5,6 +5,9 @@ test_description='Test git stash' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh diff_cmp () { @@ -220,14 +223,14 @@ test_expect_success 'stash branch' ' git commit file -m second && git stash branch stashbranch && test refs/heads/stashbranch = $(git symbolic-ref HEAD) && - test $(git rev-parse HEAD) = $(git rev-parse master^) && + test $(git rev-parse HEAD) = $(git rev-parse main^) && git diff --cached >output && diff_cmp expect output && git diff >output && diff_cmp expect1 output && git add file && git commit -m alternate\ second && - git diff master..stashbranch >output && + git diff main..stashbranch >output && diff_cmp output expect2 && test 0 = $(git stash list | wc -l) ' @@ -520,7 +523,7 @@ test_expect_success 'stash branch - no stashes on stack, stash-like argument' ' STASH_ID=$(git stash create) && git reset --hard && git stash branch stash-branch ${STASH_ID} && - test_when_finished "git reset --hard HEAD && git checkout master && + test_when_finished "git reset --hard HEAD && git checkout main && git branch -D stash-branch" && test $(git ls-files --modified | wc -l) -eq 1 ' @@ -536,7 +539,7 @@ test_expect_success 'stash branch - stashes on stack, stash-like argument' ' STASH_ID=$(git stash create) && git reset --hard && git stash branch stash-branch ${STASH_ID} && - test_when_finished "git reset --hard HEAD && git checkout master && + test_when_finished "git reset --hard HEAD && git checkout main && git branch -D stash-branch" && test $(git ls-files --modified | wc -l) -eq 1 ' @@ -561,7 +564,7 @@ test_expect_success 'stash show format defaults to --stat' ' 1 file changed, 1 insertion(+) EOF git stash show ${STASH_ID} >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'stash show - stashes on stack, stash-like argument' ' @@ -738,7 +741,7 @@ test_expect_success 'valid ref of the form "n", n < N' ' git stash && git stash show 0 && git stash branch tmp 0 && - git checkout master && + git checkout main && git stash && git stash apply 0 && git reset --hard && @@ -755,7 +758,7 @@ test_expect_success 'branch: do not drop the stash if the branch exists' ' git commit -m initial && echo bar >file && git stash && - test_must_fail git stash branch master stash@{0} && + test_must_fail git stash branch main stash@{0} && git rev-parse stash@{0} -- ' @@ -768,7 +771,7 @@ test_expect_success 'branch: should not drop the stash if the apply fails' ' echo bar >file && git stash && echo baz >file && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && test_must_fail git stash branch new_branch stash@{0} && git rev-parse stash@{0} -- ' @@ -789,7 +792,7 @@ test_expect_success 'apply: show same status as git status (relative to ./)' ' git stash apply ) | sed -e 1d >actual && # drop "Saved..." - test_i18ncmp expect actual + test_cmp expect actual ' cat >expect <<EOF @@ -902,7 +905,7 @@ test_expect_success 'push -m shows right message' ' >foo && git add foo && git stash push -m "test message" && - echo "stash@{0}: On master: test message" >expect && + echo "stash@{0}: On main: test message" >expect && git stash list -1 >actual && test_cmp expect actual ' @@ -911,7 +914,7 @@ test_expect_success 'push -m also works without space' ' >foo && git add foo && git stash push -m"unspaced test message" && - echo "stash@{0}: On master: unspaced test message" >expect && + echo "stash@{0}: On main: unspaced test message" >expect && git stash list -1 >actual && test_cmp expect actual ' @@ -968,7 +971,7 @@ test_expect_success 'push -mfoo uses right message' ' >foo && git add foo && git stash push -m"test mfoo" && - echo "stash@{0}: On master: test mfoo" >expect && + echo "stash@{0}: On main: test mfoo" >expect && git stash list -1 >actual && test_cmp expect actual ' @@ -977,7 +980,7 @@ test_expect_success 'push --message foo is synonym for -mfoo' ' >foo && git add foo && git stash push --message "test message foo" && - echo "stash@{0}: On master: test message foo" >expect && + echo "stash@{0}: On main: test message foo" >expect && git stash list -1 >actual && test_cmp expect actual ' @@ -986,7 +989,7 @@ test_expect_success 'push --message=foo is synonym for -mfoo' ' >foo && git add foo && git stash push --message="test message=foo" && - echo "stash@{0}: On master: test message=foo" >expect && + echo "stash@{0}: On main: test message=foo" >expect && git stash list -1 >actual && test_cmp expect actual ' @@ -995,7 +998,7 @@ test_expect_success 'push -m shows right message' ' >foo && git add foo && git stash push -m "test m foo" && - echo "stash@{0}: On master: test m foo" >expect && + echo "stash@{0}: On main: test m foo" >expect && git stash list -1 >actual && test_cmp expect actual ' @@ -1004,7 +1007,7 @@ test_expect_success 'create stores correct message' ' >foo && git add foo && STASH_ID=$(git stash create "create test message") && - echo "On master: create test message" >expect && + echo "On main: create test message" >expect && git show --pretty=%s -s ${STASH_ID} >actual && test_cmp expect actual ' @@ -1013,13 +1016,13 @@ test_expect_success 'create with multiple arguments for the message' ' >foo && git add foo && STASH_ID=$(git stash create test untracked) && - echo "On master: test untracked" >expect && + echo "On main: test untracked" >expect && git show --pretty=%s -s ${STASH_ID} >actual && test_cmp expect actual ' test_expect_success 'create in a detached state' ' - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && git checkout HEAD~1 && >foo && git add foo && @@ -1111,7 +1114,7 @@ test_expect_success 'stash push -p with pathspec shows no changes only once' ' git stash push -p foo >actual && echo "No local changes to save" >expect && git reset --hard HEAD~ && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'push <pathspec>: show no changes when there are none' ' @@ -1121,7 +1124,7 @@ test_expect_success 'push <pathspec>: show no changes when there are none' ' git stash push foo >actual && echo "No local changes to save" >expect && git reset --hard HEAD~ && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'push: <pathspec> not in the repository errors out' ' diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh index f075c7f1f3..dd2cdcc114 100755 --- a/t/t3905-stash-include-untracked.sh +++ b/t/t3905-stash-include-untracked.sh @@ -8,16 +8,16 @@ test_description='Test git stash --include-untracked' . ./test-lib.sh test_expect_success 'stash save --include-untracked some dirty working directory' ' - echo 1 > file && + echo 1 >file && git add file && test_tick && git commit -m initial && - echo 2 > file && + echo 2 >file && git add file && - echo 3 > file && + echo 3 >file && test_tick && - echo 1 > file2 && - echo 1 > HEAD && + echo 1 >file2 && + echo 1 >HEAD && mkdir untracked && echo untracked >untracked/untracked && git stash --include-untracked && @@ -25,48 +25,50 @@ test_expect_success 'stash save --include-untracked some dirty working directory git diff-index --cached --quiet HEAD ' -cat > expect <<EOF -?? actual -?? expect -EOF - test_expect_success 'stash save --include-untracked cleaned the untracked files' ' + cat >expect <<-EOF && + ?? actual + ?? expect + EOF + git status --porcelain >actual && test_cmp expect actual ' -tracked=$(git rev-parse --short $(echo 1 | git hash-object --stdin)) -untracked=$(git rev-parse --short $(echo untracked | git hash-object --stdin)) -cat > expect.diff <<EOF -diff --git a/HEAD b/HEAD -new file mode 100644 -index 0000000..$tracked ---- /dev/null -+++ b/HEAD -@@ -0,0 +1 @@ -+1 -diff --git a/file2 b/file2 -new file mode 100644 -index 0000000..$tracked ---- /dev/null -+++ b/file2 -@@ -0,0 +1 @@ -+1 -diff --git a/untracked/untracked b/untracked/untracked -new file mode 100644 -index 0000000..$untracked ---- /dev/null -+++ b/untracked/untracked -@@ -0,0 +1 @@ -+untracked -EOF -cat > expect.lstree <<EOF -HEAD -file2 -untracked -EOF - test_expect_success 'stash save --include-untracked stashed the untracked files' ' + one_blob=$(echo 1 | git hash-object --stdin) && + tracked=$(git rev-parse --short "$one_blob") && + untracked_blob=$(echo untracked | git hash-object --stdin) && + untracked=$(git rev-parse --short "$untracked_blob") && + cat >expect.diff <<-EOF && + diff --git a/HEAD b/HEAD + new file mode 100644 + index 0000000..$tracked + --- /dev/null + +++ b/HEAD + @@ -0,0 +1 @@ + +1 + diff --git a/file2 b/file2 + new file mode 100644 + index 0000000..$tracked + --- /dev/null + +++ b/file2 + @@ -0,0 +1 @@ + +1 + diff --git a/untracked/untracked b/untracked/untracked + new file mode 100644 + index 0000000..$untracked + --- /dev/null + +++ b/untracked/untracked + @@ -0,0 +1 @@ + +untracked + EOF + cat >expect.lstree <<-EOF && + HEAD + file2 + untracked + EOF + test_path_is_missing file2 && test_path_is_missing untracked && test_path_is_missing HEAD && @@ -83,57 +85,64 @@ test_expect_success 'stash save --patch --all fails' ' test_must_fail git stash --patch --all ' -git clean --force --quiet +test_expect_success 'clean up untracked/untracked file to prepare for next tests' ' + git clean --force --quiet -cat > expect <<EOF - M file -?? HEAD -?? actual -?? expect -?? file2 -?? untracked/ -EOF +' test_expect_success 'stash pop after save --include-untracked leaves files untracked again' ' + cat >expect <<-EOF && + M file + ?? HEAD + ?? actual + ?? expect + ?? file2 + ?? untracked/ + EOF + git stash pop && git status --porcelain >actual && test_cmp expect actual && - test "1" = "$(cat file2)" && - test untracked = "$(cat untracked/untracked)" + echo 1 >expect_file2 && + test_cmp expect_file2 file2 && + echo untracked >untracked_expect && + test_cmp untracked_expect untracked/untracked ' -git clean --force --quiet -d +test_expect_success 'clean up untracked/ directory to prepare for next tests' ' + git clean --force --quiet -d +' test_expect_success 'stash save -u dirty index' ' - echo 4 > file3 && + echo 4 >file3 && git add file3 && test_tick && git stash -u ' -blob=$(git rev-parse --short $(echo 4 | git hash-object --stdin)) -cat > expect <<EOF -diff --git a/file3 b/file3 -new file mode 100644 -index 0000000..$blob ---- /dev/null -+++ b/file3 -@@ -0,0 +1 @@ -+4 -EOF - test_expect_success 'stash save --include-untracked dirty index got stashed' ' + four_blob=$(echo 4 | git hash-object --stdin) && + blob=$(git rev-parse --short "$four_blob") && + cat >expect <<-EOF && + diff --git a/file3 b/file3 + new file mode 100644 + index 0000000..$blob + --- /dev/null + +++ b/file3 + @@ -0,0 +1 @@ + +4 + EOF + git stash pop --index && + test_when_finished "git reset" && git diff --cached >actual && test_cmp expect actual ' -git reset > /dev/null - # Must direct output somewhere where it won't be considered an untracked file test_expect_success 'stash save --include-untracked -q is quiet' ' - echo 1 > file5 && - git stash save --include-untracked --quiet > .git/stash-output.out 2>&1 && + echo 1 >file5 && + git stash save --include-untracked --quiet >.git/stash-output.out 2>&1 && test_line_count = 0 .git/stash-output.out && rm -f .git/stash-output.out ' @@ -141,35 +150,34 @@ test_expect_success 'stash save --include-untracked -q is quiet' ' test_expect_success 'stash save --include-untracked removed files' ' rm -f file && git stash save --include-untracked && - echo 1 > expect && + echo 1 >expect && + test_when_finished "rm -f expect" && test_cmp expect file ' -rm -f expect - test_expect_success 'stash save --include-untracked removed files got stashed' ' git stash pop && test_path_is_missing file ' -cat > .gitignore <<EOF -.gitignore -ignored -ignored.d/ -EOF - test_expect_success 'stash save --include-untracked respects .gitignore' ' - echo ignored > ignored && + cat >.gitignore <<-EOF && + .gitignore + ignored + ignored.d/ + EOF + + echo ignored >ignored && mkdir ignored.d && echo ignored >ignored.d/untracked && git stash -u && - test -s ignored && - test -s ignored.d/untracked && - test -s .gitignore + test_file_not_empty ignored && + test_file_not_empty ignored.d/untracked && + test_file_not_empty .gitignore ' test_expect_success 'stash save -u can stash with only untracked files different' ' - echo 4 > file4 && + echo 4 >file4 && git stash -u && test_path_is_missing file4 ' @@ -183,9 +191,9 @@ test_expect_success 'stash save --all does not respect .gitignore' ' test_expect_success 'stash save --all is stash poppable' ' git stash pop && - test -s ignored && - test -s ignored.d/untracked && - test -s .gitignore + test_file_not_empty ignored && + test_file_not_empty ignored.d/untracked && + test_file_not_empty .gitignore ' test_expect_success 'stash push --include-untracked with pathspec' ' @@ -214,17 +222,17 @@ test_expect_success 'stash push with $IFS character' ' test_path_is_file bar ' -cat > .gitignore <<EOF -ignored -ignored.d/* -EOF - test_expect_success 'stash previously ignored file' ' + cat >.gitignore <<-EOF && + ignored + ignored.d/* + EOF + git reset HEAD && git add .gitignore && git commit -m "Add .gitignore" && >ignored.d/foo && - echo "!ignored.d/foo" >> .gitignore && + echo "!ignored.d/foo" >>.gitignore && git stash save --include-untracked && test_path_is_missing ignored.d/foo && git stash pop && @@ -280,7 +288,7 @@ test_expect_success 'stash -u -- <ignored> leaves ignored file alone' ' test_expect_success 'stash -u -- <non-existent> shows no changes when there are none' ' git stash push -u -- non-existent >actual && echo "No local changes to save" >expect && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'stash -u with globs' ' @@ -289,4 +297,129 @@ test_expect_success 'stash -u with globs' ' test_path_is_missing untracked.txt ' +test_expect_success 'stash show --include-untracked shows untracked files' ' + git reset --hard && + git clean -xf && + >untracked && + >tracked && + git add tracked && + empty_blob_oid=$(git rev-parse --short :tracked) && + git stash -u && + + cat >expect <<-EOF && + tracked | 0 + untracked | 0 + 2 files changed, 0 insertions(+), 0 deletions(-) + EOF + git stash show --include-untracked >actual && + test_cmp expect actual && + git stash show -u >actual && + test_cmp expect actual && + git stash show --no-include-untracked --include-untracked >actual && + test_cmp expect actual && + git stash show --only-untracked --include-untracked >actual && + test_cmp expect actual && + git -c stash.showIncludeUntracked=true stash show >actual && + test_cmp expect actual && + + cat >expect <<-EOF && + diff --git a/tracked b/tracked + new file mode 100644 + index 0000000..$empty_blob_oid + diff --git a/untracked b/untracked + new file mode 100644 + index 0000000..$empty_blob_oid + EOF + git stash show -p --include-untracked >actual && + test_cmp expect actual && + git stash show --include-untracked -p >actual && + test_cmp expect actual && + git -c stash.showIncludeUntracked=true stash show -p >actual && + test_cmp expect actual +' + +test_expect_success 'stash show --only-untracked only shows untracked files' ' + git reset --hard && + git clean -xf && + >untracked && + >tracked && + git add tracked && + empty_blob_oid=$(git rev-parse --short :tracked) && + git stash -u && + + cat >expect <<-EOF && + untracked | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) + EOF + git stash show --only-untracked >actual && + test_cmp expect actual && + git stash show --no-include-untracked --only-untracked >actual && + test_cmp expect actual && + git stash show --include-untracked --only-untracked >actual && + test_cmp expect actual && + + cat >expect <<-EOF && + diff --git a/untracked b/untracked + new file mode 100644 + index 0000000..$empty_blob_oid + EOF + git stash show -p --only-untracked >actual && + test_cmp expect actual && + git stash show --only-untracked -p >actual && + test_cmp expect actual +' + +test_expect_success 'stash show --no-include-untracked cancels --{include,only}-untracked' ' + git reset --hard && + git clean -xf && + >untracked && + >tracked && + git add tracked && + git stash -u && + + cat >expect <<-EOF && + tracked | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) + EOF + git stash show --only-untracked --no-include-untracked >actual && + test_cmp expect actual && + git stash show --include-untracked --no-include-untracked >actual && + test_cmp expect actual +' + +test_expect_success 'stash show --include-untracked errors on duplicate files' ' + git reset --hard && + git clean -xf && + >tracked && + git add tracked && + tree=$(git write-tree) && + i_commit=$(git commit-tree -p HEAD -m "index on any-branch" "$tree") && + test_when_finished "rm -f untracked_index" && + u_commit=$( + GIT_INDEX_FILE="untracked_index" && + export GIT_INDEX_FILE && + git update-index --add tracked && + u_tree=$(git write-tree) && + git commit-tree -m "untracked files on any-branch" "$u_tree" + ) && + w_commit=$(git commit-tree -p HEAD -p "$i_commit" -p "$u_commit" -m "WIP on any-branch" "$tree") && + test_must_fail git stash show --include-untracked "$w_commit" 2>err && + test_i18ngrep "worktree and untracked commit have duplicate entries: tracked" err +' + +test_expect_success 'stash show --{include,only}-untracked on stashes without untracked entries' ' + git reset --hard && + git clean -xf && + >tracked && + git add tracked && + git stash && + + git stash show >expect && + git stash show --include-untracked >actual && + test_cmp expect actual && + + git stash show --only-untracked >actual && + test_must_be_empty actual +' + test_done diff --git a/t/t3910-mac-os-precompose.sh b/t/t3910-mac-os-precompose.sh index 54ce19e353..898267a6bd 100755 --- a/t/t3910-mac-os-precompose.sh +++ b/t/t3910-mac-os-precompose.sh @@ -5,6 +5,9 @@ test_description='utf-8 decomposed (nfd) converted to precomposed (nfc)' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh if ! test_have_prereq UTF8_NFD_TO_NFC @@ -151,7 +154,7 @@ test_expect_success "git checkout link nfd" ' git checkout l.$Odiarnfd ' test_expect_success "setup case mac2" ' - git checkout master && + git checkout main && git reset --hard && git checkout -b mac_os_2 ' @@ -163,7 +166,7 @@ test_expect_success "commit file d2.Adiarnfd/f.Adiarnfd" ' git commit -m "add d2.$Adiarnfd/f.$Adiarnfd" -- d2.$Adiarnfd/f.$Adiarnfd ' test_expect_success "setup for long decomposed filename" ' - git checkout master && + git checkout main && git reset --hard && git checkout -b mac_os_long_nfd_fn ' @@ -173,7 +176,7 @@ test_expect_success "Add long decomposed filename" ' git commit -m "Long filename" ' test_expect_success "setup for long precomposed filename" ' - git checkout master && + git checkout main && git reset --hard && git checkout -b mac_os_long_nfc_fn ' @@ -191,6 +194,22 @@ test_expect_failure 'handle existing decomposed filenames' ' test_must_be_empty untracked ' +test_expect_success "unicode decomposed: git restore -p . " ' + DIRNAMEPWD=dir.Odiarnfc && + DIRNAMEINREPO=dir.$Adiarnfc && + export DIRNAMEPWD DIRNAMEINREPO && + git init "$DIRNAMEPWD" && + ( + cd "$DIRNAMEPWD" && + mkdir "$DIRNAMEINREPO" && + cd "$DIRNAMEINREPO" && + echo "Initial" >file && + git add file && + echo "More stuff" >>file && + echo y | git restore -p . + ) +' + # Test if the global core.precomposeunicode stops autosensing # Must be the last test case test_expect_success "respect git config --global core.precomposeunicode" ' diff --git a/t/t4000-diff-format.sh b/t/t4000-diff-format.sh index e5116a76a1..cce334981e 100755 --- a/t/t4000-diff-format.sh +++ b/t/t4000-diff-format.sh @@ -7,7 +7,7 @@ test_description='Test built-in diff output engine. ' . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh +. "$TEST_DIRECTORY"/lib-diff.sh echo >path0 'Line 1 Line 2 diff --git a/t/t4001-diff-rename.sh b/t/t4001-diff-rename.sh index c16486a9d4..68f2ebca58 100755 --- a/t/t4001-diff-rename.sh +++ b/t/t4001-diff-rename.sh @@ -7,7 +7,7 @@ test_description='Test rename detection in diff engine. ' . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh +. "$TEST_DIRECTORY"/lib-diff.sh test_expect_success 'setup' ' cat >path0 <<-\EOF && @@ -262,4 +262,28 @@ test_expect_success 'diff-tree -l0 defaults to a big rename limit, not zero' ' grep "myotherfile.*myfile" actual ' +test_expect_success 'basename similarity vs best similarity' ' + mkdir subdir && + test_write_lines line1 line2 line3 line4 line5 \ + line6 line7 line8 line9 line10 >subdir/file.txt && + git add subdir/file.txt && + git commit -m "base txt" && + + git rm subdir/file.txt && + test_write_lines line1 line2 line3 line4 line5 \ + line6 line7 line8 >file.txt && + test_write_lines line1 line2 line3 line4 line5 \ + line6 line7 line8 line9 >file.md && + git add file.txt file.md && + git commit -a -m "rename" && + git diff-tree -r -M --name-status HEAD^ HEAD >actual && + # subdir/file.txt is 88% similar to file.md, 78% similar to file.txt, + # but since same basenames are checked first... + cat >expected <<-\EOF && + A file.md + R078 subdir/file.txt file.txt + EOF + test_cmp expected actual +' + test_done diff --git a/t/t4003-diff-rename-1.sh b/t/t4003-diff-rename-1.sh index df2accb655..db07ff3eb1 100755 --- a/t/t4003-diff-rename-1.sh +++ b/t/t4003-diff-rename-1.sh @@ -7,11 +7,11 @@ test_description='More rename detection ' . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash +. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash test_expect_success \ 'prepare reference tree' \ - 'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING && + 'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING && echo frotz >rezrov && git update-index --add COPYING rezrov && tree=$(git write-tree) && @@ -99,7 +99,7 @@ test_expect_success \ test_expect_success \ 'prepare work tree once again' \ - 'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING && + 'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING && git update-index --add --remove COPYING COPYING.1' # tree has COPYING and rezrov. work tree has COPYING and COPYING.1, diff --git a/t/t4004-diff-rename-symlink.sh b/t/t4004-diff-rename-symlink.sh index 6e562c80d1..3d495e37bb 100755 --- a/t/t4004-diff-rename-symlink.sh +++ b/t/t4004-diff-rename-symlink.sh @@ -10,7 +10,7 @@ copy of symbolic links, but should not produce rename/copy followed by an edit for them. ' . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh +. "$TEST_DIRECTORY"/lib-diff.sh test_expect_success SYMLINKS \ 'prepare reference tree' \ diff --git a/t/t4005-diff-rename-2.sh b/t/t4005-diff-rename-2.sh index d18a80493c..8647906132 100755 --- a/t/t4005-diff-rename-2.sh +++ b/t/t4005-diff-rename-2.sh @@ -6,10 +6,10 @@ test_description='Same rename detection as t4003 but testing diff-raw.' . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash +. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash test_expect_success 'setup reference tree' ' - cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING && + cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING && echo frotz >rezrov && git update-index --add COPYING rezrov && tree=$(git write-tree) && @@ -64,7 +64,7 @@ test_expect_success 'validate output from rename/copy detection (#2)' ' # nows how to say Copy. test_expect_success 'validate output from rename/copy detection (#3)' ' - cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING && + cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING && git update-index --add --remove COPYING COPYING.1 && cat <<-EOF >expected && diff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh index 03489aff14..275ce5fa15 100755 --- a/t/t4006-diff-mode.sh +++ b/t/t4006-diff-mode.sh @@ -39,13 +39,13 @@ test_expect_success '--stat output after text chmod' ' 1 file changed, 0 insertions(+), 0 deletions(-) EOF git diff HEAD --stat >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success '--shortstat output after text chmod' ' tail -n 1 <expect >expect.short && git diff HEAD --shortstat >actual && - test_i18ncmp expect.short actual + test_cmp expect.short actual ' test_expect_success '--stat output after binary chmod' ' @@ -56,13 +56,13 @@ test_expect_success '--stat output after binary chmod' ' 2 files changed, 0 insertions(+), 0 deletions(-) EOF git diff HEAD --stat >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success '--shortstat output after binary chmod' ' tail -n 1 <expect >expect.short && git diff HEAD --shortstat >actual && - test_i18ncmp expect.short actual + test_cmp expect.short actual ' test_done diff --git a/t/t4007-rename-3.sh b/t/t4007-rename-3.sh index b187b7f6c6..cbb9c62f53 100755 --- a/t/t4007-rename-3.sh +++ b/t/t4007-rename-3.sh @@ -7,17 +7,17 @@ test_description='Rename interaction with pathspec. ' . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash +. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash test_expect_success 'prepare reference tree' ' mkdir path0 path1 && - cp "$TEST_DIRECTORY"/diff-lib/COPYING path0/COPYING && + cp "$TEST_DIRECTORY"/lib-diff/COPYING path0/COPYING && git update-index --add path0/COPYING && tree=$(git write-tree) && echo $tree ' -blob=$(git hash-object "$TEST_DIRECTORY/diff-lib/COPYING") +blob=$(git hash-object "$TEST_DIRECTORY/lib-diff/COPYING") test_expect_success 'prepare work tree' ' cp path0/COPYING path1/COPYING && git update-index --add --remove path0/COPYING path1/COPYING diff --git a/t/t4008-diff-break-rewrite.sh b/t/t4008-diff-break-rewrite.sh index b1ccd4102e..2299f27511 100755 --- a/t/t4008-diff-break-rewrite.sh +++ b/t/t4008-diff-break-rewrite.sh @@ -22,11 +22,11 @@ With -B, this should be detected as two complete rewrites. Further, with -B and -M together, these should turn into two renames. ' . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash +. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash test_expect_success setup ' - cat "$TEST_DIRECTORY"/diff-lib/README >file0 && - cat "$TEST_DIRECTORY"/diff-lib/COPYING >file1 && + cat "$TEST_DIRECTORY"/lib-diff/README >file0 && + cat "$TEST_DIRECTORY"/lib-diff/COPYING >file1 && blob0_id=$(git hash-object file0) && blob1_id=$(git hash-object file1) && git update-index --add file0 file1 && diff --git a/t/t4009-diff-rename-4.sh b/t/t4009-diff-rename-4.sh index b63bdf031f..b1da807f16 100755 --- a/t/t4009-diff-rename-4.sh +++ b/t/t4009-diff-rename-4.sh @@ -7,11 +7,11 @@ test_description='Same rename detection as t4003 but testing diff-raw -z. ' . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash +. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash test_expect_success \ 'prepare reference tree' \ - 'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING && + 'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING && echo frotz >rezrov && git update-index --add COPYING rezrov && orig=$(git hash-object COPYING) && @@ -81,7 +81,7 @@ test_expect_success \ test_expect_success \ 'prepare work tree once again' \ - 'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING && + 'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING && git update-index --add --remove COPYING COPYING.1' git diff-index -z -C --find-copies-harder $tree >current diff --git a/t/t4010-diff-pathspec.sh b/t/t4010-diff-pathspec.sh index 65cc703c65..1bbced79ec 100755 --- a/t/t4010-diff-pathspec.sh +++ b/t/t4010-diff-pathspec.sh @@ -10,7 +10,7 @@ Prepare: path1/file1 ' . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash +. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash test_expect_success \ setup \ diff --git a/t/t4011-diff-symlink.sh b/t/t4011-diff-symlink.sh index 717034bb50..5a25c259fe 100755 --- a/t/t4011-diff-symlink.sh +++ b/t/t4011-diff-symlink.sh @@ -7,7 +7,7 @@ test_description='Test diff of symlinks. ' . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh +. "$TEST_DIRECTORY"/lib-diff.sh # Print the short OID of a symlink with the given name. symlink_oid () { diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh index 6579c81216..33ff588ebc 100755 --- a/t/t4012-diff-binary.sh +++ b/t/t4012-diff-binary.sh @@ -34,19 +34,19 @@ EOF test_expect_success 'apply --stat output for binary file change' ' git diff >diff && git apply --stat --summary <diff >current && - test_i18ncmp expected current + test_cmp expected current ' test_expect_success 'diff --shortstat output for binary file change' ' tail -n 1 expected >expect && git diff --shortstat >current && - test_i18ncmp expect current + test_cmp expect current ' test_expect_success 'diff --shortstat output for binary file change only' ' echo " 1 file changed, 0 insertions(+), 0 deletions(-)" >expected && git diff --shortstat -- b >current && - test_i18ncmp expected current + test_cmp expected current ' test_expect_success 'apply --numstat notices binary file change' ' @@ -63,7 +63,7 @@ test_expect_success 'apply --numstat understands diff --binary format' ' # apply needs to be able to skip the binary material correctly # in order to report the line number of a corrupt patch. -test_expect_success C_LOCALE_OUTPUT 'apply detecting corrupt patch correctly' ' +test_expect_success 'apply detecting corrupt patch correctly' ' git diff >output && sed -e "s/-CIT/xCIT/" <output >broken && test_must_fail git apply --stat --summary broken 2>detected && @@ -73,7 +73,7 @@ test_expect_success C_LOCALE_OUTPUT 'apply detecting corrupt patch correctly' ' test "$detected" = xCIT ' -test_expect_success C_LOCALE_OUTPUT 'apply detecting corrupt patch correctly' ' +test_expect_success 'apply detecting corrupt patch correctly' ' git diff --binary | sed -e "s/-CIT/xCIT/" >broken && test_must_fail git apply --stat --summary broken 2>detected && detected=$(cat detected) && diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index f72d456d3b..87def81699 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -5,8 +5,11 @@ test_description='Various diff formatting options' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh +. "$TEST_DIRECTORY"/lib-diff.sh test_expect_success setup ' @@ -175,6 +178,7 @@ process_diffs () { V=$(git version | sed -e 's/^git version //' -e 's/\./\\./g') while read magic cmd do + status=success case "$magic" in '' | '#'*) continue ;; @@ -183,6 +187,10 @@ do label="$magic-$cmd" case "$magic" in noellipses) ;; + failure) + status=failure + magic= + label="$cmd" ;; *) BUG "unknown magic $magic" ;; esac ;; @@ -195,7 +203,7 @@ do expect="$TEST_DIRECTORY/t4013/diff.$test" actual="$pfx-diff.$test" - test_expect_success "git $cmd # magic is ${magic:-(not used)}" ' + test_expect_$status "git $cmd # magic is ${magic:-(not used)}" ' { echo "$ git $cmd" case "$magic" in @@ -214,7 +222,7 @@ do process_diffs "$expect" >expect && case $cmd in *format-patch* | *-stat*) - test_i18ncmp expect actual;; + test_cmp expect actual;; *) test_cmp expect actual;; esac && @@ -323,8 +331,12 @@ log --no-diff-merges -p --first-parent master log --diff-merges=off -p --first-parent master log --first-parent --diff-merges=off -p master log -p --first-parent master +log -p --diff-merges=first-parent master +log --diff-merges=first-parent master log -m -p --first-parent master log -m -p master +log --cc -m -p master +log -c -m -p master log -SF master log -S F master log -SF -p master @@ -440,6 +452,37 @@ diff-tree --stat --compact-summary initial mode diff-tree -R --stat --compact-summary initial mode EOF +test_expect_success 'log --diff-merges=on matches --diff-merges=separate' ' + git log -p --diff-merges=separate master >result && + process_diffs result >expected && + git log -p --diff-merges=on master >result && + process_diffs result >actual && + test_cmp expected actual +' + +test_expect_success 'deny wrong log.diffMerges config' ' + test_config log.diffMerges wrong-value && + test_expect_code 128 git log +' + +test_expect_success 'git config log.diffMerges first-parent' ' + git log -p --diff-merges=first-parent master >result && + process_diffs result >expected && + test_config log.diffMerges first-parent && + git log -p --diff-merges=on master >result && + process_diffs result >actual && + test_cmp expected actual +' + +test_expect_success 'git config log.diffMerges first-parent vs -m' ' + git log -p --diff-merges=first-parent master >result && + process_diffs result >expected && + test_config log.diffMerges first-parent && + git log -p -m master >result && + process_diffs result >actual && + test_cmp expected actual +' + test_expect_success 'log -S requires an argument' ' test_must_fail git log -S ' diff --git a/t/t4013/diff.log_--cc_-m_-p_master b/t/t4013/diff.log_--cc_-m_-p_master new file mode 100644 index 0000000000..7c217cf348 --- /dev/null +++ b/t/t4013/diff.log_--cc_-m_-p_master @@ -0,0 +1,200 @@ +$ git log --cc -m -p master +commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (from 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0) +Merge: 9a6d494 c7a2ab9 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +diff --git a/dir/sub b/dir/sub +index cead32e..992913c 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -4,3 +4,5 @@ C + D + E + F ++1 ++2 +diff --git a/file0 b/file0 +index b414108..10a8a9f 100644 +--- a/file0 ++++ b/file0 +@@ -4,3 +4,6 @@ + 4 + 5 + 6 ++A ++B ++C + +commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (from c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a) +Merge: 9a6d494 c7a2ab9 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +diff --git a/dir/sub b/dir/sub +index 7289e35..992913c 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,4 +1,8 @@ + A + B ++C ++D ++E ++F + 1 + 2 +diff --git a/file0 b/file0 +index f4615da..10a8a9f 100644 +--- a/file0 ++++ b/file0 +@@ -1,6 +1,9 @@ + 1 + 2 + 3 ++4 ++5 ++6 + A + B + C +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 +diff --git a/file3 b/file3 +deleted file mode 100644 +index 7289e35..0000000 +--- a/file3 ++++ /dev/null +@@ -1,4 +0,0 @@ +-A +-B +-1 +-2 + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second + + This is the second commit. + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +$ diff --git a/t/t4013/diff.log_--diff-merges=first-parent_master b/t/t4013/diff.log_--diff-merges=first-parent_master new file mode 100644 index 0000000000..fa63a557dd --- /dev/null +++ b/t/t4013/diff.log_--diff-merges=first-parent_master @@ -0,0 +1,56 @@ +$ git log --diff-merges=first-parent master +commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 +Merge: 9a6d494 c7a2ab9 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +diff --git a/dir/sub b/dir/sub +index cead32e..992913c 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -4,3 +4,5 @@ C + D + E + F ++1 ++2 +diff --git a/file0 b/file0 +index b414108..10a8a9f 100644 +--- a/file0 ++++ b/file0 +@@ -4,3 +4,6 @@ + 4 + 5 + 6 ++A ++B ++C + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second + + This is the second commit. + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +$ diff --git a/t/t4013/diff.log_-c_-m_-p_master b/t/t4013/diff.log_-c_-m_-p_master new file mode 100644 index 0000000000..b660f3d5f2 --- /dev/null +++ b/t/t4013/diff.log_-c_-m_-p_master @@ -0,0 +1,200 @@ +$ git log -c -m -p master +commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (from 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0) +Merge: 9a6d494 c7a2ab9 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +diff --git a/dir/sub b/dir/sub +index cead32e..992913c 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -4,3 +4,5 @@ C + D + E + F ++1 ++2 +diff --git a/file0 b/file0 +index b414108..10a8a9f 100644 +--- a/file0 ++++ b/file0 +@@ -4,3 +4,6 @@ + 4 + 5 + 6 ++A ++B ++C + +commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (from c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a) +Merge: 9a6d494 c7a2ab9 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +diff --git a/dir/sub b/dir/sub +index 7289e35..992913c 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,4 +1,8 @@ + A + B ++C ++D ++E ++F + 1 + 2 +diff --git a/file0 b/file0 +index f4615da..10a8a9f 100644 +--- a/file0 ++++ b/file0 +@@ -1,6 +1,9 @@ + 1 + 2 + 3 ++4 ++5 ++6 + A + B + C +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 +diff --git a/file3 b/file3 +deleted file mode 100644 +index 7289e35..0000000 +--- a/file3 ++++ /dev/null +@@ -1,4 +0,0 @@ +-A +-B +-1 +-2 + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second + + This is the second commit. + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +$ diff --git a/t/t4013/diff.log_-p_--diff-merges=first-parent_master b/t/t4013/diff.log_-p_--diff-merges=first-parent_master new file mode 100644 index 0000000000..9538a27511 --- /dev/null +++ b/t/t4013/diff.log_-p_--diff-merges=first-parent_master @@ -0,0 +1,137 @@ +$ git log -p --diff-merges=first-parent master +commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 +Merge: 9a6d494 c7a2ab9 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +diff --git a/dir/sub b/dir/sub +index cead32e..992913c 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -4,3 +4,5 @@ C + D + E + F ++1 ++2 +diff --git a/file0 b/file0 +index b414108..10a8a9f 100644 +--- a/file0 ++++ b/file0 +@@ -4,3 +4,6 @@ + 4 + 5 + 6 ++A ++B ++C + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second + + This is the second commit. + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +$ diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index c5e5e0da3f..712d4b5ddf 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -5,6 +5,9 @@ test_description='various format-patch tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-terminal.sh @@ -32,11 +35,11 @@ test_expect_success setup ' test_tick && git commit -m "Side changes #3 with \\n backslash-n in it." && - git checkout master && + git checkout main && git diff-tree -p C2 >patch && git apply --index <patch && test_tick && - git commit -m "Master accepts moral equivalent of #2" && + git commit -m "Main accepts moral equivalent of #2" && git checkout side && git checkout -b patchid && @@ -56,39 +59,39 @@ test_expect_success setup ' test_tick && git commit -m "patchid 3" && - git checkout master + git checkout main ' test_expect_success 'format-patch --ignore-if-in-upstream' ' - git format-patch --stdout master..side >patch0 && + git format-patch --stdout main..side >patch0 && grep "^From " patch0 >from0 && test_line_count = 3 from0 ' test_expect_success 'format-patch --ignore-if-in-upstream' ' git format-patch --stdout \ - --ignore-if-in-upstream master..side >patch1 && + --ignore-if-in-upstream main..side >patch1 && grep "^From " patch1 >from1 && test_line_count = 2 from1 ' test_expect_success 'format-patch --ignore-if-in-upstream handles tags' ' git tag -a v1 -m tag side && - git tag -a v2 -m tag master && + git tag -a v2 -m tag main && git format-patch --stdout --ignore-if-in-upstream v2..v1 >patch1 && grep "^From " patch1 >from1 && test_line_count = 2 from1 ' test_expect_success "format-patch doesn't consider merge commits" ' - git checkout -b feature master && + git checkout -b feature main && echo "Another line" >>file && test_tick && git commit -am "Feature branch change #1" && echo "Yet another line" >>file && test_tick && git commit -am "Feature branch change #2" && - git checkout -b merger master && + git checkout -b merger main && test_tick && git merge --no-ff feature && git format-patch -3 --stdout >patch && @@ -97,16 +100,16 @@ test_expect_success "format-patch doesn't consider merge commits" ' ' test_expect_success 'format-patch result applies' ' - git checkout -b rebuild-0 master && + git checkout -b rebuild-0 main && git am -3 patch0 && - git rev-list master.. >list && + git rev-list main.. >list && test_line_count = 2 list ' test_expect_success 'format-patch --ignore-if-in-upstream result applies' ' - git checkout -b rebuild-1 master && + git checkout -b rebuild-1 main && git am -3 patch1 && - git rev-list master.. >list && + git rev-list main.. >list && test_line_count = 2 list ' @@ -130,7 +133,7 @@ test_expect_success 'extra headers' ' " && git config --add format.headers "Cc: S E Cipient <scipient@example.com> " && - git format-patch --stdout master..side >patch2 && + git format-patch --stdout main..side >patch2 && sed -e "/^\$/q" patch2 >hdrs2 && grep "^To: R E Cipient <rcipient@example.com>\$" hdrs2 && grep "^Cc: S E Cipient <scipient@example.com>\$" hdrs2 @@ -139,7 +142,7 @@ test_expect_success 'extra headers' ' test_expect_success 'extra headers without newlines' ' git config --replace-all format.headers "To: R E Cipient <rcipient@example.com>" && git config --add format.headers "Cc: S E Cipient <scipient@example.com>" && - git format-patch --stdout master..side >patch3 && + git format-patch --stdout main..side >patch3 && sed -e "/^\$/q" patch3 >hdrs3 && grep "^To: R E Cipient <rcipient@example.com>\$" hdrs3 && grep "^Cc: S E Cipient <scipient@example.com>\$" hdrs3 @@ -148,7 +151,7 @@ test_expect_success 'extra headers without newlines' ' test_expect_success 'extra headers with multiple To:s' ' git config --replace-all format.headers "To: R E Cipient <rcipient@example.com>" && git config --add format.headers "To: S E Cipient <scipient@example.com>" && - git format-patch --stdout master..side >patch4 && + git format-patch --stdout main..side >patch4 && sed -e "/^\$/q" patch4 >hdrs4 && grep "^To: R E Cipient <rcipient@example.com>,\$" hdrs4 && grep "^ *S E Cipient <scipient@example.com>\$" hdrs4 @@ -156,7 +159,7 @@ test_expect_success 'extra headers with multiple To:s' ' test_expect_success 'additional command line cc (ascii)' ' git config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" && - git format-patch --cc="S E Cipient <scipient@example.com>" --stdout master..side >patch5 && + git format-patch --cc="S E Cipient <scipient@example.com>" --stdout main..side >patch5 && sed -e "/^\$/q" patch5 >hdrs5 && grep "^Cc: R E Cipient <rcipient@example.com>,\$" hdrs5 && grep "^ *S E Cipient <scipient@example.com>\$" hdrs5 @@ -164,7 +167,7 @@ test_expect_success 'additional command line cc (ascii)' ' test_expect_failure 'additional command line cc (rfc822)' ' git config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" && - git format-patch --cc="S. E. Cipient <scipient@example.com>" --stdout master..side >patch5 && + git format-patch --cc="S. E. Cipient <scipient@example.com>" --stdout main..side >patch5 && sed -e "/^\$/q" patch5 >hdrs5 && grep "^Cc: R E Cipient <rcipient@example.com>,\$" hdrs5 && grep "^ *\"S. E. Cipient\" <scipient@example.com>\$" hdrs5 @@ -172,14 +175,14 @@ test_expect_failure 'additional command line cc (rfc822)' ' test_expect_success 'command line headers' ' git config --unset-all format.headers && - git format-patch --add-header="Cc: R E Cipient <rcipient@example.com>" --stdout master..side >patch6 && + git format-patch --add-header="Cc: R E Cipient <rcipient@example.com>" --stdout main..side >patch6 && sed -e "/^\$/q" patch6 >hdrs6 && grep "^Cc: R E Cipient <rcipient@example.com>\$" hdrs6 ' test_expect_success 'configuration headers and command line headers' ' git config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" && - git format-patch --add-header="Cc: S E Cipient <scipient@example.com>" --stdout master..side >patch7 && + git format-patch --add-header="Cc: S E Cipient <scipient@example.com>" --stdout main..side >patch7 && sed -e "/^\$/q" patch7 >hdrs7 && grep "^Cc: R E Cipient <rcipient@example.com>,\$" hdrs7 && grep "^ *S E Cipient <scipient@example.com>\$" hdrs7 @@ -187,40 +190,40 @@ test_expect_success 'configuration headers and command line headers' ' test_expect_success 'command line To: header (ascii)' ' git config --unset-all format.headers && - git format-patch --to="R E Cipient <rcipient@example.com>" --stdout master..side >patch8 && + git format-patch --to="R E Cipient <rcipient@example.com>" --stdout main..side >patch8 && sed -e "/^\$/q" patch8 >hdrs8 && grep "^To: R E Cipient <rcipient@example.com>\$" hdrs8 ' test_expect_failure 'command line To: header (rfc822)' ' - git format-patch --to="R. E. Cipient <rcipient@example.com>" --stdout master..side >patch8 && + git format-patch --to="R. E. Cipient <rcipient@example.com>" --stdout main..side >patch8 && sed -e "/^\$/q" patch8 >hdrs8 && grep "^To: \"R. E. Cipient\" <rcipient@example.com>\$" hdrs8 ' test_expect_failure 'command line To: header (rfc2047)' ' - git format-patch --to="R Ä Cipient <rcipient@example.com>" --stdout master..side >patch8 && + git format-patch --to="R Ä Cipient <rcipient@example.com>" --stdout main..side >patch8 && sed -e "/^\$/q" patch8 >hdrs8 && grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$" hdrs8 ' test_expect_success 'configuration To: header (ascii)' ' git config format.to "R E Cipient <rcipient@example.com>" && - git format-patch --stdout master..side >patch9 && + git format-patch --stdout main..side >patch9 && sed -e "/^\$/q" patch9 >hdrs9 && grep "^To: R E Cipient <rcipient@example.com>\$" hdrs9 ' test_expect_failure 'configuration To: header (rfc822)' ' git config format.to "R. E. Cipient <rcipient@example.com>" && - git format-patch --stdout master..side >patch9 && + git format-patch --stdout main..side >patch9 && sed -e "/^\$/q" patch9 >hdrs9 && grep "^To: \"R. E. Cipient\" <rcipient@example.com>\$" hdrs9 ' test_expect_failure 'configuration To: header (rfc2047)' ' git config format.to "R Ä Cipient <rcipient@example.com>" && - git format-patch --stdout master..side >patch9 && + git format-patch --stdout main..side >patch9 && sed -e "/^\$/q" patch9 >hdrs9 && grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$" hdrs9 ' @@ -234,35 +237,35 @@ check_patch () { } test_expect_success 'format.from=false' ' - git -c format.from=false format-patch --stdout master..side >patch && + git -c format.from=false format-patch --stdout main..side >patch && sed -e "/^\$/q" patch >hdrs && check_patch patch && ! grep "^From: C O Mitter <committer@example.com>\$" hdrs ' test_expect_success 'format.from=true' ' - git -c format.from=true format-patch --stdout master..side >patch && + git -c format.from=true format-patch --stdout main..side >patch && sed -e "/^\$/q" patch >hdrs && check_patch hdrs && grep "^From: C O Mitter <committer@example.com>\$" hdrs ' test_expect_success 'format.from with address' ' - git -c format.from="F R Om <from@example.com>" format-patch --stdout master..side >patch && + git -c format.from="F R Om <from@example.com>" format-patch --stdout main..side >patch && sed -e "/^\$/q" patch >hdrs && check_patch hdrs && grep "^From: F R Om <from@example.com>\$" hdrs ' test_expect_success '--no-from overrides format.from' ' - git -c format.from="F R Om <from@example.com>" format-patch --no-from --stdout master..side >patch && + git -c format.from="F R Om <from@example.com>" format-patch --no-from --stdout main..side >patch && sed -e "/^\$/q" patch >hdrs && check_patch hdrs && ! grep "^From: F R Om <from@example.com>\$" hdrs ' test_expect_success '--from overrides format.from' ' - git -c format.from="F R Om <from@example.com>" format-patch --from --stdout master..side >patch && + git -c format.from="F R Om <from@example.com>" format-patch --from --stdout main..side >patch && sed -e "/^\$/q" patch >hdrs && check_patch hdrs && ! grep "^From: F R Om <from@example.com>\$" hdrs @@ -271,7 +274,7 @@ test_expect_success '--from overrides format.from' ' test_expect_success '--no-to overrides config.to' ' git config --replace-all format.to \ "R E Cipient <rcipient@example.com>" && - git format-patch --no-to --stdout master..side >patch10 && + git format-patch --no-to --stdout main..side >patch10 && sed -e "/^\$/q" patch10 >hdrs10 && check_patch hdrs10 && ! grep "^To: R E Cipient <rcipient@example.com>\$" hdrs10 @@ -281,7 +284,7 @@ test_expect_success '--no-to and --to replaces config.to' ' git config --replace-all format.to \ "Someone <someone@out.there>" && git format-patch --no-to --to="Someone Else <else@out.there>" \ - --stdout master..side >patch11 && + --stdout main..side >patch11 && sed -e "/^\$/q" patch11 >hdrs11 && check_patch hdrs11 && ! grep "^To: Someone <someone@out.there>\$" hdrs11 && @@ -291,7 +294,7 @@ test_expect_success '--no-to and --to replaces config.to' ' test_expect_success '--no-cc overrides config.cc' ' git config --replace-all format.cc \ "C E Cipient <rcipient@example.com>" && - git format-patch --no-cc --stdout master..side >patch12 && + git format-patch --no-cc --stdout main..side >patch12 && sed -e "/^\$/q" patch12 >hdrs12 && check_patch hdrs12 && ! grep "^Cc: C E Cipient <rcipient@example.com>\$" hdrs12 @@ -300,7 +303,7 @@ test_expect_success '--no-cc overrides config.cc' ' test_expect_success '--no-add-header overrides config.headers' ' git config --replace-all format.headers \ "Header1: B E Cipient <rcipient@example.com>" && - git format-patch --no-add-header --stdout master..side >patch13 && + git format-patch --no-add-header --stdout main..side >patch13 && sed -e "/^\$/q" patch13 >hdrs13 && check_patch hdrs13 && ! grep "^Header1: B E Cipient <rcipient@example.com>\$" hdrs13 @@ -309,7 +312,7 @@ test_expect_success '--no-add-header overrides config.headers' ' test_expect_success 'multiple files' ' rm -rf patches/ && git checkout side && - git format-patch -o patches/ master && + git format-patch -o patches/ main && ls patches/0001-Side-changes-1.patch patches/0002-Side-changes-2.patch patches/0003-Side-changes-3-with-n-backslash-n-in-it.patch ' @@ -369,7 +372,7 @@ test_expect_success 'filename limit applies only to basename' ' test_expect_success 'reroll count' ' rm -fr patches && - git format-patch -o patches --cover-letter --reroll-count 4 master..side >list && + git format-patch -o patches --cover-letter --reroll-count 4 main..side >list && ! grep -v "^patches/v4-000[0-3]-" list && sed -n -e "/^Subject: /p" $(cat list) >subjects && ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects @@ -377,12 +380,36 @@ test_expect_success 'reroll count' ' test_expect_success 'reroll count (-v)' ' rm -fr patches && - git format-patch -o patches --cover-letter -v4 master..side >list && + git format-patch -o patches --cover-letter -v4 main..side >list && ! grep -v "^patches/v4-000[0-3]-" list && sed -n -e "/^Subject: /p" $(cat list) >subjects && ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects ' +test_expect_success 'reroll count (-v) with a fractional number' ' + rm -fr patches && + git format-patch -o patches --cover-letter -v4.4 main..side >list && + ! grep -v "^patches/v4.4-000[0-3]-" list && + sed -n -e "/^Subject: /p" $(cat list) >subjects && + ! grep -v "^Subject: \[PATCH v4.4 [0-3]/3\] " subjects +' + +test_expect_success 'reroll (-v) count with a non number' ' + rm -fr patches && + git format-patch -o patches --cover-letter -v4rev2 main..side >list && + ! grep -v "^patches/v4rev2-000[0-3]-" list && + sed -n -e "/^Subject: /p" $(cat list) >subjects && + ! grep -v "^Subject: \[PATCH v4rev2 [0-3]/3\] " subjects +' + +test_expect_success 'reroll (-v) count with a non-pathname character' ' + rm -fr patches && + git format-patch -o patches --cover-letter -v4---..././../--1/.2// main..side >list && + ! grep -v "patches/v4-\.-\.-\.-1-\.2-000[0-3]-" list && + sed -n -e "/^Subject: /p" $(cat list) >subjects && + ! grep -v "^Subject: \[PATCH v4---\.\.\./\./\.\./--1/\.2// [0-3]/3\] " subjects +' + check_threading () { expect="$1" && shift && @@ -413,7 +440,7 @@ EOF test_expect_success 'no threading' ' git checkout side && - check_threading expect.no-threading master + check_threading expect.no-threading main ' cat >expect.thread <<EOF @@ -430,7 +457,7 @@ References: <0> EOF test_expect_success 'thread' ' - check_threading expect.thread --thread master + check_threading expect.thread --thread main ' cat >expect.in-reply-to <<EOF @@ -450,7 +477,7 @@ EOF test_expect_success 'thread in-reply-to' ' check_threading expect.in-reply-to --in-reply-to="<test.message>" \ - --thread master + --thread main ' cat >expect.cover-letter <<EOF @@ -471,7 +498,7 @@ References: <0> EOF test_expect_success 'thread cover-letter' ' - check_threading expect.cover-letter --cover-letter --thread master + check_threading expect.cover-letter --cover-letter --thread main ' cat >expect.cl-irt <<EOF @@ -498,12 +525,12 @@ EOF test_expect_success 'thread cover-letter in-reply-to' ' check_threading expect.cl-irt --cover-letter \ - --in-reply-to="<test.message>" --thread master + --in-reply-to="<test.message>" --thread main ' test_expect_success 'thread explicit shallow' ' check_threading expect.cl-irt --cover-letter \ - --in-reply-to="<test.message>" --thread=shallow master + --in-reply-to="<test.message>" --thread=shallow main ' cat >expect.deep <<EOF @@ -521,7 +548,7 @@ References: <0> EOF test_expect_success 'thread deep' ' - check_threading expect.deep --thread=deep master + check_threading expect.deep --thread=deep main ' cat >expect.deep-irt <<EOF @@ -544,7 +571,7 @@ EOF test_expect_success 'thread deep in-reply-to' ' check_threading expect.deep-irt --thread=deep \ - --in-reply-to="<test.message>" master + --in-reply-to="<test.message>" main ' cat >expect.deep-cl <<EOF @@ -568,7 +595,7 @@ References: <0> EOF test_expect_success 'thread deep cover-letter' ' - check_threading expect.deep-cl --cover-letter --thread=deep master + check_threading expect.deep-cl --cover-letter --thread=deep main ' cat >expect.deep-cl-irt <<EOF @@ -598,27 +625,27 @@ EOF test_expect_success 'thread deep cover-letter in-reply-to' ' check_threading expect.deep-cl-irt --cover-letter \ - --in-reply-to="<test.message>" --thread=deep master + --in-reply-to="<test.message>" --thread=deep main ' test_expect_success 'thread via config' ' test_config format.thread true && - check_threading expect.thread master + check_threading expect.thread main ' test_expect_success 'thread deep via config' ' test_config format.thread deep && - check_threading expect.deep master + check_threading expect.deep main ' test_expect_success 'thread config + override' ' test_config format.thread deep && - check_threading expect.thread --thread master + check_threading expect.thread --thread main ' test_expect_success 'thread config + --no-thread' ' test_config format.thread deep && - check_threading expect.no-threading --no-thread master + check_threading expect.no-threading --no-thread main ' test_expect_success 'excessive subject' ' @@ -631,7 +658,7 @@ test_expect_success 'excessive subject' ' after=$(git rev-parse --short $after) && git update-index file && git commit -m "This is an excessively long subject line for a message due to the habit some projects have of not having a short, one-line subject at the start of the commit message, but rather sticking a whole paragraph right at the start as the only thing in the commit message. It had better not become the filename for the patch." && - git format-patch -o patches/ master..side && + git format-patch -o patches/ main..side && ls patches/0004-This-is-an-excessively-long-subject-line-for-a-messa.patch ' @@ -885,21 +912,21 @@ echo "fatal: --check does not make sense" >expect.check test_expect_success 'options no longer allowed for format-patch' ' test_must_fail git format-patch --name-only 2>output && - test_i18ncmp expect.name-only output && + test_cmp expect.name-only output && test_must_fail git format-patch --name-status 2>output && - test_i18ncmp expect.name-status output && + test_cmp expect.name-status output && test_must_fail git format-patch --check 2>output && - test_i18ncmp expect.check output + test_cmp expect.check output ' test_expect_success 'format-patch --numstat should produce a patch' ' - git format-patch --numstat --stdout master..side >output && + git format-patch --numstat --stdout main..side >output && grep "^diff --git a/" output >diff && test_line_count = 5 diff ' test_expect_success 'format-patch -- <path>' ' - git format-patch master..side -- file 2>error && + git format-patch main..side -- file 2>error && ! grep "Use .--" error ' @@ -1673,9 +1700,9 @@ test_expect_success 'cover letter with invalid --cover-from-description and conf test_config branch.rebuild-1.description "config subject body" && - test_must_fail git format-patch --cover-letter --cover-from-description garbage master && + test_must_fail git format-patch --cover-letter --cover-from-description garbage main && test_config format.coverFromDescription garbage && - test_must_fail git format-patch --cover-letter master + test_must_fail git format-patch --cover-letter main ' test_expect_success 'cover letter with format.coverFromDescription = default' ' @@ -1684,7 +1711,7 @@ test_expect_success 'cover letter with format.coverFromDescription = default' ' body" && test_config format.coverFromDescription default && git checkout rebuild-1 && - git format-patch --stdout --cover-letter master >actual && + git format-patch --stdout --cover-letter main >actual && grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && grep "^config subject$" actual && @@ -1696,7 +1723,7 @@ test_expect_success 'cover letter with --cover-from-description default' ' body" && git checkout rebuild-1 && - git format-patch --stdout --cover-letter --cover-from-description default master >actual && + git format-patch --stdout --cover-letter --cover-from-description default main >actual && grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && grep "^config subject$" actual && @@ -1709,7 +1736,7 @@ test_expect_success 'cover letter with format.coverFromDescription = none' ' body" && test_config format.coverFromDescription none && git checkout rebuild-1 && - git format-patch --stdout --cover-letter master >actual && + git format-patch --stdout --cover-letter main >actual && grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && grep "^\*\*\* BLURB HERE \*\*\*$" actual && ! grep "^config subject$" actual && @@ -1721,7 +1748,7 @@ test_expect_success 'cover letter with --cover-from-description none' ' body" && git checkout rebuild-1 && - git format-patch --stdout --cover-letter --cover-from-description none master >actual && + git format-patch --stdout --cover-letter --cover-from-description none main >actual && grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && grep "^\*\*\* BLURB HERE \*\*\*$" actual && ! grep "^config subject$" actual && @@ -1734,7 +1761,7 @@ test_expect_success 'cover letter with format.coverFromDescription = message' ' body" && test_config format.coverFromDescription message && git checkout rebuild-1 && - git format-patch --stdout --cover-letter master >actual && + git format-patch --stdout --cover-letter main >actual && grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && grep "^config subject$" actual && @@ -1746,7 +1773,7 @@ test_expect_success 'cover letter with --cover-from-description message' ' body" && git checkout rebuild-1 && - git format-patch --stdout --cover-letter --cover-from-description message master >actual && + git format-patch --stdout --cover-letter --cover-from-description message main >actual && grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && grep "^config subject$" actual && @@ -1759,7 +1786,7 @@ test_expect_success 'cover letter with format.coverFromDescription = subject' ' body" && test_config format.coverFromDescription subject && git checkout rebuild-1 && - git format-patch --stdout --cover-letter master >actual && + git format-patch --stdout --cover-letter main >actual && grep "^Subject: \[PATCH 0/2\] config subject$" actual && ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && ! grep "^config subject$" actual && @@ -1771,7 +1798,7 @@ test_expect_success 'cover letter with --cover-from-description subject' ' body" && git checkout rebuild-1 && - git format-patch --stdout --cover-letter --cover-from-description subject master >actual && + git format-patch --stdout --cover-letter --cover-from-description subject main >actual && grep "^Subject: \[PATCH 0/2\] config subject$" actual && ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && ! grep "^config subject$" actual && @@ -1784,7 +1811,7 @@ test_expect_success 'cover letter with format.coverFromDescription = auto (short body" && test_config format.coverFromDescription auto && git checkout rebuild-1 && - git format-patch --stdout --cover-letter master >actual && + git format-patch --stdout --cover-letter main >actual && grep "^Subject: \[PATCH 0/2\] config subject$" actual && ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && ! grep "^config subject$" actual && @@ -1796,7 +1823,7 @@ test_expect_success 'cover letter with --cover-from-description auto (short subj body" && git checkout rebuild-1 && - git format-patch --stdout --cover-letter --cover-from-description auto master >actual && + git format-patch --stdout --cover-letter --cover-from-description auto main >actual && grep "^Subject: \[PATCH 0/2\] config subject$" actual && ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && ! grep "^config subject$" actual && @@ -1809,7 +1836,7 @@ test_expect_success 'cover letter with format.coverFromDescription = auto (long body" && test_config format.coverFromDescription auto && git checkout rebuild-1 && - git format-patch --stdout --cover-letter master >actual && + git format-patch --stdout --cover-letter main >actual && grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && grep "^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$" actual && @@ -1821,7 +1848,7 @@ test_expect_success 'cover letter with --cover-from-description auto (long subje body" && git checkout rebuild-1 && - git format-patch --stdout --cover-letter --cover-from-description auto master >actual && + git format-patch --stdout --cover-letter --cover-from-description auto main >actual && grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && grep "^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$" actual && @@ -1834,7 +1861,7 @@ test_expect_success 'cover letter with command-line --cover-from-description ove body" && test_config format.coverFromDescription none && git checkout rebuild-1 && - git format-patch --stdout --cover-letter --cover-from-description subject master >actual && + git format-patch --stdout --cover-letter --cover-from-description subject main >actual && grep "^Subject: \[PATCH 0/2\] config subject$" actual && ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && ! grep "^config subject$" actual && @@ -1844,7 +1871,7 @@ body" && test_expect_success 'cover letter using branch description (1)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && - git format-patch --stdout --cover-letter master >actual && + git format-patch --stdout --cover-letter main >actual && grep hello actual ' @@ -1858,14 +1885,14 @@ test_expect_success 'cover letter using branch description (2)' ' test_expect_success 'cover letter using branch description (3)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && - git format-patch --stdout --cover-letter ^master rebuild-1 >actual && + git format-patch --stdout --cover-letter ^main rebuild-1 >actual && grep hello actual ' test_expect_success 'cover letter using branch description (4)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && - git format-patch --stdout --cover-letter master.. >actual && + git format-patch --stdout --cover-letter main.. >actual && grep hello actual ' @@ -1932,8 +1959,8 @@ test_expect_success 'From line has expected format' ' test_expect_success 'format-patch -o with no leading directories' ' rm -fr patches && - git format-patch -o patches master..side && - count=$(git rev-list --count master..side) && + git format-patch -o patches main..side && + count=$(git rev-list --count main..side) && ls patches >list && test_line_count = $count list ' @@ -1941,16 +1968,16 @@ test_expect_success 'format-patch -o with no leading directories' ' test_expect_success 'format-patch -o with leading existing directories' ' rm -rf existing-dir && mkdir existing-dir && - git format-patch -o existing-dir/patches master..side && - count=$(git rev-list --count master..side) && + git format-patch -o existing-dir/patches main..side && + count=$(git rev-list --count main..side) && ls existing-dir/patches >list && test_line_count = $count list ' test_expect_success 'format-patch -o with leading non-existing directories' ' rm -rf non-existing-dir && - git format-patch -o non-existing-dir/patches master..side && - count=$(git rev-list --count master..side) && + git format-patch -o non-existing-dir/patches main..side && + count=$(git rev-list --count main..side) && test_path_is_dir non-existing-dir && ls non-existing-dir/patches >list && test_line_count = $count list @@ -1959,8 +1986,8 @@ test_expect_success 'format-patch -o with leading non-existing directories' ' test_expect_success 'format-patch format.outputDirectory option' ' test_config format.outputDirectory patches && rm -fr patches && - git format-patch master..side && - count=$(git rev-list --count master..side) && + git format-patch main..side && + count=$(git rev-list --count main..side) && ls patches >list && test_line_count = $count list ' @@ -1968,7 +1995,7 @@ test_expect_success 'format-patch format.outputDirectory option' ' test_expect_success 'format-patch -o overrides format.outputDirectory' ' test_config format.outputDirectory patches && rm -fr patches patchset && - git format-patch master..side -o patchset && + git format-patch main..side -o patchset && test_path_is_missing patches && test_path_is_dir patchset ' @@ -2065,14 +2092,14 @@ test_expect_success 'format-patch --base errors out when base commit is not ance # ------------W # # If "format-patch Z..X" is given, P and Z can not be specified as the base commit - git checkout -b topic1 master && + git checkout -b topic1 main && git rev-parse HEAD >commit-id-base && test_commit P && git rev-parse HEAD >commit-id-P && test_commit Z && git rev-parse HEAD >commit-id-Z && test_commit Y && - git checkout -b topic2 master && + git checkout -b topic2 main && test_commit W && git merge topic1 && test_commit X && @@ -2085,7 +2112,7 @@ test_expect_success 'format-patch --base errors out when base commit is not ance ' test_expect_success 'format-patch --base=auto' ' - git checkout -b upstream master && + git checkout -b upstream main && git checkout -b local upstream && git branch --set-upstream-to=upstream && test_commit N1 && @@ -2106,11 +2133,11 @@ test_expect_success 'format-patch errors out when history involves criss-cross' # \ / \ # C---M2---E # - git checkout master && + git checkout main && test_commit A && - git checkout -b xb master && + git checkout -b xb main && test_commit B && - git checkout -b xc master && + git checkout -b xc main && test_commit C && git checkout -b xbc xb -- && git merge xc && @@ -2230,7 +2257,7 @@ test_expect_success 'format-patch --pretty=mboxrd' ' ' test_expect_success 'interdiff: setup' ' - git checkout -b boop master && + git checkout -b boop main && test_commit fnorp blorp && test_commit fleep blorp ' @@ -2252,6 +2279,16 @@ test_expect_success 'interdiff: reroll-count' ' test_i18ngrep "^Interdiff ..* v1:$" v2-0000-cover-letter.patch ' +test_expect_success 'interdiff: reroll-count with a non-integer' ' + git format-patch --cover-letter --interdiff=boop~2 -v2.2 -1 boop && + test_i18ngrep "^Interdiff:$" v2.2-0000-cover-letter.patch +' + +test_expect_success 'interdiff: reroll-count with a integer' ' + git format-patch --cover-letter --interdiff=boop~2 -v2 -1 boop && + test_i18ngrep "^Interdiff ..* v1:$" v2-0000-cover-letter.patch +' + test_expect_success 'interdiff: solo-patch' ' cat >expect <<-\EOF && +fleep diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index 8c574221b2..2c13b62d3c 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -7,7 +7,7 @@ test_description='Test special whitespace in diff engine. ' . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh +. "$TEST_DIRECTORY"/lib-diff.sh test_expect_success "Ray Lehtiniemi's example" ' cat <<-\EOF >x && diff --git a/t/t4016-diff-quote.sh b/t/t4016-diff-quote.sh index 9c48e5c2c9..876271d682 100755 --- a/t/t4016-diff-quote.sh +++ b/t/t4016-diff-quote.sh @@ -82,7 +82,7 @@ test_expect_success 'git diff --stat -M HEAD' ' 7 files changed, 0 insertions(+), 0 deletions(-) EOF git diff --stat -M HEAD >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_done diff --git a/t/t4017-diff-retval.sh b/t/t4017-diff-retval.sh index 95a7ca7070..ed461f481e 100755 --- a/t/t4017-diff-retval.sh +++ b/t/t4017-diff-retval.sh @@ -2,6 +2,9 @@ test_description='Return value of diffs' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -111,7 +114,7 @@ test_expect_success 'check detects leftover conflict markers' ' git checkout HEAD^ && echo binary >>b && git commit -m "side" b && - test_must_fail git merge master && + test_must_fail git merge main && git add b && test_expect_code 2 git --no-pager diff --cached --check >test.out && test 3 = $(grep "conflict marker" test.out | wc -l) && diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 9675bc17db..740696c8f7 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -25,33 +25,26 @@ test_expect_success 'setup' ' echo B >B.java ' +test_expect_success 'setup: test-tool userdiff' ' + # Make sure additions to builtin_drivers are sorted + test_when_finished "rm builtin-drivers.sorted" && + test-tool userdiff list-builtin-drivers >builtin-drivers && + test_file_not_empty builtin-drivers && + sort <builtin-drivers >builtin-drivers.sorted && + test_cmp builtin-drivers.sorted builtin-drivers && + + # Ditto, but "custom" requires the .git directory and config + # to be setup and read. + test_when_finished "rm custom-drivers.sorted" && + test-tool userdiff list-custom-drivers >custom-drivers && + test_file_not_empty custom-drivers && + sort <custom-drivers >custom-drivers.sorted && + test_cmp custom-drivers.sorted custom-drivers +' + diffpatterns=" - ada - bash - bibtex - cpp - csharp - css - dts - elixir - fortran - fountain - golang - html - java - markdown - matlab - objc - pascal - perl - php - python - ruby - rust - tex - custom1 - custom2 - custom3 + $(cat builtin-drivers) + $(cat custom-drivers) " for p in $diffpatterns @@ -101,13 +94,7 @@ test_expect_success 'setup hunk header tests' ' # check each individual file for i in $(git ls-files) do - if grep broken "$i" >/dev/null 2>&1 - then - result=failure - else - result=success - fi - test_expect_$result "hunk header: $i" " + test_expect_success "hunk header: $i" " git diff -U1 $i >actual && grep '@@ .* @@.*RIGHT' actual " diff --git a/t/t4018/README b/t/t4018/README index 283e01cca1..2d25b2b4fc 100644 --- a/t/t4018/README +++ b/t/t4018/README @@ -7,9 +7,6 @@ at least two lines from the line that must appear in the hunk header. The text that must appear in the hunk header must contain the word "right", but in all upper-case, like in the title above. -To mark a test case that highlights a malfunction, insert the word -BROKEN in all lower-case somewhere in the file. - This text is a bit twisted and out of order, but it is itself a test case for the default hunk header pattern. Know what you are doing if you change it. diff --git a/t/t4018/scheme-class b/t/t4018/scheme-class new file mode 100644 index 0000000000..e5e07b43fb --- /dev/null +++ b/t/t4018/scheme-class @@ -0,0 +1,7 @@ +(define book-class% + (class* () object% RIGHT + (field (pages 5)) + (field (ChangeMe 5)) + (define/public (letters) + (* pages 500)) + (super-new))) diff --git a/t/t4018/scheme-def b/t/t4018/scheme-def new file mode 100644 index 0000000000..1e2673da96 --- /dev/null +++ b/t/t4018/scheme-def @@ -0,0 +1,4 @@ +(def (some-func x y z) RIGHT + (let ((a x) + (b y)) + (ChangeMe a b))) diff --git a/t/t4018/scheme-def-variant b/t/t4018/scheme-def-variant new file mode 100644 index 0000000000..d857a61d64 --- /dev/null +++ b/t/t4018/scheme-def-variant @@ -0,0 +1,4 @@ +(defmethod {print point} RIGHT + (lambda (self) + (with ((point x y) self) + (printf "{ChangeMe x:~a y:~a}~n" x y)))) diff --git a/t/t4018/scheme-define-slash-public b/t/t4018/scheme-define-slash-public new file mode 100644 index 0000000000..39a93a1600 --- /dev/null +++ b/t/t4018/scheme-define-slash-public @@ -0,0 +1,7 @@ +(define bar-class% + (class object% + (field (info 5)) + (define/public (foo) RIGHT + (+ info 42) + (* info ChangeMe)) + (super-new))) diff --git a/t/t4018/scheme-define-syntax b/t/t4018/scheme-define-syntax new file mode 100644 index 0000000000..7d5e99e0fc --- /dev/null +++ b/t/t4018/scheme-define-syntax @@ -0,0 +1,8 @@ +(define-syntax define-test-suite RIGHT + (syntax-rules () + ((_ suite-name (name test) ChangeMe ...) + (define suite-name + (let ((tests + `((name . ,test) ...))) + (lambda () + (run-suite 'suite-name tests))))))) diff --git a/t/t4018/scheme-define-variant b/t/t4018/scheme-define-variant new file mode 100644 index 0000000000..911708854d --- /dev/null +++ b/t/t4018/scheme-define-variant @@ -0,0 +1,4 @@ +(define* (some-func x y z) RIGHT + (let ((a x) + (b y)) + (ChangeMe a b))) diff --git a/t/t4018/scheme-library b/t/t4018/scheme-library new file mode 100644 index 0000000000..82ea3df510 --- /dev/null +++ b/t/t4018/scheme-library @@ -0,0 +1,11 @@ +(library (my-helpers id-stuff) RIGHT + (export find-dup) + (import (ChangeMe)) + (define (find-dup l) + (and (pair? l) + (let loop ((rest (cdr l))) + (cond + [(null? rest) (find-dup (cdr l))] + [(bound-identifier=? (car l) (car rest)) + (car rest)] + [else (loop (cdr rest))]))))) diff --git a/t/t4018/scheme-local-define b/t/t4018/scheme-local-define new file mode 100644 index 0000000000..bc6d8aebbe --- /dev/null +++ b/t/t4018/scheme-local-define @@ -0,0 +1,4 @@ +(define (higher-order) + (define local-function RIGHT + (lambda (x) + (car "this is" "ChangeMe")))) diff --git a/t/t4018/scheme-module b/t/t4018/scheme-module new file mode 100644 index 0000000000..edfae0ebf7 --- /dev/null +++ b/t/t4018/scheme-module @@ -0,0 +1,6 @@ +(module A RIGHT + (export with-display-exception) + (extern (display-exception display-exception ChangeMe)) + (def (with-display-exception thunk) + (with-catch (lambda (e) (display-exception e (current-error-port)) e) + thunk))) diff --git a/t/t4018/scheme-top-level-define b/t/t4018/scheme-top-level-define new file mode 100644 index 0000000000..624743c22b --- /dev/null +++ b/t/t4018/scheme-top-level-define @@ -0,0 +1,4 @@ +(define (some-func x y z) RIGHT + (let ((a x) + (b y)) + (ChangeMe a b))) diff --git a/t/t4018/scheme-user-defined-define b/t/t4018/scheme-user-defined-define new file mode 100644 index 0000000000..35fe7cc9bf --- /dev/null +++ b/t/t4018/scheme-user-defined-define @@ -0,0 +1,6 @@ +(define-test-suite record\ case-tests RIGHT + (record-case-1 (lambda (fail) + (let ((a (make-foo 1 2))) + (record-case a + ((bar x) (ChangeMe)) + ((foo a b) (+ a b))))))) diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh index d7145ccca4..94ef77e1df 100755 --- a/t/t4027-diff-submodule.sh +++ b/t/t4027-diff-submodule.sh @@ -3,7 +3,7 @@ test_description='difference in submodules' . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh +. "$TEST_DIRECTORY"/lib-diff.sh test_expect_success setup ' test_tick && @@ -93,6 +93,14 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked)' ' ) && git diff HEAD >actual && sed -e "1,/^@@/d" actual >actual.body && + expect_from_to >expect.body $subtip $subprev && + test_cmp expect.body actual.body +' + +test_expect_success 'git diff HEAD with dirty submodule (untracked) (none ignored)' ' + test_config diff.ignoreSubmodules none && + git diff HEAD >actual && + sed -e "1,/^@@/d" actual >actual.body && expect_from_to >expect.body $subtip $subprev-dirty && test_cmp expect.body actual.body ' @@ -168,13 +176,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)' git clean -qfdx && >cruft ) && - git diff HEAD >actual && + git diff --ignore-submodules=none HEAD >actual && sed -e "1,/^@@/d" actual >actual.body && expect_from_to >expect.body $subprev $subprev-dirty && test_cmp expect.body actual.body && git diff --ignore-submodules=all HEAD >actual2 && test_must_be_empty actual2 && - git diff --ignore-submodules=untracked HEAD >actual3 && + git diff HEAD >actual3 && test_must_be_empty actual3 && git diff --ignore-submodules=dirty HEAD >actual4 && test_must_be_empty actual4 diff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh index 4cb9f0e523..c906320b60 100755 --- a/t/t4030-diff-textconv.sh +++ b/t/t4030-diff-textconv.sh @@ -139,7 +139,7 @@ EOF test_expect_success 'diffstat does not run textconv' ' echo file diff=fail >.gitattributes && git diff --stat HEAD^ HEAD >actual && - test_i18ncmp expect.stat actual && + test_cmp expect.stat actual && head -n1 <expect.stat >expect.line1 && head -n1 <actual >actual.line1 && diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh index 0c8fb39ced..561c582d16 100755 --- a/t/t4034-diff-words.sh +++ b/t/t4034-diff-words.sh @@ -3,7 +3,7 @@ test_description='word diff colors' . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh +. "$TEST_DIRECTORY"/lib-diff.sh cat >pre.simple <<-\EOF h(4) @@ -184,6 +184,11 @@ test_expect_success 'word diff with a regular expression' ' word_diff --color-words="[a-z]+" ' +test_expect_success 'word diff with zero length matches' ' + cp expect.letter-runs-are-words expect && + word_diff --color-words="[a-z${LF}]*" +' + test_expect_success 'set up a diff driver' ' git config diff.testdriver.wordRegex "[^[:space:]]" && cat <<-\EOF >.gitattributes @@ -325,6 +330,7 @@ test_language_driver perl test_language_driver php test_language_driver python test_language_driver ruby +test_language_driver scheme test_language_driver tex test_expect_success 'word-diff with diff.sbe' ' diff --git a/t/t4034/scheme/expect b/t/t4034/scheme/expect new file mode 100644 index 0000000000..496cd5de8c --- /dev/null +++ b/t/t4034/scheme/expect @@ -0,0 +1,11 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index 74b6605..63b6ac4 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,6 +1,6 @@<RESET> +(define (<RED>myfunc a b<RESET><GREEN>my-func first second<RESET>) + ; This is a <RED>really<RESET><GREEN>(moderately)<RESET> cool function. + (<RED>this\place<RESET><GREEN>that\place<RESET> (+ 3 4)) + (define <RED>some-text<RESET><GREEN>|a greeting|<RESET> "hello") + (let ((c (<RED>+ a b<RESET><GREEN>add1 first<RESET>))) + (format "one more than the total is %d" (<RED>add1<RESET><GREEN>+<RESET> c <GREEN>second<RESET>)))) diff --git a/t/t4034/scheme/post b/t/t4034/scheme/post new file mode 100644 index 0000000000..63b6ac4f87 --- /dev/null +++ b/t/t4034/scheme/post @@ -0,0 +1,6 @@ +(define (my-func first second) + ; This is a (moderately) cool function. + (that\place (+ 3 4)) + (define |a greeting| "hello") + (let ((c (add1 first))) + (format "one more than the total is %d" (+ c second)))) diff --git a/t/t4034/scheme/pre b/t/t4034/scheme/pre new file mode 100644 index 0000000000..74b6605357 --- /dev/null +++ b/t/t4034/scheme/pre @@ -0,0 +1,6 @@ +(define (myfunc a b) + ; This is a really cool function. + (this\place (+ 3 4)) + (define some-text "hello") + (let ((c (+ a b))) + (format "one more than the total is %d" (add1 c)))) diff --git a/t/t4038-diff-combined.sh b/t/t4038-diff-combined.sh index 94680836ce..aeac203c42 100755 --- a/t/t4038-diff-combined.sh +++ b/t/t4038-diff-combined.sh @@ -2,8 +2,11 @@ test_description='combined diff' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh +. "$TEST_DIRECTORY"/lib-diff.sh setup_helper () { one=$1 branch=$2 side=$3 && @@ -115,7 +118,7 @@ test_expect_success 'check --cc --raw with forty trees' ' ' test_expect_success 'setup combined ignore spaces' ' - git checkout master && + git checkout main && >test && git add test && git commit -m initial && @@ -143,7 +146,7 @@ test_expect_success 'setup combined ignore spaces' ' EOF git commit -m "test other space changes" -a && - test_must_fail git merge master && + test_must_fail git merge main && tr -d Q <<-\EOF >test && eol spaces Q space change @@ -404,7 +407,7 @@ test_expect_success 'combine diff missing delete bug' ' test_expect_success 'combine diff gets tree sorting right' ' # create a directory and a file that sort differently in trees # versus byte-wise (implied "/" sorts after ".") - git checkout -f master && + git checkout -f main && mkdir foo && echo base >foo/one && echo base >foo/two && @@ -414,9 +417,9 @@ test_expect_success 'combine diff gets tree sorting right' ' # one side modifies a file in the directory, along with the root # file... - echo master >foo/one && - echo master >foo.ext && - git commit -a -m master && + echo main >foo/one && + echo main >foo.ext && + git commit -a -m main && # the other side modifies the other file in the directory git checkout -b other HEAD^ && @@ -426,7 +429,7 @@ test_expect_success 'combine diff gets tree sorting right' ' # And now we merge. The files in the subdirectory will resolve cleanly, # meaning that a combined diff will not find them interesting. But it # will find the tree itself interesting, because it had to be merged. - git checkout master && + git checkout main && git merge other && printf "MM\tfoo\n" >expect && diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh index f852136585..0c1502d4b0 100755 --- a/t/t4041-diff-submodule-option.sh +++ b/t/t4041-diff-submodule-option.sh @@ -9,6 +9,9 @@ test_description='Support for verbose submodule differences in git diff This test tries to verify the sanity of the --submodule option of git diff. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # Tested non-UTF-8 encoding @@ -262,7 +265,7 @@ test_expect_success 'submodule is up to date' ' test_expect_success 'submodule contains untracked content' ' echo new > sm1/new-file && - git diff-index -p --submodule=log HEAD >actual && + git diff-index -p --ignore-submodules=none --submodule=log HEAD >actual && cat >expected <<-EOF && Submodule sm1 contains untracked content EOF @@ -270,7 +273,7 @@ test_expect_success 'submodule contains untracked content' ' ' test_expect_success 'submodule contains untracked content (untracked ignored)' ' - git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && + git diff-index -p --submodule=log HEAD >actual && test_must_be_empty actual ' @@ -286,7 +289,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' ' test_expect_success 'submodule contains untracked and modified content' ' echo new > sm1/foo6 && - git diff-index -p --submodule=log HEAD >actual && + git diff-index -p --ignore-submodules=none --submodule=log HEAD >actual && cat >expected <<-EOF && Submodule sm1 contains untracked content Submodule sm1 contains modified content @@ -296,7 +299,7 @@ test_expect_success 'submodule contains untracked and modified content' ' test_expect_success 'submodule contains untracked and modified content (untracked ignored)' ' echo new > sm1/foo6 && - git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && + git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && Submodule sm1 contains modified content EOF @@ -337,7 +340,7 @@ test_expect_success 'submodule is modified' ' test_expect_success 'modified submodule contains untracked content' ' echo new > sm1/new-file && - git diff-index -p --submodule=log HEAD >actual && + git diff-index -p --ignore-submodules=none --submodule=log HEAD >actual && cat >expected <<-EOF && Submodule sm1 contains untracked content Submodule sm1 $head6..$head8: @@ -347,7 +350,7 @@ test_expect_success 'modified submodule contains untracked content' ' ' test_expect_success 'modified submodule contains untracked content (untracked ignored)' ' - git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && + git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && Submodule sm1 $head6..$head8: > change @@ -371,7 +374,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored) test_expect_success 'modified submodule contains untracked and modified content' ' echo modification >> sm1/foo6 && - git diff-index -p --submodule=log HEAD >actual && + git diff-index -p --ignore-submodules=none --submodule=log HEAD >actual && cat >expected <<-EOF && Submodule sm1 contains untracked content Submodule sm1 contains modified content @@ -383,7 +386,7 @@ test_expect_success 'modified submodule contains untracked and modified content' test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' ' echo modification >> sm1/foo6 && - git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && + git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && Submodule sm1 contains modified content Submodule sm1 $head6..$head8: @@ -538,7 +541,7 @@ test_expect_success 'diff --submodule with objects referenced by alternates' ' (cd super && (cd sub && git fetch && - git checkout origin/master + git checkout origin/main ) && git diff --submodule > ../actual ) && diff --git a/t/t4045-diff-relative.sh b/t/t4045-diff-relative.sh index 7be1de736d..61ba5f707f 100755 --- a/t/t4045-diff-relative.sh +++ b/t/t4045-diff-relative.sh @@ -61,7 +61,7 @@ check_stat () { EOF test_expect_success "--stat $*" " git -C '$dir' diff --stat $* HEAD^ >actual && - test_i18ncmp expected actual + test_cmp expected actual " } diff --git a/t/t4048-diff-combined-binary.sh b/t/t4048-diff-combined-binary.sh index 7f9ad9fa3d..0260cf64f5 100755 --- a/t/t4048-diff-combined-binary.sh +++ b/t/t4048-diff-combined-binary.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='combined and merge diff handle binary files and textconv' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup binary merge conflict' ' @@ -14,7 +17,7 @@ test_expect_success 'setup binary merge conflict' ' echo threeQ3 | q_to_nul >binary && git commit -a -m three && three=$(git rev-parse --short HEAD:binary) && - test_must_fail git merge master && + test_must_fail git merge main && echo resolvedQhooray | q_to_nul >binary && git commit -a -m resolved && res=$(git rev-parse --short HEAD:binary) @@ -62,14 +65,14 @@ test_expect_success 'diff --cc indicates binary-ness' ' ' test_expect_success 'setup non-binary with binary attribute' ' - git checkout master && + git checkout main && test_commit one text && test_commit two text && two=$(git rev-parse --short HEAD:text) && git checkout -b branch-text HEAD^ && test_commit three text && three=$(git rev-parse --short HEAD:text) && - test_must_fail git merge master && + test_must_fail git merge main && test_commit resolved text && res=$(git rev-parse --short HEAD:text) && echo text -diff >.gitattributes @@ -206,11 +209,11 @@ index $three,$two..0000000 +THREE ++======= + TWO -++>>>>>>> MASTER +++>>>>>>> MAIN EOF test_expect_success 'diff --cc respects textconv on worktree file' ' git reset --hard HEAD^ && - test_must_fail git merge master && + test_must_fail git merge main && git diff >actual && test_cmp expect actual ' diff --git a/t/t4049-diff-stat-count.sh b/t/t4049-diff-stat-count.sh index a34121740a..53061b104e 100755 --- a/t/t4049-diff-stat-count.sh +++ b/t/t4049-diff-stat-count.sh @@ -25,7 +25,7 @@ test_expect_success 'mode-only change show as a 0-line change' ' 4 files changed, 2 insertions(+) EOF git diff --stat --stat-count=2 HEAD >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'binary changes do not count in lines' ' @@ -40,7 +40,7 @@ test_expect_success 'binary changes do not count in lines' ' 3 files changed, 2 insertions(+) EOF git diff --stat --stat-count=2 >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'exclude unmerged entries from total file count' ' @@ -62,7 +62,7 @@ test_expect_success 'exclude unmerged entries from total file count' ' 3 files changed, 3 insertions(+) EOF git diff --stat --stat-count=2 >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_done diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh index 28c053849a..9eba436211 100755 --- a/t/t4052-stat-output.sh +++ b/t/t4052-stat-output.sh @@ -5,6 +5,9 @@ test_description='test --stat output of various commands' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-terminal.sh @@ -353,7 +356,7 @@ cat >expect <<'EOF' EOF test_expect_success 'merge --stat respects COLUMNS (big change)' ' git checkout -b branch HEAD^^ && - COLUMNS=100 git merge --stat --no-ff master^ >output && + COLUMNS=100 git merge --stat --no-ff main^ >output && grep " | " output >actual && test_cmp expect actual ' @@ -362,7 +365,7 @@ cat >expect <<'EOF' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++ EOF test_expect_success 'merge --stat respects COLUMNS (long filename)' ' - COLUMNS=100 git merge --stat --no-ff master >output && + COLUMNS=100 git merge --stat --no-ff main >output && grep " | " output >actual && test_cmp expect actual ' diff --git a/t/t4053-diff-no-index.sh b/t/t4053-diff-no-index.sh index 0168946b63..3feadf0e35 100755 --- a/t/t4053-diff-no-index.sh +++ b/t/t4053-diff-no-index.sh @@ -16,6 +16,11 @@ test_expect_success 'setup' ' echo 1 >non/git/b ' +test_expect_success 'git diff --no-index --exit-code' ' + git diff --no-index --exit-code a/1 non/git/a && + test_expect_code 1 git diff --no-index --exit-code a/1 a/2 +' + test_expect_success 'git diff --no-index directories' ' test_expect_code 1 git diff --no-index a b >cnt && test_line_count = 14 cnt @@ -144,4 +149,59 @@ test_expect_success 'diff --no-index allows external diff' ' test_cmp expect actual ' +test_expect_success 'diff --no-index normalizes mode: no changes' ' + echo foo >x && + cp x y && + git diff --no-index x y >out && + test_must_be_empty out +' + +test_expect_success POSIXPERM 'diff --no-index normalizes mode: chmod +x' ' + chmod +x y && + cat >expected <<-\EOF && + diff --git a/x b/y + old mode 100644 + new mode 100755 + EOF + test_expect_code 1 git diff --no-index x y >actual && + test_cmp expected actual +' + +test_expect_success POSIXPERM 'diff --no-index normalizes: mode not like git mode' ' + chmod 666 x && + chmod 777 y && + cat >expected <<-\EOF && + diff --git a/x b/y + old mode 100644 + new mode 100755 + EOF + test_expect_code 1 git diff --no-index x y >actual && + test_cmp expected actual +' + +test_expect_success POSIXPERM,SYMLINKS 'diff --no-index normalizes: mode not like git mode (symlink)' ' + ln -s y z && + X_OID=$(git hash-object --stdin <x) && + Z_OID=$(printf y | git hash-object --stdin) && + cat >expected <<-EOF && + diff --git a/x b/x + deleted file mode 100644 + index $X_OID..$ZERO_OID + --- a/x + +++ /dev/null + @@ -1 +0,0 @@ + -foo + diff --git a/z b/z + new file mode 120000 + index $ZERO_OID..$Z_OID + --- /dev/null + +++ b/z + @@ -0,0 +1 @@ + +y + \ No newline at end of file + EOF + test_expect_code 1 git -c core.abbrev=no diff --no-index x z >actual && + test_cmp expected actual +' + test_done diff --git a/t/t4056-diff-order.sh b/t/t4056-diff-order.sh index 43dd474a12..aec1d9d1b4 100755 --- a/t/t4056-diff-order.sh +++ b/t/t4056-diff-order.sh @@ -1,6 +1,9 @@ #!/bin/sh -test_description='diff order' +test_description='diff order & rotate' + +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh @@ -106,7 +109,7 @@ done test_expect_success 'setup for testing combine-diff order' ' git checkout -b tmp HEAD~ && create_files 3 && - git checkout master && + git checkout main && git merge --no-commit -s ours tmp && create_files 5 ' @@ -124,4 +127,74 @@ do ' done +### rotate and skip + +test_expect_success 'rotate and skip setup' ' + >sample1.t && + >sample2.t && + >sample3.t && + >sample4.t && + git add sample[1234].t && + git commit -m "added" sample[1234].t && + echo modified >>sample1.t && + echo modified >>sample2.t && + echo modified >>sample4.t && + git commit -m "updated" sample[1234].t +' + +test_expect_success 'diff --rotate-to' ' + git diff --rotate-to=sample2.t --name-only HEAD^ >actual && + test_write_lines sample2.t sample4.t sample1.t >expect && + test_cmp expect actual +' + +test_expect_success 'diff --skip-to' ' + git diff --skip-to=sample2.t --name-only HEAD^ >actual && + test_write_lines sample2.t sample4.t >expect && + test_cmp expect actual +' + +test_expect_success 'diff --rotate/skip-to error condition' ' + test_must_fail git diff --rotate-to=sample3.t HEAD^ && + test_must_fail git diff --skip-to=sample3.t HEAD^ +' + +test_expect_success 'log --rotate-to' ' + git log --rotate-to=sample3.t --raw HEAD~2.. >raw && + # just distill the commit header and paths + sed -n -e "s/^commit.*/commit/p" \ + -e "/^:/s/^.* //p" raw >actual && + + cat >expect <<-\EOF && + commit + sample4.t + sample1.t + sample2.t + commit + sample3.t + sample4.t + sample1.t + sample2.t + EOF + + test_cmp expect actual +' + +test_expect_success 'log --skip-to' ' + git log --skip-to=sample3.t --raw HEAD~2.. >raw && + # just distill the commit header and paths + sed -n -e "s/^commit.*/commit/p" \ + -e "/^:/s/^.* //p" raw >actual && + + cat >expect <<-\EOF && + commit + sample4.t + commit + sample3.t + sample4.t + EOF + + test_cmp expect actual +' + test_done diff --git a/t/t4057-diff-combined-paths.sh b/t/t4057-diff-combined-paths.sh index 0b78573733..7e5b74f72e 100755 --- a/t/t4057-diff-combined-paths.sh +++ b/t/t4057-diff-combined-paths.sh @@ -2,6 +2,9 @@ test_description='combined diff show only paths that are different to all parents' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # verify that diffc.expect matches output of @@ -24,9 +27,9 @@ test_expect_success 'trivial merge - combine-diff empty' ' echo $i/2 >>$i.txt done && git commit -a -m "side 2-9" && - git checkout master && + git checkout main && echo 1/2 >1.txt && - git commit -a -m "master 1" && + git commit -a -m "main 1" && git merge side && >diffc.expect && diffc_verify @@ -41,19 +44,19 @@ test_expect_success 'only one truly conflicting path' ' done && echo "4side" >>4.txt && git commit -a -m "side 2-9 +4" && - git checkout master && + git checkout main && for i in $(test_seq 1 9) do echo $i/3 >>$i.txt done && - echo "4master" >>4.txt && - git commit -a -m "master 1-9 +4" && + echo "4main" >>4.txt && + git commit -a -m "main 1-9 +4" && test_must_fail git merge side && cat <<-\EOF >4.txt && 4 4/2 4/3 - 4master + 4main 4side EOF git add 4.txt && @@ -69,12 +72,12 @@ test_expect_success 'merge introduces new file' ' echo $i/4 >>$i.txt done && git commit -a -m "side 5-9" && - git checkout master && + git checkout main && for i in $(test_seq 1 3) do echo $i/4 >>$i.txt done && - git commit -a -m "master 1-3 +4hello" && + git commit -a -m "main 1-3 +4hello" && git merge side && echo "Hello World" >4hello.txt && git add 4hello.txt && @@ -90,12 +93,12 @@ test_expect_success 'merge removed a file' ' echo $i/5 >>$i.txt done && git commit -a -m "side 5-9" && - git checkout master && + git checkout main && for i in $(test_seq 1 3) do echo $i/4 >>$i.txt done && - git commit -a -m "master 1-3" && + git commit -a -m "main 1-3" && git merge side && git rm 4.txt && git commit --amend && diff --git a/t/t4058-diff-duplicates.sh b/t/t4058-diff-duplicates.sh index c24ee175ef..54614b814d 100755 --- a/t/t4058-diff-duplicates.sh +++ b/t/t4058-diff-duplicates.sh @@ -1,5 +1,14 @@ #!/bin/sh +# NOTICE: +# This testsuite does a number of diffs and checks that the output match. +# However, it is a "garbage in, garbage out" situation; the trees have +# duplicate entries for individual paths, and it results in diffs that do +# not make much sense. As such, it is not clear that the diffs are +# "correct". The primary purpose of these tests was to verify that +# diff-tree does not segfault, but there is perhaps some value in ensuring +# that the diff output isn't wildly unreasonable. + test_description='test tree diff when trees have duplicate entries' . ./test-lib.sh @@ -57,7 +66,16 @@ test_expect_success 'create trees with duplicate entries' ' git tag two $outer_two ' -test_expect_success 'diff-tree between trees' ' +test_expect_success 'create tree without duplicate entries' ' + blob_one=$(echo one | git hash-object -w --stdin) && + outer_three=$(make_tree \ + 100644 renamed $blob_one + ) && + git tag three $outer_three +' + +test_expect_success 'diff-tree between duplicate trees' ' + # See NOTICE at top of file { printf ":000000 100644 $ZERO_OID $blob_two A\touter/inner\n" && printf ":000000 100644 $ZERO_OID $blob_two A\touter/inner\n" && @@ -71,9 +89,101 @@ test_expect_success 'diff-tree between trees' ' ' test_expect_success 'diff-tree with renames' ' - # same expectation as above, since we disable rename detection + # See NOTICE at top of file. git diff-tree -M -r --no-abbrev one two >actual && + test_must_be_empty actual +' + +test_expect_success 'diff-tree FROM duplicate tree' ' + # See NOTICE at top of file. + { + printf ":100644 000000 $blob_one $ZERO_OID D\touter/inner\n" && + printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" && + printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" && + printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" && + printf ":000000 100644 $ZERO_OID $blob_one A\trenamed\n" + } >expect && + git diff-tree -r --no-abbrev one three >actual && test_cmp expect actual ' +test_expect_success 'diff-tree FROM duplicate tree, with renames' ' + # See NOTICE at top of file. + { + printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" && + printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" && + printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" && + printf ":100644 100644 $blob_one $blob_one R100\touter/inner\trenamed\n" + } >expect && + git diff-tree -M -r --no-abbrev one three >actual && + test_cmp expect actual +' + +test_expect_success 'create a few commits' ' + git commit-tree -m "Duplicate Entries" two^{tree} >commit_id && + git branch base $(cat commit_id) && + + git commit-tree -p $(cat commit_id) -m "Just one" three^{tree} >up && + git branch update $(cat up) && + + git commit-tree -p $(cat up) -m "Back to weird" two^{tree} >final && + git branch final $(cat final) && + + rm commit_id up final +' + +test_expect_failure 'git read-tree does not segfault' ' + test_when_finished rm .git/index.lock && + test_might_fail git read-tree --reset base +' + +test_expect_failure 'reset --hard does not segfault' ' + test_when_finished rm .git/index.lock && + git checkout base && + test_might_fail git reset --hard +' + +test_expect_failure 'git diff HEAD does not segfault' ' + git checkout base && + GIT_TEST_CHECK_CACHE_TREE=false && + git reset --hard && + test_might_fail git diff HEAD +' + +test_expect_failure 'can switch to another branch when status is empty' ' + git clean -ffdqx && + git status --porcelain -uno >actual && + test_must_be_empty actual && + git checkout update +' + +test_expect_success 'forcibly switch to another branch, verify status empty' ' + git checkout -f update && + git status --porcelain -uno >actual && + test_must_be_empty actual +' + +test_expect_success 'fast-forward from non-duplicate entries to duplicate' ' + git merge final +' + +test_expect_failure 'clean status, switch branches, status still clean' ' + git status --porcelain -uno >actual && + test_must_be_empty actual && + git checkout base && + git status --porcelain -uno >actual && + test_must_be_empty actual +' + +test_expect_success 'switch to base branch and force status to be clean' ' + git checkout base && + GIT_TEST_CHECK_CACHE_TREE=false git reset --hard && + git status --porcelain -uno >actual && + test_must_be_empty actual +' + +test_expect_failure 'fast-forward from duplicate entries to non-duplicate' ' + git merge update +' + test_done diff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh index fc8229c726..dc7b242697 100755 --- a/t/t4060-diff-submodule-option-diff-format.sh +++ b/t/t4060-diff-submodule-option-diff-format.sh @@ -409,7 +409,7 @@ test_expect_success 'submodule is up to date' ' test_expect_success 'submodule contains untracked content' ' echo new > sm1/new-file && - git diff-index -p --submodule=diff HEAD >actual && + git diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual && cat >expected <<-EOF && Submodule sm1 contains untracked content EOF @@ -417,7 +417,7 @@ test_expect_success 'submodule contains untracked content' ' ' test_expect_success 'submodule contains untracked content (untracked ignored)' ' - git diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual && + git diff-index -p --submodule=diff HEAD >actual && test_must_be_empty actual ' @@ -433,7 +433,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' ' test_expect_success 'submodule contains untracked and modified content' ' echo new > sm1/foo6 && - git diff-index -p --submodule=diff HEAD >actual && + git diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual && cat >expected <<-EOF && Submodule sm1 contains untracked content Submodule sm1 contains modified content @@ -451,7 +451,7 @@ test_expect_success 'submodule contains untracked and modified content' ' # NOT OK test_expect_success 'submodule contains untracked and modified content (untracked ignored)' ' echo new > sm1/foo6 && - git diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual && + git diff-index -p --submodule=diff HEAD >actual && cat >expected <<-EOF && Submodule sm1 contains modified content diff --git a/sm1/foo6 b/sm1/foo6 @@ -512,7 +512,7 @@ test_expect_success 'submodule is modified' ' test_expect_success 'modified submodule contains untracked content' ' echo new > sm1/new-file && - git diff-index -p --submodule=diff HEAD >actual && + git diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual && cat >expected <<-EOF && Submodule sm1 contains untracked content Submodule sm1 $head7..$head8: @@ -528,7 +528,7 @@ test_expect_success 'modified submodule contains untracked content' ' ' test_expect_success 'modified submodule contains untracked content (untracked ignored)' ' - git diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual && + git diff-index -p --submodule=diff HEAD >actual && cat >expected <<-EOF && Submodule sm1 $head7..$head8: diff --git a/sm1/foo6 b/sm1/foo6 @@ -564,7 +564,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored) test_expect_success 'modified submodule contains untracked and modified content' ' echo modification >> sm1/foo6 && - git diff-index -p --submodule=diff HEAD >actual && + git diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual && cat >expected <<-EOF && Submodule sm1 contains untracked content Submodule sm1 contains modified content @@ -583,7 +583,7 @@ test_expect_success 'modified submodule contains untracked and modified content' test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' ' echo modification >> sm1/foo6 && - git diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual && + git diff-index -p --submodule=diff HEAD >actual && cat >expected <<-EOF && Submodule sm1 contains modified content Submodule sm1 $head7..$head8: diff --git a/t/t4061-diff-indent.sh b/t/t4061-diff-indent.sh index 0f7a6d97a8..7750b87ca1 100755 --- a/t/t4061-diff-indent.sh +++ b/t/t4061-diff-indent.sh @@ -3,8 +3,11 @@ test_description='Test diff indent heuristic. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh +. "$TEST_DIRECTORY"/lib-diff.sh # Compare two diff outputs. Ignore "index" lines, because we don't # care about SHA-1s or file modes. @@ -266,7 +269,7 @@ test_expect_success 'diff-index: nice spaces with --indent-heuristic' ' git reset --soft HEAD~ && git diff-index --indent-heuristic -p old -- spaces.txt >out-diff-index-compacted && compare_diff spaces-compacted-expect out-diff-index-compacted && - git checkout -f master + git checkout -f main ' test_expect_success 'diff-index: nice spaces with diff.indentHeuristic=true' ' @@ -274,7 +277,7 @@ test_expect_success 'diff-index: nice spaces with diff.indentHeuristic=true' ' git reset --soft HEAD~ && git -c diff.indentHeuristic=true diff-index -p old -- spaces.txt >out-diff-index-compacted2 && compare_diff spaces-compacted-expect out-diff-index-compacted2 && - git checkout -f master + git checkout -f main ' test_expect_success 'diff-index: ugly spaces with --no-indent-heuristic' ' @@ -282,7 +285,7 @@ test_expect_success 'diff-index: ugly spaces with --no-indent-heuristic' ' git reset --soft HEAD~ && git diff-index --no-indent-heuristic -p old -- spaces.txt >out-diff-index && compare_diff spaces-expect out-diff-index && - git checkout -f master + git checkout -f main ' test_expect_success 'diff-index: ugly spaces with diff.indentHeuristic=false' ' @@ -290,7 +293,7 @@ test_expect_success 'diff-index: ugly spaces with diff.indentHeuristic=false' ' git reset --soft HEAD~ && git -c diff.indentHeuristic=false diff-index -p old -- spaces.txt >out-diff-index2 && compare_diff spaces-expect out-diff-index2 && - git checkout -f master + git checkout -f main ' test_expect_success 'diff-index: --indent-heuristic overrides config' ' @@ -298,7 +301,7 @@ test_expect_success 'diff-index: --indent-heuristic overrides config' ' git reset --soft HEAD~ && git -c diff.indentHeuristic=false diff-index --indent-heuristic -p old -- spaces.txt >out-diff-index-compacted3 && compare_diff spaces-compacted-expect out-diff-index-compacted3 && - git checkout -f master + git checkout -f main ' test_expect_success 'diff-index: --no-indent-heuristic overrides config' ' @@ -306,7 +309,7 @@ test_expect_success 'diff-index: --no-indent-heuristic overrides config' ' git reset --soft HEAD~ && git -c diff.indentHeuristic=true diff-index --no-indent-heuristic -p old -- spaces.txt >out-diff-index3 && compare_diff spaces-expect out-diff-index3 && - git checkout -f master + git checkout -f main ' # --- diff-files tests ---------------------------------------------------- @@ -317,7 +320,7 @@ test_expect_success 'diff-files: nice spaces with --indent-heuristic' ' git diff-files --indent-heuristic -p spaces.txt >out-diff-files-raw && grep -v index out-diff-files-raw >out-diff-files-compacted && compare_diff spaces-compacted-expect out-diff-files-compacted && - git checkout -f master + git checkout -f main ' test_expect_success 'diff-files: nice spaces with diff.indentHeuristic=true' ' @@ -326,7 +329,7 @@ test_expect_success 'diff-files: nice spaces with diff.indentHeuristic=true' ' git -c diff.indentHeuristic=true diff-files -p spaces.txt >out-diff-files-raw2 && grep -v index out-diff-files-raw2 >out-diff-files-compacted2 && compare_diff spaces-compacted-expect out-diff-files-compacted2 && - git checkout -f master + git checkout -f main ' test_expect_success 'diff-files: ugly spaces with --no-indent-heuristic' ' @@ -335,7 +338,7 @@ test_expect_success 'diff-files: ugly spaces with --no-indent-heuristic' ' git diff-files --no-indent-heuristic -p spaces.txt >out-diff-files-raw && grep -v index out-diff-files-raw >out-diff-files && compare_diff spaces-expect out-diff-files && - git checkout -f master + git checkout -f main ' test_expect_success 'diff-files: ugly spaces with diff.indentHeuristic=false' ' @@ -344,7 +347,7 @@ test_expect_success 'diff-files: ugly spaces with diff.indentHeuristic=false' ' git -c diff.indentHeuristic=false diff-files -p spaces.txt >out-diff-files-raw2 && grep -v index out-diff-files-raw2 >out-diff-files && compare_diff spaces-expect out-diff-files && - git checkout -f master + git checkout -f main ' test_expect_success 'diff-files: --indent-heuristic overrides config' ' @@ -353,7 +356,7 @@ test_expect_success 'diff-files: --indent-heuristic overrides config' ' git -c diff.indentHeuristic=false diff-files --indent-heuristic -p spaces.txt >out-diff-files-raw3 && grep -v index out-diff-files-raw3 >out-diff-files-compacted && compare_diff spaces-compacted-expect out-diff-files-compacted && - git checkout -f master + git checkout -f main ' test_expect_success 'diff-files: --no-indent-heuristic overrides config' ' @@ -362,7 +365,7 @@ test_expect_success 'diff-files: --no-indent-heuristic overrides config' ' git -c diff.indentHeuristic=true diff-files --no-indent-heuristic -p spaces.txt >out-diff-files-raw4 && grep -v index out-diff-files-raw4 >out-diff-files && compare_diff spaces-expect out-diff-files && - git checkout -f master + git checkout -f main ' test_done diff --git a/t/t4066-diff-emit-delay.sh b/t/t4066-diff-emit-delay.sh index 6331f63b12..a1de63b77f 100755 --- a/t/t4066-diff-emit-delay.sh +++ b/t/t4066-diff-emit-delay.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='test combined/stat/moved interaction' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # This test covers a weird 3-way interaction between "--cc -p", which will run @@ -13,7 +16,7 @@ test_expect_success 'set up history with a merge' ' test_commit B && git checkout -b side HEAD^ && test_commit C && - git merge -m M master && + git merge -m M main && test_commit D ' diff --git a/t/t4068-diff-symmetric-merge-base.sh b/t/t4068-diff-symmetric-merge-base.sh index 03487cc945..2d650d8f10 100755 --- a/t/t4068-diff-symmetric-merge-base.sh +++ b/t/t4068-diff-symmetric-merge-base.sh @@ -2,14 +2,17 @@ test_description='behavior of diff with symmetric-diff setups and --merge-base' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # build these situations: # - normal merge with one merge base (br1...b2r); -# - criss-cross merge ie 2 merge bases (br1...master); -# - disjoint subgraph (orphan branch, br3...master). +# - criss-cross merge ie 2 merge bases (br1...main); +# - disjoint subgraph (orphan branch, br3...main). # -# B---E <-- master +# B---E <-- main # / \ / # A X # \ / \ @@ -32,9 +35,9 @@ test_expect_success setup ' git add c && git commit -m C && git tag commit-C && - git merge -m D master && + git merge -m D main && git tag commit-D && - git checkout master && + git checkout main && git merge -m E commit-C && git checkout -b br2 commit-C && echo f >f && @@ -58,7 +61,7 @@ test_expect_success 'diff with one merge base' ' # It should have one of those two, which comes out # to seven lines. test_expect_success 'diff with two merge bases' ' - git diff br1...master >tmp 2>err && + git diff br1...main >tmp 2>err && test_line_count = 7 tmp && test_line_count = 1 err ' @@ -69,22 +72,22 @@ test_expect_success 'diff with no merge bases' ' ' test_expect_success 'diff with too many symmetric differences' ' - test_must_fail git diff br1...master br2...br3 2>err && + test_must_fail git diff br1...main br2...br3 2>err && test_i18ngrep "usage" err ' test_expect_success 'diff with symmetric difference and extraneous arg' ' - test_must_fail git diff master br1...master 2>err && + test_must_fail git diff main br1...main 2>err && test_i18ngrep "usage" err ' test_expect_success 'diff with two ranges' ' - test_must_fail git diff master br1..master br2..br3 2>err && + test_must_fail git diff main br1..main br2..br3 2>err && test_i18ngrep "usage" err ' test_expect_success 'diff with ranges and extra arg' ' - test_must_fail git diff master br1..master commit-D 2>err && + test_must_fail git diff main br1..main commit-D 2>err && test_i18ngrep "usage" err ' @@ -93,21 +96,21 @@ test_expect_success 'diff --merge-base with no commits' ' ' test_expect_success 'diff --merge-base with three commits' ' - test_must_fail git diff --merge-base br1 br2 master 2>err && + test_must_fail git diff --merge-base br1 br2 main 2>err && test_i18ngrep "usage" err ' for cmd in diff-index diff do test_expect_success "$cmd --merge-base with one commit" ' - git checkout master && + git checkout main && git $cmd commit-C >expect && git $cmd --merge-base br2 >actual && test_cmp expect actual ' test_expect_success "$cmd --merge-base with one commit and unstaged changes" ' - git checkout master && + git checkout main && test_when_finished git reset --hard && echo unstaged >>c && git $cmd commit-C >expect && @@ -116,7 +119,7 @@ do ' test_expect_success "$cmd --merge-base with one commit and staged and unstaged changes" ' - git checkout master && + git checkout main && test_when_finished git reset --hard && echo staged >>c && git add c && @@ -127,7 +130,7 @@ do ' test_expect_success "$cmd --merge-base --cached with one commit and staged and unstaged changes" ' - git checkout master && + git checkout main && test_when_finished git reset --hard && echo staged >>c && git add c && @@ -138,19 +141,19 @@ do ' test_expect_success "$cmd --merge-base with non-commit" ' - git checkout master && - test_must_fail git $cmd --merge-base master^{tree} 2>err && + git checkout main && + test_must_fail git $cmd --merge-base main^{tree} 2>err && test_i18ngrep "fatal: --merge-base only works with commits" err ' test_expect_success "$cmd --merge-base with no merge bases and one commit" ' - git checkout master && + git checkout main && test_must_fail git $cmd --merge-base br3 2>err && test_i18ngrep "fatal: no merge base found" err ' test_expect_success "$cmd --merge-base with multiple merge bases and one commit" ' - git checkout master && + git checkout main && test_must_fail git $cmd --merge-base br1 2>err && test_i18ngrep "fatal: multiple merge bases found" err ' @@ -159,13 +162,13 @@ done for cmd in diff-tree diff do test_expect_success "$cmd --merge-base with two commits" ' - git $cmd commit-C master >expect && - git $cmd --merge-base br2 master >actual && + git $cmd commit-C main >expect && + git $cmd --merge-base br2 main >actual && test_cmp expect actual ' test_expect_success "$cmd --merge-base commit and non-commit" ' - test_must_fail git $cmd --merge-base br2 master^{tree} 2>err && + test_must_fail git $cmd --merge-base br2 main^{tree} 2>err && test_i18ngrep "fatal: --merge-base only works with commits" err ' @@ -175,13 +178,13 @@ do ' test_expect_success "$cmd --merge-base with multiple merge bases and two commits" ' - test_must_fail git $cmd --merge-base master br1 2>err && + test_must_fail git $cmd --merge-base main br1 2>err && test_i18ngrep "fatal: multiple merge bases found" err ' done test_expect_success 'diff-tree --merge-base with one commit' ' - test_must_fail git diff-tree --merge-base master 2>err && + test_must_fail git diff-tree --merge-base main 2>err && test_i18ngrep "fatal: --merge-base only works with two commits" err ' diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh index 744b8e51be..9b433de836 100755 --- a/t/t4100-apply-stat.sh +++ b/t/t4100-apply-stat.sh @@ -17,13 +17,13 @@ do test_expect_success "$title" ' git apply --stat --summary \ <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" >current && - test_i18ncmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current + test_cmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current ' test_expect_success "$title with recount" ' sed -e "$UNC" <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" | git apply --recount --stat --summary >current && - test_i18ncmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current + test_cmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current ' done <<\EOF rename diff --git a/t/t4103-apply-binary.sh b/t/t4103-apply-binary.sh index 1b420e3b5f..fad6d3f542 100755 --- a/t/t4103-apply-binary.sh +++ b/t/t4103-apply-binary.sh @@ -6,6 +6,9 @@ test_description='git apply handling binary patches ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -31,64 +34,64 @@ test_expect_success 'setup' ' git update-index --add --remove file1 file2 file3 file4 && git commit -m "Second Version" && - git diff-tree -p master binary >B.diff && - git diff-tree -p -C master binary >C.diff && + git diff-tree -p main binary >B.diff && + git diff-tree -p -C main binary >C.diff && - git diff-tree -p --binary master binary >BF.diff && - git diff-tree -p --binary -C master binary >CF.diff && + git diff-tree -p --binary main binary >BF.diff && + git diff-tree -p --binary -C main binary >CF.diff && - git diff-tree -p --full-index master binary >B-index.diff && - git diff-tree -p -C --full-index master binary >C-index.diff && + git diff-tree -p --full-index main binary >B-index.diff && + git diff-tree -p -C --full-index main binary >C-index.diff && - git diff-tree -p --binary --no-prefix master binary -- file3 >B0.diff && + git diff-tree -p --binary --no-prefix main binary -- file3 >B0.diff && git init other-repo && ( cd other-repo && - git fetch .. master && + git fetch .. main && git reset --hard FETCH_HEAD ) ' test_expect_success 'stat binary diff -- should not fail.' \ - 'git checkout master && + 'git checkout main && git apply --stat --summary B.diff' test_expect_success 'stat binary -p0 diff -- should not fail.' ' - git checkout master && + git checkout main && git apply --stat -p0 B0.diff ' test_expect_success 'stat binary diff (copy) -- should not fail.' \ - 'git checkout master && + 'git checkout main && git apply --stat --summary C.diff' test_expect_success 'check binary diff -- should fail.' \ - 'git checkout master && + 'git checkout main && test_must_fail git apply --check B.diff' test_expect_success 'check binary diff (copy) -- should fail.' \ - 'git checkout master && + 'git checkout main && test_must_fail git apply --check C.diff' test_expect_success \ 'check incomplete binary diff with replacement -- should fail.' ' - git checkout master && + git checkout main && test_must_fail git apply --check --allow-binary-replacement B.diff ' test_expect_success \ 'check incomplete binary diff with replacement (copy) -- should fail.' ' - git checkout master && + git checkout main && test_must_fail git apply --check --allow-binary-replacement C.diff ' test_expect_success 'check binary diff with replacement.' \ - 'git checkout master && + 'git checkout main && git apply --check --allow-binary-replacement BF.diff' test_expect_success 'check binary diff with replacement (copy).' \ - 'git checkout master && + 'git checkout main && git apply --check --allow-binary-replacement CF.diff' # Now we start applying them. @@ -96,7 +99,7 @@ test_expect_success 'check binary diff with replacement (copy).' \ do_reset () { rm -f file? && git reset --hard && - git checkout -f master + git checkout -f main } test_expect_success 'apply binary diff -- should fail.' \ diff --git a/t/t4108-apply-threeway.sh b/t/t4108-apply-threeway.sh index d7349ced6b..65147efdea 100755 --- a/t/t4108-apply-threeway.sh +++ b/t/t4108-apply-threeway.sh @@ -2,6 +2,9 @@ test_description='git apply --3way' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh print_sanitized_conflicted_diff () { @@ -24,14 +27,14 @@ test_expect_success setup ' test_tick && test_write_lines 1 two 3 4 5 six 7 >one && test_write_lines 1 two 3 4 5 6 7 >two && - git commit -a -m master && + git commit -a -m main && git checkout side && test_write_lines 1 2 3 4 five 6 7 >one && test_write_lines 1 2 3 4 five 6 7 >two && git commit -a -m side && - git checkout master + git checkout main ' test_expect_success 'apply without --3way' ' @@ -39,7 +42,7 @@ test_expect_success 'apply without --3way' ' # should fail to apply git reset --hard && - git checkout master^0 && + git checkout main^0 && test_must_fail git apply --index P.diff && # should leave things intact git diff-files --exit-code && @@ -52,14 +55,14 @@ test_apply_with_3way () { # The corresponding conflicted merge git reset --hard && - git checkout master^0 && + git checkout main^0 && test_must_fail git merge --no-commit side && git ls-files -s >expect.ls && print_sanitized_conflicted_diff >expect.diff && # should fail to apply git reset --hard && - git checkout master^0 && + git checkout main^0 && test_must_fail git apply --index --3way P.diff && git ls-files -s >actual.ls && print_sanitized_conflicted_diff >actual.diff && @@ -86,7 +89,7 @@ test_expect_success 'apply with --3way with rerere enabled' ' # The corresponding conflicted merge git reset --hard && - git checkout master^0 && + git checkout main^0 && test_must_fail git merge --no-commit side && # Manually resolve and record the resolution @@ -96,7 +99,7 @@ test_expect_success 'apply with --3way with rerere enabled' ' # should fail to apply git reset --hard && - git checkout master^0 && + git checkout main^0 && test_must_fail git apply --index --3way P.diff && # but rerere should have replayed the recorded resolution @@ -157,4 +160,74 @@ test_expect_success 'apply -3 with add/add conflict (dirty working tree)' ' test_cmp three.save three ' +test_expect_success 'apply -3 with ambiguous repeating file' ' + git reset --hard && + test_write_lines 1 2 1 2 1 2 1 2 1 2 1 >one_two_repeat && + git add one_two_repeat && + git commit -m "init one" && + test_write_lines 1 2 1 2 1 2 1 2 one 2 1 >one_two_repeat && + git commit -a -m "change one" && + + git diff HEAD~ >Repeat.diff && + git reset --hard HEAD~ && + + test_write_lines 1 2 1 2 1 2 one 2 1 2 one >one_two_repeat && + git commit -a -m "change surrounding one" && + + git apply --index --3way Repeat.diff && + test_write_lines 1 2 1 2 1 2 one 2 one 2 one >expect && + + test_cmp expect one_two_repeat +' + +test_expect_success 'apply with --3way --cached clean apply' ' + # Merging side should be similar to applying this patch + git diff ...side >P.diff && + + # The corresponding cleanly applied merge + git reset --hard && + git checkout main~ && + git merge --no-commit side && + git ls-files -s >expect.ls && + + # should succeed + git reset --hard && + git checkout main~ && + git apply --cached --3way P.diff && + git ls-files -s >actual.ls && + print_sanitized_conflicted_diff >actual.diff && + + # The cache should resemble the corresponding merge + # (both files at stage #0) + test_cmp expect.ls actual.ls && + # However the working directory should not change + >expect.diff && + test_cmp expect.diff actual.diff +' + +test_expect_success 'apply with --3way --cached and conflicts' ' + # Merging side should be similar to applying this patch + git diff ...side >P.diff && + + # The corresponding conflicted merge + git reset --hard && + git checkout main^0 && + test_must_fail git merge --no-commit side && + git ls-files -s >expect.ls && + + # should fail to apply + git reset --hard && + git checkout main^0 && + test_must_fail git apply --cached --3way P.diff && + git ls-files -s >actual.ls && + print_sanitized_conflicted_diff >actual.diff && + + # The cache should resemble the corresponding merge + # (one file at stage #0, one file at stages #1 #2 #3) + test_cmp expect.ls actual.ls && + # However the working directory should not change + >expect.diff && + test_cmp expect.diff actual.diff +' + test_done diff --git a/t/t4121-apply-diffs.sh b/t/t4121-apply-diffs.sh index 66368effd5..b45454aaf4 100755 --- a/t/t4121-apply-diffs.sh +++ b/t/t4121-apply-diffs.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='git apply for contextually independent diffs' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh echo '1 @@ -23,7 +26,7 @@ test_expect_success 'setup' \ git commit -a -q -m 2 && echo 9 >>file && git commit -a -q -m 3 && - git checkout master' + git checkout main' test_expect_success \ 'check if contextually independent diffs for the same file apply' \ diff --git a/t/t4122-apply-symlink-inside.sh b/t/t4122-apply-symlink-inside.sh index 4acb3f336e..aa52de401b 100755 --- a/t/t4122-apply-symlink-inside.sh +++ b/t/t4122-apply-symlink-inside.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='apply to deeper directory without getting fooled with symlink' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -35,11 +38,11 @@ test_expect_success apply ' test_expect_success 'check result' ' - git diff --exit-code master && - git diff --exit-code --cached master && + git diff --exit-code main && + git diff --exit-code --cached main && test_tick && git commit -m replay && - T1=$(git rev-parse "master^{tree}") && + T1=$(git rev-parse "main^{tree}") && T2=$(git rev-parse "HEAD^{tree}") && test "z$T1" = "z$T2" diff --git a/t/t4150-am.sh b/t/t4150-am.sh index 3ecbef6f8e..2aaaa0d7de 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -2,6 +2,9 @@ test_description='git am running' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup: messages' ' @@ -179,8 +182,8 @@ test_expect_success setup ' test_tick && git commit -m "added another file" && - git format-patch --stdout master >lorem-move.patch && - git format-patch --no-prefix --stdout master >lorem-zero.patch && + git format-patch --stdout main >lorem-move.patch && + git format-patch --no-prefix --stdout main >lorem-zero.patch && git checkout -b rename && git mv file renamed && @@ -453,11 +456,11 @@ test_expect_success 'am changes committer and keeps author' ' git checkout first && git am patch2 && test_path_is_missing .git/rebase-apply && - test "$(git rev-parse master^^)" = "$(git rev-parse HEAD^^)" && - git diff --exit-code master..HEAD && - git diff --exit-code master^..HEAD^ && - compare author master HEAD && - compare author master^ HEAD^ && + test "$(git rev-parse main^^)" = "$(git rev-parse HEAD^^)" && + git diff --exit-code main..HEAD && + git diff --exit-code main^..HEAD^ && + compare author main HEAD && + compare author main^ HEAD^ && test "$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" = \ "$(git log -1 --pretty=format:"%cn <%ce>" HEAD)" ' @@ -759,7 +762,7 @@ test_expect_success 'am takes patches from a Pine mailbox' ' git checkout first && cat pine patch1 | git am && test_path_is_missing .git/rebase-apply && - git diff --exit-code master^..HEAD + git diff --exit-code main^..HEAD ' test_expect_success 'am fails on mail without patch' ' @@ -903,7 +906,7 @@ test_expect_success 'am empty-file does not infloop' ' test_tick && test_must_fail git am empty-file 2>actual && echo Patch format detection failed. >expected && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'am --message-id really adds the message id' ' @@ -1112,21 +1115,21 @@ test_expect_success 'am and .gitattibutes' ' test_commit sixth && git checkout test && - git format-patch --stdout master..HEAD >patches && - git reset --hard master && + git format-patch --stdout main..HEAD >patches && + git reset --hard main && git am patches && grep "smudged" a.txt && git checkout removal && git reset --hard && - git format-patch --stdout master..HEAD >patches && - git reset --hard master && + git format-patch --stdout main..HEAD >patches && + git reset --hard main && git am patches && grep "clean" a.txt && git checkout conflict && git reset --hard && - git format-patch --stdout master..HEAD >patches && + git format-patch --stdout main..HEAD >patches && git reset --hard fourth && test_must_fail git am -3 patches && grep "<<<<<<<<<<" a.txt diff --git a/t/t4153-am-resume-override-opts.sh b/t/t4153-am-resume-override-opts.sh index 8ea22d1bcb..b7c3861407 100755 --- a/t/t4153-am-resume-override-opts.sh +++ b/t/t4153-am-resume-override-opts.sh @@ -61,7 +61,7 @@ test_expect_success '--no-quiet overrides --quiet' ' # Applying side2 will be quiet. git am --no-quiet --continue >out && echo "Applying: side1" >expected && - test_i18ncmp expected out + test_cmp expected out ' test_expect_success '--signoff overrides --no-signoff' ' diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index b12b43e9e9..9f8c76dffb 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -8,7 +8,7 @@ test_description='git rerere ! [fifth] version1 ! [first] first ! [fourth] version1 - ! [master] initial + ! [main] initial ! [second] prefer first over second ! [third] version2 ------ @@ -19,9 +19,12 @@ test_description='git rerere - [second] prefer first over second + + [first] first + [second^] second -++++++ [master] initial +++++++ [main] initial ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -57,7 +60,7 @@ test_expect_success 'setup' ' test_tick && git commit -q -a -m first && - git checkout -b second master && + git checkout -b second main && git show first:a1 | sed -e "s/To die, t/To die! T/" -e "s/Some title/Some Title/" >a1 && echo "* END *" >>a1 && @@ -168,7 +171,7 @@ test_expect_success 'first postimage wins' ' oldmtimepost=$(test-tool chmtime --get -60 $rr/postimage) && - git checkout -b third master && + git checkout -b third main && git show second^:a1 | sed "s/To die: t/To die! T/" >a1 && git commit -q -a -m third && @@ -580,13 +583,13 @@ test_expect_success 'multiple identical conflicts' ' test_expect_success 'rerere with unexpected conflict markers does not crash' ' git reset --hard && - git checkout -b branch-1 master && + git checkout -b branch-1 main && echo "bar" >test && git add test && git commit -q -m two && git reset --hard && - git checkout -b branch-2 master && + git checkout -b branch-2 main && echo "foo" >test && git add test && git commit -q -a -m one && @@ -601,7 +604,7 @@ test_expect_success 'rerere with unexpected conflict markers does not crash' ' test_expect_success 'rerere with inner conflict markers' ' git reset --hard && - git checkout -b A master && + git checkout -b A main && echo "bar" >test && git add test && git commit -q -m two && @@ -610,7 +613,7 @@ test_expect_success 'rerere with inner conflict markers' ' git commit -q -m three && git reset --hard && - git checkout -b B master && + git checkout -b B main && echo "foo" >test && git add test && git commit -q -a -m one && @@ -651,11 +654,11 @@ test_expect_success 'setup simple stage 1 handling' ' git add original && git commit -m original && - git checkout -b A master && + git checkout -b A main && git mv original A && git commit -m "rename to A" && - git checkout -b B master && + git checkout -b B main && git mv original B && git commit -m "rename to B" ) diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh index 3d5c4a2086..3095b1b2ff 100755 --- a/t/t4201-shortlog.sh +++ b/t/t4201-shortlog.sh @@ -6,6 +6,9 @@ test_description='git shortlog ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -191,7 +194,7 @@ test_expect_success 'shortlog with revision pseudo options' ' ' test_expect_success 'shortlog with --output=<file>' ' - git shortlog --output=shortlog -1 master >output && + git shortlog --output=shortlog -1 main >output && test_must_be_empty output && test_line_count = 3 shortlog ' diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 56d34ed465..350cfa3593 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -2,6 +2,9 @@ test_description='git log' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY/lib-gpg.sh" . "$TEST_DIRECTORY/lib-terminal.sh" @@ -478,7 +481,7 @@ test_expect_success 'set up merge history' ' git checkout -b side HEAD~4 && test_commit side-1 1 1 && test_commit side-2 2 2 && - git checkout master && + git checkout main && git merge side ' @@ -541,17 +544,17 @@ test_expect_success 'log --graph with merge with log.graphColors' ' ' test_expect_success 'log --raw --graph -m with merge' ' - git log --raw --graph --oneline -m master | head -n 500 >actual && + git log --raw --graph --oneline -m main | head -n 500 >actual && grep "initial" actual ' test_expect_success 'diff-tree --graph' ' - git diff-tree --graph master^ | head -n 500 >actual && + git diff-tree --graph main^ | head -n 500 >actual && grep "one" actual ' cat > expect <<\EOF -* commit master +* commit main |\ Merge: A B | | Author: A U Thor <author@example.com> | | @@ -567,22 +570,22 @@ cat > expect <<\EOF | | | | side-1 | | -* | commit master~1 +* | commit main~1 | | Author: A U Thor <author@example.com> | | | | Second | | -* | commit master~2 +* | commit main~2 | | Author: A U Thor <author@example.com> | | | | sixth | | -* | commit master~3 +* | commit main~3 | | Author: A U Thor <author@example.com> | | | | fifth | | -* | commit master~4 +* | commit main~4 |/ Author: A U Thor <author@example.com> | | fourth @@ -613,19 +616,19 @@ test_expect_success 'log --graph with full output' ' test_expect_success 'set up more tangled history' ' git checkout -b tangle HEAD~6 && test_commit tangle-a tangle-a a && - git merge master~3 && + git merge main~3 && git merge side~1 && - git checkout master && + git checkout main && git merge tangle && git checkout -b reach && test_commit reach && - git checkout master && + git checkout main && git checkout -b octopus-a && test_commit octopus-a && - git checkout master && + git checkout main && git checkout -b octopus-b && test_commit octopus-b && - git checkout master && + git checkout main && test_commit seventh && git merge octopus-a octopus-b && git merge reach @@ -650,7 +653,7 @@ cat > expect <<\EOF |\ | * Merge branch 'side' (early part) into tangle | |\ -| * \ Merge branch 'master' (early part) into tangle +| * \ Merge branch 'main' (early part) into tangle | |\ \ | * | | tangle-a * | | | Merge branch 'side' @@ -794,7 +797,7 @@ test_expect_success 'multiple decorate-refs' ' test_expect_success 'decorate-refs-exclude with glob' ' cat >expect.decorate <<-\EOF && - Merge-tag-reach (HEAD -> master) + Merge-tag-reach (HEAD -> main) Merge-tags-octopus-a-and-octopus-b seventh (tag: seventh) octopus-b (tag: octopus-b) @@ -811,7 +814,7 @@ test_expect_success 'decorate-refs-exclude with glob' ' test_expect_success 'decorate-refs-exclude without globs' ' cat >expect.decorate <<-\EOF && - Merge-tag-reach (HEAD -> master) + Merge-tag-reach (HEAD -> main) Merge-tags-octopus-a-and-octopus-b seventh (tag: seventh) octopus-b (tag: octopus-b, octopus-b) @@ -828,7 +831,7 @@ test_expect_success 'decorate-refs-exclude without globs' ' test_expect_success 'multiple decorate-refs-exclude' ' cat >expect.decorate <<-\EOF && - Merge-tag-reach (HEAD -> master) + Merge-tag-reach (HEAD -> main) Merge-tags-octopus-a-and-octopus-b seventh (tag: seventh) octopus-b (tag: octopus-b) @@ -851,7 +854,7 @@ test_expect_success 'multiple decorate-refs-exclude' ' test_expect_success 'decorate-refs and decorate-refs-exclude' ' cat >expect.no-decorate <<-\EOF && - Merge-tag-reach (master) + Merge-tag-reach (main) Merge-tags-octopus-a-and-octopus-b seventh octopus-b @@ -866,7 +869,7 @@ test_expect_success 'decorate-refs and decorate-refs-exclude' ' test_expect_success 'deocrate-refs and log.excludeDecoration' ' cat >expect.decorate <<-\EOF && - Merge-tag-reach (master) + Merge-tag-reach (main) Merge-tags-octopus-a-and-octopus-b seventh octopus-b (octopus-b) @@ -881,7 +884,7 @@ test_expect_success 'deocrate-refs and log.excludeDecoration' ' test_expect_success 'decorate-refs-exclude and simplify-by-decoration' ' cat >expect.decorate <<-\EOF && - Merge-tag-reach (HEAD -> master) + Merge-tag-reach (HEAD -> main) reach (tag: reach, reach) seventh (tag: seventh) Merge-branch-tangle @@ -1080,7 +1083,7 @@ cat >expect <<\EOF | |\ \ Merge: MERGE_PARENTS | | | | Author: A U Thor <author@example.com> | | | | -| | | | Merge branch 'master' (early part) into tangle +| | | | Merge branch 'main' (early part) into tangle | | | | | * | | commit COMMIT_OBJECT_NAME | | | | Author: A U Thor <author@example.com> @@ -1355,7 +1358,7 @@ cat >expect <<\EOF *** | |\ \ Merge: MERGE_PARENTS *** | | | | Author: A U Thor <author@example.com> *** | | | | -*** | | | | Merge branch 'master' (early part) into tangle +*** | | | | Merge branch 'main' (early part) into tangle *** | | | | *** | * | | commit COMMIT_OBJECT_NAME *** | | | | Author: A U Thor <author@example.com> @@ -1588,24 +1591,24 @@ test_expect_success 'dotdot is a parent directory' ' ' test_expect_success GPG 'setup signed branch' ' - test_when_finished "git reset --hard && git checkout master" && - git checkout -b signed master && + test_when_finished "git reset --hard && git checkout main" && + git checkout -b signed main && echo foo >foo && git add foo && git commit -S -m signed_commit ' test_expect_success GPG 'setup signed branch with subkey' ' - test_when_finished "git reset --hard && git checkout master" && - git checkout -b signed-subkey master && + test_when_finished "git reset --hard && git checkout main" && + git checkout -b signed-subkey main && echo foo >foo && git add foo && git commit -SB7227189 -m signed_commit ' test_expect_success GPGSM 'setup signed branch x509' ' - test_when_finished "git reset --hard && git checkout master" && - git checkout -b signed-x509 master && + test_when_finished "git reset --hard && git checkout main" && + git checkout -b signed-x509 main && echo foo >foo && git add foo && test_config gpg.format x509 && @@ -1638,12 +1641,12 @@ test_expect_success GPGSM 'log --graph --show-signature x509' ' ' test_expect_success GPG 'log --graph --show-signature for merged tag' ' - test_when_finished "git reset --hard && git checkout master" && - git checkout -b plain master && + test_when_finished "git reset --hard && git checkout main" && + git checkout -b plain main && echo aaa >bar && git add bar && git commit -m bar_commit && - git checkout -b tagged master && + git checkout -b tagged main && echo bbb >baz && git add baz && git commit -m baz_commit && @@ -1657,12 +1660,12 @@ test_expect_success GPG 'log --graph --show-signature for merged tag' ' ' test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' ' - test_when_finished "git reset --hard && git checkout master" && - git checkout -b plain-shallow master && + test_when_finished "git reset --hard && git checkout main" && + git checkout -b plain-shallow main && echo aaa >bar && git add bar && git commit -m bar_commit && - git checkout --detach master && + git checkout --detach main && echo bbb >baz && git add baz && git commit -m baz_commit && @@ -1677,12 +1680,12 @@ test_expect_success GPG 'log --graph --show-signature for merged tag in shallow ' test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' ' - test_when_finished "git reset --hard && git checkout master" && - git checkout -b plain-nokey master && + test_when_finished "git reset --hard && git checkout main" && + git checkout -b plain-nokey main && echo aaa >bar && git add bar && git commit -m bar_commit && - git checkout -b tagged-nokey master && + git checkout -b tagged-nokey main && echo bbb >baz && git add baz && git commit -m baz_commit && @@ -1696,12 +1699,12 @@ test_expect_success GPG 'log --graph --show-signature for merged tag with missin ' test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' ' - test_when_finished "git reset --hard && git checkout master" && - git checkout -b plain-bad master && + test_when_finished "git reset --hard && git checkout main" && + git checkout -b plain-bad main && echo aaa >bar && git add bar && git commit -m bar_commit && - git checkout -b tagged-bad master && + git checkout -b tagged-bad main && echo bbb >baz && git add baz && git commit -m baz_commit && @@ -1718,12 +1721,12 @@ test_expect_success GPG 'log --graph --show-signature for merged tag with bad si ' test_expect_success GPG 'log --show-signature for merged tag with GPG failure' ' - test_when_finished "git reset --hard && git checkout master" && - git checkout -b plain-fail master && + test_when_finished "git reset --hard && git checkout main" && + git checkout -b plain-fail main && echo aaa >bar && git add bar && git commit -m bar_commit && - git checkout -b tagged-fail master && + git checkout -b tagged-fail main && echo bbb >baz && git add baz && git commit -m baz_commit && @@ -1737,14 +1740,14 @@ test_expect_success GPG 'log --show-signature for merged tag with GPG failure' ' ' test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' ' - test_when_finished "git reset --hard && git checkout master" && + test_when_finished "git reset --hard && git checkout main" && test_config gpg.format x509 && test_config user.signingkey $GIT_COMMITTER_EMAIL && - git checkout -b plain-x509 master && + git checkout -b plain-x509 main && echo aaa >bar && git add bar && git commit -m bar_commit && - git checkout -b tagged-x509 master && + git checkout -b tagged-x509 main && echo bbb >baz && git add baz && git commit -m baz_commit && @@ -1758,14 +1761,14 @@ test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' ' ' test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' ' - test_when_finished "git reset --hard && git checkout master" && + test_when_finished "git reset --hard && git checkout main" && test_config gpg.format x509 && test_config user.signingkey $GIT_COMMITTER_EMAIL && - git checkout -b plain-x509-nokey master && + git checkout -b plain-x509-nokey main && echo aaa >bar && git add bar && git commit -m bar_commit && - git checkout -b tagged-x509-nokey master && + git checkout -b tagged-x509-nokey main && echo bbb >baz && git add baz && git commit -m baz_commit && @@ -1778,14 +1781,14 @@ test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 miss ' test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' ' - test_when_finished "git reset --hard && git checkout master" && + test_when_finished "git reset --hard && git checkout main" && test_config gpg.format x509 && test_config user.signingkey $GIT_COMMITTER_EMAIL && - git checkout -b plain-x509-bad master && + git checkout -b plain-x509-bad main && echo aaa >bar && git add bar && git commit -m bar_commit && - git checkout -b tagged-x509-bad master && + git checkout -b tagged-x509-bad main && echo bbb >baz && git add baz && git commit -m baz_commit && @@ -1835,7 +1838,7 @@ test_expect_success 'log diagnoses bogus HEAD' ' git init empty && test_must_fail git -C empty log 2>stderr && test_i18ngrep does.not.have.any.commits stderr && - echo 1234abcd >empty/.git/refs/heads/master && + echo 1234abcd >empty/.git/refs/heads/main && test_must_fail git -C empty log 2>stderr && test_i18ngrep broken stderr && echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD && diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh index 586c3a86b1..d8e7374234 100755 --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@ -2,30 +2,14 @@ test_description='.mailmap configurations' -. ./test-lib.sh - -fuzz_blame () { - sed " - s/$_x05[0-9a-f][0-9a-f][0-9a-f]/OBJID/g - s/$_x05[0-9a-f][0-9a-f]/OBJI/g - s/[-0-9]\{10\} [:0-9]\{8\} [-+][0-9]\{4\}/DATE/g - " "$@" -} +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME -test_expect_success setup ' - cat >contacts <<- EOF && - $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> - nick1 <bugs@company.xx> - EOF +. ./test-lib.sh - echo one >one && - git add one && - test_tick && - git commit -m initial && - echo two >>one && - git add one && - test_tick && - git commit --author "nick1 <bugs@company.xx>" -m second +test_expect_success 'setup commits and contacts file' ' + test_commit initial one one && + test_commit --author "nick1 <bugs@company.xx>" --append second one two ' test_expect_success 'check-mailmap no arguments' ' @@ -33,7 +17,7 @@ test_expect_success 'check-mailmap no arguments' ' ' test_expect_success 'check-mailmap arguments' ' - cat >expect <<- EOF && + cat >expect <<-EOF && $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> nick1 <bugs@company.xx> EOF @@ -44,172 +28,256 @@ test_expect_success 'check-mailmap arguments' ' ' test_expect_success 'check-mailmap --stdin' ' - cat >expect <<- EOF && + cat >expect <<-EOF && $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> nick1 <bugs@company.xx> EOF - git check-mailmap --stdin <contacts >actual && + git check-mailmap --stdin <expect >actual && test_cmp expect actual ' -test_expect_success 'check-mailmap --stdin arguments' ' +test_expect_success 'check-mailmap --stdin arguments: no mapping' ' + test_when_finished "rm contacts" && + cat >contacts <<-EOF && + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> + nick1 <bugs@company.xx> + EOF cat >expect <<-\EOF && Internal Guy <bugs@company.xy> EOF - cat <contacts >>expect && + cat contacts >>expect && + git check-mailmap --stdin "Internal Guy <bugs@company.xy>" \ <contacts >actual && test_cmp expect actual ' +test_expect_success 'check-mailmap --stdin arguments: mapping' ' + test_when_finished "rm .mailmap" && + cat >.mailmap <<-EOF && + New Name <$GIT_AUTHOR_EMAIL> + EOF + cat >stdin <<-EOF && + Old Name <$GIT_AUTHOR_EMAIL> + EOF + + cp .mailmap expect && + git check-mailmap --stdin <stdin >actual && + test_cmp expect actual && + + cat .mailmap >>expect && + git check-mailmap --stdin "Another Old Name <$GIT_AUTHOR_EMAIL>" \ + <stdin >actual && + test_cmp expect actual +' + test_expect_success 'check-mailmap bogus contact' ' test_must_fail git check-mailmap bogus ' -cat >expect << EOF -$GIT_AUTHOR_NAME (1): - initial +test_expect_success 'check-mailmap bogus contact --stdin' ' + test_must_fail git check-mailmap --stdin bogus </dev/null +' -nick1 (1): - second +test_expect_success 'No mailmap' ' + cat >expect <<-EOF && + $GIT_AUTHOR_NAME (1): + initial -EOF + nick1 (1): + second -test_expect_success 'No mailmap' ' + EOF git shortlog HEAD >actual && test_cmp expect actual ' -cat >expect <<\EOF -Repo Guy (1): - initial +test_expect_success 'setup default .mailmap' ' + cat >default.map <<-EOF + Repo Guy <$GIT_AUTHOR_EMAIL> + EOF +' + +test_expect_success 'test default .mailmap' ' + test_when_finished "rm .mailmap" && + cp default.map .mailmap && -nick1 (1): - second + cat >expect <<-\EOF && + Repo Guy (1): + initial -EOF + nick1 (1): + second -test_expect_success 'default .mailmap' ' - echo "Repo Guy <$GIT_AUTHOR_EMAIL>" > .mailmap && + EOF git shortlog HEAD >actual && test_cmp expect actual ' -# Using a mailmap file in a subdirectory of the repo here, but -# could just as well have been a file outside of the repository -cat >expect <<\EOF -Internal Guy (1): - second +test_expect_success 'mailmap.file set' ' + test_when_finished "rm .mailmap" && + cp default.map .mailmap && -Repo Guy (1): - initial + test_config mailmap.file internal.map && + cat >internal.map <<-\EOF && + Internal Guy <bugs@company.xx> + EOF -EOF -test_expect_success 'mailmap.file set' ' - mkdir -p internal_mailmap && - echo "Internal Guy <bugs@company.xx>" > internal_mailmap/.mailmap && - git config mailmap.file internal_mailmap/.mailmap && + cat >expect <<-\EOF && + Internal Guy (1): + second + + Repo Guy (1): + initial + + EOF git shortlog HEAD >actual && - test_cmp expect actual + test_cmp expect actual && + + # The internal_mailmap/.mailmap file is an a subdirectory, but + # as shown here it can also be outside the repository + test_when_finished "rm -rf sub-repo" && + git clone . sub-repo && + ( + cd sub-repo && + cp ../.mailmap . && + git config mailmap.file ../internal.map && + git shortlog HEAD >actual && + test_cmp ../expect actual + ) ' -cat >expect <<\EOF -External Guy (1): - initial +test_expect_success 'mailmap.file override' ' + test_config mailmap.file internal.map && + cat >internal.map <<-EOF && + Internal Guy <bugs@company.xx> + External Guy <$GIT_AUTHOR_EMAIL> + EOF -Internal Guy (1): - second + cat >expect <<-\EOF && + External Guy (1): + initial -EOF -test_expect_success 'mailmap.file override' ' - echo "External Guy <$GIT_AUTHOR_EMAIL>" >> internal_mailmap/.mailmap && - git config mailmap.file internal_mailmap/.mailmap && + Internal Guy (1): + second + + EOF git shortlog HEAD >actual && test_cmp expect actual ' -cat >expect <<\EOF -Repo Guy (1): - initial +test_expect_success 'mailmap.file non-existent' ' + test_when_finished "rm .mailmap" && + cp default.map .mailmap && -nick1 (1): - second + cat >expect <<-\EOF && + Repo Guy (1): + initial -EOF + nick1 (1): + second -test_expect_success 'mailmap.file non-existent' ' - rm internal_mailmap/.mailmap && - rmdir internal_mailmap && + EOF git shortlog HEAD >actual && test_cmp expect actual ' -cat >expect <<\EOF -Internal Guy (1): - second +test_expect_success 'name entry after email entry' ' + test_when_finished "rm .mailmap" && + cp default.map .mailmap && -Repo Guy (1): - initial + test_config mailmap.file internal.map && + cat >internal.map <<-\EOF && + <bugs@company.xy> <bugs@company.xx> + Internal Guy <bugs@company.xx> + EOF -EOF + cat >expect <<-\EOF && + Internal Guy (1): + second + + Repo Guy (1): + initial + + EOF -test_expect_success 'name entry after email entry' ' - mkdir -p internal_mailmap && - echo "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap && - echo "Internal Guy <bugs@company.xx>" >>internal_mailmap/.mailmap && git shortlog HEAD >actual && test_cmp expect actual ' -cat >expect <<\EOF -Internal Guy (1): - second +test_expect_success 'name entry after email entry, case-insensitive' ' + test_when_finished "rm .mailmap" && + cp default.map .mailmap && -Repo Guy (1): - initial + test_config mailmap.file internal.map && + cat >internal.map <<-\EOF && + <bugs@company.xy> <bugs@company.xx> + Internal Guy <BUGS@Company.xx> + EOF -EOF + cat >expect <<-\EOF && + Internal Guy (1): + second -test_expect_success 'name entry after email entry, case-insensitive' ' - mkdir -p internal_mailmap && - echo "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap && - echo "Internal Guy <BUGS@Company.xx>" >>internal_mailmap/.mailmap && + Repo Guy (1): + initial + + EOF + git shortlog HEAD >actual && + test_cmp expect actual && + + cat >internal.map <<-\EOF && + NiCk <BuGs@CoMpAnY.Xy> NICK1 <BUGS@COMPANY.XX> + EOF + + cat >expect <<-\EOF && + NiCk (1): + second + + Repo Guy (1): + initial + + EOF git shortlog HEAD >actual && test_cmp expect actual ' -cat >expect << EOF -$GIT_AUTHOR_NAME (1): - initial +test_expect_success 'No mailmap files, but configured' ' + cat >expect <<-EOF && + $GIT_AUTHOR_NAME (1): + initial -nick1 (1): - second + nick1 (1): + second -EOF -test_expect_success 'No mailmap files, but configured' ' - rm -f .mailmap internal_mailmap/.mailmap && + EOF git shortlog HEAD >actual && test_cmp expect actual ' test_expect_success 'setup mailmap blob tests' ' git checkout -b map && - test_when_finished "git checkout master" && - cat >just-bugs <<- EOF && + test_when_finished "git checkout main" && + cat >just-bugs <<-\EOF && Blob Guy <bugs@company.xx> EOF - cat >both <<- EOF && + cat >both <<-EOF && Blob Guy <$GIT_AUTHOR_EMAIL> Blob Guy <bugs@company.xx> EOF printf "Tricky Guy <$GIT_AUTHOR_EMAIL>" >no-newline && git add just-bugs both no-newline && git commit -m "my mailmaps" && - echo "Repo Guy <$GIT_AUTHOR_EMAIL>" >.mailmap && - echo "Internal Guy <$GIT_AUTHOR_EMAIL>" >internal.map + + cat >internal.map <<-EOF + Internal Guy <$GIT_AUTHOR_EMAIL> + EOF ' test_expect_success 'mailmap.blob set' ' + test_when_finished "rm .mailmap" && + cp default.map .mailmap && + cat >expect <<-\EOF && Blob Guy (1): second @@ -223,6 +291,9 @@ test_expect_success 'mailmap.blob set' ' ' test_expect_success 'mailmap.blob overrides .mailmap' ' + test_when_finished "rm .mailmap" && + cp default.map .mailmap && + cat >expect <<-\EOF && Blob Guy (2): initial @@ -249,7 +320,28 @@ test_expect_success 'mailmap.file overrides mailmap.blob' ' test_cmp expect actual ' +test_expect_success 'mailmap.file can be missing' ' + test_when_finished "rm .mailmap" && + cp default.map .mailmap && + + test_config mailmap.file nonexistent && + cat >expect <<-\EOF && + Repo Guy (1): + initial + + nick1 (1): + second + + EOF + git shortlog HEAD >actual 2>err && + test_must_be_empty err && + test_cmp expect actual +' + test_expect_success 'mailmap.blob can be missing' ' + test_when_finished "rm .mailmap" && + cp default.map .mailmap && + cat >expect <<-\EOF && Repo Guy (1): initial @@ -258,7 +350,17 @@ test_expect_success 'mailmap.blob can be missing' ' second EOF - git -c mailmap.blob=map:nonexistent shortlog HEAD >actual && + git -c mailmap.blob=map:nonexistent shortlog HEAD >actual 2>err && + test_must_be_empty err && + test_cmp expect actual +' + +test_expect_success 'mailmap.blob might be the wrong type' ' + test_when_finished "rm .mailmap" && + cp default.map .mailmap && + + git -c mailmap.blob=HEAD: shortlog HEAD >actual 2>err && + test_i18ngrep "mailmap is not a blob" err && test_cmp expect actual ' @@ -267,11 +369,15 @@ test_expect_success 'mailmap.blob defaults to off in non-bare repo' ' ( cd non-bare && test_commit one .mailmap "Fake Name <$GIT_AUTHOR_EMAIL>" && - echo " 1 Fake Name" >expect && + cat >expect <<-\EOF && + 1 Fake Name + EOF git shortlog -ns HEAD >actual && test_cmp expect actual && rm .mailmap && - echo " 1 $GIT_AUTHOR_NAME" >expect && + cat >expect <<-EOF && + 1 $GIT_AUTHOR_NAME + EOF git shortlog -ns HEAD >actual && test_cmp expect actual ) @@ -281,7 +387,9 @@ test_expect_success 'mailmap.blob defaults to HEAD:.mailmap in bare repo' ' git clone --bare non-bare bare && ( cd bare && - echo " 1 Fake Name" >expect && + cat >expect <<-\EOF && + 1 Fake Name + EOF git shortlog -ns HEAD >actual && test_cmp expect actual ) @@ -300,178 +408,260 @@ test_expect_success 'mailmap.blob can handle blobs without trailing newline' ' test_cmp expect actual ' -test_expect_success 'cleanup after mailmap.blob tests' ' - rm -f .mailmap -' - test_expect_success 'single-character name' ' - echo " 1 A <$GIT_AUTHOR_EMAIL>" >expect && - echo " 1 nick1 <bugs@company.xx>" >>expect && - echo "A <$GIT_AUTHOR_EMAIL>" >.mailmap && test_when_finished "rm .mailmap" && + cat >.mailmap <<-EOF && + A <$GIT_AUTHOR_EMAIL> + EOF + + cat >expect <<-EOF && + 1 A <$GIT_AUTHOR_EMAIL> + 1 nick1 <bugs@company.xx> + EOF git shortlog -es HEAD >actual && test_cmp expect actual ' test_expect_success 'preserve canonical email case' ' - echo " 1 $GIT_AUTHOR_NAME <AUTHOR@example.com>" >expect && - echo " 1 nick1 <bugs@company.xx>" >>expect && - echo "<AUTHOR@example.com> <$GIT_AUTHOR_EMAIL>" >.mailmap && test_when_finished "rm .mailmap" && + cat >.mailmap <<-EOF && + <AUTHOR@example.com> <$GIT_AUTHOR_EMAIL> + EOF + + cat >expect <<-EOF && + 1 $GIT_AUTHOR_NAME <AUTHOR@example.com> + 1 nick1 <bugs@company.xx> + EOF git shortlog -es HEAD >actual && test_cmp expect actual ' -# Extended mailmap configurations should give us the following output for shortlog -cat >expect << EOF -$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1): - initial +test_expect_success 'gitmailmap(5) example output: setup' ' + test_create_repo doc && + test_commit -C doc --author "Joe Developer <joe@example.com>" A && + test_commit -C doc --author "Joe R. Developer <joe@example.com>" B && + test_commit -C doc --author "Jane Doe <jane@example.com>" C && + test_commit -C doc --author "Jane Doe <jane@laptop.(none)>" D && + test_commit -C doc --author "Jane D. <jane@desktop.(none)>" E +' + +test_expect_success 'gitmailmap(5) example output: example #1' ' + test_config -C doc mailmap.file ../doc.map && + cat >doc.map <<-\EOF && + Joe R. Developer <joe@example.com> + Jane Doe <jane@example.com> + Jane Doe <jane@desktop.(none)> + EOF + + cat >expect <<-\EOF && + Author Joe Developer <joe@example.com> maps to Joe R. Developer <joe@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author Joe R. Developer <joe@example.com> maps to Joe R. Developer <joe@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author Jane Doe <jane@example.com> maps to Jane Doe <jane@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author Jane Doe <jane@laptop.(none)> maps to Jane Doe <jane@laptop.(none)> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author Jane D <jane@desktop.(none)> maps to Jane Doe <jane@desktop.(none)> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + EOF + git -C doc log --reverse --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual && + test_cmp expect actual +' + +test_expect_success 'gitmailmap(5) example output: example #2' ' + test_config -C doc mailmap.file ../doc.map && + cat >doc.map <<-\EOF && + Joe R. Developer <joe@example.com> + Jane Doe <jane@example.com> <jane@laptop.(none)> + Jane Doe <jane@example.com> <jane@desktop.(none)> + EOF + + cat >expect <<-\EOF && + Author Joe Developer <joe@example.com> maps to Joe R. Developer <joe@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author Joe R. Developer <joe@example.com> maps to Joe R. Developer <joe@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author Jane Doe <jane@example.com> maps to Jane Doe <jane@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author Jane Doe <jane@laptop.(none)> maps to Jane Doe <jane@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author Jane D <jane@desktop.(none)> maps to Jane Doe <jane@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + EOF + git -C doc log --reverse --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual && + test_cmp expect actual +' + +test_expect_success 'gitmailmap(5) example output: example #3' ' + test_config -C doc mailmap.file ../doc.map && + cat >>doc.map <<-\EOF && + Joe R. Developer <joe@example.com> Joe <bugs@example.com> + Jane Doe <jane@example.com> Jane <bugs@example.com> + EOF -CTO <cto@company.xx> (1): - seventh + test_commit -C doc --author "Joe <bugs@example.com>" F && + test_commit -C doc --author "Jane <bugs@example.com>" G && -Other Author <other@author.xx> (2): - third - fourth + cat >>expect <<-\EOF && -Santa Claus <santa.claus@northpole.xx> (2): - fifth - sixth + Author Joe <bugs@example.com> maps to Joe R. Developer <joe@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> -Some Dude <some@dude.xx> (1): - second + Author Jane <bugs@example.com> maps to Jane Doe <jane@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + EOF + git -C doc log --reverse --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual && + test_cmp expect actual +' -EOF test_expect_success 'Shortlog output (complex mapping)' ' - echo three >>one && - git add one && - test_tick && - git commit --author "nick2 <bugs@company.xx>" -m third && - - echo four >>one && - git add one && - test_tick && - git commit --author "nick2 <nick2@company.xx>" -m fourth && - - echo five >>one && - git add one && - test_tick && - git commit --author "santa <me@company.xx>" -m fifth && - - echo six >>one && - git add one && - test_tick && - git commit --author "claus <me@company.xx>" -m sixth && - - echo seven >>one && - git add one && - test_tick && - git commit --author "CTO <cto@coompany.xx>" -m seventh && - - mkdir -p internal_mailmap && - echo "Committed <$GIT_COMMITTER_EMAIL>" > internal_mailmap/.mailmap && - echo "<cto@company.xx> <cto@coompany.xx>" >> internal_mailmap/.mailmap && - echo "Some Dude <some@dude.xx> nick1 <bugs@company.xx>" >> internal_mailmap/.mailmap && - echo "Other Author <other@author.xx> nick2 <bugs@company.xx>" >> internal_mailmap/.mailmap && - echo "Other Author <other@author.xx> <nick2@company.xx>" >> internal_mailmap/.mailmap && - echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap && - echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap && + test_config mailmap.file complex.map && + cat >complex.map <<-EOF && + Committed <$GIT_COMMITTER_EMAIL> + <cto@company.xx> <cto@coompany.xx> + Some Dude <some@dude.xx> nick1 <bugs@company.xx> + Other Author <other@author.xx> nick2 <bugs@company.xx> + Other Author <other@author.xx> <nick2@company.xx> + Santa Claus <santa.claus@northpole.xx> <me@company.xx> + EOF + + test_commit --author "nick2 <bugs@company.xx>" --append third one three && + test_commit --author "nick2 <nick2@company.xx>" --append fourth one four && + test_commit --author "santa <me@company.xx>" --append fifth one five && + test_commit --author "claus <me@company.xx>" --append sixth one six && + test_commit --author "CTO <cto@coompany.xx>" --append seventh one seven && + + cat >expect <<-EOF && + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1): + initial + + CTO <cto@company.xx> (1): + seventh + + Other Author <other@author.xx> (2): + third + fourth + + Santa Claus <santa.claus@northpole.xx> (2): + fifth + sixth + + Some Dude <some@dude.xx> (1): + second + + EOF git shortlog -e HEAD >actual && test_cmp expect actual ' -# git log with --pretty format which uses the name and email mailmap placemarkers -cat >expect << EOF -Author CTO <cto@coompany.xx> maps to CTO <cto@company.xx> -Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> +test_expect_success 'Log output (complex mapping)' ' + test_config mailmap.file complex.map && -Author claus <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx> -Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> + cat >expect <<-EOF && + Author CTO <cto@coompany.xx> maps to CTO <cto@company.xx> + Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> -Author santa <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx> -Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> + Author claus <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx> + Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> -Author nick2 <nick2@company.xx> maps to Other Author <other@author.xx> -Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> + Author santa <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx> + Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> -Author nick2 <bugs@company.xx> maps to Other Author <other@author.xx> -Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> + Author nick2 <nick2@company.xx> maps to Other Author <other@author.xx> + Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> -Author nick1 <bugs@company.xx> maps to Some Dude <some@dude.xx> -Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> + Author nick2 <bugs@company.xx> maps to Other Author <other@author.xx> + Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> -Author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> maps to $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> -Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> -EOF + Author nick1 <bugs@company.xx> maps to Some Dude <some@dude.xx> + Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> + + Author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> maps to $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> + Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> + EOF -test_expect_success 'Log output (complex mapping)' ' git log --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual && test_cmp expect actual ' -cat >expect << EOF -Author email cto@coompany.xx has local-part cto -Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME +test_expect_success 'Log output (local-part email address)' ' + cat >expect <<-EOF && + Author email cto@coompany.xx has local-part cto + Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME -Author email me@company.xx has local-part me -Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + Author email me@company.xx has local-part me + Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME -Author email me@company.xx has local-part me -Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + Author email me@company.xx has local-part me + Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME -Author email nick2@company.xx has local-part nick2 -Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + Author email nick2@company.xx has local-part nick2 + Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME -Author email bugs@company.xx has local-part bugs -Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + Author email bugs@company.xx has local-part bugs + Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME -Author email bugs@company.xx has local-part bugs -Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + Author email bugs@company.xx has local-part bugs + Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME -Author email author@example.com has local-part author -Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME -EOF + Author email author@example.com has local-part author + Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + EOF -test_expect_success 'Log output (local-part email address)' ' git log --pretty=format:"Author email %ae has local-part %al%nCommitter email %ce has local-part %cl%n" >actual && test_cmp expect actual ' -cat >expect << EOF -Author: CTO <cto@company.xx> -Author: Santa Claus <santa.claus@northpole.xx> -Author: Santa Claus <santa.claus@northpole.xx> -Author: Other Author <other@author.xx> -Author: Other Author <other@author.xx> -Author: Some Dude <some@dude.xx> -Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> -EOF - test_expect_success 'Log output with --use-mailmap' ' - git log --use-mailmap | grep Author >actual && + test_config mailmap.file complex.map && + + cat >expect <<-EOF && + Author: CTO <cto@company.xx> + Author: Santa Claus <santa.claus@northpole.xx> + Author: Santa Claus <santa.claus@northpole.xx> + Author: Other Author <other@author.xx> + Author: Other Author <other@author.xx> + Author: Some Dude <some@dude.xx> + Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> + EOF + + git log --use-mailmap >log && + grep Author log >actual && test_cmp expect actual ' -cat >expect << EOF -Author: CTO <cto@company.xx> -Author: Santa Claus <santa.claus@northpole.xx> -Author: Santa Claus <santa.claus@northpole.xx> -Author: Other Author <other@author.xx> -Author: Other Author <other@author.xx> -Author: Some Dude <some@dude.xx> -Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> -EOF - test_expect_success 'Log output with log.mailmap' ' - git -c log.mailmap=True log | grep Author >actual && + test_config mailmap.file complex.map && + + cat >expect <<-EOF && + Author: CTO <cto@company.xx> + Author: Santa Claus <santa.claus@northpole.xx> + Author: Santa Claus <santa.claus@northpole.xx> + Author: Other Author <other@author.xx> + Author: Other Author <other@author.xx> + Author: Some Dude <some@dude.xx> + Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> + EOF + + git -c log.mailmap=True log >log && + grep Author log >actual && test_cmp expect actual ' test_expect_success 'log.mailmap=false disables mailmap' ' - cat >expect <<- EOF && + cat >expect <<-EOF && Author: CTO <cto@coompany.xx> Author: claus <me@company.xx> Author: santa <me@company.xx> @@ -480,12 +670,13 @@ test_expect_success 'log.mailmap=false disables mailmap' ' Author: nick1 <bugs@company.xx> Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> EOF - git -c log.mailmap=False log | grep Author > actual && + git -c log.mailmap=false log >log && + grep Author log >actual && test_cmp expect actual ' test_expect_success '--no-use-mailmap disables mailmap' ' - cat >expect <<- EOF && + cat >expect <<-EOF && Author: CTO <cto@coompany.xx> Author: claus <me@company.xx> Author: santa <me@company.xx> @@ -494,64 +685,282 @@ test_expect_success '--no-use-mailmap disables mailmap' ' Author: nick1 <bugs@company.xx> Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> EOF - git log --no-use-mailmap | grep Author > actual && + git log --no-use-mailmap >log && + grep Author log >actual && test_cmp expect actual ' -cat >expect <<\EOF -Author: Santa Claus <santa.claus@northpole.xx> -Author: Santa Claus <santa.claus@northpole.xx> -EOF - test_expect_success 'Grep author with --use-mailmap' ' - git log --use-mailmap --author Santa | grep Author >actual && + test_config mailmap.file complex.map && + + cat >expect <<-\EOF && + Author: Santa Claus <santa.claus@northpole.xx> + Author: Santa Claus <santa.claus@northpole.xx> + EOF + git log --use-mailmap --author Santa >log && + grep Author log >actual && test_cmp expect actual ' -cat >expect <<\EOF -Author: Santa Claus <santa.claus@northpole.xx> -Author: Santa Claus <santa.claus@northpole.xx> -EOF test_expect_success 'Grep author with log.mailmap' ' - git -c log.mailmap=True log --author Santa | grep Author >actual && + test_config mailmap.file complex.map && + + cat >expect <<-\EOF && + Author: Santa Claus <santa.claus@northpole.xx> + Author: Santa Claus <santa.claus@northpole.xx> + EOF + + git -c log.mailmap=True log --author Santa >log && + grep Author log >actual && test_cmp expect actual ' test_expect_success 'log.mailmap is true by default these days' ' - git log --author Santa | grep Author >actual && + test_config mailmap.file complex.map && + git log --author Santa >log && + grep Author log >actual && test_cmp expect actual ' test_expect_success 'Only grep replaced author with --use-mailmap' ' + test_config mailmap.file complex.map && git log --use-mailmap --author "<cto@coompany.xx>" >actual && test_must_be_empty actual ' -# git blame -cat >expect <<EOF -^OBJI ($GIT_AUTHOR_NAME DATE 1) one -OBJID (Some Dude DATE 2) two -OBJID (Other Author DATE 3) three -OBJID (Other Author DATE 4) four -OBJID (Santa Claus DATE 5) five -OBJID (Santa Claus DATE 6) six -OBJID (CTO DATE 7) seven -EOF -test_expect_success 'Blame output (complex mapping)' ' - git blame one >actual && - fuzz_blame actual >actual.fuzz && +test_expect_success 'Blame --porcelain output (complex mapping)' ' + test_config mailmap.file complex.map && + + cat >expect <<-EOF && + 1 1 1 + A U Thor + 2 2 1 + Some Dude + 3 3 1 + Other Author + 4 4 1 + Other Author + 5 5 1 + Santa Claus + 6 6 1 + Santa Claus + 7 7 1 + CTO + EOF + + git blame --porcelain one >actual.blame && + + NUM="[0-9][0-9]*" && + sed -n <actual.blame >actual.fuzz \ + -e "s/^author //p" \ + -e "s/^$OID_REGEX \\($NUM $NUM $NUM\\)$/\\1/p" && test_cmp expect actual.fuzz ' -cat >expect <<\EOF -Some Dude <some@dude.xx> -EOF +test_expect_success 'Blame output (complex mapping)' ' + git -c mailmap.file=complex.map blame one >a && + git blame one >b && + test_file_not_empty a && + ! cmp a b +' test_expect_success 'commit --author honors mailmap' ' + test_config mailmap.file complex.map && + + cat >expect <<-\EOF && + Some Dude <some@dude.xx> + EOF + test_must_fail git commit --author "nick" --allow-empty -meight && git commit --author "Some Dude" --allow-empty -meight && git show --pretty=format:"%an <%ae>%n" >actual && test_cmp expect actual ' +test_expect_success 'comment syntax: setup' ' + test_create_repo comm && + test_commit -C comm --author "A <a@example.com>" A && + test_commit -C comm --author "B <b@example.com>" B && + test_commit -C comm --author "C <#@example.com>" C && + test_commit -C comm --author "D <d@e#ample.com>" D && + + test_config -C comm mailmap.file ../doc.map && + cat >>doc.map <<-\EOF && + # Ah <a@example.com> + + ; Bee <b@example.com> + Cee <cee@example.com> <#@example.com> + Dee <dee@example.com> <d@e#ample.com> + EOF + + cat >expect <<-\EOF && + Author A <a@example.com> maps to A <a@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author B <b@example.com> maps to ; Bee <b@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author C <#@example.com> maps to Cee <cee@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author D <d@e#ample.com> maps to Dee <dee@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + EOF + git -C comm log --reverse --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual && + test_cmp expect actual +' + +test_expect_success 'whitespace syntax: setup' ' + test_create_repo space && + test_commit -C space --author "A <a@example.com>" A && + test_commit -C space --author "B <b@example.com>" B && + test_commit -C space --author " C <c@example.com>" C && + test_commit -C space --author " D <d@example.com>" D && + test_commit -C space --author "E E <e@example.com>" E && + test_commit -C space --author "F F <f@example.com>" F && + test_commit -C space --author "G G <g@example.com>" G && + test_commit -C space --author "H H <h@example.com>" H && + + test_config -C space mailmap.file ../space.map && + cat >>space.map <<-\EOF && + Ah <ah@example.com> < a@example.com > + Bee <bee@example.com > < b@example.com > + Cee <cee@example.com> C <c@example.com> + dee <dee@example.com> D <d@example.com> + eee <eee@example.com> E E <e@example.com> + eff <eff@example.com> F F <f@example.com> + gee <gee@example.com> G G <g@example.com> + aitch <aitch@example.com> H H <h@example.com> + EOF + + cat >expect <<-\EOF && + Author A <a@example.com> maps to A <a@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author B <b@example.com> maps to B <b@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author C <c@example.com> maps to Cee <cee@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author D <d@example.com> maps to dee <dee@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author E E <e@example.com> maps to eee <eee@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author F F <f@example.com> maps to eff <eff@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author G G <g@example.com> maps to gee <gee@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author H H <h@example.com> maps to H H <h@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + EOF + git -C space log --reverse --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual && + test_cmp expect actual +' + +test_expect_success 'empty syntax: setup' ' + test_create_repo empty && + test_commit -C empty --author "A <>" A && + test_commit -C empty --author "B <b@example.com>" B && + test_commit -C empty --author "C <c@example.com>" C && + + test_config -C empty mailmap.file ../empty.map && + cat >>empty.map <<-\EOF && + Ah <ah@example.com> <> + Bee <bee@example.com> <> + Cee <> <c@example.com> + EOF + + cat >expect <<-\EOF && + Author A <> maps to Bee <bee@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author B <b@example.com> maps to B <b@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + + Author C <c@example.com> maps to C <c@example.com> + Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com> + EOF + git -C empty log --reverse --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual && + test_cmp expect actual +' + +test_expect_success 'set up mailmap location tests' ' + git init --bare loc-bare && + git --git-dir=loc-bare --work-tree=. commit \ + --allow-empty -m foo --author="Orig <orig@example.com>" && + echo "New <new@example.com> <orig@example.com>" >loc-bare/.mailmap +' + +test_expect_success 'bare repo with --work-tree finds mailmap at top-level' ' + git -C loc-bare --work-tree=. log -1 --format=%aE >actual && + echo new@example.com >expect && + test_cmp expect actual +' + +test_expect_success 'bare repo does not look in current directory' ' + git -C loc-bare log -1 --format=%aE >actual && + echo orig@example.com >expect && + test_cmp expect actual +' + +test_expect_success 'non-git shortlog respects mailmap in current dir' ' + git --git-dir=loc-bare log -1 >input && + nongit cp "$TRASH_DIRECTORY/loc-bare/.mailmap" . && + nongit git shortlog -s <input >actual && + echo " 1 New" >expect && + test_cmp expect actual +' + +test_expect_success 'shortlog on stdin respects mailmap from repo' ' + cp loc-bare/.mailmap . && + git shortlog -s <input >actual && + echo " 1 New" >expect && + test_cmp expect actual +' + +test_expect_success 'find top-level mailmap from subdir' ' + git clone loc-bare loc-wt && + cp loc-bare/.mailmap loc-wt && + mkdir loc-wt/subdir && + git -C loc-wt/subdir log -1 --format=%aE >actual && + echo new@example.com >expect && + test_cmp expect actual +' + +test_expect_success SYMLINKS 'set up symlink tests' ' + git commit --allow-empty -m foo --author="Orig <orig@example.com>" && + echo "New <new@example.com> <orig@example.com>" >map && + rm -f .mailmap +' + +test_expect_success SYMLINKS 'symlinks respected in mailmap.file' ' + test_when_finished "rm symlink" && + ln -s map symlink && + git -c mailmap.file="$(pwd)/symlink" log -1 --format=%aE >actual && + echo "new@example.com" >expect && + test_cmp expect actual +' + +test_expect_success SYMLINKS 'symlinks respected in non-repo shortlog' ' + git log -1 >input && + test_when_finished "nongit rm .mailmap" && + nongit ln -sf "$TRASH_DIRECTORY/map" .mailmap && + nongit git shortlog -s <input >actual && + echo " 1 New" >expect && + test_cmp expect actual +' + +test_expect_success SYMLINKS 'symlinks not respected in-tree' ' + test_when_finished "rm .mailmap" && + ln -s map .mailmap && + git log -1 --format=%aE >actual && + echo "orig@example.com" >expect&& + test_cmp expect actual +' + test_done diff --git a/t/t4204-patch-id.sh b/t/t4204-patch-id.sh index 8ff8bd84c7..f120857c20 100755 --- a/t/t4204-patch-id.sh +++ b/t/t4204-patch-id.sh @@ -2,6 +2,9 @@ test_description='git patch-id' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -13,9 +16,9 @@ test_expect_success 'setup' ' test_write_lines $as b >foo && test_write_lines $as b >bar && git commit -a -m first && - git checkout -b same master && + git checkout -b same main && git commit --amend -m same-msg && - git checkout -b notsame master && + git checkout -b notsame main && echo c >foo && echo c >bar && git commit --amend -a -m notsame-msg && @@ -46,31 +49,31 @@ get_patch_id () { } test_expect_success 'patch-id detects equality' ' - get_patch_id master && + get_patch_id main && get_patch_id same && - test_cmp patch-id_master patch-id_same + test_cmp patch-id_main patch-id_same ' test_expect_success 'patch-id detects inequality' ' - get_patch_id master && + get_patch_id main && get_patch_id notsame && - ! test_cmp patch-id_master patch-id_notsame + ! test_cmp patch-id_main patch-id_notsame ' test_expect_success 'patch-id supports git-format-patch output' ' - get_patch_id master && + get_patch_id main && git checkout same && git format-patch -1 --stdout | calc_patch_id same && - test_cmp patch-id_master patch-id_same && + test_cmp patch-id_main patch-id_same && set $(git format-patch -1 --stdout | git patch-id) && test "$2" = $(git rev-parse HEAD) ' test_expect_success 'whitespace is irrelevant in footer' ' - get_patch_id master && + get_patch_id main && git checkout same && git format-patch -1 --stdout | sed "s/ \$//" | calc_patch_id same && - test_cmp patch-id_master patch-id_same + test_cmp patch-id_main patch-id_same ' cmp_patch_id () { @@ -88,7 +91,7 @@ test_patch_id_file_order () { shift name="order-${1}-$relevant" shift - get_top_diff "master" | calc_patch_id "$name" "$@" && + get_top_diff "main" | calc_patch_id "$name" "$@" && git checkout same && git format-patch -1 --stdout -O foo-then-bar | calc_patch_id "ordered-$name" "$@" && @@ -137,10 +140,10 @@ test_expect_success '--stable overrides patchid.stable = false' ' ' test_expect_success 'patch-id supports git-format-patch MIME output' ' - get_patch_id master && + get_patch_id main && git checkout same && git format-patch -1 --attach --stdout | calc_patch_id same && - test_cmp patch-id_master patch-id_same + test_cmp patch-id_main patch-id_same ' test_expect_success 'patch-id respects config from subdir' ' diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 204c149d5a..8272d94ce6 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -123,10 +123,10 @@ test_expect_success 'NUL separation with --stat' ' stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) && printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected && git log -z --stat --pretty="format:%s" >actual && - test_i18ncmp expected actual + test_cmp expected actual ' -test_expect_failure C_LOCALE_OUTPUT 'NUL termination with --stat' ' +test_expect_failure 'NUL termination with --stat' ' stat0_part=$(git diff --stat HEAD^ HEAD) && stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) && printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected && @@ -525,20 +525,25 @@ test_expect_success 'strbuf_utf8_replace() not producing NUL' ' ! grep Q actual ' -# ISO strict date format -test_expect_success 'ISO and ISO-strict date formats display the same values' ' - git log --format=%ai%n%ci | - sed -e "s/ /T/; s/ //; s/..\$/:&/" >expected && +# --date=[XXX] and corresponding %a[X] %c[X] format equivalency +test_expect_success '--date=iso-strict %ad%cd is the same as %aI%cI' ' + git log --format=%ad%n%cd --date=iso-strict >expected && git log --format=%aI%n%cI >actual && test_cmp expected actual ' -test_expect_success 'short date' ' +test_expect_success '--date=short %ad%cd is the same as %as%cs' ' git log --format=%ad%n%cd --date=short >expected && git log --format=%as%n%cs >actual && test_cmp expected actual ' +test_expect_success '--date=human %ad%cd is the same as %ah%ch' ' + git log --format=%ad%n%cd --date=human >expected && + git log --format=%ah%n%ch >actual && + test_cmp expected actual +' + # get new digests (with no abbreviations) test_expect_success 'set up log decoration tests' ' head1=$(git rev-parse --verify HEAD~0) && @@ -605,6 +610,12 @@ test_expect_success 'pretty format %(trailers) shows trailers' ' test_cmp expect actual ' +test_expect_success 'pretty format %(trailers:) enables no options' ' + git log --no-walk --pretty="%(trailers:)" >actual && + # "expect" the same as the test above + test_cmp expect actual +' + test_expect_success '%(trailers:only) shows only "key: value" trailers' ' git log --no-walk --pretty="%(trailers:only)" >actual && { @@ -709,19 +720,101 @@ test_expect_success '%(trailers:key) without value is error' ' test_cmp expect actual ' +test_expect_success '%(trailers:keyonly) shows only keys' ' + git log --no-walk --pretty="format:%(trailers:keyonly)" >actual && + test_write_lines \ + "Signed-off-by" \ + "Acked-by" \ + "[ v2 updated patch description ]" \ + "Signed-off-by" >expect && + test_cmp expect actual +' + +test_expect_success '%(trailers:key=foo,keyonly) shows only key' ' + git log --no-walk --pretty="format:%(trailers:key=Acked-by,keyonly)" >actual && + echo "Acked-by" >expect && + test_cmp expect actual +' + test_expect_success '%(trailers:key=foo,valueonly) shows only value' ' git log --no-walk --pretty="format:%(trailers:key=Acked-by,valueonly)" >actual && echo "A U Thor <author@example.com>" >expect && test_cmp expect actual ' +test_expect_success '%(trailers:valueonly) shows only values' ' + git log --no-walk --pretty="format:%(trailers:valueonly)" >actual && + test_write_lines \ + "A U Thor <author@example.com>" \ + "A U Thor <author@example.com>" \ + "[ v2 updated patch description ]" \ + "A U Thor" \ + " <author@example.com>" >expect && + test_cmp expect actual +' + +test_expect_success '%(trailers:key=foo,keyonly,valueonly) shows nothing' ' + git log --no-walk --pretty="format:%(trailers:key=Acked-by,keyonly,valueonly)" >actual && + echo >expect && + test_cmp expect actual +' + test_expect_success 'pretty format %(trailers:separator) changes separator' ' + git log --no-walk --pretty=format:"X%(trailers:separator=%x00)X" >actual && + ( + printf "XSigned-off-by: A U Thor <author@example.com>\0" && + printf "Acked-by: A U Thor <author@example.com>\0" && + printf "[ v2 updated patch description ]\0" && + printf "Signed-off-by: A U Thor\n <author@example.com>X" + ) >expect && + test_cmp expect actual +' + +test_expect_success 'pretty format %(trailers:separator=X,unfold) changes separator' ' git log --no-walk --pretty=format:"X%(trailers:separator=%x00,unfold)X" >actual && - printf "XSigned-off-by: A U Thor <author@example.com>\0Acked-by: A U Thor <author@example.com>\0[ v2 updated patch description ]\0Signed-off-by: A U Thor <author@example.com>X" >expect && + ( + printf "XSigned-off-by: A U Thor <author@example.com>\0" && + printf "Acked-by: A U Thor <author@example.com>\0" && + printf "[ v2 updated patch description ]\0" && + printf "Signed-off-by: A U Thor <author@example.com>X" + ) >expect && test_cmp expect actual ' -test_expect_success 'pretty format %(trailers) combining separator/key/valueonly' ' +test_expect_success 'pretty format %(trailers:key_value_separator) changes key-value separator' ' + git log --no-walk --pretty=format:"X%(trailers:key_value_separator=%x00)X" >actual && + ( + printf "XSigned-off-by\0A U Thor <author@example.com>\n" && + printf "Acked-by\0A U Thor <author@example.com>\n" && + printf "[ v2 updated patch description ]\n" && + printf "Signed-off-by\0A U Thor\n <author@example.com>\nX" + ) >expect && + test_cmp expect actual +' + +test_expect_success 'pretty format %(trailers:key_value_separator,unfold) changes key-value separator' ' + git log --no-walk --pretty=format:"X%(trailers:key_value_separator=%x00,unfold)X" >actual && + ( + printf "XSigned-off-by\0A U Thor <author@example.com>\n" && + printf "Acked-by\0A U Thor <author@example.com>\n" && + printf "[ v2 updated patch description ]\n" && + printf "Signed-off-by\0A U Thor <author@example.com>\nX" + ) >expect && + test_cmp expect actual +' + +test_expect_success 'pretty format %(trailers:separator,key_value_separator) changes both separators' ' + git log --no-walk --pretty=format:"%(trailers:separator=%x00,key_value_separator=%x00%x00,unfold)" >actual && + ( + printf "Signed-off-by\0\0A U Thor <author@example.com>\0" && + printf "Acked-by\0\0A U Thor <author@example.com>\0" && + printf "[ v2 updated patch description ]\0" && + printf "Signed-off-by\0\0A U Thor <author@example.com>" + ) >expect && + test_cmp expect actual +' + +test_expect_success 'pretty format %(trailers) combining separator/key/keyonly/valueonly' ' git commit --allow-empty -F - <<-\EOF && Important fix @@ -748,6 +841,13 @@ test_expect_success 'pretty format %(trailers) combining separator/key/valueonly "Does not close any tickets" \ "Another fix #567, #890" \ "Important fix #1234" >expect && + test_cmp expect actual && + + git log --pretty="%s% (trailers:separator=%x2c%x20,key=Closes,keyonly)" HEAD~3.. >actual && + test_write_lines \ + "Does not close any tickets" \ + "Another fix Closes, Closes" \ + "Important fix Closes" >expect && test_cmp expect actual ' @@ -867,4 +967,39 @@ test_expect_success 'log --pretty=reference is colored appropriately' ' test_cmp expect actual ' +test_expect_success '%(describe) vs git describe' ' + git log --format="%H" | while read hash + do + if desc=$(git describe $hash) + then + : >expect-contains-good + else + : >expect-contains-bad + fi && + echo "$hash $desc" + done >expect && + test_path_exists expect-contains-good && + test_path_exists expect-contains-bad && + + git log --format="%H %(describe)" >actual 2>err && + test_cmp expect actual && + test_must_be_empty err +' + +test_expect_success '%(describe:match=...) vs git describe --match ...' ' + test_when_finished "git tag -d tag-match" && + git tag -a -m tagged tag-match&& + git describe --match "*-match" >expect && + git log -1 --format="%(describe:match=*-match)" >actual && + test_cmp expect actual +' + +test_expect_success '%(describe:exclude=...) vs git describe --exclude ...' ' + test_when_finished "git tag -d tag-exclude" && + git tag -a -m tagged tag-exclude && + git describe --exclude "*-exclude" >expect && + git log -1 --format="%(describe:exclude=*-exclude)" >actual && + test_cmp expect actual +' + test_done diff --git a/t/t4206-log-follow-harder-copies.sh b/t/t4206-log-follow-harder-copies.sh index ad29e65fcb..4871a5dc92 100755 --- a/t/t4206-log-follow-harder-copies.sh +++ b/t/t4206-log-follow-harder-copies.sh @@ -7,7 +7,7 @@ test_description='Test --follow should always find copies hard in git log. ' . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh +. "$TEST_DIRECTORY"/lib-diff.sh echo >path0 'Line 1 Line 2 diff --git a/t/t4207-log-decoration-colors.sh b/t/t4207-log-decoration-colors.sh index 60f040cab8..b870942498 100755 --- a/t/t4207-log-decoration-colors.sh +++ b/t/t4207-log-decoration-colors.sh @@ -5,6 +5,9 @@ test_description='Test for "git log --decorate" colors' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -40,13 +43,13 @@ test_expect_success setup ' cat >expected <<EOF ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD ->\ - ${c_reset}${c_branch}master${c_reset}${c_commit},\ + ${c_reset}${c_branch}main${c_reset}${c_commit},\ ${c_reset}${c_tag}tag: v1.0${c_reset}${c_commit},\ ${c_reset}${c_tag}tag: B${c_reset}${c_commit})${c_reset} B ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A1${c_reset}${c_commit},\ - ${c_reset}${c_remoteBranch}other/master${c_reset}${c_commit})${c_reset} A1 + ${c_reset}${c_remoteBranch}other/main${c_reset}${c_commit})${c_reset} A1 ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_stash}refs/stash${c_reset}${c_commit})${c_reset}\ - On master: Changes to A.t + On main: Changes to A.t ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A${c_reset}${c_commit})${c_reset} A EOF diff --git a/t/t4208-log-magic-pathspec.sh b/t/t4208-log-magic-pathspec.sh index 6cdbe4747a..7f0c1dcc0f 100755 --- a/t/t4208-log-magic-pathspec.sh +++ b/t/t4208-log-magic-pathspec.sh @@ -2,6 +2,9 @@ test_description='magic pathspec tests using git-log' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -26,15 +29,10 @@ test_expect_success '"git log :/a -- " should not be ambiguous' ' ' test_expect_success '"git log :/detached -- " should find a commit only in HEAD' ' - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && git checkout --detach && - # Must manually call `test_tick` instead of using `test_commit`, - # because the latter additionally creates a tag, which would make - # the commit reachable not only via HEAD. - test_tick && - git commit --allow-empty -m detached && - test_tick && - git commit --allow-empty -m something-else && + test_commit --no-tag detached && + test_commit --no-tag something-else && git log :/detached -- ' @@ -119,7 +117,7 @@ test_expect_success 'command line pathspec parsing for "git log"' ' git checkout HEAD^ && echo 2 >a && git commit -a -m "update a to 2" && - test_must_fail git merge master && + test_must_fail git merge main && git add a && git log --merge -- a ' diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh index 85d151423d..560127cc07 100755 --- a/t/t4211-line-log.sh +++ b/t/t4211-line-log.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='test log -L' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup (import history)' ' diff --git a/t/t4211/history.export b/t/t4211/history.export index f9f41e211e..006972a1f2 100644 --- a/t/t4211/history.export +++ b/t/t4211/history.export @@ -316,7 +316,7 @@ long f(long x) return s; } -commit refs/heads/master +commit refs/heads/main mark :19 author Thomas Rast <trast@student.ethz.ch> 1362045024 +0100 committer Thomas Rast <trast@student.ethz.ch> 1362045024 +0100 diff --git a/t/t4214-log-graph-octopus.sh b/t/t4214-log-graph-octopus.sh index a080325098..f70c46bbbf 100755 --- a/t/t4214-log-graph-octopus.sh +++ b/t/t4214-log-graph-octopus.sh @@ -2,6 +2,9 @@ test_description='git log --graph of skewed left octopus merge.' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-log-graph.sh @@ -17,7 +20,7 @@ test_cmp_colored_graph () { test_expect_success 'set up merge history' ' test_commit initial && for i in 1 2 3 4 ; do - git checkout master -b $i || return $? + git checkout main -b $i || return $? # Make tag name different from branch name, to avoid # ambiguity error when calling checkout. test_commit $i $i $i tag$i || return $? diff --git a/t/t4216-log-bloom.sh b/t/t4216-log-bloom.sh index d11040ce41..50f206db55 100755 --- a/t/t4216-log-bloom.sh +++ b/t/t4216-log-bloom.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='git log for a path with Bloom filters' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh GIT_TEST_COMMIT_GRAPH=0 @@ -21,7 +24,7 @@ test_expect_success 'setup test - repo, commits, commit graph, log outputs' ' test_commit c10 file_to_be_deleted && git checkout -b side HEAD~4 && test_commit side-1 file4 && - git checkout master && + git checkout main && git merge side && test_commit c11 file5 && mv file5 file5_renamed && @@ -40,11 +43,11 @@ test_expect_success 'setup test - repo, commits, commit graph, log outputs' ' ' graph_read_expect () { - NUM_CHUNKS=5 + NUM_CHUNKS=6 cat >expect <<- EOF header: 43475048 1 $(test_oid oid_version) $NUM_CHUNKS 0 num_commits: $1 - chunks: oid_fanout oid_lookup commit_metadata bloom_indexes bloom_data + chunks: oid_fanout oid_lookup commit_metadata generation_data bloom_indexes bloom_data EOF test-tool read-graph >actual && test_cmp expect actual @@ -94,7 +97,7 @@ do "--topo-order" \ "--date-order" \ "--author-date-order" \ - "--ancestry-path side..master" + "--ancestry-path side..main" do test_expect_success "git log option: $option for path: $path" ' test_bloom_filters_used "$option -- $path" && diff --git a/t/t4253-am-keep-cr-dos.sh b/t/t4253-am-keep-cr-dos.sh index 6e1b73ec3a..0ee69d2a0c 100755 --- a/t/t4253-am-keep-cr-dos.sh +++ b/t/t4253-am-keep-cr-dos.sh @@ -6,6 +6,9 @@ test_description='git-am mbox with dos line ending. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # Three patches which will be added as files with dos line ending. @@ -43,7 +46,7 @@ test_expect_success 'setup repository with dos files' ' test_expect_success 'am with dos files without --keep-cr' ' git checkout -b dosfiles initial && - git format-patch -k initial..master && + git format-patch -k initial..main && test_must_fail git am -k -3 000*.patch && git am --abort && rm -rf .git/rebase-apply 000*.patch @@ -51,23 +54,23 @@ test_expect_success 'am with dos files without --keep-cr' ' test_expect_success 'am with dos files with --keep-cr' ' git checkout -b dosfiles-keep-cr initial && - git format-patch -k --stdout initial..master >output && + git format-patch -k --stdout initial..main >output && git am --keep-cr -k -3 output && - git diff --exit-code master + git diff --exit-code main ' test_expect_success 'am with dos files config am.keepcr' ' git config am.keepcr 1 && git checkout -b dosfiles-conf-keepcr initial && - git format-patch -k --stdout initial..master >output && + git format-patch -k --stdout initial..main >output && git am -k -3 output && - git diff --exit-code master + git diff --exit-code main ' test_expect_success 'am with dos files config am.keepcr overridden by --no-keep-cr' ' git config am.keepcr 1 && git checkout -b dosfiles-conf-keepcr-override initial && - git format-patch -k initial..master && + git format-patch -k initial..main && test_must_fail git am -k -3 --no-keep-cr 000*.patch && git am --abort && rm -rf .git/rebase-apply 000*.patch @@ -75,14 +78,14 @@ test_expect_success 'am with dos files config am.keepcr overridden by --no-keep- test_expect_success 'am with dos files with --keep-cr continue' ' git checkout -b dosfiles-keep-cr-continue initial && - git format-patch -k initial..master && + git format-patch -k initial..main && append_cr <file1a >file && git commit -m "different patch" file && test_must_fail git am --keep-cr -k -3 000*.patch && append_cr <file2 >file && git add file && git am -3 --resolved && - git diff --exit-code master + git diff --exit-code main ' test_expect_success 'am with unix files config am.keepcr overridden by --no-keep-cr' ' @@ -90,9 +93,9 @@ test_expect_success 'am with unix files config am.keepcr overridden by --no-keep git checkout -b unixfiles-conf-keepcr-override initial && cp -f file1 file && git commit -m "line ending to unix" file && - git format-patch -k initial..master && + git format-patch -k initial..main && git am -k -3 --no-keep-cr 000*.patch && - git diff --exit-code -w master + git diff --exit-code -w main ' test_done diff --git a/t/t4254-am-corrupt.sh b/t/t4254-am-corrupt.sh index daf01c309d..54be7da161 100755 --- a/t/t4254-am-corrupt.sh +++ b/t/t4254-am-corrupt.sh @@ -60,7 +60,7 @@ test_expect_success 'try to apply corrupted patch' ' test_must_fail git -c advice.amWorkDir=false am bad-patch.diff 2>actual && echo "error: git diff header lacks filename information (line 4)" >expected && test_path_is_file f && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success "NUL in commit message's body" ' diff --git a/t/t4257-am-interactive.sh b/t/t4257-am-interactive.sh index 5344bd248a..aed8f4de3d 100755 --- a/t/t4257-am-interactive.sh +++ b/t/t4257-am-interactive.sh @@ -10,7 +10,7 @@ test_expect_success 'set up patches to apply' ' git format-patch --stdout -2 >mbox && git reset --hard unrelated && - test_commit conflict-master file master base + test_commit conflict-main file main base ' # Sanity check our setup. diff --git a/t/t4258-am-quoted-cr.sh b/t/t4258-am-quoted-cr.sh new file mode 100755 index 0000000000..fb5071f914 --- /dev/null +++ b/t/t4258-am-quoted-cr.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +test_description='test am --quoted-cr=<action>' + +. ./test-lib.sh + +DATA="$TEST_DIRECTORY/t4258" + +test_expect_success 'setup' ' + test_write_lines one two three >text && + test_commit one text && + test_write_lines one owt three >text && + test_commit two text +' + +test_expect_success 'am warn if quoted-cr is found' ' + git reset --hard one && + test_must_fail git am "$DATA/mbox" 2>err && + grep "quoted CRLF detected" err +' + +test_expect_success 'am --quoted-cr=strip' ' + test_might_fail git am --abort && + git reset --hard one && + git am --quoted-cr=strip "$DATA/mbox" && + git diff --exit-code HEAD two +' + +test_expect_success 'am with config mailinfo.quotecr=strip' ' + test_might_fail git am --abort && + git reset --hard one && + test_config mailinfo.quotedCr strip && + git am "$DATA/mbox" && + git diff --exit-code HEAD two +' + +test_done diff --git a/t/t4258/mbox b/t/t4258/mbox new file mode 100644 index 0000000000..c62819f3d2 --- /dev/null +++ b/t/t4258/mbox @@ -0,0 +1,12 @@ +From: A U Thor <mail@example.com> +To: list@example.org +Subject: [PATCH v2] sample +Date: Mon, 3 Aug 2020 22:40:55 +0700 +Message-Id: <msg-id@example.com> +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: base64 + +VGhpcyBpcyBjb21taXQgbWVzc2FnZS4NCi0tLQ0KIHRleHQgfCAyICstDQogMSBmaWxlIGNoYW5n +ZWQsIDEgaW5zZXJ0aW9uKCspLCAxIGRlbGV0aW9uKC0pDQoNCmRpZmYgLS1naXQgYS90ZXh0IGIv +dGV4dA0KaW5kZXggNTYyNmFiZi4uZjcxOWVmZCAxMDA2NDQNCi0tLSBhL3RleHQNCisrKyBiL3Rl +eHQNCkBAIC0xICsxIEBADQotb25lDQordHdvDQotLSANCjIuMzEuMQoK diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index 3ebb0d3b65..7204799a0b 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -431,15 +431,33 @@ test_expect_success TAR_HUGE,LONG_IS_64BIT 'system tar can read our huge size' ' test_cmp expect actual ' -test_expect_success TIME_IS_64BIT 'set up repository with far-future commit' ' +test_expect_success TIME_IS_64BIT 'set up repository with far-future (2^34 - 1) commit' ' + rm -f .git/index && + echo foo >file && + git add file && + GIT_COMMITTER_DATE="@17179869183 +0000" \ + git commit -m "tempori parendum" +' + +test_expect_success TIME_IS_64BIT 'generate tar with far-future mtime' ' + git archive HEAD >future.tar +' + +test_expect_success TAR_HUGE,TIME_IS_64BIT,TIME_T_IS_64BIT 'system tar can read our future mtime' ' + echo 2514 >expect && + tar_info future.tar | cut -d" " -f2 >actual && + test_cmp expect actual +' + +test_expect_success TIME_IS_64BIT 'set up repository with far-far-future (2^36 + 1) commit' ' rm -f .git/index && echo content >file && git add file && - GIT_COMMITTER_DATE="@68719476737 +0000" \ + GIT_TEST_COMMIT_GRAPH=0 GIT_COMMITTER_DATE="@68719476737 +0000" \ git commit -m "tempori parendum" ' -test_expect_success TIME_IS_64BIT 'generate tar with future mtime' ' +test_expect_success TIME_IS_64BIT 'generate tar with far-far-future mtime' ' git archive HEAD >future.tar ' diff --git a/t/t5001-archive-attr.sh b/t/t5001-archive-attr.sh index e9aa97117a..712ae52299 100755 --- a/t/t5001-archive-attr.sh +++ b/t/t5001-archive-attr.sh @@ -128,4 +128,18 @@ test_expect_success 'export-subst' ' test_cmp substfile2 archive/substfile2 ' +test_expect_success 'export-subst expands %(describe) once' ' + echo "\$Format:%(describe)\$" >substfile3 && + echo "\$Format:%(describe)\$" >>substfile3 && + echo "\$Format:%(describe)${LF}%(describe)\$" >substfile4 && + git add substfile[34] && + git commit -m export-subst-describe && + git tag -m export-subst-describe export-subst-describe && + git archive HEAD >archive-describe.tar && + extract_tar_to_dir archive-describe && + desc=$(git describe) && + grep -F "$desc" archive-describe/substfile[34] >substituted && + test_line_count = 1 substituted +' + test_done diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh index 3e7b23cb32..2d32d0ed12 100755 --- a/t/t5004-archive-corner-cases.sh +++ b/t/t5004-archive-corner-cases.sh @@ -153,7 +153,8 @@ test_expect_success ZIPINFO 'zip archive with many entries' ' # check the number of entries in the ZIP file directory expr 65536 + 256 >expect && - "$ZIPINFO" many.zip | head -2 | sed -n "2s/.* //p" >actual && + "$ZIPINFO" -h many.zip >zipinfo && + sed -n "2s/.* //p" <zipinfo >actual && test_cmp expect actual ' diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh index 147e616533..141b29f031 100755 --- a/t/t5100-mailinfo.sh +++ b/t/t5100-mailinfo.sh @@ -228,4 +228,44 @@ test_expect_success 'mailinfo handles unusual header whitespace' ' test_cmp expect actual ' +check_quoted_cr_mail () { + mail="$1" && shift && + git mailinfo -u "$@" "$mail.msg" "$mail.patch" \ + <"$mail" >"$mail.info" 2>"$mail.err" && + test_cmp "$mail-expected.msg" "$mail.msg" && + test_cmp "$mail-expected.patch" "$mail.patch" && + test_cmp "$DATA/quoted-cr-info" "$mail.info" +} + +test_expect_success 'split base64 email with quoted-cr' ' + mkdir quoted-cr && + git mailsplit -oquoted-cr "$DATA/quoted-cr.mbox" >quoted-cr/last && + test $(cat quoted-cr/last) = 2 +' + +test_expect_success 'mailinfo warn CR in base64 encoded email' ' + sed -e "s/%%$//" -e "s/%%/$(printf \\015)/g" "$DATA/quoted-cr-msg" \ + >quoted-cr/0001-expected.msg && + sed "s/%%/$(printf \\015)/g" "$DATA/quoted-cr-msg" \ + >quoted-cr/0002-expected.msg && + sed -e "s/%%$//" -e "s/%%/$(printf \\015)/g" "$DATA/quoted-cr-patch" \ + >quoted-cr/0001-expected.patch && + sed "s/%%/$(printf \\015)/g" "$DATA/quoted-cr-patch" \ + >quoted-cr/0002-expected.patch && + check_quoted_cr_mail quoted-cr/0001 && + test_must_be_empty quoted-cr/0001.err && + check_quoted_cr_mail quoted-cr/0002 && + grep "quoted CRLF detected" quoted-cr/0002.err && + check_quoted_cr_mail quoted-cr/0001 --quoted-cr=nowarn && + test_must_be_empty quoted-cr/0001.err && + check_quoted_cr_mail quoted-cr/0002 --quoted-cr=nowarn && + test_must_be_empty quoted-cr/0002.err && + cp quoted-cr/0001-expected.msg quoted-cr/0002-expected.msg && + cp quoted-cr/0001-expected.patch quoted-cr/0002-expected.patch && + check_quoted_cr_mail quoted-cr/0001 --quoted-cr=strip && + test_must_be_empty quoted-cr/0001.err && + check_quoted_cr_mail quoted-cr/0002 --quoted-cr=strip && + test_must_be_empty quoted-cr/0002.err +' + test_done diff --git a/t/t5100/quoted-cr-info b/t/t5100/quoted-cr-info new file mode 100644 index 0000000000..dab2228b70 --- /dev/null +++ b/t/t5100/quoted-cr-info @@ -0,0 +1,5 @@ +Author: A U Thor +Email: mail@example.com +Subject: sample +Date: Mon, 3 Aug 2020 22:40:55 +0700 + diff --git a/t/t5100/quoted-cr-msg b/t/t5100/quoted-cr-msg new file mode 100644 index 0000000000..89b05a0784 --- /dev/null +++ b/t/t5100/quoted-cr-msg @@ -0,0 +1,2 @@ +On different distro, %%pytest is suffixed with different patterns.%% +%% diff --git a/t/t5100/quoted-cr-patch b/t/t5100/quoted-cr-patch new file mode 100644 index 0000000000..65b13eeef7 --- /dev/null +++ b/t/t5100/quoted-cr-patch @@ -0,0 +1,22 @@ +---%% + configure | 2 +-%% + 1 file changed, 1 insertion(+), 1 deletion(-)%% +%% +diff --git a/configure b/configure%% +index db3538b3..f7c1c095 100755%% +--- a/configure%% ++++ b/configure%% +@@ -814,7 +814,7 @@ if [ $have_python3 -eq 1 ]; then%% + printf "%%Checking for python3 pytest (>= 3.0)... "%% + conf=$(mktemp)%% + printf "[pytest]\nminversion=3.0\n" > $conf%% +- if pytest-3 -c $conf --version >/dev/null 2>&1; then%% ++ if "$python" -m pytest -c $conf --version >/dev/null 2>&1; then%% + printf "Yes.\n"%% + have_python3_pytest=1%% + else%% +-- %% +2.28.0%% +_______________________________________________ +example mailing list -- list@example.org +To unsubscribe send an email to list-leave@example.org diff --git a/t/t5100/quoted-cr.mbox b/t/t5100/quoted-cr.mbox new file mode 100644 index 0000000000..909021bb7a --- /dev/null +++ b/t/t5100/quoted-cr.mbox @@ -0,0 +1,47 @@ +From nobody Mon Sep 17 00:00:00 2001 +From: A U Thor <mail@example.com> +To: list@example.org +Subject: [PATCH v2] sample +Date: Mon, 3 Aug 2020 22:40:55 +0700 +Message-Id: <msg-id@example.com> +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: base64 + +T24gZGlmZmVyZW50IGRpc3RybywgDXB5dGVzdCBpcyBzdWZmaXhlZCB3aXRoIGRpZmZlcmVudCBw +YXR0ZXJucy4KCi0tLQogY29uZmlndXJlIHwgMiArLQogMSBmaWxlIGNoYW5nZWQsIDEgaW5zZXJ0 +aW9uKCspLCAxIGRlbGV0aW9uKC0pCgpkaWZmIC0tZ2l0IGEvY29uZmlndXJlIGIvY29uZmlndXJl +CmluZGV4IGRiMzUzOGIzLi5mN2MxYzA5NSAxMDA3NTUKLS0tIGEvY29uZmlndXJlCisrKyBiL2Nv +bmZpZ3VyZQpAQCAtODE0LDcgKzgxNCw3IEBAIGlmIFsgJGhhdmVfcHl0aG9uMyAtZXEgMSBdOyB0 +aGVuCiAgICAgcHJpbnRmICINQ2hlY2tpbmcgZm9yIHB5dGhvbjMgcHl0ZXN0ICg+PSAzLjApLi4u +ICIKICAgICBjb25mPSQobWt0ZW1wKQogICAgIHByaW50ZiAiW3B5dGVzdF1cbm1pbnZlcnNpb249 +My4wXG4iID4gJGNvbmYKLSAgICBpZiBweXRlc3QtMyAtYyAkY29uZiAtLXZlcnNpb24gPi9kZXYv +bnVsbCAyPiYxOyB0aGVuCisgICAgaWYgIiRweXRob24iIC1tIHB5dGVzdCAtYyAkY29uZiAtLXZl +cnNpb24gPi9kZXYvbnVsbCAyPiYxOyB0aGVuCiAgICAgICAgIHByaW50ZiAiWWVzLlxuIgogICAg +ICAgICBoYXZlX3B5dGhvbjNfcHl0ZXN0PTEKICAgICBlbHNlCi0tIAoyLjI4LjAKX19fX19fX19f +X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZXhhbXBsZSBtYWlsaW5nIGxp +c3QgLS0gbGlzdEBleGFtcGxlLm9yZwpUbyB1bnN1YnNjcmliZSBzZW5kIGFuIGVtYWlsIHRvIGxp +c3QtbGVhdmVAZXhhbXBsZS5vcmcK + +From nobody Mon Sep 17 00:00:00 2001 +From: A U Thor <mail@example.com> +To: list@example.org +Subject: [PATCH v2] sample +Date: Mon, 3 Aug 2020 22:40:55 +0700 +Message-Id: <msg-id2@example.com> +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: base64 + +T24gZGlmZmVyZW50IGRpc3RybywgDXB5dGVzdCBpcyBzdWZmaXhlZCB3aXRoIGRpZmZlcmVudCBw +YXR0ZXJucy4NCg0KLS0tDQogY29uZmlndXJlIHwgMiArLQ0KIDEgZmlsZSBjaGFuZ2VkLCAxIGlu +c2VydGlvbigrKSwgMSBkZWxldGlvbigtKQ0KDQpkaWZmIC0tZ2l0IGEvY29uZmlndXJlIGIvY29u +ZmlndXJlDQppbmRleCBkYjM1MzhiMy4uZjdjMWMwOTUgMTAwNzU1DQotLS0gYS9jb25maWd1cmUN +CisrKyBiL2NvbmZpZ3VyZQ0KQEAgLTgxNCw3ICs4MTQsNyBAQCBpZiBbICRoYXZlX3B5dGhvbjMg +LWVxIDEgXTsgdGhlbg0KICAgICBwcmludGYgIg1DaGVja2luZyBmb3IgcHl0aG9uMyBweXRlc3Qg +KD49IDMuMCkuLi4gIg0KICAgICBjb25mPSQobWt0ZW1wKQ0KICAgICBwcmludGYgIltweXRlc3Rd +XG5taW52ZXJzaW9uPTMuMFxuIiA+ICRjb25mDQotICAgIGlmIHB5dGVzdC0zIC1jICRjb25mIC0t +dmVyc2lvbiA+L2Rldi9udWxsIDI+JjE7IHRoZW4NCisgICAgaWYgIiRweXRob24iIC1tIHB5dGVz +dCAtYyAkY29uZiAtLXZlcnNpb24gPi9kZXYvbnVsbCAyPiYxOyB0aGVuDQogICAgICAgICBwcmlu +dGYgIlllcy5cbiINCiAgICAgICAgIGhhdmVfcHl0aG9uM19weXRlc3Q9MQ0KICAgICBlbHNlDQot +LSANCjIuMjguMA0KX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f +X18KZXhhbXBsZSBtYWlsaW5nIGxpc3QgLS0gbGlzdEBleGFtcGxlLm9yZwpUbyB1bnN1YnNjcmli +ZSBzZW5kIGFuIGVtYWlsIHRvIGxpc3QtbGVhdmVAZXhhbXBsZS5vcmcK diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh index c1811ea0f4..cb67bac1c4 100755 --- a/t/t5150-request-pull.sh +++ b/t/t5150-request-pull.sh @@ -2,6 +2,9 @@ test_description='Test workflows involving pull request.' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh if ! test_have_prereq PERL @@ -31,13 +34,13 @@ test_expect_success 'setup' ' test_tick && git commit -m "\"Thirty days\", a reminder of month lengths" && git tag -m "version 1" -a initial && - git push --tags origin master + git push --tags origin main ) && ( cd local && git remote add upstream "$trash_url/upstream.git" && git fetch upstream && - git pull upstream master && + git pull upstream main && cat <<-\EOT >>mnemonic.txt && Of twyecescore-eightt is but eine, And all the remnante be thrycescore-eine. @@ -59,7 +62,7 @@ test_expect_success 'setup' ' git commit -a -m "Adapt to use modern, simpler English But keep the old version, too, in case some people prefer it." && - git checkout master + git checkout main ) ' @@ -129,7 +132,7 @@ test_expect_success 'pull request when forgot to push' ' ( cd local && git checkout initial && - git merge --ff-only master && + git merge --ff-only main && test_must_fail git request-pull initial "$downstream_url" \ 2>../err ) && @@ -145,9 +148,9 @@ test_expect_success 'pull request after push' ' ( cd local && git checkout initial && - git merge --ff-only master && - git push origin master:for-upstream && - git request-pull initial origin master:for-upstream >../request + git merge --ff-only main && + git push origin main:for-upstream && + git request-pull initial origin main:for-upstream >../request ) && sed -nf read-request.sed <request >digest && { @@ -172,9 +175,9 @@ test_expect_success 'request asks HEAD to be pulled' ' ( cd local && git checkout initial && - git merge --ff-only master && - git push --tags origin master simplify && - git push origin master:for-upstream && + git merge --ff-only main && + git push --tags origin main simplify && + git push origin main:for-upstream && git request-pull initial "$downstream_url" >../request ) && sed -nf read-request.sed <request >digest && @@ -215,19 +218,19 @@ test_expect_success 'pull request format' ' ( cd local && git checkout initial && - git merge --ff-only master && + git merge --ff-only main && git push origin tags/full && git request-pull initial "$downstream_url" tags/full >../request ) && <request sed -nf fuzz.sed >request.fuzzy && - test_i18ncmp expect request.fuzzy && + test_cmp expect request.fuzzy && ( cd local && git request-pull initial "$downstream_url" tags/full:refs/tags/full ) >request && sed -nf fuzz.sed <request >request.fuzzy && - test_i18ncmp expect request.fuzzy && + test_cmp expect request.fuzzy && ( cd local && @@ -243,9 +246,9 @@ test_expect_success 'request-pull ignores OPTIONS_KEEPDASHDASH poison' ' OPTIONS_KEEPDASHDASH=Yes && export OPTIONS_KEEPDASHDASH && git checkout initial && - git merge --ff-only master && - git push origin master:for-upstream && - git request-pull -- initial "$downstream_url" master:for-upstream >../request + git merge --ff-only main && + git push origin main:for-upstream && + git request-pull -- initial "$downstream_url" main:for-upstream >../request ) ' @@ -257,7 +260,7 @@ test_expect_success 'request-pull quotes regex metacharacters properly' ' ( cd local && git checkout initial && - git merge --ff-only master && + git merge --ff-only main && git tag -mrelease v2.0 && git push origin refs/tags/v2.0:refs/tags/v2-0 && test_must_fail git request-pull initial "$downstream_url" tags/v2.0 \ @@ -275,7 +278,7 @@ test_expect_success 'pull request with mismatched object' ' ( cd local && git checkout initial && - git merge --ff-only master && + git merge --ff-only main && git push origin HEAD:refs/tags/full && test_must_fail git request-pull initial "$downstream_url" tags/full \ 2>../err @@ -292,7 +295,7 @@ test_expect_success 'pull request with stale object' ' ( cd local && git checkout initial && - git merge --ff-only master && + git merge --ff-only main && git push origin refs/tags/full && git tag -f -m"Thirty-one days" full && test_must_fail git request-pull initial "$downstream_url" tags/full \ diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index 392201cabd..5c5e53f0be 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -8,125 +8,91 @@ test_description='git pack-object ' . ./test-lib.sh -TRASH=$(pwd) - -test_expect_success \ - 'setup' \ - 'rm -f .git/index* && - perl -e "print \"a\" x 4096;" > a && - perl -e "print \"b\" x 4096;" > b && - perl -e "print \"c\" x 4096;" > c && - test-tool genrandom "seed a" 2097152 > a_big && - test-tool genrandom "seed b" 2097152 > b_big && - git update-index --add a a_big b b_big c && - cat c >d && echo foo >>d && git update-index --add d && - tree=$(git write-tree) && - commit=$(git commit-tree $tree </dev/null) && { - echo $tree && - echo $commit && - git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/" - } >obj-list && { - git diff-tree --root -p $commit && - while read object - do - t=$(git cat-file -t $object) && - git cat-file $t $object || return 1 - done <obj-list - } >expect' - -test_expect_success \ - 'pack without delta' \ - 'packname_1=$(git pack-objects --window=0 test-1 <obj-list)' - -test_expect_success \ - 'pack-objects with bogus arguments' \ - 'test_must_fail git pack-objects --window=0 test-1 blah blah <obj-list' - -rm -fr .git2 -mkdir .git2 - -test_expect_success \ - 'unpack without delta' \ - "GIT_OBJECT_DIRECTORY=.git2/objects && - export GIT_OBJECT_DIRECTORY && - git init && - git unpack-objects -n <test-1-${packname_1}.pack && - git unpack-objects <test-1-${packname_1}.pack" - -unset GIT_OBJECT_DIRECTORY -cd "$TRASH/.git2" +test_expect_success 'setup' ' + rm -f .git/index* && + perl -e "print \"a\" x 4096;" >a && + perl -e "print \"b\" x 4096;" >b && + perl -e "print \"c\" x 4096;" >c && + test-tool genrandom "seed a" 2097152 >a_big && + test-tool genrandom "seed b" 2097152 >b_big && + git update-index --add a a_big b b_big c && + cat c >d && echo foo >>d && git update-index --add d && + tree=$(git write-tree) && + commit=$(git commit-tree $tree </dev/null) && + { + echo $tree && + echo $commit && + git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/" + } >obj-list && + { + git diff-tree --root -p $commit && + while read object + do + t=$(git cat-file -t $object) && + git cat-file $t $object || return 1 + done <obj-list + } >expect +' -test_expect_success \ - 'check unpack without delta' \ - '(cd ../.git && find objects -type f -print) | - while read path - do - cmp $path ../.git/$path || { - echo $path differs. - return 1 - } - done' -cd "$TRASH" +# usage: check_deltas <stderr_from_pack_objects> <cmp_op> <nr_deltas> +# e.g.: check_deltas stderr -gt 0 +check_deltas() { + deltas=$(perl -lne '/delta (\d+)/ and print $1' "$1") && + shift && + if ! test "$deltas" "$@" + then + echo >&2 "unexpected number of deltas (compared $delta $*)" + return 1 + fi +} + +test_expect_success 'pack without delta' ' + packname_1=$(git pack-objects --progress --window=0 test-1 \ + <obj-list 2>stderr) && + check_deltas stderr = 0 +' -test_expect_success \ - 'pack with REF_DELTA' \ - 'pwd && - packname_2=$(git pack-objects test-2 <obj-list)' +test_expect_success 'pack-objects with bogus arguments' ' + test_must_fail git pack-objects --window=0 test-1 blah blah <obj-list +' -rm -fr .git2 -mkdir .git2 +check_unpack () { + test_when_finished "rm -rf git2" && + git init --bare git2 && + git -C git2 unpack-objects -n <"$1".pack && + git -C git2 unpack-objects <"$1".pack && + (cd .git && find objects -type f -print) | + while read path + do + cmp git2/$path .git/$path || { + echo $path differs. + return 1 + } + done +} + +test_expect_success 'unpack without delta' ' + check_unpack test-1-${packname_1} +' -test_expect_success \ - 'unpack with REF_DELTA' \ - 'GIT_OBJECT_DIRECTORY=.git2/objects && - export GIT_OBJECT_DIRECTORY && - git init && - git unpack-objects -n <test-2-${packname_2}.pack && - git unpack-objects <test-2-${packname_2}.pack' - -unset GIT_OBJECT_DIRECTORY -cd "$TRASH/.git2" -test_expect_success \ - 'check unpack with REF_DELTA' \ - '(cd ../.git && find objects -type f -print) | - while read path - do - cmp $path ../.git/$path || { - echo $path differs. - return 1 - } - done' -cd "$TRASH" +test_expect_success 'pack with REF_DELTA' ' + packname_2=$(git pack-objects --progress test-2 <obj-list 2>stderr) && + check_deltas stderr -gt 0 +' -test_expect_success \ - 'pack with OFS_DELTA' \ - 'pwd && - packname_3=$(git pack-objects --delta-base-offset test-3 <obj-list)' +test_expect_success 'unpack with REF_DELTA' ' + check_unpack test-2-${packname_2} +' -rm -fr .git2 -mkdir .git2 +test_expect_success 'pack with OFS_DELTA' ' + packname_3=$(git pack-objects --progress --delta-base-offset test-3 \ + <obj-list 2>stderr) && + check_deltas stderr -gt 0 +' -test_expect_success \ - 'unpack with OFS_DELTA' \ - 'GIT_OBJECT_DIRECTORY=.git2/objects && - export GIT_OBJECT_DIRECTORY && - git init && - git unpack-objects -n <test-3-${packname_3}.pack && - git unpack-objects <test-3-${packname_3}.pack' - -unset GIT_OBJECT_DIRECTORY -cd "$TRASH/.git2" -test_expect_success \ - 'check unpack with OFS_DELTA' \ - '(cd ../.git && find objects -type f -print) | - while read path - do - cmp $path ../.git/$path || { - echo $path differs. - return 1 - } - done' -cd "$TRASH" +test_expect_success 'unpack with OFS_DELTA' ' + check_unpack test-3-${packname_3} +' test_expect_success 'compare delta flavors' ' perl -e '\'' @@ -135,55 +101,33 @@ test_expect_success 'compare delta flavors' ' '\'' test-2-$packname_2.pack test-3-$packname_3.pack ' -rm -fr .git2 -mkdir .git2 +check_use_objects () { + test_when_finished "rm -rf git2" && + git init --bare git2 && + cp "$1".pack "$1".idx git2/objects/pack && + ( + cd git2 && + git diff-tree --root -p $commit && + while read object + do + t=$(git cat-file -t $object) && + git cat-file $t $object || exit 1 + done + ) <obj-list >current && + cmp expect current +} -test_expect_success \ - 'use packed objects' \ - 'GIT_OBJECT_DIRECTORY=.git2/objects && - export GIT_OBJECT_DIRECTORY && - git init && - cp test-1-${packname_1}.pack test-1-${packname_1}.idx .git2/objects/pack && { - git diff-tree --root -p $commit && - while read object - do - t=$(git cat-file -t $object) && - git cat-file $t $object || return 1 - done <obj-list - } >current && - cmp expect current' +test_expect_success 'use packed objects' ' + check_use_objects test-1-${packname_1} +' -test_expect_success \ - 'use packed deltified (REF_DELTA) objects' \ - 'GIT_OBJECT_DIRECTORY=.git2/objects && - export GIT_OBJECT_DIRECTORY && - rm -f .git2/objects/pack/test-* && - cp test-2-${packname_2}.pack test-2-${packname_2}.idx .git2/objects/pack && { - git diff-tree --root -p $commit && - while read object - do - t=$(git cat-file -t $object) && - git cat-file $t $object || return 1 - done <obj-list - } >current && - cmp expect current' +test_expect_success 'use packed deltified (REF_DELTA) objects' ' + check_use_objects test-2-${packname_2} +' -test_expect_success \ - 'use packed deltified (OFS_DELTA) objects' \ - 'GIT_OBJECT_DIRECTORY=.git2/objects && - export GIT_OBJECT_DIRECTORY && - rm -f .git2/objects/pack/test-* && - cp test-3-${packname_3}.pack test-3-${packname_3}.idx .git2/objects/pack && { - git diff-tree --root -p $commit && - while read object - do - t=$(git cat-file -t $object) && - git cat-file $t $object || return 1 - done <obj-list - } >current && - cmp expect current' - -unset GIT_OBJECT_DIRECTORY +test_expect_success 'use packed deltified (OFS_DELTA) objects' ' + check_use_objects test-3-${packname_3} +' test_expect_success 'survive missing objects/pack directory' ' ( @@ -427,7 +371,8 @@ test_expect_success 'index-pack --strict <pack> works in non-repo' ' test_path_is_file foo.idx ' -test_expect_success !PTHREADS,C_LOCALE_OUTPUT 'index-pack --threads=N or pack.threads=N warns when no pthreads' ' +test_expect_success !PTHREADS,!FAIL_PREREQS \ + 'index-pack --threads=N or pack.threads=N warns when no pthreads' ' test_must_fail git index-pack --threads=2 2>err && grep ^warning: err >warnings && test_line_count = 1 warnings && @@ -445,7 +390,8 @@ test_expect_success !PTHREADS,C_LOCALE_OUTPUT 'index-pack --threads=N or pack.th grep -F "no threads support, ignoring pack.threads" err ' -test_expect_success !PTHREADS,C_LOCALE_OUTPUT 'pack-objects --threads=N or pack.threads=N warns when no pthreads' ' +test_expect_success !PTHREADS,!FAIL_PREREQS \ + 'pack-objects --threads=N or pack.threads=N warns when no pthreads' ' git pack-objects --threads=2 --stdout --all </dev/null >/dev/null 2>err && grep ^warning: err >warnings && test_line_count = 1 warnings && @@ -532,4 +478,144 @@ test_expect_success 'prefetch objects' ' test_line_count = 1 donelines ' +test_expect_success 'setup for --stdin-packs tests' ' + git init stdin-packs && + ( + cd stdin-packs && + + test_commit A && + test_commit B && + test_commit C && + + for id in A B C + do + git pack-objects .git/objects/pack/pack-$id \ + --incremental --revs <<-EOF + refs/tags/$id + EOF + done && + + ls -la .git/objects/pack + ) +' + +test_expect_success '--stdin-packs with excluded packs' ' + ( + cd stdin-packs && + + PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" && + PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" && + PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" && + + git pack-objects test --stdin-packs <<-EOF && + $PACK_A + ^$PACK_B + $PACK_C + EOF + + ( + git show-index <$(ls .git/objects/pack/pack-A-*.idx) && + git show-index <$(ls .git/objects/pack/pack-C-*.idx) + ) >expect.raw && + git show-index <$(ls test-*.idx) >actual.raw && + + cut -d" " -f2 <expect.raw | sort >expect && + cut -d" " -f2 <actual.raw | sort >actual && + test_cmp expect actual + ) +' + +test_expect_success '--stdin-packs is incompatible with --filter' ' + ( + cd stdin-packs && + test_must_fail git pack-objects --stdin-packs --stdout \ + --filter=blob:none </dev/null 2>err && + test_i18ngrep "cannot use --filter with --stdin-packs" err + ) +' + +test_expect_success '--stdin-packs is incompatible with --revs' ' + ( + cd stdin-packs && + test_must_fail git pack-objects --stdin-packs --revs out \ + </dev/null 2>err && + test_i18ngrep "cannot use internal rev list with --stdin-packs" err + ) +' + +test_expect_success '--stdin-packs with loose objects' ' + ( + cd stdin-packs && + + PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" && + PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" && + PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" && + + test_commit D && # loose + + git pack-objects test2 --stdin-packs --unpacked <<-EOF && + $PACK_A + ^$PACK_B + $PACK_C + EOF + + ( + git show-index <$(ls .git/objects/pack/pack-A-*.idx) && + git show-index <$(ls .git/objects/pack/pack-C-*.idx) && + git rev-list --objects --no-object-names \ + refs/tags/C..refs/tags/D + + ) >expect.raw && + ls -la . && + git show-index <$(ls test2-*.idx) >actual.raw && + + cut -d" " -f2 <expect.raw | sort >expect && + cut -d" " -f2 <actual.raw | sort >actual && + test_cmp expect actual + ) +' + +test_expect_success '--stdin-packs with broken links' ' + ( + cd stdin-packs && + + # make an unreachable object with a bogus parent + git cat-file -p HEAD >commit && + sed "s/$(git rev-parse HEAD^)/$(test_oid zero)/" <commit | + git hash-object -w -t commit --stdin >in && + + git pack-objects .git/objects/pack/pack-D <in && + + PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" && + PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" && + PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" && + PACK_D="$(basename .git/objects/pack/pack-D-*.pack)" && + + git pack-objects test3 --stdin-packs --unpacked <<-EOF && + $PACK_A + ^$PACK_B + $PACK_C + $PACK_D + EOF + + ( + git show-index <$(ls .git/objects/pack/pack-A-*.idx) && + git show-index <$(ls .git/objects/pack/pack-C-*.idx) && + git show-index <$(ls .git/objects/pack/pack-D-*.idx) && + git rev-list --objects --no-object-names \ + refs/tags/C..refs/tags/D + ) >expect.raw && + git show-index <$(ls test3-*.idx) >actual.raw && + + cut -d" " -f2 <expect.raw | sort >expect && + cut -d" " -f2 <actual.raw | sort >actual && + test_cmp expect actual + ) +' + +test_expect_success 'negative window clamps to 0' ' + git pack-objects --progress --window=-1 neg-window <obj-list 2>stderr && + check_deltas stderr = 0 +' + test_done diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh index df60f18fb8..3475b06aeb 100755 --- a/t/t5304-prune.sh +++ b/t/t5304-prune.sh @@ -4,6 +4,9 @@ # test_description='prune' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh day=$((60*60*24)) @@ -119,7 +122,7 @@ test_expect_success 'prune: do not prune detached HEAD with no reflog' ' test_expect_success 'prune: prune former HEAD after checking out branch' ' head_oid=$(git rev-parse HEAD) && - git checkout --quiet master && + git checkout --quiet main && git prune -v >prune_actual && grep "$head_oid" prune_actual @@ -349,4 +352,20 @@ test_expect_success 'trivial prune with bitmaps enabled' ' test_must_fail git cat-file -e $blob ' +test_expect_success 'old reachable-from-recent retained with bitmaps' ' + git repack -adb && + to_drop=$(echo bitmap-from-recent-1 | git hash-object -w --stdin) && + test-tool chmtime -86400 .git/objects/$(test_oid_to_path $to_drop) && + to_save=$(echo bitmap-from-recent-2 | git hash-object -w --stdin) && + test-tool chmtime -86400 .git/objects/$(test_oid_to_path $to_save) && + tree=$(printf "100644 blob $to_save\tfile\n" | git mktree) && + test-tool chmtime -86400 .git/objects/$(test_oid_to_path $tree) && + commit=$(echo foo | git commit-tree $tree) && + git prune --expire=12.hours.ago && + git cat-file -e $commit && + git cat-file -e $tree && + git cat-file -e $to_save && + test_must_fail git cat-file -e $to_drop +' + test_done diff --git a/t/t5305-include-tag.sh b/t/t5305-include-tag.sh index a5eca210b8..44bd9ef45f 100755 --- a/t/t5305-include-tag.sh +++ b/t/t5305-include-tag.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='git pack-object --include-tag' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh TRASH=$(pwd) @@ -111,7 +114,7 @@ test_expect_success 'check unpacked result (have all objects)' ' test_expect_success 'single-branch clone can transfer tag' ' rm -rf clone.git && - git clone --no-local --single-branch -b master . clone.git && + git clone --no-local --single-branch -b main . clone.git && git -C clone.git fsck ' diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh index 1d40fcad39..b02838750e 100755 --- a/t/t5310-pack-bitmaps.sh +++ b/t/t5310-pack-bitmaps.sh @@ -1,7 +1,12 @@ #!/bin/sh test_description='exercise basic bitmap functionality' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-bundle.sh +. "$TEST_DIRECTORY"/lib-bitmap.sh objpath () { echo ".git/objects/$(echo "$1" | sed -e 's|\(..\)|\1/|')" @@ -20,84 +25,172 @@ has_any () { grep -Ff "$1" "$2" } +# To ensure the logic for "maximal commits" is exercised, make +# the repository a bit more complicated. +# +# other second +# * * +# (99 commits) (99 commits) +# * * +# |\ /| +# | * octo-other octo-second * | +# |/|\_________ ____________/|\| +# | \ \/ __________/ | +# | | ________/\ / | +# * |/ * merge-right * +# | _|__________/ \____________ | +# |/ | \| +# (l1) * * merge-left * (r1) +# | / \________________________ | +# |/ \| +# (l2) * * (r2) +# \___________________________ | +# \| +# * (base) +# +# We only push bits down the first-parent history, which +# makes some of these commits unimportant! +# +# The important part for the maximal commit algorithm is how +# the bitmasks are extended. Assuming starting bit positions +# for second (bit 0) and other (bit 1), the bitmasks at the +# end should be: +# +# second: 1 (maximal, selected) +# other: 01 (maximal, selected) +# (base): 11 (maximal) +# +# This complicated history was important for a previous +# version of the walk that guarantees never walking a +# commit multiple times. That goal might be important +# again, so preserve this complicated case. For now, this +# test will guarantee that the bitmaps are computed +# correctly, even with the repeat calculations. + test_expect_success 'setup repo with moderate-sized history' ' - test_commit_bulk --id=file 100 && + test_commit_bulk --id=file 10 && + git branch -M second && git checkout -b other HEAD~5 && test_commit_bulk --id=side 10 && - git checkout master && - bitmaptip=$(git rev-parse master) && + + # add complicated history setup, including merges and + # ambiguous merge-bases + + git checkout -b merge-left other~2 && + git merge second~2 -m "merge-left" && + + git checkout -b merge-right second~1 && + git merge other~1 -m "merge-right" && + + git checkout -b octo-second second && + git merge merge-left merge-right -m "octopus-second" && + + git checkout -b octo-other other && + git merge merge-left merge-right -m "octopus-other" && + + git checkout other && + git merge octo-other -m "pull octopus" && + + git checkout second && + git merge octo-second -m "pull octopus" && + + # Remove these branches so they are not selected + # as bitmap tips + git branch -D merge-left && + git branch -D merge-right && + git branch -D octo-other && + git branch -D octo-second && + + # add padding to make these merges less interesting + # and avoid having them selected for bitmaps + test_commit_bulk --id=file 100 && + git checkout other && + test_commit_bulk --id=side 100 && + git checkout second && + + bitmaptip=$(git rev-parse second) && blob=$(echo tagged-blob | git hash-object -w --stdin) && git tag tagged-blob $blob && git config repack.writebitmaps true ' test_expect_success 'full repack creates bitmaps' ' - git repack -ad && + GIT_TRACE2_EVENT_NESTING=4 GIT_TRACE2_EVENT="$(pwd)/trace" \ + git repack -ad && ls .git/objects/pack/ | grep bitmap >output && - test_line_count = 1 output + test_line_count = 1 output && + grep "\"key\":\"num_selected_commits\",\"value\":\"106\"" trace && + grep "\"key\":\"num_maximal_commits\",\"value\":\"107\"" trace ' test_expect_success 'rev-list --test-bitmap verifies bitmaps' ' git rev-list --test-bitmap HEAD ' -rev_list_tests() { - state=$1 - - test_expect_success "counting commits via bitmap ($state)" ' - git rev-list --count HEAD >expect && - git rev-list --use-bitmap-index --count HEAD >actual && +rev_list_tests_head () { + test_expect_success "counting commits via bitmap ($state, $branch)" ' + git rev-list --count $branch >expect && + git rev-list --use-bitmap-index --count $branch >actual && test_cmp expect actual ' - test_expect_success "counting partial commits via bitmap ($state)" ' - git rev-list --count HEAD~5..HEAD >expect && - git rev-list --use-bitmap-index --count HEAD~5..HEAD >actual && + test_expect_success "counting partial commits via bitmap ($state, $branch)" ' + git rev-list --count $branch~5..$branch >expect && + git rev-list --use-bitmap-index --count $branch~5..$branch >actual && test_cmp expect actual ' - test_expect_success "counting commits with limit ($state)" ' - git rev-list --count -n 1 HEAD >expect && - git rev-list --use-bitmap-index --count -n 1 HEAD >actual && + test_expect_success "counting commits with limit ($state, $branch)" ' + git rev-list --count -n 1 $branch >expect && + git rev-list --use-bitmap-index --count -n 1 $branch >actual && test_cmp expect actual ' - test_expect_success "counting non-linear history ($state)" ' - git rev-list --count other...master >expect && - git rev-list --use-bitmap-index --count other...master >actual && + test_expect_success "counting non-linear history ($state, $branch)" ' + git rev-list --count other...second >expect && + git rev-list --use-bitmap-index --count other...second >actual && test_cmp expect actual ' - test_expect_success "counting commits with limiting ($state)" ' - git rev-list --count HEAD -- 1.t >expect && - git rev-list --use-bitmap-index --count HEAD -- 1.t >actual && + test_expect_success "counting commits with limiting ($state, $branch)" ' + git rev-list --count $branch -- 1.t >expect && + git rev-list --use-bitmap-index --count $branch -- 1.t >actual && test_cmp expect actual ' - test_expect_success "counting objects via bitmap ($state)" ' - git rev-list --count --objects HEAD >expect && - git rev-list --use-bitmap-index --count --objects HEAD >actual && + test_expect_success "counting objects via bitmap ($state, $branch)" ' + git rev-list --count --objects $branch >expect && + git rev-list --use-bitmap-index --count --objects $branch >actual && test_cmp expect actual ' - test_expect_success "enumerate commits ($state)" ' - git rev-list --use-bitmap-index HEAD >actual && - git rev-list HEAD >expect && + test_expect_success "enumerate commits ($state, $branch)" ' + git rev-list --use-bitmap-index $branch >actual && + git rev-list $branch >expect && test_bitmap_traversal --no-confirm-bitmaps expect actual ' - test_expect_success "enumerate --objects ($state)" ' - git rev-list --objects --use-bitmap-index HEAD >actual && - git rev-list --objects HEAD >expect && + test_expect_success "enumerate --objects ($state, $branch)" ' + git rev-list --objects --use-bitmap-index $branch >actual && + git rev-list --objects $branch >expect && test_bitmap_traversal expect actual ' - test_expect_success "bitmap --objects handles non-commit objects ($state)" ' - git rev-list --objects --use-bitmap-index HEAD tagged-blob >actual && + test_expect_success "bitmap --objects handles non-commit objects ($state, $branch)" ' + git rev-list --objects --use-bitmap-index $branch tagged-blob >actual && grep $blob actual ' } +rev_list_tests () { + state=$1 + + for branch in "second" "other" + do + rev_list_tests_head + done +} + rev_list_tests 'full bitmap' test_expect_success 'clone from bitmapped repository' ' @@ -128,7 +221,7 @@ test_expect_success 'setup further non-bitmapped commits' ' rev_list_tests 'partial bitmap' test_expect_success 'fetch (partial bitmap)' ' - git --git-dir=clone.git fetch origin master:master && + git --git-dir=clone.git fetch origin second:second && git rev-parse HEAD >expect && git --git-dir=clone.git rev-parse HEAD >actual && test_cmp expect actual @@ -230,7 +323,7 @@ test_expect_success 'full repack, reusing previous bitmaps' ' ' test_expect_success 'fetch (full bitmap)' ' - git --git-dir=clone.git fetch origin master:master && + git --git-dir=clone.git fetch origin second:second && git rev-parse HEAD >expect && git --git-dir=clone.git rev-parse HEAD >actual && test_cmp expect actual @@ -343,7 +436,20 @@ test_expect_success 'pack reuse respects --incremental' ' test_must_be_empty actual ' -test_expect_success 'truncated bitmap fails gracefully' ' +test_expect_success 'truncated bitmap fails gracefully (ewah)' ' + test_config pack.writebitmaphashcache false && + git repack -ad && + git rev-list --use-bitmap-index --count --all >expect && + bitmap=$(ls .git/objects/pack/*.bitmap) && + test_when_finished "rm -f $bitmap" && + test_copy_bytes 256 <$bitmap >$bitmap.tmp && + mv -f $bitmap.tmp $bitmap && + git rev-list --use-bitmap-index --count --all >actual 2>stderr && + test_cmp expect actual && + test_i18ngrep corrupt.ewah.bitmap stderr +' + +test_expect_success 'truncated bitmap fails gracefully (cache)' ' git repack -ad && git rev-list --use-bitmap-index --count --all >expect && bitmap=$(ls .git/objects/pack/*.bitmap) && @@ -352,7 +458,30 @@ test_expect_success 'truncated bitmap fails gracefully' ' mv -f $bitmap.tmp $bitmap && git rev-list --use-bitmap-index --count --all >actual 2>stderr && test_cmp expect actual && - test_i18ngrep corrupt stderr + test_i18ngrep corrupted.bitmap.index stderr +' + +test_expect_success 'enumerating progress counts pack-reused objects' ' + count=$(git rev-list --objects --all --count) && + git repack -adb && + + # check first with only reused objects; confirm that our progress + # showed the right number, and also that we did pack-reuse as expected. + # Check only the final "done" line of the meter (there may be an + # arbitrary number of intermediate lines ending with CR). + GIT_PROGRESS_DELAY=0 \ + git pack-objects --all --stdout --progress \ + </dev/null >/dev/null 2>stderr && + grep "Enumerating objects: $count, done" stderr && + grep "pack-reused $count" stderr && + + # now the same but with one non-reused object + git commit --allow-empty -m "an extra commit object" && + GIT_PROGRESS_DELAY=0 \ + git pack-objects --all --stdout --progress \ + </dev/null >/dev/null 2>stderr && + grep "Enumerating objects: $((count+1)), done" stderr && + grep "pack-reused $count" stderr ' # have_delta <obj> <expected_base> @@ -448,4 +577,42 @@ test_expect_success 'fetch with bitmaps can reuse old base' ' ) ' +test_expect_success 'pack.preferBitmapTips' ' + git init repo && + test_when_finished "rm -fr repo" && + ( + cd repo && + + # create enough commits that not all are receive bitmap + # coverage even if they are all at the tip of some reference. + test_commit_bulk --message="%s" 103 && + + git rev-list HEAD >commits.raw && + sort <commits.raw >commits && + + git log --format="create refs/tags/%s %H" HEAD >refs && + git update-ref --stdin <refs && + + git repack -adb && + test-tool bitmap list-commits | sort >bitmaps && + + # remember which commits did not receive bitmaps + comm -13 bitmaps commits >before && + test_file_not_empty before && + + # mark the commits which did not receive bitmaps as preferred, + # and generate the bitmap again + perl -pe "s{^}{create refs/tags/include/$. }" <before | + git update-ref --stdin && + git -c pack.preferBitmapTips=refs/tags/include repack -adb && + + # finally, check that the commit(s) without bitmap coverage + # are not the same ones as before + test-tool bitmap list-commits | sort >bitmaps && + comm -13 bitmaps commits >after && + + ! test_cmp before after + ) +' + test_done diff --git a/t/t5312-prune-corruption.sh b/t/t5312-prune-corruption.sh index da9d59940d..11423b3cb2 100755 --- a/t/t5312-prune-corruption.sh +++ b/t/t5312-prune-corruption.sh @@ -8,6 +8,9 @@ bail out or to proceed using it as a reachable tip, but it is _not_ OK to proceed as if it did not exist. Otherwise we might silently delete objects that cannot be recovered. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'disable reflogs' ' @@ -16,7 +19,7 @@ test_expect_success 'disable reflogs' ' ' test_expect_success 'create history reachable only from a bogus-named ref' ' - test_tick && git commit --allow-empty -m master && + test_tick && git commit --allow-empty -m main && base=$(git rev-parse HEAD) && test_tick && git commit --allow-empty -m bogus && bogus=$(git rev-parse HEAD) && @@ -51,7 +54,7 @@ test_expect_success 'clean up bogus ref' ' ' # We create two new objects here, "one" and "two". Our -# master branch points to "two", which is deleted, +# main branch points to "two", which is deleted, # corrupting the repository. But we'd like to make sure # that the otherwise unreachable "one" is not pruned # (since it is the user's best bet for recovering @@ -81,7 +84,7 @@ test_expect_success 'pruning with a corrupted tip does not drop history' ' test_expect_success 'pack-refs does not silently delete broken loose ref' ' git pack-refs --all --prune && echo $missing >expect && - git rev-parse refs/heads/master >actual && + git rev-parse refs/heads/main >actual && test_cmp expect actual ' @@ -89,25 +92,25 @@ test_expect_success 'pack-refs does not silently delete broken loose ref' ' # actually pack it, as it is perfectly reasonable to # skip processing a broken ref test_expect_success 'create packed-refs file with broken ref' ' - rm -f .git/refs/heads/master && + rm -f .git/refs/heads/main && cat >.git/packed-refs <<-EOF && - $missing refs/heads/master + $missing refs/heads/main $recoverable refs/heads/other EOF echo $missing >expect && - git rev-parse refs/heads/master >actual && + git rev-parse refs/heads/main >actual && test_cmp expect actual ' test_expect_success 'pack-refs does not silently delete broken packed ref' ' git pack-refs --all --prune && - git rev-parse refs/heads/master >actual && + git rev-parse refs/heads/main >actual && test_cmp expect actual ' test_expect_success 'pack-refs does not drop broken refs during deletion' ' git update-ref -d refs/heads/other && - git rev-parse refs/heads/master >actual && + git rev-parse refs/heads/main >actual && test_cmp expect actual ' diff --git a/t/t5316-pack-delta-depth.sh b/t/t5316-pack-delta-depth.sh index 0f06c40eb1..759169d074 100755 --- a/t/t5316-pack-delta-depth.sh +++ b/t/t5316-pack-delta-depth.sh @@ -69,6 +69,7 @@ test_expect_success 'create series of packs' ' max_chain() { git index-pack --verify-stat-only "$1" >output && perl -lne ' + BEGIN { $len = 0 } /chain length = (\d+)/ and $len = $1; END { print $len } ' output @@ -84,14 +85,28 @@ test_expect_success 'packing produces a long delta' ' pack=$(git pack-objects --all --window=0 </dev/null pack) && echo 9 >expect && max_chain pack-$pack.pack >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success '--depth limits depth' ' pack=$(git pack-objects --all --depth=5 </dev/null pack) && echo 5 >expect && max_chain pack-$pack.pack >actual && - test_i18ncmp expect actual + test_cmp expect actual +' + +test_expect_success '--depth=0 disables deltas' ' + pack=$(git pack-objects --all --depth=0 </dev/null pack) && + echo 0 >expect && + max_chain pack-$pack.pack >actual && + test_cmp expect actual +' + +test_expect_success 'negative depth disables deltas' ' + pack=$(git pack-objects --all --depth=-1 </dev/null pack) && + echo 0 >expect && + max_chain pack-$pack.pack >actual && + test_cmp expect actual ' test_done diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh index dc0446574b..13ed3eb136 100755 --- a/t/t5317-pack-objects-filter-objects.sh +++ b/t/t5317-pack-objects-filter-objects.sh @@ -2,6 +2,9 @@ test_description='git pack-objects using object filtering' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # Test blob:none filter. @@ -382,7 +385,7 @@ test_expect_success 'verify sparse:oid=oid-ish' ' awk -f print_2.awk ls_files_result | sort >expected && - git -C r4 pack-objects --revs --stdout --filter=sparse:oid=master:pattern >filter.pack <<-EOF && + git -C r4 pack-objects --revs --stdout --filter=sparse:oid=main:pattern >filter.pack <<-EOF && HEAD EOF git -C r4 index-pack ../filter.pack && diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh index 2ed0c1544d..af88f805aa 100755 --- a/t/t5318-commit-graph.sh +++ b/t/t5318-commit-graph.sh @@ -76,7 +76,7 @@ graph_git_behavior 'no graph' full commits/3 commits/1 graph_read_expect() { OPTIONAL="" NUM_CHUNKS=3 - if test ! -z $2 + if test ! -z "$2" then OPTIONAL=" $2" NUM_CHUNKS=$((3 + $(echo "$2" | wc -w))) @@ -103,14 +103,14 @@ test_expect_success 'exit with correct error on bad input to --stdin-commits' ' # valid commit and tree OID git rev-parse HEAD HEAD^{tree} >in && git commit-graph write --stdin-commits <in && - graph_read_expect 3 + graph_read_expect 3 generation_data ' test_expect_success 'write graph' ' cd "$TRASH_DIRECTORY/full" && git commit-graph write && test_path_is_file $objdir/info/commit-graph && - graph_read_expect "3" + graph_read_expect "3" generation_data ' test_expect_success POSIXPERM 'write graph has correct permissions' ' @@ -219,7 +219,7 @@ test_expect_success 'write graph with merges' ' cd "$TRASH_DIRECTORY/full" && git commit-graph write && test_path_is_file $objdir/info/commit-graph && - graph_read_expect "10" "extra_edges" + graph_read_expect "10" "generation_data extra_edges" ' graph_git_behavior 'merge 1 vs 2' full merge/1 merge/2 @@ -254,7 +254,7 @@ test_expect_success 'write graph with new commit' ' cd "$TRASH_DIRECTORY/full" && git commit-graph write && test_path_is_file $objdir/info/commit-graph && - graph_read_expect "11" "extra_edges" + graph_read_expect "11" "generation_data extra_edges" ' graph_git_behavior 'full graph, commit 8 vs merge 1' full commits/8 merge/1 @@ -264,7 +264,7 @@ test_expect_success 'write graph with nothing new' ' cd "$TRASH_DIRECTORY/full" && git commit-graph write && test_path_is_file $objdir/info/commit-graph && - graph_read_expect "11" "extra_edges" + graph_read_expect "11" "generation_data extra_edges" ' graph_git_behavior 'cleared graph, commit 8 vs merge 1' full commits/8 merge/1 @@ -274,7 +274,7 @@ test_expect_success 'build graph from latest pack with closure' ' cd "$TRASH_DIRECTORY/full" && cat new-idx | git commit-graph write --stdin-packs && test_path_is_file $objdir/info/commit-graph && - graph_read_expect "9" "extra_edges" + graph_read_expect "9" "generation_data extra_edges" ' graph_git_behavior 'graph from pack, commit 8 vs merge 1' full commits/8 merge/1 @@ -287,7 +287,7 @@ test_expect_success 'build graph from commits with closure' ' git rev-parse merge/1 >>commits-in && cat commits-in | git commit-graph write --stdin-commits && test_path_is_file $objdir/info/commit-graph && - graph_read_expect "6" + graph_read_expect "6" "generation_data" ' graph_git_behavior 'graph from commits, commit 8 vs merge 1' full commits/8 merge/1 @@ -297,7 +297,7 @@ test_expect_success 'build graph from commits with append' ' cd "$TRASH_DIRECTORY/full" && git rev-parse merge/3 | git commit-graph write --stdin-commits --append && test_path_is_file $objdir/info/commit-graph && - graph_read_expect "10" "extra_edges" + graph_read_expect "10" "generation_data extra_edges" ' graph_git_behavior 'append graph, commit 8 vs merge 1' full commits/8 merge/1 @@ -307,7 +307,7 @@ test_expect_success 'build graph using --reachable' ' cd "$TRASH_DIRECTORY/full" && git commit-graph write --reachable && test_path_is_file $objdir/info/commit-graph && - graph_read_expect "11" "extra_edges" + graph_read_expect "11" "generation_data extra_edges" ' graph_git_behavior 'append graph, commit 8 vs merge 1' full commits/8 merge/1 @@ -328,7 +328,7 @@ test_expect_success 'write graph in bare repo' ' cd "$TRASH_DIRECTORY/bare" && git commit-graph write && test_path_is_file $baredir/info/commit-graph && - graph_read_expect "11" "extra_edges" + graph_read_expect "11" "generation_data extra_edges" ' graph_git_behavior 'bare repo with graph, commit 8 vs merge 1' bare commits/8 merge/1 @@ -446,6 +446,27 @@ test_expect_success 'warn on improper hash version' ' ) ' +test_expect_success 'lower layers have overflow chunk' ' + cd "$TRASH_DIRECTORY/full" && + UNIX_EPOCH_ZERO="@0 +0000" && + FUTURE_DATE="@2147483646 +0000" && + rm -f .git/objects/info/commit-graph && + test_commit --date "$FUTURE_DATE" future-1 && + test_commit --date "$UNIX_EPOCH_ZERO" old-1 && + git commit-graph write --reachable && + test_commit --date "$FUTURE_DATE" future-2 && + test_commit --date "$UNIX_EPOCH_ZERO" old-2 && + git commit-graph write --reachable --split=no-merge && + test_commit extra && + git commit-graph write --reachable --split=no-merge && + git commit-graph write --reachable && + graph_read_expect 16 "generation_data generation_data_overflow extra_edges" && + mv .git/objects/info/commit-graph commit-graph-upgraded && + git commit-graph write --reachable && + graph_read_expect 16 "generation_data generation_data_overflow extra_edges" && + test_cmp .git/objects/info/commit-graph commit-graph-upgraded +' + # the verify tests below expect the commit-graph to contain # exactly the commits reachable from the commits/8 branch. # If the file changes the set of commits in the list, then the @@ -454,8 +475,9 @@ test_expect_success 'warn on improper hash version' ' test_expect_success 'git commit-graph verify' ' cd "$TRASH_DIRECTORY/full" && - git rev-parse commits/8 | git commit-graph write --stdin-commits && - git commit-graph verify >output + git rev-parse commits/8 | git -c commitGraph.generationVersion=1 commit-graph write --stdin-commits && + git commit-graph verify >output && + graph_read_expect 9 extra_edges ' NUM_COMMITS=9 @@ -529,7 +551,7 @@ corrupt_graph_and_verify() { zero_pos=${4:-${orig_size}} && printf "$data" | dd of="$objdir/info/commit-graph" bs=1 seek="$pos" conv=notrunc && dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" if=/dev/null && - generate_zero_bytes $(($orig_size - $zero_pos)) >>"$objdir/info/commit-graph" && + test-tool genzeros $(($orig_size - $zero_pos)) >>"$objdir/info/commit-graph" && corrupt_graph_verify "$grepstr" } @@ -563,7 +585,7 @@ test_expect_success 'detect bad hash version' ' test_expect_success 'detect low chunk count' ' corrupt_graph_and_verify $GRAPH_BYTE_CHUNK_COUNT "\01" \ - "missing the .* chunk" + "final chunk has non-zero id" ' test_expect_success 'detect missing OID fanout chunk' ' @@ -741,4 +763,56 @@ test_expect_success 'corrupt commit-graph write (missing tree)' ' ) ' +# We test the overflow-related code with the following repo history: +# +# 4:F - 5:N - 6:U +# / \ +# 1:U - 2:N - 3:U M:N +# \ / +# 7:N - 8:F - 9:N +# +# Here the commits denoted by U have committer date of zero seconds +# since Unix epoch, the commits denoted by N have committer date +# starting from 1112354055 seconds since Unix epoch (default committer +# date for the test suite), and the commits denoted by F have committer +# date of (2 ^ 31 - 2) seconds since Unix epoch. +# +# The largest offset observed is 2 ^ 31, just large enough to overflow. +# + +test_expect_success 'set up and verify repo with generation data overflow chunk' ' + objdir=".git/objects" && + UNIX_EPOCH_ZERO="@0 +0000" && + FUTURE_DATE="@2147483646 +0000" && + test_oid_cache <<-EOF && + oid_version sha1:1 + oid_version sha256:2 + EOF + cd "$TRASH_DIRECTORY" && + mkdir repo && + cd repo && + git init && + test_commit --date "$UNIX_EPOCH_ZERO" 1 && + test_commit 2 && + test_commit --date "$UNIX_EPOCH_ZERO" 3 && + git commit-graph write --reachable && + graph_read_expect 3 generation_data && + test_commit --date "$FUTURE_DATE" 4 && + test_commit 5 && + test_commit --date "$UNIX_EPOCH_ZERO" 6 && + git branch left && + git reset --hard 3 && + test_commit 7 && + test_commit --date "$FUTURE_DATE" 8 && + test_commit 9 && + git branch right && + git reset --hard 3 && + test_merge M left right && + git commit-graph write --reachable && + graph_read_expect 10 "generation_data generation_data_overflow" && + git commit-graph verify +' + +graph_git_behavior 'generation data overflow chunk repo' repo left right + test_done diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh index 297de502a9..5641d158df 100755 --- a/t/t5319-multi-pack-index.sh +++ b/t/t5319-multi-pack-index.sh @@ -234,6 +234,48 @@ test_expect_success 'warn on improper hash version' ' ) ' +test_expect_success 'midx picks objects from preferred pack' ' + test_when_finished rm -rf preferred.git && + git init --bare preferred.git && + ( + cd preferred.git && + + a=$(echo "a" | git hash-object -w --stdin) && + b=$(echo "b" | git hash-object -w --stdin) && + c=$(echo "c" | git hash-object -w --stdin) && + + # Set up two packs, duplicating the object "B" at different + # offsets. + # + # Note that the "BC" pack (the one we choose as preferred) sorts + # lexically after the "AB" pack, meaning that omitting the + # --preferred-pack argument would cause this test to fail (since + # the MIDX code would select the copy of "b" in the "AB" pack). + git pack-objects objects/pack/test-AB <<-EOF && + $a + $b + EOF + bc=$(git pack-objects objects/pack/test-BC <<-EOF + $b + $c + EOF + ) && + + git multi-pack-index --object-dir=objects \ + write --preferred-pack=test-BC-$bc.idx 2>err && + test_must_be_empty err && + + test-tool read-midx --show-objects objects >out && + + ofs=$(git show-index <objects/pack/test-BC-$bc.idx | grep $b | + cut -d" " -f1) && + printf "%s %s\tobjects/pack/test-BC-%s.pack\n" \ + "$b" "$ofs" "$bc" >expect && + grep ^$b out >actual && + + test_cmp expect actual + ) +' test_expect_success 'verify multi-pack-index success' ' git multi-pack-index verify --object-dir=$objdir @@ -314,12 +356,12 @@ test_expect_success 'verify bad OID version' ' test_expect_success 'verify truncated chunk count' ' corrupt_midx_and_verify $MIDX_BYTE_CHUNK_COUNT "\01" $objdir \ - "missing required" + "final chunk has non-zero id" ' test_expect_success 'verify extended chunk count' ' corrupt_midx_and_verify $MIDX_BYTE_CHUNK_COUNT "\07" $objdir \ - "terminating multi-pack-index chunk id appears earlier than expected" + "terminating chunk id appears earlier than expected" ' test_expect_success 'verify missing required chunk' ' @@ -329,7 +371,7 @@ test_expect_success 'verify missing required chunk' ' test_expect_success 'verify invalid chunk offset' ' corrupt_midx_and_verify $MIDX_BYTE_CHUNK_OFFSET "\01" $objdir \ - "invalid chunk offset (too large)" + "improper chunk offset(s)" ' test_expect_success 'verify packnames out of order' ' @@ -710,8 +752,9 @@ test_expect_success 'expire respects .keep files' ' PACKA=$(ls .git/objects/pack/a-pack*\.pack | sed s/\.pack\$//) && touch $PACKA.keep && git multi-pack-index expire && - ls -S .git/objects/pack/a-pack* | grep $PACKA >a-pack-files && - test_line_count = 3 a-pack-files && + test_path_is_file $PACKA.idx && + test_path_is_file $PACKA.keep && + test_path_is_file $PACKA.pack && test-tool read-midx .git/objects | grep idx >midx-list && test_line_count = 2 midx-list ) diff --git a/t/t5322-pack-objects-sparse.sh b/t/t5322-pack-objects-sparse.sh index a581eaf529..61cb907a90 100755 --- a/t/t5322-pack-objects-sparse.sh +++ b/t/t5322-pack-objects-sparse.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='pack-objects object selection using sparse algorithm' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup repo' ' @@ -18,7 +21,7 @@ test_expect_success 'setup repo' ' git commit -m "Initialized trees" && for i in $(test_seq 1 3) do - git checkout -b topic$i master && + git checkout -b topic$i main && echo change-$i >f$i/f$i/data.txt && git commit -a -m "Changed f$i/f$i/data.txt" done && diff --git a/t/t5323-pack-redundant.sh b/t/t5323-pack-redundant.sh index 7e3340843f..8b01793845 100755 --- a/t/t5323-pack-redundant.sh +++ b/t/t5323-pack-redundant.sh @@ -6,7 +6,7 @@ test_description='Test git pack-redundant In order to test git-pack-redundant, we will create a number of objects and -packs in the repository `master.git`. The relationship between packs (P1-P8) +packs in the repository `main.git`. The relationship between packs (P1-P8) and objects (T, A-R) is showed in the following chart. Objects of a pack will be marked with letter x, while objects of redundant packs will be marked with exclamation point, and redundant pack itself will be marked with asterisk. @@ -25,7 +25,7 @@ exclamation point, and redundant pack itself will be marked with asterisk. ALL | x x x x x x x x x x x x x x x x x x x Another repository `shared.git` has unique objects (X-Z), while other objects -(marked with letter s) are shared through alt-odb (of `master.git`). The +(marked with letter s) are shared through alt-odb (of `main.git`). The relationship between packs and objects is as follows: | T A B C D E F G H I J K L M N O P Q R X Y Z @@ -36,9 +36,11 @@ relationship between packs and objects is as follows: . ./test-lib.sh -master_repo=master.git +main_repo=main.git shared_repo=shared.git +git_pack_redundant='git pack-redundant --i-still-use-this' + # Create commits in <repo> and assign each commit's oid to shell variables # given in the arguments (A, B, and C). E.g.: # @@ -69,7 +71,7 @@ create_commits_in () { shift || return 1 done && - git -C "$repo" update-ref refs/heads/master $oid + git -C "$repo" update-ref refs/heads/main $oid } # Create pack in <repo> and assign pack id to variable given in the 2nd argument @@ -107,9 +109,9 @@ format_packfiles () { sort } -test_expect_success 'setup master repo' ' - git init --bare "$master_repo" && - create_commits_in "$master_repo" A B C D E F G H I J K L M N O P Q R +test_expect_success 'setup main repo' ' + git init --bare "$main_repo" && + create_commits_in "$main_repo" A B C D E F G H I J K L M N O P Q R ' test_expect_success 'master: pack-redundant works with no packfile' ' @@ -118,7 +120,7 @@ test_expect_success 'master: pack-redundant works with no packfile' ' cat >expect <<-EOF && fatal: Zero packs found! EOF - test_must_fail git pack-redundant --all >actual 2>&1 && + test_must_fail $git_pack_redundant --all >actual 2>&1 && test_cmp expect actual ) ' @@ -133,8 +135,8 @@ test_expect_success 'master: pack-redundant works with no packfile' ' # ALL | x x x x x x x x # ############################################################################# -test_expect_success 'master: pack-redundant works with one packfile' ' - create_pack_in "$master_repo" P1 <<-EOF && +test_expect_success 'main: pack-redundant works with one packfile' ' + create_pack_in "$main_repo" P1 <<-EOF && $T $A $B @@ -145,8 +147,8 @@ test_expect_success 'master: pack-redundant works with one packfile' ' $R EOF ( - cd "$master_repo" && - git pack-redundant --all >out && + cd "$main_repo" && + $git_pack_redundant --all >out && test_must_be_empty out ) ' @@ -163,8 +165,8 @@ test_expect_success 'master: pack-redundant works with one packfile' ' # ALL | x x x x x x x x x x x x x x x # ############################################################################# -test_expect_success 'master: no redundant for pack 1, 2, 3' ' - create_pack_in "$master_repo" P2 <<-EOF && +test_expect_success 'main: no redundant for pack 1, 2, 3' ' + create_pack_in "$main_repo" P2 <<-EOF && $B $C $D @@ -173,7 +175,7 @@ test_expect_success 'master: no redundant for pack 1, 2, 3' ' $H $I EOF - create_pack_in "$master_repo" P3 <<-EOF && + create_pack_in "$main_repo" P3 <<-EOF && $F $I $J @@ -182,8 +184,8 @@ test_expect_success 'master: no redundant for pack 1, 2, 3' ' $M EOF ( - cd "$master_repo" && - git pack-redundant --all >out && + cd "$main_repo" && + $git_pack_redundant --all >out && test_must_be_empty out ) ' @@ -202,26 +204,26 @@ test_expect_success 'master: no redundant for pack 1, 2, 3' ' # ALL | x x x x x x x x x x x x x x x x x x # ############################################################################# -test_expect_success 'master: one of pack-2/pack-3 is redundant' ' - create_pack_in "$master_repo" P4 <<-EOF && +test_expect_success 'main: one of pack-2/pack-3 is redundant' ' + create_pack_in "$main_repo" P4 <<-EOF && $J $K $L $M $P EOF - create_pack_in "$master_repo" P5 <<-EOF && + create_pack_in "$main_repo" P5 <<-EOF && $G $H $N $O EOF ( - cd "$master_repo" && + cd "$main_repo" && cat >expect <<-EOF && P3:$P3 EOF - git pack-redundant --all >out && + $git_pack_redundant --all >out && format_packfiles <out >actual && test_cmp expect actual ) @@ -243,24 +245,24 @@ test_expect_success 'master: one of pack-2/pack-3 is redundant' ' # ALL | x x x x x x x x x x x x x x x x x x x # ############################################################################# -test_expect_success 'master: pack 2, 4, and 6 are redundant' ' - create_pack_in "$master_repo" P6 <<-EOF && +test_expect_success 'main: pack 2, 4, and 6 are redundant' ' + create_pack_in "$main_repo" P6 <<-EOF && $N $O $Q EOF - create_pack_in "$master_repo" P7 <<-EOF && + create_pack_in "$main_repo" P7 <<-EOF && $P $Q EOF ( - cd "$master_repo" && + cd "$main_repo" && cat >expect <<-EOF && P2:$P2 P4:$P4 P6:$P6 EOF - git pack-redundant --all >out && + $git_pack_redundant --all >out && format_packfiles <out >actual && test_cmp expect actual ) @@ -283,57 +285,57 @@ test_expect_success 'master: pack 2, 4, and 6 are redundant' ' # ALL | x x x x x x x x x x x x x x x x x x x # ############################################################################# -test_expect_success 'master: pack-8 (subset of pack-1) is also redundant' ' - create_pack_in "$master_repo" P8 <<-EOF && +test_expect_success 'main: pack-8 (subset of pack-1) is also redundant' ' + create_pack_in "$main_repo" P8 <<-EOF && $A EOF ( - cd "$master_repo" && + cd "$main_repo" && cat >expect <<-EOF && P2:$P2 P4:$P4 P6:$P6 P8:$P8 EOF - git pack-redundant --all >out && + $git_pack_redundant --all >out && format_packfiles <out >actual && test_cmp expect actual ) ' -test_expect_success 'master: clean loose objects' ' +test_expect_success 'main: clean loose objects' ' ( - cd "$master_repo" && + cd "$main_repo" && git prune-packed && find objects -type f | sed -e "/objects\/pack\//d" >out && test_must_be_empty out ) ' -test_expect_success 'master: remove redundant packs and pass fsck' ' +test_expect_success 'main: remove redundant packs and pass fsck' ' ( - cd "$master_repo" && - git pack-redundant --all | xargs rm && + cd "$main_repo" && + $git_pack_redundant --all | xargs rm && git fsck && - git pack-redundant --all >out && + $git_pack_redundant --all >out && test_must_be_empty out ) ' # The following test cases will execute inside `shared.git`, instead of -# inside `master.git`. +# inside `main.git`. test_expect_success 'setup shared.git' ' - git clone --mirror "$master_repo" "$shared_repo" && + git clone --mirror "$main_repo" "$shared_repo" && ( cd "$shared_repo" && - printf "../../$master_repo/objects\n" >objects/info/alternates + printf "../../$main_repo/objects\n" >objects/info/alternates ) ' test_expect_success 'shared: all packs are redundant, but no output without --alt-odb' ' ( cd "$shared_repo" && - git pack-redundant --all >out && + $git_pack_redundant --all >out && test_must_be_empty out ) ' @@ -341,7 +343,7 @@ test_expect_success 'shared: all packs are redundant, but no output without --al ############################################################################# # Chart of packs and objects for this test case # -# ================ master.git =============== +# ================= main.git ================ # | T A B C D E F G H I J K L M N O P Q R <----------+ # ----+-------------------------------------- | # P1 | x x x x x x x x | @@ -372,7 +374,7 @@ test_expect_success 'shared: show redundant packs in stderr for verbose mode' ' P5:$P5 P7:$P7 EOF - git pack-redundant --all --verbose >out 2>out.err && + $git_pack_redundant --all --verbose >out 2>out.err && test_must_be_empty out && grep "pack$" out.err | format_packfiles >actual && test_cmp expect actual @@ -385,9 +387,9 @@ test_expect_success 'shared: remove redundant packs, no packs left' ' cat >expect <<-EOF && fatal: Zero packs found! EOF - git pack-redundant --all --alt-odb | xargs rm && + $git_pack_redundant --all --alt-odb | xargs rm && git fsck && - test_must_fail git pack-redundant --all --alt-odb >actual 2>&1 && + test_must_fail $git_pack_redundant --all --alt-odb >actual 2>&1 && test_cmp expect actual ) ' @@ -415,7 +417,7 @@ test_expect_success 'shared: create new objects and packs' ' test_expect_success 'shared: no redundant without --alt-odb' ' ( cd "$shared_repo" && - git pack-redundant --all >out && + $git_pack_redundant --all >out && test_must_be_empty out ) ' @@ -423,7 +425,7 @@ test_expect_success 'shared: no redundant without --alt-odb' ' ############################################################################# # Chart of packs and objects for this test case # -# ================ master.git =============== +# ================= main.git ================ # | T A B C D E F G H I J K L M N O P Q R <----------------+ # ----+-------------------------------------- | # P1 | x x x x x x x x | @@ -446,7 +448,7 @@ test_expect_success 'shared: no redundant without --alt-odb' ' test_expect_success 'shared: one pack is redundant with --alt-odb' ' ( cd "$shared_repo" && - git pack-redundant --all --alt-odb >out && + $git_pack_redundant --all --alt-odb >out && format_packfiles <out >actual && test_line_count = 1 actual ) @@ -455,7 +457,7 @@ test_expect_success 'shared: one pack is redundant with --alt-odb' ' ############################################################################# # Chart of packs and objects for this test case # -# ================ master.git =============== +# ================= main.git ================ # | T A B C D E F G H I J K L M N O P Q R <----------------+ # ----+-------------------------------------- | # P1 | x x x x x x x x | @@ -483,7 +485,7 @@ test_expect_success 'shared: ignore unique objects and all two packs are redunda Px1:$Px1 Px2:$Px2 EOF - git pack-redundant --all --alt-odb >out <<-EOF && + $git_pack_redundant --all --alt-odb >out <<-EOF && $X $Y $Z diff --git a/t/t5324-split-commit-graph.sh b/t/t5324-split-commit-graph.sh index 4d3842b83b..587226ed10 100755 --- a/t/t5324-split-commit-graph.sh +++ b/t/t5324-split-commit-graph.sh @@ -13,11 +13,11 @@ test_expect_success 'setup repo' ' infodir=".git/objects/info" && graphdir="$infodir/commit-graphs" && test_oid_cache <<-EOM - shallow sha1:1760 - shallow sha256:2064 + shallow sha1:2132 + shallow sha256:2436 - base sha1:1376 - base sha256:1496 + base sha1:1408 + base sha256:1528 oid_version sha1:1 oid_version sha256:2 @@ -31,9 +31,9 @@ graph_read_expect() { NUM_BASE=$2 fi cat >expect <<- EOF - header: 43475048 1 $(test_oid oid_version) 3 $NUM_BASE + header: 43475048 1 $(test_oid oid_version) 4 $NUM_BASE num_commits: $1 - chunks: oid_fanout oid_lookup commit_metadata + chunks: oid_fanout oid_lookup commit_metadata generation_data EOF test-tool read-graph >output && test_cmp expect output @@ -453,4 +453,185 @@ test_expect_success 'prevent regression for duplicate commits across layers' ' git -C dup commit-graph verify ' +NUM_FIRST_LAYER_COMMITS=64 +NUM_SECOND_LAYER_COMMITS=16 +NUM_THIRD_LAYER_COMMITS=7 +NUM_FOURTH_LAYER_COMMITS=8 +NUM_FIFTH_LAYER_COMMITS=16 +SECOND_LAYER_SEQUENCE_START=$(($NUM_FIRST_LAYER_COMMITS + 1)) +SECOND_LAYER_SEQUENCE_END=$(($SECOND_LAYER_SEQUENCE_START + $NUM_SECOND_LAYER_COMMITS - 1)) +THIRD_LAYER_SEQUENCE_START=$(($SECOND_LAYER_SEQUENCE_END + 1)) +THIRD_LAYER_SEQUENCE_END=$(($THIRD_LAYER_SEQUENCE_START + $NUM_THIRD_LAYER_COMMITS - 1)) +FOURTH_LAYER_SEQUENCE_START=$(($THIRD_LAYER_SEQUENCE_END + 1)) +FOURTH_LAYER_SEQUENCE_END=$(($FOURTH_LAYER_SEQUENCE_START + $NUM_FOURTH_LAYER_COMMITS - 1)) +FIFTH_LAYER_SEQUENCE_START=$(($FOURTH_LAYER_SEQUENCE_END + 1)) +FIFTH_LAYER_SEQUENCE_END=$(($FIFTH_LAYER_SEQUENCE_START + $NUM_FIFTH_LAYER_COMMITS - 1)) + +# Current split graph chain: +# +# 16 commits (No GDAT) +# ------------------------ +# 64 commits (GDAT) +# +test_expect_success 'setup repo for mixed generation commit-graph-chain' ' + graphdir=".git/objects/info/commit-graphs" && + test_oid_cache <<-EOF && + oid_version sha1:1 + oid_version sha256:2 + EOF + git init mixed && + ( + cd mixed && + git config core.commitGraph true && + git config gc.writeCommitGraph false && + for i in $(test_seq $NUM_FIRST_LAYER_COMMITS) + do + test_commit $i && + git branch commits/$i || return 1 + done && + git -c commitGraph.generationVersion=2 commit-graph write --reachable --split && + graph_read_expect $NUM_FIRST_LAYER_COMMITS && + test_line_count = 1 $graphdir/commit-graph-chain && + for i in $(test_seq $SECOND_LAYER_SEQUENCE_START $SECOND_LAYER_SEQUENCE_END) + do + test_commit $i && + git branch commits/$i || return 1 + done && + git -c commitGraph.generationVersion=1 commit-graph write --reachable --split=no-merge && + test_line_count = 2 $graphdir/commit-graph-chain && + test-tool read-graph >output && + cat >expect <<-EOF && + header: 43475048 1 $(test_oid oid_version) 4 1 + num_commits: $NUM_SECOND_LAYER_COMMITS + chunks: oid_fanout oid_lookup commit_metadata + EOF + test_cmp expect output && + git commit-graph verify && + cat $graphdir/commit-graph-chain + ) +' + +# The new layer will be added without generation data chunk as it was not +# present on the layer underneath it. +# +# 7 commits (No GDAT) +# ------------------------ +# 16 commits (No GDAT) +# ------------------------ +# 64 commits (GDAT) +# +test_expect_success 'do not write generation data chunk if not present on existing tip' ' + git clone mixed mixed-no-gdat && + ( + cd mixed-no-gdat && + for i in $(test_seq $THIRD_LAYER_SEQUENCE_START $THIRD_LAYER_SEQUENCE_END) + do + test_commit $i && + git branch commits/$i || return 1 + done && + git commit-graph write --reachable --split=no-merge && + test_line_count = 3 $graphdir/commit-graph-chain && + test-tool read-graph >output && + cat >expect <<-EOF && + header: 43475048 1 $(test_oid oid_version) 4 2 + num_commits: $NUM_THIRD_LAYER_COMMITS + chunks: oid_fanout oid_lookup commit_metadata + EOF + test_cmp expect output && + git commit-graph verify + ) +' + +# Number of commits in each layer of the split-commit graph before merge: +# +# 8 commits (No GDAT) +# ------------------------ +# 7 commits (No GDAT) +# ------------------------ +# 16 commits (No GDAT) +# ------------------------ +# 64 commits (GDAT) +# +# The top two layers are merged and do not have generation data chunk as layer below them does +# not have generation data chunk. +# +# 15 commits (No GDAT) +# ------------------------ +# 16 commits (No GDAT) +# ------------------------ +# 64 commits (GDAT) +# +test_expect_success 'do not write generation data chunk if the topmost remaining layer does not have generation data chunk' ' + git clone mixed-no-gdat mixed-merge-no-gdat && + ( + cd mixed-merge-no-gdat && + for i in $(test_seq $FOURTH_LAYER_SEQUENCE_START $FOURTH_LAYER_SEQUENCE_END) + do + test_commit $i && + git branch commits/$i || return 1 + done && + git commit-graph write --reachable --split --size-multiple 1 && + test_line_count = 3 $graphdir/commit-graph-chain && + test-tool read-graph >output && + cat >expect <<-EOF && + header: 43475048 1 $(test_oid oid_version) 4 2 + num_commits: $(($NUM_THIRD_LAYER_COMMITS + $NUM_FOURTH_LAYER_COMMITS)) + chunks: oid_fanout oid_lookup commit_metadata + EOF + test_cmp expect output && + git commit-graph verify + ) +' + +# Number of commits in each layer of the split-commit graph before merge: +# +# 16 commits (No GDAT) +# ------------------------ +# 15 commits (No GDAT) +# ------------------------ +# 16 commits (No GDAT) +# ------------------------ +# 64 commits (GDAT) +# +# The top three layers are merged and has generation data chunk as the topmost remaining layer +# has generation data chunk. +# +# 47 commits (GDAT) +# ------------------------ +# 64 commits (GDAT) +# +test_expect_success 'write generation data chunk if topmost remaining layer has generation data chunk' ' + git clone mixed-merge-no-gdat mixed-merge-gdat && + ( + cd mixed-merge-gdat && + for i in $(test_seq $FIFTH_LAYER_SEQUENCE_START $FIFTH_LAYER_SEQUENCE_END) + do + test_commit $i && + git branch commits/$i || return 1 + done && + git commit-graph write --reachable --split --size-multiple 1 && + test_line_count = 2 $graphdir/commit-graph-chain && + test-tool read-graph >output && + cat >expect <<-EOF && + header: 43475048 1 $(test_oid oid_version) 5 1 + num_commits: $(($NUM_SECOND_LAYER_COMMITS + $NUM_THIRD_LAYER_COMMITS + $NUM_FOURTH_LAYER_COMMITS + $NUM_FIFTH_LAYER_COMMITS)) + chunks: oid_fanout oid_lookup commit_metadata generation_data + EOF + test_cmp expect output + ) +' + +test_expect_success 'write generation data chunk when commit-graph chain is replaced' ' + git clone mixed mixed-replace && + ( + cd mixed-replace && + git commit-graph write --reachable --split=replace && + test_path_is_file $graphdir/commit-graph-chain && + test_line_count = 1 $graphdir/commit-graph-chain && + verify_chain_files_exist $graphdir && + graph_read_expect $(($NUM_FIRST_LAYER_COMMITS + $NUM_SECOND_LAYER_COMMITS)) && + git commit-graph verify + ) +' + test_done diff --git a/t/t5325-reverse-index.sh b/t/t5325-reverse-index.sh new file mode 100755 index 0000000000..da453f68d6 --- /dev/null +++ b/t/t5325-reverse-index.sh @@ -0,0 +1,120 @@ +#!/bin/sh + +test_description='on-disk reverse index' +. ./test-lib.sh + +# The below tests want control over the 'pack.writeReverseIndex' setting +# themselves to assert various combinations of it with other options. +sane_unset GIT_TEST_WRITE_REV_INDEX + +packdir=.git/objects/pack + +test_expect_success 'setup' ' + test_commit base && + + pack=$(git pack-objects --all $packdir/pack) && + rev=$packdir/pack-$pack.rev && + + test_path_is_missing $rev +' + +test_index_pack () { + rm -f $rev && + conf=$1 && + shift && + # remove the index since Windows won't overwrite an existing file + rm $packdir/pack-$pack.idx && + git -c pack.writeReverseIndex=$conf index-pack "$@" \ + $packdir/pack-$pack.pack +} + +test_expect_success 'index-pack with pack.writeReverseIndex' ' + test_index_pack "" && + test_path_is_missing $rev && + + test_index_pack false && + test_path_is_missing $rev && + + test_index_pack true && + test_path_is_file $rev +' + +test_expect_success 'index-pack with --[no-]rev-index' ' + for conf in "" true false + do + test_index_pack "$conf" --rev-index && + test_path_exists $rev && + + test_index_pack "$conf" --no-rev-index && + test_path_is_missing $rev + done +' + +test_expect_success 'index-pack can verify reverse indexes' ' + test_when_finished "rm -f $rev" && + test_index_pack true && + + test_path_is_file $rev && + git index-pack --rev-index --verify $packdir/pack-$pack.pack && + + # Intentionally corrupt the reverse index. + chmod u+w $rev && + printf "xxxx" | dd of=$rev bs=1 count=4 conv=notrunc && + + test_must_fail git index-pack --rev-index --verify \ + $packdir/pack-$pack.pack 2>err && + grep "validation error" err +' + +test_expect_success 'index-pack infers reverse index name with -o' ' + git index-pack --rev-index -o other.idx $packdir/pack-$pack.pack && + test_path_is_file other.idx && + test_path_is_file other.rev +' + +test_expect_success 'pack-objects respects pack.writeReverseIndex' ' + test_when_finished "rm -fr pack-1-*" && + + git -c pack.writeReverseIndex= pack-objects --all pack-1 && + test_path_is_missing pack-1-*.rev && + + git -c pack.writeReverseIndex=false pack-objects --all pack-1 && + test_path_is_missing pack-1-*.rev && + + git -c pack.writeReverseIndex=true pack-objects --all pack-1 && + test_path_is_file pack-1-*.rev +' + +test_expect_success 'reverse index is not generated when available on disk' ' + test_index_pack true && + test_path_is_file $rev && + + git rev-parse HEAD >tip && + GIT_TEST_REV_INDEX_DIE_IN_MEMORY=1 git cat-file \ + --batch-check="%(objectsize:disk)" <tip +' + +test_expect_success 'revindex in-memory vs on-disk' ' + git init repo && + test_when_finished "rm -fr repo" && + ( + cd repo && + + test_commit commit && + + git rev-list --objects --no-object-names --all >objects && + + git -c pack.writeReverseIndex=false repack -ad && + test_path_is_missing $packdir/pack-*.rev && + git cat-file --batch-check="%(objectsize:disk) %(objectname)" \ + <objects >in-core && + + git -c pack.writeReverseIndex=true repack -ad && + test_path_is_file $packdir/pack-*.rev && + git cat-file --batch-check="%(objectsize:disk) %(objectname)" \ + <objects >on-disk && + + test_cmp on-disk in-core + ) +' +test_done diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index cc86ef213e..3f81f16e13 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -6,6 +6,9 @@ test_description='See why rewinding head breaks send-pack ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh cnt=64 @@ -66,20 +69,20 @@ test_expect_success 'pack the destination repository' ' ' test_expect_success 'refuse pushing rewound head without --force' ' - pushed_head=$(git rev-parse --verify master) && - victim_orig=$(cd victim && git rev-parse --verify master) && - test_must_fail git send-pack ./victim master && - victim_head=$(cd victim && git rev-parse --verify master) && + pushed_head=$(git rev-parse --verify main) && + victim_orig=$(cd victim && git rev-parse --verify main) && + test_must_fail git send-pack ./victim main && + victim_head=$(cd victim && git rev-parse --verify main) && test "$victim_head" = "$victim_orig" && # this should update - git send-pack --force ./victim master && - victim_head=$(cd victim && git rev-parse --verify master) && + git send-pack --force ./victim main && + victim_head=$(cd victim && git rev-parse --verify main) && test "$victim_head" = "$pushed_head" ' test_expect_success 'push can be used to delete a ref' ' - ( cd victim && git branch extra master ) && - git send-pack ./victim :extra master && + ( cd victim && git branch extra main ) && + git send-pack ./victim :extra main && ( cd victim && test_must_fail git rev-parse --verify extra ) ' @@ -89,9 +92,9 @@ test_expect_success 'refuse deleting push with denyDeletes' ' cd victim && test_might_fail git branch -D extra && git config receive.denyDeletes true && - git branch extra master + git branch extra main ) && - test_must_fail git send-pack ./victim :extra master + test_must_fail git send-pack ./victim :extra main ' test_expect_success 'cannot override denyDeletes with git -c send-pack' ' @@ -99,10 +102,10 @@ test_expect_success 'cannot override denyDeletes with git -c send-pack' ' cd victim && test_might_fail git branch -D extra && git config receive.denyDeletes true && - git branch extra master + git branch extra main ) && test_must_fail git -c receive.denyDeletes=false \ - send-pack ./victim :extra master + send-pack ./victim :extra main ' test_expect_success 'override denyDeletes with git -c receive-pack' ' @@ -110,11 +113,11 @@ test_expect_success 'override denyDeletes with git -c receive-pack' ' cd victim && test_might_fail git branch -D extra && git config receive.denyDeletes true && - git branch extra master + git branch extra main ) && git send-pack \ --receive-pack="git -c receive.denyDeletes=false receive-pack" \ - ./victim :extra master + ./victim :extra main ' test_expect_success 'denyNonFastforwards trumps --force' ' @@ -123,9 +126,9 @@ test_expect_success 'denyNonFastforwards trumps --force' ' test_might_fail git branch -D extra && git config receive.denyNonFastforwards true ) && - victim_orig=$(cd victim && git rev-parse --verify master) && - test_must_fail git send-pack --force ./victim master^:master && - victim_head=$(cd victim && git rev-parse --verify master) && + victim_orig=$(cd victim && git rev-parse --verify main) && + test_must_fail git send-pack --force ./victim main^:main && + victim_head=$(cd victim && git rev-parse --verify main) && test "$victim_orig" = "$victim_head" ' @@ -210,41 +213,41 @@ rewound_push_setup() { test_expect_success 'pushing explicit refspecs respects forcing' ' rewound_push_setup && - parent_orig=$(cd parent && git rev-parse --verify master) && + parent_orig=$(cd parent && git rev-parse --verify main) && ( cd child && test_must_fail git send-pack ../parent \ - refs/heads/master:refs/heads/master + refs/heads/main:refs/heads/main ) && - parent_head=$(cd parent && git rev-parse --verify master) && + parent_head=$(cd parent && git rev-parse --verify main) && test "$parent_orig" = "$parent_head" && ( cd child && git send-pack ../parent \ - +refs/heads/master:refs/heads/master + +refs/heads/main:refs/heads/main ) && - parent_head=$(cd parent && git rev-parse --verify master) && - child_head=$(cd child && git rev-parse --verify master) && + parent_head=$(cd parent && git rev-parse --verify main) && + child_head=$(cd child && git rev-parse --verify main) && test "$parent_head" = "$child_head" ' test_expect_success 'pushing wildcard refspecs respects forcing' ' rewound_push_setup && - parent_orig=$(cd parent && git rev-parse --verify master) && + parent_orig=$(cd parent && git rev-parse --verify main) && ( cd child && test_must_fail git send-pack ../parent \ "refs/heads/*:refs/heads/*" ) && - parent_head=$(cd parent && git rev-parse --verify master) && + parent_head=$(cd parent && git rev-parse --verify main) && test "$parent_orig" = "$parent_head" && ( cd child && git send-pack ../parent \ "+refs/heads/*:refs/heads/*" ) && - parent_head=$(cd parent && git rev-parse --verify master) && - child_head=$(cd child && git rev-parse --verify master) && + parent_head=$(cd parent && git rev-parse --verify main) && + child_head=$(cd child && git rev-parse --verify main) && test "$parent_head" = "$child_head" ' @@ -252,7 +255,7 @@ test_expect_success 'deny pushing to delete current branch' ' rewound_push_setup && ( cd child && - test_must_fail git send-pack ../parent :refs/heads/master 2>errs + test_must_fail git send-pack ../parent :refs/heads/main 2>errs ) ' @@ -283,9 +286,9 @@ test_expect_success 'receive-pack de-dupes .have lines' ' local=$(git -C fork rev-parse HEAD) && shared=$(git -C shared rev-parse only-shared) && cat >expect <<-EOF && - $local refs/heads/master + $local refs/heads/main $local refs/remotes/origin/HEAD - $local refs/remotes/origin/master + $local refs/remotes/origin/main $shared .have EOF diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh index 956d69f5b1..6012cc8172 100755 --- a/t/t5401-update-hooks.sh +++ b/t/t5401-update-hooks.sh @@ -15,11 +15,11 @@ test_expect_success setup ' git update-index a && tree1=$(git write-tree) && commit1=$(echo modify | git commit-tree $tree1 -p $commit0) && - git update-ref refs/heads/master $commit0 && + git update-ref refs/heads/main $commit0 && git update-ref refs/heads/tofail $commit1 && git clone --bare ./. victim.git && GIT_DIR=victim.git git update-ref refs/heads/tofail $commit1 && - git update-ref refs/heads/master $commit1 && + git update-ref refs/heads/main $commit1 && git update-ref refs/heads/tofail $commit0 ' @@ -38,7 +38,7 @@ echo "$@" >>$GIT_DIR/update.args read x; printf %s "$x" >$GIT_DIR/update.stdin echo STDOUT update $1 echo STDERR update $1 >&2 -test "$1" = refs/heads/master || exit +test "$1" = refs/heads/main || exit EOF chmod u+x victim.git/hooks/update @@ -62,11 +62,11 @@ chmod u+x victim.git/hooks/post-update test_expect_success push ' test_must_fail git send-pack --force ./victim.git \ - master tofail >send.out 2>send.err + main tofail >send.out 2>send.err ' test_expect_success 'updated as expected' ' - test $(GIT_DIR=victim.git git rev-parse master) = $commit1 && + test $(GIT_DIR=victim.git git rev-parse main) = $commit1 && test $(GIT_DIR=victim.git git rev-parse tofail) = $commit1 ' @@ -82,24 +82,24 @@ test_expect_success 'hooks ran' ' ' test_expect_success 'pre-receive hook input' ' - (echo $commit0 $commit1 refs/heads/master && + (echo $commit0 $commit1 refs/heads/main && echo $commit1 $commit0 refs/heads/tofail ) | test_cmp - victim.git/pre-receive.stdin ' test_expect_success 'update hook arguments' ' - (echo refs/heads/master $commit0 $commit1 && + (echo refs/heads/main $commit0 $commit1 && echo refs/heads/tofail $commit1 $commit0 ) | test_cmp - victim.git/update.args ' test_expect_success 'post-receive hook input' ' - echo $commit0 $commit1 refs/heads/master | + echo $commit0 $commit1 refs/heads/main | test_cmp - victim.git/post-receive.stdin ' test_expect_success 'post-update hook arguments' ' - echo refs/heads/master | + echo refs/heads/main | test_cmp - victim.git/post-update.args ' @@ -120,8 +120,8 @@ test_expect_success 'send-pack produced no output' ' cat <<EOF >expect remote: STDOUT pre-receive remote: STDERR pre-receive -remote: STDOUT update refs/heads/master -remote: STDERR update refs/heads/master +remote: STDOUT update refs/heads/main +remote: STDERR update refs/heads/main remote: STDOUT update refs/heads/tofail remote: STDERR update refs/heads/tofail remote: error: hook declined to update refs/heads/tofail @@ -143,7 +143,7 @@ test_expect_success 'pre-receive hook that forgets to read its input' ' for v in $(test_seq 100 999) do - git branch branch_$v master || return + git branch branch_$v main || return done && git push ./victim.git "+refs/heads/*:refs/heads/*" ' diff --git a/t/t5402-post-merge-hook.sh b/t/t5402-post-merge-hook.sh index 4aeea8f5b7..3e5e19c719 100755 --- a/t/t5402-post-merge-hook.sh +++ b/t/t5402-post-merge-hook.sh @@ -4,6 +4,9 @@ # test_description='Test the post-merge hook.' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -15,7 +18,7 @@ test_expect_success setup ' git update-index a && tree1=$(git write-tree) && commit1=$(echo modify | git commit-tree $tree1 -p $commit0) && - git update-ref refs/heads/master $commit0 && + git update-ref refs/heads/main $commit0 && git clone ./. clone1 && GIT_DIR=clone1/.git git update-index --add a && git clone ./. clone2 && diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh index a39b3b5c78..1ec9e23be7 100755 --- a/t/t5403-post-checkout-hook.sh +++ b/t/t5403-post-checkout-hook.sh @@ -4,6 +4,9 @@ # test_description='Test the post-checkout hook.' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -20,7 +23,7 @@ test_expect_success setup ' test_expect_success 'post-checkout receives the right arguments with HEAD unchanged ' ' test_when_finished "rm -f .git/post-checkout.args" && - git checkout master && + git checkout main && read old new flag <.git/post-checkout.args && test $old = $new && test $flag = 1 ' @@ -41,14 +44,14 @@ test_expect_success 'post-checkout receives the right args with HEAD changed ' ' test_expect_success 'post-checkout receives the right args when not switching branches ' ' test_when_finished "rm -f .git/post-checkout.args" && - git checkout master -- three.t && + git checkout main -- three.t && read old new flag <.git/post-checkout.args && test $old = $new && test $flag = 0 ' test_expect_success 'post-checkout is triggered on rebase' ' test_when_finished "rm -f .git/post-checkout.args" && - git checkout -b rebase-test master && + git checkout -b rebase-test main && rm -f .git/post-checkout.args && git rebase rebase-on-me && read old new flag <.git/post-checkout.args && diff --git a/t/t5404-tracking-branches.sh b/t/t5404-tracking-branches.sh index 2762f420bc..cc07889667 100755 --- a/t/t5404-tracking-branches.sh +++ b/t/t5404-tracking-branches.sh @@ -2,6 +2,9 @@ test_description='tracking branch update checks for git push' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -30,9 +33,9 @@ test_expect_success 'prepare pushable branches' ' git checkout -b b2 origin/b2 && echo aa-b2 >>file && git commit -a -m aa-b2 && - git checkout master && - echo aa-master >>file && - git commit -a -m aa-master + git checkout main && + echo aa-main >>file && + git commit -a -m aa-main ' test_expect_success 'mixed-success push returns error' ' @@ -40,7 +43,7 @@ test_expect_success 'mixed-success push returns error' ' ' test_expect_success 'check tracking branches updated correctly after push' ' - test "$(git rev-parse origin/master)" = "$(git rev-parse master)" + test "$(git rev-parse origin/main)" = "$(git rev-parse main)" ' test_expect_success 'check tracking branches not updated for failed refs' ' diff --git a/t/t5405-send-pack-rewind.sh b/t/t5405-send-pack-rewind.sh index 235fb7686a..11f03239a0 100755 --- a/t/t5405-send-pack-rewind.sh +++ b/t/t5405-send-pack-rewind.sh @@ -2,6 +2,9 @@ test_description='forced push to replace commit we do not have' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -13,7 +16,7 @@ test_expect_success setup ' mkdir another && ( cd another && git init && - git fetch --update-head-ok .. master:master + git fetch --update-head-ok .. main:main ) && >file2 && git add file2 && test_tick && @@ -25,7 +28,7 @@ test_expect_success 'non forced push should die not segfault' ' ( cd another && - test_must_fail git push .. master:master + test_must_fail git push .. main:main ) ' @@ -34,7 +37,7 @@ test_expect_success 'forced push should succeed' ' ( cd another && - git push .. +master:master + git push .. +main:main ) ' diff --git a/t/t5407-post-rewrite-hook.sh b/t/t5407-post-rewrite-hook.sh index 80750a817e..5bb23cc3a4 100755 --- a/t/t5407-post-rewrite-hook.sh +++ b/t/t5407-post-rewrite-hook.sh @@ -4,6 +4,9 @@ # test_description='Test the post-rewrite hook.' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -14,7 +17,7 @@ test_expect_success 'setup' ' git checkout A^0 && test_commit E bar E && test_commit F foo F && - git checkout master + git checkout main ' mkdir .git/hooks diff --git a/t/t5410-receive-pack-alternates.sh b/t/t5410-receive-pack-alternates.sh index f00d0da860..0b28e4e452 100755 --- a/t/t5410-receive-pack-alternates.sh +++ b/t/t5410-receive-pack-alternates.sh @@ -2,14 +2,17 @@ test_description='git receive-pack with alternate ref filtering' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' test_commit base && git clone -s --bare . fork && - git checkout -b public/branch master && + git checkout -b public/branch main && test_commit public && - git checkout -b private/branch master && + git checkout -b private/branch main && test_commit private ' diff --git a/t/t5411/common-functions.sh b/t/t5411/common-functions.sh index 344d13f61a..6694858e18 100644 --- a/t/t5411/common-functions.sh +++ b/t/t5411/common-functions.sh @@ -36,9 +36,8 @@ create_commits_in () { # without having to worry about future changes of the commit ID and spaces # of the output. Single quotes are replaced with double quotes, because # it is boring to prepare unquoted single quotes in expect text. We also -# remove some locale error messages, which break test if we turn on -# `GIT_TEST_GETTEXT_POISON=true` in order to test unintentional translations -# on plumbing commands. +# remove some locale error messages. The emitted human-readable errors are +# redundant to the more machine-readable output the tests already assert. make_user_friendly_and_stable_output () { sed \ -e "s/ *\$//" \ @@ -59,3 +58,18 @@ filter_out_user_friendly_and_stable_output () { make_user_friendly_and_stable_output | sed -n ${1+"$@"} } + +test_cmp_refs () { + indir= + if test "$1" = "-C" + then + shift + indir="$1" + shift + fi + indir=${indir:+"$indir"/} + cat >show-ref.expect && + git ${indir:+ -C "$indir"} show-ref >show-ref.pristine && + make_user_friendly_and_stable_output <show-ref.pristine >show-ref.filtered && + test_cmp show-ref.expect show-ref.filtered +} diff --git a/t/t5411/once-0010-report-status-v1.sh b/t/t5411/once-0010-report-status-v1.sh index cb431a9c91..1233a46eac 100644 --- a/t/t5411/once-0010-report-status-v1.sh +++ b/t/t5411/once-0010-report-status-v1.sh @@ -83,12 +83,9 @@ test_expect_success "proc-receive: report status v1" ' EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/for/main/topic1 <COMMIT-A> refs/heads/foo <COMMIT-B> refs/heads/main EOF - test_cmp expect actual ' diff --git a/t/t5411/test-0000-standard-git-push.sh b/t/t5411/test-0000-standard-git-push.sh index 47b058af7e..e1e0175c12 100644 --- a/t/t5411/test-0000-standard-git-push.sh +++ b/t/t5411/test-0000-standard-git-push.sh @@ -19,13 +19,11 @@ test_expect_success "git-push ($PROTOCOL)" ' * [new branch] HEAD -> next EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-B> refs/heads/main <COMMIT-A> refs/heads/next EOF - test_cmp expect actual ' # Refs of upstream : main(B) next(A) @@ -35,24 +33,22 @@ test_expect_success "git-push --atomic ($PROTOCOL)" ' test_must_fail git -C workbench push --atomic origin \ main \ $B:refs/heads/next \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; }" \ -e "/^ ! / { p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! [rejected] main -> main (non-fast-forward) ! [rejected] <COMMIT-B> -> next (atomic push failed) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-B> refs/heads/main <COMMIT-A> refs/heads/next EOF - test_cmp expect actual ' # Refs of upstream : main(B) next(A) @@ -65,8 +61,8 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL)" ' push origin \ main \ $B:refs/heads/next \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/next @@ -77,13 +73,11 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL)" ' ! [rejected] main -> main (non-fast-forward) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-B> refs/heads/main <COMMIT-B> refs/heads/next EOF - test_cmp expect actual ' # Refs of upstream : main(B) next(B) @@ -119,15 +113,13 @@ test_expect_success "git-push -f ($PROTOCOL)" ' * [new branch] HEAD -> a/b/c EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/a/b/c <COMMIT-A> refs/heads/main <COMMIT-A> refs/review/main/topic <TAG-v123> refs/tags/v123 EOF - test_cmp expect actual ' # Refs of upstream : main(A) tags/v123 refs/review/main/topic(A) a/b/c(A) diff --git a/t/t5411/test-0001-standard-git-push--porcelain.sh b/t/t5411/test-0001-standard-git-push--porcelain.sh index bbead12bbb..bcbda72341 100644 --- a/t/t5411/test-0001-standard-git-push--porcelain.sh +++ b/t/t5411/test-0001-standard-git-push--porcelain.sh @@ -20,13 +20,11 @@ test_expect_success "git-push ($PROTOCOL/porcelain)" ' Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-B> refs/heads/main <COMMIT-A> refs/heads/next EOF - test_cmp expect actual ' # Refs of upstream : main(B) next(A) @@ -36,25 +34,23 @@ test_expect_success "git-push --atomic ($PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --atomic --porcelain origin \ main \ $B:refs/heads/next \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "s/^# GETTEXT POISON #//" \ -e "/^To / { p; }" \ -e "/^! / { p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) ! <COMMIT-B>:refs/heads/next [rejected] (atomic push failed) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-B> refs/heads/main <COMMIT-A> refs/heads/next EOF - test_cmp expect actual ' # Refs of upstream : main(B) next(A) @@ -67,8 +63,8 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL/porcelain)" ' push --porcelain origin \ main \ $B:refs/heads/next \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/next @@ -80,13 +76,11 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL/porcelain)" ' Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-B> refs/heads/main <COMMIT-B> refs/heads/next EOF - test_cmp expect actual ' # Refs of upstream : main(B) next(B) @@ -123,15 +117,13 @@ test_expect_success "git-push -f ($PROTOCOL/porcelain)" ' Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/a/b/c <COMMIT-A> refs/heads/main <COMMIT-A> refs/review/main/topic <TAG-v123> refs/tags/v123 EOF - test_cmp expect actual ' # Refs of upstream : main(A) tags/v123 refs/review/main/topic(A) a/b/c(A) diff --git a/t/t5411/test-0002-pre-receive-declined.sh b/t/t5411/test-0002-pre-receive-declined.sh index e7d113a158..0c3490c9b1 100644 --- a/t/t5411/test-0002-pre-receive-declined.sh +++ b/t/t5411/test-0002-pre-receive-declined.sh @@ -12,20 +12,18 @@ test_expect_success "git-push is declined ($PROTOCOL)" ' test_must_fail git -C workbench push origin \ $B:refs/heads/main \ HEAD:refs/heads/next \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! [remote rejected] <COMMIT-B> -> main (pre-receive hook declined) ! [remote rejected] HEAD -> next (pre-receive hook declined) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "cleanup ($PROTOCOL)" ' diff --git a/t/t5411/test-0003-pre-receive-declined--porcelain.sh b/t/t5411/test-0003-pre-receive-declined--porcelain.sh index cc0cca6a47..e9c9db5d1f 100644 --- a/t/t5411/test-0003-pre-receive-declined--porcelain.sh +++ b/t/t5411/test-0003-pre-receive-declined--porcelain.sh @@ -12,8 +12,8 @@ test_expect_success "git-push is declined ($PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ $B:refs/heads/main \ HEAD:refs/heads/next \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! <COMMIT-B>:refs/heads/main [remote rejected] (pre-receive hook declined) @@ -21,12 +21,10 @@ test_expect_success "git-push is declined ($PROTOCOL/porcelain)" ' Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "cleanup ($PROTOCOL/porcelain)" ' diff --git a/t/t5411/test-0011-no-hook-error.sh b/t/t5411/test-0011-no-hook-error.sh index c50830982f..3ef136e6ef 100644 --- a/t/t5411/test-0011-no-hook-error.sh +++ b/t/t5411/test-0011-no-hook-error.sh @@ -5,8 +5,8 @@ test_expect_success "proc-receive: no hook, fail to push special ref ($PROTOCOL) test_must_fail git -C workbench push origin \ HEAD:next \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next @@ -19,13 +19,11 @@ test_expect_success "proc-receive: no hook, fail to push special ref ($PROTOCOL) ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF - test_cmp expect actual ' # Refs of upstream : main(A) next(A) @@ -41,8 +39,8 @@ test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCO test_must_fail git -C workbench push --atomic origin \ $B:main \ HEAD:next \ - HEAD:refs/for/main/topic >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + HEAD:refs/for/main/topic >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main @@ -55,10 +53,8 @@ test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCO ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' diff --git a/t/t5411/test-0012-no-hook-error--porcelain.sh b/t/t5411/test-0012-no-hook-error--porcelain.sh index 14ea433481..19f66fbd7d 100644 --- a/t/t5411/test-0012-no-hook-error--porcelain.sh +++ b/t/t5411/test-0012-no-hook-error--porcelain.sh @@ -5,8 +5,8 @@ test_expect_success "proc-receive: no hook, fail to push special ref ($PROTOCOL/ test_must_fail git -C workbench push --porcelain origin \ HEAD:next \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next @@ -20,13 +20,11 @@ test_expect_success "proc-receive: no hook, fail to push special ref ($PROTOCOL/ Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF - test_cmp expect actual ' # Refs of upstream : main(A) next(A) @@ -42,8 +40,8 @@ test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCO test_must_fail git -C workbench push --porcelain --atomic origin \ $B:main \ HEAD:next \ - HEAD:refs/for/main/topic >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + HEAD:refs/for/main/topic >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main @@ -57,10 +55,8 @@ test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCO Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' diff --git a/t/t5411/test-0013-bad-protocol.sh b/t/t5411/test-0013-bad-protocol.sh index b9be12be77..095e613f6f 100644 --- a/t/t5411/test-0013-bad-protocol.sh +++ b/t/t5411/test-0013-bad-protocol.sh @@ -11,8 +11,8 @@ test_expect_success "setup proc-receive hook (unknown version, $PROTOCOL)" ' test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && # Check status report for git-push sed -n \ @@ -34,12 +34,9 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL)" ' EOF test_cmp expect actual-error && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (hook --die-read-version, $PROTOCOL)" ' @@ -55,25 +52,22 @@ test_expect_success "setup proc-receive hook (hook --die-read-version, $PROTOCOL test_expect_success "proc-receive: bad protocol (hook --die-read-version, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; }" \ -e "/^ ! / { p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && - grep "remote: fatal: die with the --die-read-version option" out && - grep "remote: error: fail to negotiate version with proc-receive hook" out && + grep "remote: fatal: die with the --die-read-version option" out-$test_count && + grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (hook --die-write-version, $PROTOCOL)" ' @@ -89,25 +83,22 @@ test_expect_success "setup proc-receive hook (hook --die-write-version, $PROTOCO test_expect_success "proc-receive: bad protocol (hook --die-write-version, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; }" \ -e "/^ ! / { p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && - grep "remote: fatal: die with the --die-write-version option" out && - grep "remote: error: fail to negotiate version with proc-receive hook" out && + grep "remote: fatal: die with the --die-write-version option" out-$test_count && + grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (hook --die-read-commands, $PROTOCOL)" ' @@ -123,24 +114,21 @@ test_expect_success "setup proc-receive hook (hook --die-read-commands, $PROTOCO test_expect_success "proc-receive: bad protocol (hook --die-read-commands, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; }" \ -e "/^ ! / { p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && - grep "remote: fatal: die with the --die-read-commands option" out && + grep "remote: fatal: die with the --die-read-commands option" out-$test_count && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (hook --die-read-push-options, $PROTOCOL)" ' @@ -158,24 +146,21 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-push-options, $ test_must_fail git -C workbench push origin \ -o reviewers=user1,user2 \ HEAD:refs/for/main/topic \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; }" \ -e "/^ ! / { p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && - grep "remote: fatal: die with the --die-read-push-options option" out && + grep "remote: fatal: die with the --die-read-push-options option" out-$test_count && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (hook --die-write-report, $PROTOCOL)" ' @@ -191,24 +176,21 @@ test_expect_success "setup proc-receive hook (hook --die-write-report, $PROTOCOL test_expect_success "proc-receive: bad protocol (hook --die-write-report, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; }" \ -e "/^ ! / { p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && - grep "remote: fatal: die with the --die-write-report option" out && + grep "remote: fatal: die with the --die-write-report option" out-$test_count && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (no report, $PROTOCOL)" ' @@ -224,8 +206,8 @@ test_expect_success "setup proc-receive hook (no report, $PROTOCOL)" ' test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/heads/next \ - HEAD:refs/for/main/topic >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + HEAD:refs/for/main/topic >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next @@ -240,13 +222,10 @@ test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL)" ' EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF - test_cmp expect actual ' # Refs of upstream : main(A) next(A) @@ -270,8 +249,8 @@ test_expect_success "setup proc-receive hook (no ref, $PROTOCOL)" ' test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic\ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic @@ -284,12 +263,9 @@ test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL)" ' EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (unknown status, $PROTOCOL)" ' @@ -306,8 +282,8 @@ test_expect_success "setup proc-receive hook (unknown status, $PROTOCOL)" ' test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic @@ -320,10 +296,7 @@ test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL)" ' EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' diff --git a/t/t5411/test-0014-bad-protocol--porcelain.sh b/t/t5411/test-0014-bad-protocol--porcelain.sh index fdb4569109..a44649789c 100644 --- a/t/t5411/test-0014-bad-protocol--porcelain.sh +++ b/t/t5411/test-0014-bad-protocol--porcelain.sh @@ -11,8 +11,8 @@ test_expect_success "setup proc-receive hook (unknown version, $PROTOCOL/porcela test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && # Check status report for git-push sed -n \ @@ -34,12 +34,9 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL/porc EOF test_cmp expect actual-error && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (hook --die-read-version, $PROTOCOL/porcelain)" ' @@ -55,25 +52,22 @@ test_expect_success "setup proc-receive hook (hook --die-read-version, $PROTOCOL test_expect_success "proc-receive: bad protocol (hook --die-read-version, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; n; p; n; p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) Done EOF test_cmp expect actual && - grep "remote: fatal: die with the --die-read-version option" out && - grep "remote: error: fail to negotiate version with proc-receive hook" out && + grep "remote: fatal: die with the --die-read-version option" out-$test_count && + grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (hook --die-write-version, $PROTOCOL/porcelain)" ' @@ -89,25 +83,22 @@ test_expect_success "setup proc-receive hook (hook --die-write-version, $PROTOCO test_expect_success "proc-receive: bad protocol (hook --die-write-version, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; n; p; n; p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) Done EOF test_cmp expect actual && - grep "remote: fatal: die with the --die-write-version option" out && - grep "remote: error: fail to negotiate version with proc-receive hook" out && + grep "remote: fatal: die with the --die-write-version option" out-$test_count && + grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (hook --die-read-commands, $PROTOCOL/porcelain)" ' @@ -123,24 +114,21 @@ test_expect_success "setup proc-receive hook (hook --die-read-commands, $PROTOCO test_expect_success "proc-receive: bad protocol (hook --die-read-commands, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; n; p; n; p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) Done EOF test_cmp expect actual && - grep "remote: fatal: die with the --die-read-commands option" out && + grep "remote: fatal: die with the --die-read-commands option" out-$test_count && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (hook --die-read-push-options, $PROTOCOL/porcelain)" ' @@ -158,24 +146,21 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-push-options, $ test_must_fail git -C workbench push --porcelain origin \ -o reviewers=user1,user2 \ HEAD:refs/for/main/topic \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; n; p; n; p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) Done EOF test_cmp expect actual && - grep "remote: fatal: die with the --die-read-push-options option" out && + grep "remote: fatal: die with the --die-read-push-options option" out-$test_count && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (hook --die-write-report, $PROTOCOL/porcelain)" ' @@ -191,24 +176,21 @@ test_expect_success "setup proc-receive hook (hook --die-write-report, $PROTOCOL test_expect_success "proc-receive: bad protocol (hook --die-write-report, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; n; p; n; p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) Done EOF test_cmp expect actual && - grep "remote: fatal: die with the --die-write-report option" out && + grep "remote: fatal: die with the --die-write-report option" out-$test_count && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (no report, $PROTOCOL/porcelain)" ' @@ -224,8 +206,8 @@ test_expect_success "setup proc-receive hook (no report, $PROTOCOL/porcelain)" ' test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ HEAD:refs/heads/next \ - HEAD:refs/for/main/topic >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + HEAD:refs/for/main/topic >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next @@ -241,13 +223,10 @@ test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL/porcelain) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF - test_cmp expect actual ' # Refs of upstream : main(A) next(A) @@ -270,8 +249,8 @@ test_expect_success "setup proc-receive hook (no ref, $PROTOCOL/porcelain)" ' test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ HEAD:refs/for/main/topic\ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic @@ -285,12 +264,9 @@ test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL/porcelain)" ' EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (unknown status, $PROTOCOL/porcelain)" ' @@ -307,8 +283,8 @@ test_expect_success "setup proc-receive hook (unknown status, $PROTOCOL/porcelai test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic @@ -322,10 +298,7 @@ test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL/porce EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' diff --git a/t/t5411/test-0020-report-ng.sh b/t/t5411/test-0020-report-ng.sh index 5a9e0daf2d..ad2c8f6535 100644 --- a/t/t5411/test-0020-report-ng.sh +++ b/t/t5411/test-0020-report-ng.sh @@ -12,8 +12,8 @@ test_expect_success "setup proc-receive hook (ng, no message, $PROTOCOL)" ' test_expect_success "proc-receive: fail to update (ng, no message, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic @@ -24,12 +24,10 @@ test_expect_success "proc-receive: fail to update (ng, no message, $PROTOCOL)" ' ! [remote rejected] HEAD -> refs/for/main/topic (failed) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (ng message, $PROTOCOL)" ' @@ -46,8 +44,8 @@ test_expect_success "setup proc-receive hook (ng message, $PROTOCOL)" ' test_expect_success "proc-receive: fail to update (ng, with message, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic @@ -58,10 +56,8 @@ test_expect_success "proc-receive: fail to update (ng, with message, $PROTOCOL)" ! [remote rejected] HEAD -> refs/for/main/topic (error msg) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' diff --git a/t/t5411/test-0021-report-ng--porcelain.sh b/t/t5411/test-0021-report-ng--porcelain.sh index 93475a83cf..d8ae9d3414 100644 --- a/t/t5411/test-0021-report-ng--porcelain.sh +++ b/t/t5411/test-0021-report-ng--porcelain.sh @@ -12,8 +12,8 @@ test_expect_success "setup proc-receive hook (ng, no message, $PROTOCOL/porcelai test_expect_success "proc-receive: fail to update (ng, no message, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic @@ -25,12 +25,10 @@ test_expect_success "proc-receive: fail to update (ng, no message, $PROTOCOL/por Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (ng message, $PROTOCOL/porcelain)" ' @@ -47,8 +45,8 @@ test_expect_success "setup proc-receive hook (ng message, $PROTOCOL/porcelain)" test_expect_success "proc-receive: fail to update (ng, with message, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic @@ -60,10 +58,8 @@ test_expect_success "proc-receive: fail to update (ng, with message, $PROTOCOL/p Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' diff --git a/t/t5411/test-0022-report-unexpect-ref.sh b/t/t5411/test-0022-report-unexpect-ref.sh index f8be8a0ba1..dbed467186 100644 --- a/t/t5411/test-0022-report-unexpect-ref.sh +++ b/t/t5411/test-0022-report-unexpect-ref.sh @@ -13,8 +13,8 @@ test_expect_success "proc-receive: report unexpected ref ($PROTOCOL)" ' test_must_fail git -C workbench push origin \ $B:refs/heads/main \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main @@ -30,12 +30,10 @@ test_expect_success "proc-receive: report unexpected ref ($PROTOCOL)" ' ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-B> refs/heads/main EOF - test_cmp expect actual ' # Refs of upstream : main(B) diff --git a/t/t5411/test-0023-report-unexpect-ref--porcelain.sh b/t/t5411/test-0023-report-unexpect-ref--porcelain.sh index 778150fa03..e89096fa13 100644 --- a/t/t5411/test-0023-report-unexpect-ref--porcelain.sh +++ b/t/t5411/test-0023-report-unexpect-ref--porcelain.sh @@ -13,8 +13,8 @@ test_expect_success "proc-receive: report unexpected ref ($PROTOCOL/porcelain)" test_must_fail git -C workbench push --porcelain origin \ $B:refs/heads/main \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main @@ -31,12 +31,10 @@ test_expect_success "proc-receive: report unexpected ref ($PROTOCOL/porcelain)" Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-B> refs/heads/main EOF - test_cmp expect actual ' # Refs of upstream : main(B) diff --git a/t/t5411/test-0024-report-unknown-ref.sh b/t/t5411/test-0024-report-unknown-ref.sh index d4e74e4681..77204244b8 100644 --- a/t/t5411/test-0024-report-unknown-ref.sh +++ b/t/t5411/test-0024-report-unknown-ref.sh @@ -12,8 +12,8 @@ test_expect_success "setup proc-receive hook (unexpected ref, $PROTOCOL)" ' test_expect_success "proc-receive: report unknown reference ($PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/a/b/c/my/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/my/topic @@ -25,10 +25,8 @@ test_expect_success "proc-receive: report unknown reference ($PROTOCOL)" ' ! [remote rejected] HEAD -> refs/for/a/b/c/my/topic (proc-receive failed to report status) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' diff --git a/t/t5411/test-0025-report-unknown-ref--porcelain.sh b/t/t5411/test-0025-report-unknown-ref--porcelain.sh index 039e8b6163..eeb1ce6b2c 100644 --- a/t/t5411/test-0025-report-unknown-ref--porcelain.sh +++ b/t/t5411/test-0025-report-unknown-ref--porcelain.sh @@ -12,8 +12,8 @@ test_expect_success "setup proc-receive hook (unexpected ref, $PROTOCOL/porcelai test_expect_success "proc-receive: report unknown reference ($PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ HEAD:refs/for/a/b/c/my/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/my/topic @@ -26,10 +26,8 @@ test_expect_success "proc-receive: report unknown reference ($PROTOCOL/porcelain Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' diff --git a/t/t5411/test-0026-push-options.sh b/t/t5411/test-0026-push-options.sh index e88edb16a4..1ec2cb95bc 100644 --- a/t/t5411/test-0026-push-options.sh +++ b/t/t5411/test-0026-push-options.sh @@ -16,16 +16,14 @@ test_expect_success "proc-receive: not support push options ($PROTOCOL)" ' -o reviewer=user1 \ origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && test_i18ngrep "fatal: the receiving end does not support push options" \ actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "enable push options ($PROTOCOL)" ' @@ -69,13 +67,11 @@ test_expect_success "proc-receive: ignore push-options for version 0 ($PROTOCOL) * [new reference] HEAD -> refs/for/main/topic EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF - test_cmp expect actual ' test_expect_success "restore proc-receive hook ($PROTOCOL)" ' @@ -123,13 +119,11 @@ test_expect_success "proc-receive: push with options ($PROTOCOL)" ' * [new reference] HEAD -> refs/for/main/topic EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF - test_cmp expect actual ' # Refs of upstream : main(A) next(A) diff --git a/t/t5411/test-0027-push-options--porcelain.sh b/t/t5411/test-0027-push-options--porcelain.sh index 3a6561b5ea..447fbfec0c 100644 --- a/t/t5411/test-0027-push-options--porcelain.sh +++ b/t/t5411/test-0027-push-options--porcelain.sh @@ -17,16 +17,14 @@ test_expect_success "proc-receive: not support push options ($PROTOCOL/porcelain -o reviewer=user1 \ origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && test_i18ngrep "fatal: the receiving end does not support push options" \ actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "enable push options ($PROTOCOL/porcelain)" ' @@ -72,13 +70,11 @@ test_expect_success "proc-receive: ignore push-options for version 0 ($PROTOCOL/ Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF - test_cmp expect actual ' test_expect_success "restore proc-receive hook ($PROTOCOL/porcelain)" ' @@ -128,13 +124,11 @@ test_expect_success "proc-receive: push with options ($PROTOCOL/porcelain)" ' Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF - test_cmp expect actual ' # Refs of upstream : main(A) next(A) diff --git a/t/t5411/test-0030-report-ok.sh b/t/t5411/test-0030-report-ok.sh index 5d6feef118..8acb4f204f 100644 --- a/t/t5411/test-0030-report-ok.sh +++ b/t/t5411/test-0030-report-ok.sh @@ -26,10 +26,8 @@ test_expect_success "proc-receive: ok ($PROTOCOL)" ' * [new reference] HEAD -> refs/for/main/topic EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' diff --git a/t/t5411/test-0031-report-ok--porcelain.sh b/t/t5411/test-0031-report-ok--porcelain.sh index 91666d32df..a967718046 100644 --- a/t/t5411/test-0031-report-ok--porcelain.sh +++ b/t/t5411/test-0031-report-ok--porcelain.sh @@ -27,10 +27,8 @@ test_expect_success "proc-receive: ok ($PROTOCOL/porcelain)" ' Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' diff --git a/t/t5411/test-0032-report-with-options.sh b/t/t5411/test-0032-report-with-options.sh index a0faf5c7ff..437ade012d 100644 --- a/t/t5411/test-0032-report-with-options.sh +++ b/t/t5411/test-0032-report-with-options.sh @@ -13,8 +13,8 @@ test_expect_success "setup proc-receive hook (option without matching ok, $PROTO test_expect_success "proc-receive: report option without matching ok ($PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic @@ -247,10 +247,7 @@ test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL)" ' EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' diff --git a/t/t5411/test-0033-report-with-options--porcelain.sh b/t/t5411/test-0033-report-with-options--porcelain.sh index 32ae26bcfb..11486720ee 100644 --- a/t/t5411/test-0033-report-with-options--porcelain.sh +++ b/t/t5411/test-0033-report-with-options--porcelain.sh @@ -13,8 +13,8 @@ test_expect_success "setup proc-receive hook (option without matching ok, $PROTO test_expect_success "proc-receive: report option without matching ok ($PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic @@ -256,10 +256,7 @@ test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL/porc EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' diff --git a/t/t5411/test-0034-report-ft.sh b/t/t5411/test-0034-report-ft.sh index c355c290d2..6e0d08b327 100644 --- a/t/t5411/test-0034-report-ft.sh +++ b/t/t5411/test-0034-report-ft.sh @@ -28,13 +28,11 @@ test_expect_success "proc-receive: fall throught, let receive-pack to execute ($ * [new reference] <COMMIT-B> -> refs/for/main/topic EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-B> refs/for/main/topic <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' # Refs of upstream : main(A) refs/for/main/topic(A) diff --git a/t/t5411/test-0035-report-ft--porcelain.sh b/t/t5411/test-0035-report-ft--porcelain.sh index 8ce4e58f2a..81bae9f2ec 100644 --- a/t/t5411/test-0035-report-ft--porcelain.sh +++ b/t/t5411/test-0035-report-ft--porcelain.sh @@ -29,13 +29,11 @@ test_expect_success "proc-receive: fall throught, let receive-pack to execute ($ Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-B> refs/for/main/topic <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' # Refs of upstream : main(A) refs/for/main/topic(A) diff --git a/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh b/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh index fad8eea8a0..be9b18b2b6 100644 --- a/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh +++ b/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh @@ -65,12 +65,10 @@ test_expect_success "proc-receive: multiple rewrite for one ref, no refname for <OID-A>..<OID-B> HEAD -> refs/changes/25/125/1 EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "proc-receive: check remote-tracking #1 ($PROTOCOL)" ' @@ -142,12 +140,10 @@ test_expect_success "proc-receive: multiple rewrites for one ref, no refname for + <OID-B>...<OID-A> HEAD -> refs/changes/25/125/1 (forced update) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "proc-receive: check remote-tracking #2 ($PROTOCOL)" ' @@ -205,12 +201,10 @@ test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL)" ' <OID-A>..<OID-B> HEAD -> refs/changes/24/124/2 EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "proc-receive: check remote-tracking #3 ($PROTOCOL)" ' diff --git a/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh b/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh index dc254d57eb..95fb89c031 100644 --- a/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh +++ b/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh @@ -51,12 +51,10 @@ test_expect_success "proc-receive: multiple rewrite for one ref, no refname for Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (multiple rewrites for one ref, no refname for the 2nd rewrite, $PROTOCOL/porcelain)" ' @@ -114,12 +112,10 @@ test_expect_success "proc-receive: multiple rewrites for one ref, no refname for Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (multiple rewrites for one ref, $PROTOCOL/porcelain)" ' @@ -163,10 +159,8 @@ test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL/porc Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' diff --git a/t/t5411/test-0038-report-mixed-refs.sh b/t/t5411/test-0038-report-mixed-refs.sh index 0d071ebaa6..5e005299cc 100644 --- a/t/t5411/test-0038-report-mixed-refs.sh +++ b/t/t5411/test-0038-report-mixed-refs.sh @@ -24,8 +24,8 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL)" ' HEAD:refs/heads/foo \ HEAD:refs/for/main/topic \ HEAD:refs/for/next/topic3 \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main @@ -65,15 +65,13 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL)" ' ! [remote rejected] HEAD -> refs/for/next/topic3 (proc-receive failed to report status) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/bar <COMMIT-A> refs/heads/baz <COMMIT-A> refs/heads/foo <COMMIT-B> refs/heads/main EOF - test_cmp expect actual ' # Refs of upstream : main(B) foo(A) bar(A)) baz(A) diff --git a/t/t5411/test-0039-report-mixed-refs--porcelain.sh b/t/t5411/test-0039-report-mixed-refs--porcelain.sh index d8409912fd..8f891c5385 100644 --- a/t/t5411/test-0039-report-mixed-refs--porcelain.sh +++ b/t/t5411/test-0039-report-mixed-refs--porcelain.sh @@ -24,8 +24,8 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL/porcel HEAD:refs/heads/foo \ HEAD:refs/for/main/topic \ HEAD:refs/for/next/topic3 \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main @@ -66,15 +66,13 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL/porcel Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/bar <COMMIT-A> refs/heads/baz <COMMIT-A> refs/heads/foo <COMMIT-B> refs/heads/main EOF - test_cmp expect actual ' # Refs of upstream : main(B) foo(A) bar(A)) baz(A) diff --git a/t/t5411/test-0040-process-all-refs.sh b/t/t5411/test-0040-process-all-refs.sh index 2565302a17..fdcdcc7c2e 100644 --- a/t/t5411/test-0040-process-all-refs.sh +++ b/t/t5411/test-0040-process-all-refs.sh @@ -92,14 +92,12 @@ test_expect_success "proc-receive: process all refs ($PROTOCOL)" ' + <OID-B>...<OID-A> HEAD -> refs/pull/124/head (forced update) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-B> refs/heads/bar <COMMIT-A> refs/heads/baz <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' # Refs of upstream : main(A) bar(A) baz(B) diff --git a/t/t5411/test-0041-process-all-refs--porcelain.sh b/t/t5411/test-0041-process-all-refs--porcelain.sh index e21420b60d..73b35fe0aa 100644 --- a/t/t5411/test-0041-process-all-refs--porcelain.sh +++ b/t/t5411/test-0041-process-all-refs--porcelain.sh @@ -93,14 +93,12 @@ test_expect_success "proc-receive: process all refs ($PROTOCOL/porcelain)" ' Done EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-B> refs/heads/bar <COMMIT-A> refs/heads/baz <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' # Refs of upstream : main(A) bar(A) baz(B) diff --git a/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh b/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh index 2e29518ec5..7214647ada 100644 --- a/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh +++ b/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh @@ -50,12 +50,10 @@ test_expect_success "proc-receive: update branch and new tag ($PROTOCOL)" ' * [new reference] v123 -> refs/pull/124/head EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' # Refs of upstream : main(A) @@ -63,14 +61,12 @@ test_expect_success "proc-receive: update branch and new tag ($PROTOCOL)" ' test_expect_success "setup upstream: create tags/v123 ($PROTOCOL)" ' git -C "$upstream" update-ref refs/heads/topic $A && git -C "$upstream" update-ref refs/tags/v123 $TAG && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/topic <TAG-v123> refs/tags/v123 EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook ($PROTOCOL)" ' @@ -125,11 +121,9 @@ test_expect_success "proc-receive: create/delete branch, and delete tag ($PROTOC * [new reference] <COMMIT-A> -> refs/pull/124/head EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main <COMMIT-B> refs/heads/topic EOF - test_cmp expect actual ' diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 3557374312..8a5d3492c7 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -5,6 +5,9 @@ test_description='Testing multi_ack pack fetching' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # Test fetch-pack/upload-pack pair. @@ -407,14 +410,14 @@ test_expect_success 'in_vain resetted upon ACK' ' rm -rf myserver myclient && git init myserver && - # Linked list of commits on master. The first is common; the rest are + # Linked list of commits on main. The first is common; the rest are # not. - test_commit -C myserver first_master_commit && + test_commit -C myserver first_main_commit && git clone "file://$(pwd)/myserver" myclient && test_commit_bulk -C myclient 255 && # Another linked list of commits on anotherbranch with no connection to - # master. The first is common; the rest are not. + # main. The first is common; the rest are not. git -C myserver checkout --orphan anotherbranch && test_commit -C myserver first_anotherbranch_commit && git -C myclient fetch origin anotherbranch:refs/heads/anotherbranch && @@ -422,14 +425,14 @@ test_expect_success 'in_vain resetted upon ACK' ' test_commit_bulk -C myclient 255 && # The new commit that the client wants to fetch. - git -C myserver checkout master && + git -C myserver checkout main && test_commit -C myserver to_fetch && # The client will send (as "have"s) all 256 commits in anotherbranch # first. The 256th commit is common between the client and the server, # and should reset in_vain. This allows negotiation to continue until # the client reports that first_anotherbranch_commit is common. - git -C myclient fetch --progress origin master 2>log && + git -C myclient fetch --progress origin main 2>log && test_i18ngrep "Total 3 " log ' @@ -544,7 +547,7 @@ test_expect_success 'test lonely missing ref' ' cd client && test_must_fail git fetch-pack --no-progress .. refs/heads/xyzzy 2>../error-m ) && - test_i18ncmp expect-error error-m + test_cmp expect-error error-m ' test_expect_success 'test missing ref after existing' ' @@ -552,7 +555,7 @@ test_expect_success 'test missing ref after existing' ' cd client && test_must_fail git fetch-pack --no-progress .. refs/heads/A refs/heads/xyzzy 2>../error-em ) && - test_i18ncmp expect-error error-em + test_cmp expect-error error-em ' test_expect_success 'test missing ref before existing' ' @@ -560,7 +563,7 @@ test_expect_success 'test missing ref before existing' ' cd client && test_must_fail git fetch-pack --no-progress .. refs/heads/xyzzy refs/heads/A 2>../error-me ) && - test_i18ncmp expect-error error-me + test_cmp expect-error error-me ' test_expect_success 'test --all, --depth, and explicit head' ' @@ -637,7 +640,7 @@ test_expect_success 'shallow fetch with tags does not break the repository' ' mkdir repo2 && cd repo2 && git init && - git fetch --depth=2 ../.git master:branch && + git fetch --depth=2 ../.git main:branch && git fsck ) ' @@ -662,7 +665,7 @@ test_expect_success 'fetch-pack can fetch a raw sha1 that is advertised as a ref git init client && git -C client fetch-pack ../server \ - $(git -C server rev-parse refs/heads/master) + $(git -C server rev-parse refs/heads/main) ' test_expect_success 'fetch-pack can fetch a raw sha1 overlapping a named ref' ' @@ -688,7 +691,7 @@ test_expect_success 'fetch-pack cannot fetch a raw sha1 that is not advertised a # Some protocol versions (e.g. 2) support fetching # unadvertised objects, so restrict this test to v0. test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -C client fetch-pack ../server \ - $(git -C server rev-parse refs/heads/master^) 2>err && + $(git -C server rev-parse refs/heads/main^) 2>err && test_i18ngrep "Server does not allow request for unadvertised object" err ' @@ -822,7 +825,7 @@ test_expect_success 'clone shallow since ...' ' test_expect_success 'fetch shallow since ...' ' git -C shallow11 fetch --shallow-since "200000000 +0700" origin && - git -C shallow11 log --pretty=tformat:%s origin/master >actual && + git -C shallow11 log --pretty=tformat:%s origin/main >actual && cat >expected <<-\EOF && three two @@ -863,7 +866,7 @@ test_expect_success 'shallow since with commit graph and already-seen commit' ' ( cd shallow-since-graph && test_commit base && - test_commit master && + test_commit main && git checkout -b other HEAD^ && test_commit other && git commit-graph write --reachable && @@ -874,7 +877,7 @@ test_expect_success 'shallow since with commit graph and already-seen commit' ' $(echo "object-format=$(test_oid algo)" | packetize) 00010013deepen-since 1 $(echo "want $(git rev-parse other)" | packetize) - $(echo "have $(git rev-parse master)" | packetize) + $(echo "have $(git rev-parse main)" | packetize) 0000 EOF ) @@ -896,7 +899,7 @@ test_expect_success 'shallow clone exclude tag two' ' test_expect_success 'fetch exclude tag one' ' git -C shallow12 fetch --shallow-exclude one origin && - git -C shallow12 log --pretty=tformat:%s origin/master >actual && + git -C shallow12 log --pretty=tformat:%s origin/main >actual && test_write_lines three two >expected && test_cmp expected actual ' @@ -910,11 +913,11 @@ test_expect_success 'fetching deepen' ' test_commit three && git clone --depth 1 "file://$(pwd)/." deepen && test_commit four && - git -C deepen log --pretty=tformat:%s master >actual && + git -C deepen log --pretty=tformat:%s main >actual && echo three >expected && test_cmp expected actual && git -C deepen fetch --deepen=1 && - git -C deepen log --pretty=tformat:%s origin/master >actual && + git -C deepen log --pretty=tformat:%s origin/main >actual && cat >expected <<-\EOF && four three diff --git a/t/t5501-fetch-push-alternates.sh b/t/t5501-fetch-push-alternates.sh index 1bc57ac03f..66f19a4ef2 100755 --- a/t/t5501-fetch-push-alternates.sh +++ b/t/t5501-fetch-push-alternates.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='fetch/push involving alternates' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh count_objects () { @@ -45,7 +48,7 @@ test_expect_success setup ' test_expect_success 'pushing into a repository with the same alternate' ' ( cd one && - git push ../receiver master:refs/heads/it + git push ../receiver main:refs/heads/it ) && ( cd receiver && @@ -57,7 +60,7 @@ test_expect_success 'pushing into a repository with the same alternate' ' test_expect_success 'fetching from a repository with the same alternate' ' ( cd fetcher && - git fetch ../one master:refs/heads/it && + git fetch ../one main:refs/heads/it && count_objects >../fetcher.count ) && test_cmp one.count fetcher.count diff --git a/t/t5502-quickfetch.sh b/t/t5502-quickfetch.sh index 7a46cbdbe6..8c05c7715b 100755 --- a/t/t5502-quickfetch.sh +++ b/t/t5502-quickfetch.sh @@ -2,6 +2,9 @@ test_description='test quickfetch from local' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -108,14 +111,14 @@ test_expect_success 'quickfetch should not copy from alternate' ' q }" ) ) && - origin_master=$( ( + origin_main=$( ( cd quickclone && - git rev-parse origin/master + git rev-parse origin/main ) ) && echo "loose objects: $obj_cnt, packfiles: $pck_cnt" && test $obj_cnt -eq 0 && test $pck_cnt -eq 0 && - test z$origin_master = z$(git rev-parse master) + test z$origin_main = z$(git rev-parse main) ' diff --git a/t/t5503-tagfollow.sh b/t/t5503-tagfollow.sh index 6041a4dd32..195fc64dd4 100755 --- a/t/t5503-tagfollow.sh +++ b/t/t5503-tagfollow.sh @@ -2,6 +2,9 @@ test_description='test automatic tag following' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # End state of the repository: @@ -11,7 +14,7 @@ test_description='test automatic tag following' # L - A ------ O ------ B # \ \ \ # \ C - origin/cat \ -# origin/master master +# origin/main main test_expect_success setup ' test_tick && @@ -57,7 +60,7 @@ test_expect_success 'fetch A (new commit : 1 connection)' ' ( cd cloned && GIT_TRACE_PACKET=$UPATH git fetch && - test $A = $(git rev-parse --verify origin/master) + test $A = $(git rev-parse --verify origin/main) ) && get_needs $U >actual && test_cmp expect actual @@ -72,7 +75,7 @@ test_expect_success "create tag T on A, create C on branch cat" ' git add file && git commit -m C && C=$(git rev-parse --verify HEAD) && - git checkout master + git checkout main ' test_expect_success 'setup expect' ' @@ -123,7 +126,7 @@ test_expect_success 'fetch B, S (commit and tag : 1 connection)' ' ( cd cloned && GIT_TRACE_PACKET=$UPATH git fetch && - test $B = $(git rev-parse --verify origin/master) && + test $B = $(git rev-parse --verify origin/main) && test $B = $(git rev-parse --verify tag2^0) && test $S = $(git rev-parse --verify tag2) ) && @@ -138,7 +141,7 @@ want $S EOF ' -test_expect_success 'new clone fetch master and tags' ' +test_expect_success 'new clone fetch main and tags' ' test_might_fail git branch -D cat && rm -f $U && ( @@ -147,7 +150,7 @@ test_expect_success 'new clone fetch master and tags' ' git init && git remote add origin .. && GIT_TRACE_PACKET=$UPATH git fetch && - test $B = $(git rev-parse --verify origin/master) && + test $B = $(git rev-parse --verify origin/main) && test $S = $(git rev-parse --verify tag2) && test $B = $(git rev-parse --verify tag2^0) && test $T = $(git rev-parse --verify tag1) && diff --git a/t/t5504-fetch-receive-strict.sh b/t/t5504-fetch-receive-strict.sh index 1a16ac4c0d..6e5a9c20e7 100755 --- a/t/t5504-fetch-receive-strict.sh +++ b/t/t5504-fetch-receive-strict.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='fetch/receive strict mode' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup and inject "corrupt or missing" object' ' @@ -25,7 +28,7 @@ test_expect_success 'fetch without strict' ' cd dst && git config fetch.fsckobjects false && git config transfer.fsckobjects false && - test_must_fail git fetch ../.git master + test_must_fail git fetch ../.git main ) ' @@ -36,7 +39,7 @@ test_expect_success 'fetch with !fetch.fsckobjects' ' cd dst && git config fetch.fsckobjects false && git config transfer.fsckobjects true && - test_must_fail git fetch ../.git master + test_must_fail git fetch ../.git main ) ' @@ -47,7 +50,7 @@ test_expect_success 'fetch with fetch.fsckobjects' ' cd dst && git config fetch.fsckobjects true && git config transfer.fsckobjects false && - test_must_fail git fetch ../.git master + test_must_fail git fetch ../.git main ) ' @@ -57,13 +60,13 @@ test_expect_success 'fetch with transfer.fsckobjects' ' ( cd dst && git config transfer.fsckobjects true && - test_must_fail git fetch ../.git master + test_must_fail git fetch ../.git main ) ' cat >exp <<EOF To dst -! refs/heads/master:refs/heads/test [remote rejected] (missing necessary objects) +! refs/heads/main:refs/heads/test [remote rejected] (missing necessary objects) Done EOF @@ -75,7 +78,7 @@ test_expect_success 'push without strict' ' git config fetch.fsckobjects false && git config transfer.fsckobjects false ) && - test_must_fail git push --porcelain dst master:refs/heads/test >act && + test_must_fail git push --porcelain dst main:refs/heads/test >act && test_cmp exp act ' @@ -87,13 +90,13 @@ test_expect_success 'push with !receive.fsckobjects' ' git config receive.fsckobjects false && git config transfer.fsckobjects true ) && - test_must_fail git push --porcelain dst master:refs/heads/test >act && + test_must_fail git push --porcelain dst main:refs/heads/test >act && test_cmp exp act ' cat >exp <<EOF To dst -! refs/heads/master:refs/heads/test [remote rejected] (unpacker error) +! refs/heads/main:refs/heads/test [remote rejected] (unpacker error) EOF test_expect_success 'push with receive.fsckobjects' ' @@ -104,7 +107,7 @@ test_expect_success 'push with receive.fsckobjects' ' git config receive.fsckobjects true && git config transfer.fsckobjects false ) && - test_must_fail git push --porcelain dst master:refs/heads/test >act && + test_must_fail git push --porcelain dst main:refs/heads/test >act && test_cmp exp act ' @@ -115,7 +118,7 @@ test_expect_success 'push with transfer.fsckobjects' ' cd dst && git config transfer.fsckobjects true ) && - test_must_fail git push --porcelain dst master:refs/heads/test >act && + test_must_fail git push --porcelain dst main:refs/heads/test >act && test_cmp exp act ' diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index ecadf02d64..c7b392794b 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -2,6 +2,9 @@ test_description='git remote porcelain-ish' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh setup_repository () { @@ -56,7 +59,7 @@ test_expect_success 'add remote whose URL agrees with url.<...>.insteadOf' ' git remote add myremote git@host.com:team/repo.git ' -test_expect_success C_LOCALE_OUTPUT 'remote information for the origin' ' +test_expect_success 'remote information for the origin' ' ( cd test && tokens_match origin "$(git remote)" && @@ -78,7 +81,7 @@ test_expect_success 'add another remote' ' ) ' -test_expect_success C_LOCALE_OUTPUT 'check remote-tracking' ' +test_expect_success 'check remote-tracking' ' ( cd test && check_remote_track origin main side && @@ -104,7 +107,7 @@ test_expect_success 'remove remote' ' ) ' -test_expect_success C_LOCALE_OUTPUT 'remove remote' ' +test_expect_success 'remove remote' ' ( cd test && tokens_match origin "$(git remote)" && @@ -137,8 +140,8 @@ test_expect_success 'remove remote protects local branches' ' git remote rm oops 2>actual2 && git branch -d foobranch && git tag -d footag && - test_i18ncmp expect1 actual1 && - test_i18ncmp expect2 actual2 + test_cmp expect1 actual1 && + test_cmp expect2 actual2 ) ' @@ -147,7 +150,7 @@ test_expect_success 'remove errors out early when deleting non-existent branch' cd test && echo "error: No such remote: '\''foo'\''" >expect && test_expect_code 2 git remote rm foo 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ) ' @@ -175,7 +178,7 @@ test_expect_success 'rename errors out early when deleting non-existent branch' cd test && echo "error: No such remote: '\''foo'\''" >expect && test_expect_code 2 git remote rename foo bar 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ) ' @@ -183,14 +186,14 @@ test_expect_success 'rename errors out early when when new name is invalid' ' test_config remote.foo.vcs bar && echo "fatal: '\''invalid...name'\'' is not a valid remote name" >expect && test_must_fail git remote rename foo invalid...name 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'add existing foreign_vcs remote' ' test_config remote.foo.vcs bar && echo "error: remote foo already exists." >expect && test_expect_code 3 git remote add foo bar 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'add existing foreign_vcs remote' ' @@ -198,13 +201,13 @@ test_expect_success 'add existing foreign_vcs remote' ' test_config remote.bar.vcs bar && echo "error: remote bar already exists." >expect && test_expect_code 3 git remote rename foo bar 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'add invalid foreign_vcs remote' ' echo "fatal: '\''invalid...name'\'' is not a valid remote name" >expect && test_must_fail git remote add invalid...name bar 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' cat >test/expect <<EOF @@ -264,7 +267,7 @@ test_expect_success 'show' ' git config --add remote.two.push refs/heads/main:refs/heads/another && git remote show origin two >output && git branch -d rebase octopus && - test_i18ncmp expect output + test_cmp expect output ) ' @@ -291,7 +294,7 @@ test_expect_success 'show -n' ' cd test && git remote show -n origin >output && mv ../one.unreachable ../one && - test_i18ncmp expect output + test_cmp expect output ) ' @@ -334,7 +337,7 @@ test_expect_success 'set-head --auto has no problem w/multiple HEADs' ' git fetch two "refs/heads/*:refs/remotes/two/*" && git remote set-head --auto two >output 2>&1 && echo "two/HEAD set to main" >expect && - test_i18ncmp expect output + test_cmp expect output ) ' @@ -366,7 +369,7 @@ test_expect_success 'prune --dry-run' ' git remote prune --dry-run origin >output && git rev-parse refs/remotes/origin/side2 && test_must_fail git rev-parse refs/remotes/origin/side && - test_i18ncmp expect output + test_cmp expect output ) ' @@ -591,6 +594,7 @@ test_expect_success 'add --no-tags' ' cd add-no-tags && git init && git remote add -f --no-tags origin ../one && + grep tagOpt .git/config && git tag -l some-tag >../test/output && git tag -l foobar-tag >../test/output && git config remote.origin.tagopt >>../test/output @@ -753,6 +757,7 @@ test_expect_success 'rename a remote' ' cd four && git config branch.main.pushRemote origin && git remote rename origin upstream && + grep "pushRemote" .git/config && test -z "$(git for-each-ref refs/remotes/origin)" && test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/main" && test "$(git rev-parse upstream/main)" = "$(git rev-parse main)" && @@ -769,6 +774,7 @@ test_expect_success 'rename a remote renames repo remote.pushDefault' ' cd four.1 && git config remote.pushDefault origin && git remote rename origin upstream && + grep pushDefault .git/config && test "$(git config --local remote.pushDefault)" = "upstream" ) ' diff --git a/t/t5506-remote-groups.sh b/t/t5506-remote-groups.sh index 83d5558c0e..8f150c0793 100755 --- a/t/t5506-remote-groups.sh +++ b/t/t5506-remote-groups.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='git remote group handling' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh mark() { @@ -31,8 +34,8 @@ repo_fetched() { test_expect_success 'setup' ' mkdir one && (cd one && git init) && mkdir two && (cd two && git init) && - git remote add -m master one one && - git remote add -m master two two + git remote add -m main one one && + git remote add -m main two two ' test_expect_success 'no group updates all' ' diff --git a/t/t5509-fetch-push-namespaces.sh b/t/t5509-fetch-push-namespaces.sh index a67f792adf..31553b48df 100755 --- a/t/t5509-fetch-push-namespaces.sh +++ b/t/t5509-fetch-push-namespaces.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='fetch/push involving ref namespaces' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -27,9 +30,9 @@ test_expect_success setup ' test_expect_success 'pushing into a repository using a ref namespace' ' ( cd original && - git push pushee-namespaced master && + git push pushee-namespaced main && git ls-remote pushee-namespaced >actual && - printf "$commit1\trefs/heads/master\n" >expected && + printf "$commit1\trefs/heads/main\n" >expected && test_cmp expected actual && git push pushee-namespaced --tags && git ls-remote pushee-namespaced >actual && @@ -56,7 +59,7 @@ test_expect_success 'pulling from a repository using a ref namespace' ' cd puller && git remote add -f pushee-namespaced "ext::git --namespace=namespace %s ../pushee" && git for-each-ref refs/ >actual && - printf "$commit1 commit\trefs/remotes/pushee-namespaced/master\n" >expected && + printf "$commit1 commit\trefs/remotes/pushee-namespaced/main\n" >expected && printf "$commit0 commit\trefs/tags/0\n" >>expected && printf "$commit1 commit\trefs/tags/1\n" >>expected && test_cmp expected actual @@ -76,7 +79,7 @@ test_expect_success 'mirroring a repository using a ref namespace' ' ( cd mirror && git for-each-ref refs/ >actual && - printf "$commit1 commit\trefs/namespaces/namespace/refs/heads/master\n" >expected && + printf "$commit1 commit\trefs/namespaces/namespace/refs/heads/main\n" >expected && printf "$commit0 commit\trefs/namespaces/namespace/refs/tags/0\n" >>expected && printf "$commit1 commit\trefs/namespaces/namespace/refs/tags/1\n" >>expected && test_cmp expected actual @@ -87,7 +90,7 @@ test_expect_success 'hide namespaced refs with transfer.hideRefs' ' GIT_NAMESPACE=namespace \ git -C pushee -c transfer.hideRefs=refs/tags \ ls-remote "ext::git %s ." >actual && - printf "$commit1\trefs/heads/master\n" >expected && + printf "$commit1\trefs/heads/main\n" >expected && test_cmp expected actual ' @@ -95,7 +98,7 @@ test_expect_success 'check that transfer.hideRefs does not match unstripped refs GIT_NAMESPACE=namespace \ git -C pushee -c transfer.hideRefs=refs/namespaces/namespace/refs/tags \ ls-remote "ext::git %s ." >actual && - printf "$commit1\trefs/heads/master\n" >expected && + printf "$commit1\trefs/heads/main\n" >expected && printf "$commit0\trefs/tags/0\n" >>expected && printf "$commit1\trefs/tags/1\n" >>expected && test_cmp expected actual @@ -105,23 +108,23 @@ test_expect_success 'hide full refs with transfer.hideRefs' ' GIT_NAMESPACE=namespace \ git -C pushee -c transfer.hideRefs="^refs/namespaces/namespace/refs/tags" \ ls-remote "ext::git %s ." >actual && - printf "$commit1\trefs/heads/master\n" >expected && + printf "$commit1\trefs/heads/main\n" >expected && test_cmp expected actual ' test_expect_success 'try to update a hidden ref' ' - test_config -C pushee transfer.hideRefs refs/heads/master && - test_must_fail git -C original push pushee-namespaced master + test_config -C pushee transfer.hideRefs refs/heads/main && + test_must_fail git -C original push pushee-namespaced main ' test_expect_success 'try to update a ref that is not hidden' ' - test_config -C pushee transfer.hideRefs refs/namespaces/namespace/refs/heads/master && - git -C original push pushee-namespaced master + test_config -C pushee transfer.hideRefs refs/namespaces/namespace/refs/heads/main && + git -C original push pushee-namespaced main ' test_expect_success 'try to update a hidden full ref' ' - test_config -C pushee transfer.hideRefs "^refs/namespaces/namespace/refs/heads/master" && - test_must_fail git -C original push pushee-namespaced master + test_config -C pushee transfer.hideRefs "^refs/namespaces/namespace/refs/heads/main" && + test_must_fail git -C original push pushee-namespaced main ' test_expect_success 'set up ambiguous HEAD' ' @@ -157,9 +160,9 @@ test_expect_success 'denyCurrentBranch and unborn branch with ref namespace' ' cd original && git init unborn && git remote add unborn-namespaced "ext::git --namespace=namespace %s unborn" && - test_must_fail git push unborn-namespaced HEAD:master && + test_must_fail git push unborn-namespaced HEAD:main && git -C unborn config receive.denyCurrentBranch updateInstead && - git push unborn-namespaced HEAD:master + git push unborn-namespaced HEAD:main ) ' diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 2013051a64..e83b2a6506 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -5,23 +5,14 @@ test_description='Per branch config variables affects "git fetch". ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-bundle.sh D=$(pwd) -test_bundle_object_count () { - git verify-pack -v "$1" >verify.out && - test "$2" = $(grep "^$OID_REGEX " verify.out | wc -l) -} - -convert_bundle_to_pack () { - while read x && test -n "$x" - do - :; - done - cat -} - test_expect_success setup ' echo >file original && git add file && @@ -176,6 +167,174 @@ test_expect_success 'fetch --prune --tags with refspec prunes based on refspec' git rev-parse sometag ' +test_expect_success 'fetch --atomic works with a single branch' ' + test_when_finished "rm -rf \"$D\"/atomic" && + + cd "$D" && + git clone . atomic && + git branch atomic-branch && + oid=$(git rev-parse atomic-branch) && + echo "$oid" >expected && + + git -C atomic fetch --atomic origin && + git -C atomic rev-parse origin/atomic-branch >actual && + test_cmp expected actual && + test $oid = "$(git -C atomic rev-parse --verify FETCH_HEAD)" +' + +test_expect_success 'fetch --atomic works with multiple branches' ' + test_when_finished "rm -rf \"$D\"/atomic" && + + cd "$D" && + git clone . atomic && + git branch atomic-branch-1 && + git branch atomic-branch-2 && + git branch atomic-branch-3 && + git rev-parse refs/heads/atomic-branch-1 refs/heads/atomic-branch-2 refs/heads/atomic-branch-3 >actual && + + git -C atomic fetch --atomic origin && + git -C atomic rev-parse refs/remotes/origin/atomic-branch-1 refs/remotes/origin/atomic-branch-2 refs/remotes/origin/atomic-branch-3 >expected && + test_cmp expected actual +' + +test_expect_success 'fetch --atomic works with mixed branches and tags' ' + test_when_finished "rm -rf \"$D\"/atomic" && + + cd "$D" && + git clone . atomic && + git branch atomic-mixed-branch && + git tag atomic-mixed-tag && + git rev-parse refs/heads/atomic-mixed-branch refs/tags/atomic-mixed-tag >actual && + + git -C atomic fetch --tags --atomic origin && + git -C atomic rev-parse refs/remotes/origin/atomic-mixed-branch refs/tags/atomic-mixed-tag >expected && + test_cmp expected actual +' + +test_expect_success 'fetch --atomic prunes references' ' + test_when_finished "rm -rf \"$D\"/atomic" && + + cd "$D" && + git branch atomic-prune-delete && + git clone . atomic && + git branch --delete atomic-prune-delete && + git branch atomic-prune-create && + git rev-parse refs/heads/atomic-prune-create >actual && + + git -C atomic fetch --prune --atomic origin && + test_must_fail git -C atomic rev-parse refs/remotes/origin/atomic-prune-delete && + git -C atomic rev-parse refs/remotes/origin/atomic-prune-create >expected && + test_cmp expected actual +' + +test_expect_success 'fetch --atomic aborts with non-fast-forward update' ' + test_when_finished "rm -rf \"$D\"/atomic" && + + cd "$D" && + git branch atomic-non-ff && + git clone . atomic && + git rev-parse HEAD >actual && + + git branch atomic-new-branch && + parent_commit=$(git rev-parse atomic-non-ff~) && + git update-ref refs/heads/atomic-non-ff $parent_commit && + + test_must_fail git -C atomic fetch --atomic origin refs/heads/*:refs/remotes/origin/* && + test_must_fail git -C atomic rev-parse refs/remotes/origin/atomic-new-branch && + git -C atomic rev-parse refs/remotes/origin/atomic-non-ff >expected && + test_cmp expected actual && + test_must_be_empty atomic/.git/FETCH_HEAD +' + +test_expect_success 'fetch --atomic executes a single reference transaction only' ' + test_when_finished "rm -rf \"$D\"/atomic" && + + cd "$D" && + git clone . atomic && + git branch atomic-hooks-1 && + git branch atomic-hooks-2 && + head_oid=$(git rev-parse HEAD) && + + cat >expected <<-EOF && + prepared + $ZERO_OID $head_oid refs/remotes/origin/atomic-hooks-1 + $ZERO_OID $head_oid refs/remotes/origin/atomic-hooks-2 + committed + $ZERO_OID $head_oid refs/remotes/origin/atomic-hooks-1 + $ZERO_OID $head_oid refs/remotes/origin/atomic-hooks-2 + EOF + + rm -f atomic/actual && + write_script atomic/.git/hooks/reference-transaction <<-\EOF && + ( echo "$*" && cat ) >>actual + EOF + + git -C atomic fetch --atomic origin && + test_cmp expected atomic/actual +' + +test_expect_success 'fetch --atomic aborts all reference updates if hook aborts' ' + test_when_finished "rm -rf \"$D\"/atomic" && + + cd "$D" && + git clone . atomic && + git branch atomic-hooks-abort-1 && + git branch atomic-hooks-abort-2 && + git branch atomic-hooks-abort-3 && + git tag atomic-hooks-abort && + head_oid=$(git rev-parse HEAD) && + + cat >expected <<-EOF && + prepared + $ZERO_OID $head_oid refs/remotes/origin/atomic-hooks-abort-1 + $ZERO_OID $head_oid refs/remotes/origin/atomic-hooks-abort-2 + $ZERO_OID $head_oid refs/remotes/origin/atomic-hooks-abort-3 + $ZERO_OID $head_oid refs/tags/atomic-hooks-abort + aborted + $ZERO_OID $head_oid refs/remotes/origin/atomic-hooks-abort-1 + $ZERO_OID $head_oid refs/remotes/origin/atomic-hooks-abort-2 + $ZERO_OID $head_oid refs/remotes/origin/atomic-hooks-abort-3 + $ZERO_OID $head_oid refs/tags/atomic-hooks-abort + EOF + + rm -f atomic/actual && + write_script atomic/.git/hooks/reference-transaction <<-\EOF && + ( echo "$*" && cat ) >>actual + exit 1 + EOF + + git -C atomic for-each-ref >expected-refs && + test_must_fail git -C atomic fetch --tags --atomic origin && + git -C atomic for-each-ref >actual-refs && + test_cmp expected-refs actual-refs && + test_must_be_empty atomic/.git/FETCH_HEAD +' + +test_expect_success 'fetch --atomic --append appends to FETCH_HEAD' ' + test_when_finished "rm -rf \"$D\"/atomic" && + + cd "$D" && + git clone . atomic && + oid=$(git rev-parse HEAD) && + + git branch atomic-fetch-head-1 && + git -C atomic fetch --atomic origin atomic-fetch-head-1 && + test_line_count = 1 atomic/.git/FETCH_HEAD && + + git branch atomic-fetch-head-2 && + git -C atomic fetch --atomic --append origin atomic-fetch-head-2 && + test_line_count = 2 atomic/.git/FETCH_HEAD && + cp atomic/.git/FETCH_HEAD expected && + + write_script atomic/.git/hooks/reference-transaction <<-\EOF && + exit 1 + EOF + + git branch atomic-fetch-head-3 && + test_must_fail git -C atomic fetch --atomic --append origin atomic-fetch-head-3 && + test_cmp expected atomic/.git/FETCH_HEAD +' + test_expect_success '--refmap="" ignores configured refspec' ' cd "$TRASH_DIRECTORY" && git clone "$D" remote-refs && @@ -312,9 +471,7 @@ test_expect_success 'unbundle 1' ' test_expect_success 'bundle 1 has only 3 files ' ' cd "$D" && - convert_bundle_to_pack <bundle1 >bundle.pack && - git index-pack bundle.pack && - test_bundle_object_count bundle.pack 3 + test_bundle_object_count bundle1 3 ' test_expect_success 'unbundle 2' ' @@ -329,9 +486,7 @@ test_expect_success 'bundle does not prerequisite objects' ' git add file2 && git commit -m add.file2 file2 && git bundle create bundle3 -1 HEAD && - convert_bundle_to_pack <bundle3 >bundle.pack && - git index-pack bundle.pack && - test_bundle_object_count bundle.pack 3 + test_bundle_object_count bundle3 3 ' test_expect_success 'bundle should be able to create a full history' ' @@ -884,9 +1039,7 @@ test_expect_success 'all boundary commits are excluded' ' git merge otherside && ad=$(git log --no-walk --format=%ad HEAD) && git bundle create twoside-boundary.bdl main --since="$ad" && - convert_bundle_to_pack <twoside-boundary.bdl >twoside-boundary.pack && - pack=$(git index-pack --fix-thin --stdin <twoside-boundary.pack) && - test_bundle_object_count .git/objects/pack/pack-${pack##pack }.pack 3 + test_bundle_object_count --thin twoside-boundary.bdl 3 ' test_expect_success 'fetch --prune prints the remotes url' ' @@ -898,7 +1051,7 @@ test_expect_success 'fetch --prune prints the remotes url' ' git fetch --prune origin 2>&1 | head -n1 >../actual ) && echo "From ${D}/." >expect && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'branchname D/F conflict resolved by --prune' ' @@ -944,7 +1097,7 @@ test_expect_success 'fetching with auto-gc does not lock up' ' ) ' -test_expect_success C_LOCALE_OUTPUT 'fetch aligned output' ' +test_expect_success 'fetch aligned output' ' git clone . full-output && test_commit looooooooooooong-tag && ( @@ -959,7 +1112,7 @@ test_expect_success C_LOCALE_OUTPUT 'fetch aligned output' ' test_cmp expect actual ' -test_expect_success C_LOCALE_OUTPUT 'fetch compact output' ' +test_expect_success 'fetch compact output' ' git clone . compact && test_commit extraaa && ( diff --git a/t/t5511-refspec.sh b/t/t5511-refspec.sh index f808649de4..be025b90f9 100755 --- a/t/t5511-refspec.sh +++ b/t/t5511-refspec.sh @@ -33,7 +33,7 @@ test_refspec fetch '::' invalid test_refspec push 'refs/heads/*:refs/remotes/frotz/*' test_refspec push 'refs/heads/*:refs/remotes/frotz' invalid test_refspec push 'refs/heads:refs/remotes/frotz/*' invalid -test_refspec push 'refs/heads/master:refs/remotes/frotz/xyzzy' +test_refspec push 'refs/heads/main:refs/remotes/frotz/xyzzy' # These have invalid LHS, but we do not have a formal "valid sha-1 @@ -41,18 +41,18 @@ test_refspec push 'refs/heads/master:refs/remotes/frotz/xyzzy' # code. They will be caught downstream anyway, but we may want to # have tighter check later... -: test_refspec push 'refs/heads/master::refs/remotes/frotz/xyzzy' invalid +: test_refspec push 'refs/heads/main::refs/remotes/frotz/xyzzy' invalid : test_refspec push 'refs/heads/maste :refs/remotes/frotz/xyzzy' invalid test_refspec fetch 'refs/heads/*:refs/remotes/frotz/*' test_refspec fetch 'refs/heads/*:refs/remotes/frotz' invalid test_refspec fetch 'refs/heads:refs/remotes/frotz/*' invalid -test_refspec fetch 'refs/heads/master:refs/remotes/frotz/xyzzy' -test_refspec fetch 'refs/heads/master::refs/remotes/frotz/xyzzy' invalid +test_refspec fetch 'refs/heads/main:refs/remotes/frotz/xyzzy' +test_refspec fetch 'refs/heads/main::refs/remotes/frotz/xyzzy' invalid test_refspec fetch 'refs/heads/maste :refs/remotes/frotz/xyzzy' invalid -test_refspec push 'master~1:refs/remotes/frotz/backup' -test_refspec fetch 'master~1:refs/remotes/frotz/backup' invalid +test_refspec push 'main~1:refs/remotes/frotz/backup' +test_refspec fetch 'main~1:refs/remotes/frotz/backup' invalid test_refspec push 'HEAD~4:refs/remotes/frotz/new' test_refspec fetch 'HEAD~4:refs/remotes/frotz/new' invalid diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh index e98c3a0174..f53f58895a 100755 --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@ -2,6 +2,9 @@ test_description='git ls-remote' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh generate_references () { @@ -118,7 +121,7 @@ test_expect_success 'use branch.<name>.remote if possible' ' echo "From $URL" >exp_err && git remote add other $URL && - git config branch.master.remote other && + git config branch.main.remote other && git ls-remote 2>actual_err >actual && test_cmp exp_err actual_err && @@ -129,9 +132,9 @@ test_expect_success 'confuses pattern as remote when no remote specified' ' if test_have_prereq MINGW then # Windows does not like asterisks in pathname - does_not_exist=master + does_not_exist=main else - does_not_exist="refs*master" + does_not_exist="refs*main" fi && cat >exp <<-EOF && fatal: '\''$does_not_exist'\'' does not appear to be a git repository @@ -144,10 +147,10 @@ test_expect_success 'confuses pattern as remote when no remote specified' ' # Do not expect "git ls-remote <pattern>" to work; ls-remote needs # <remote> if you want to feed <pattern>, just like you cannot say # fetch <branch>. - # We could just as easily have used "master"; the "*" emphasizes its + # We could just as easily have used "main"; the "*" emphasizes its # role as a pattern. test_must_fail git ls-remote "$does_not_exist" >actual 2>&1 && - test_i18ncmp exp actual + test_cmp exp actual ' test_expect_success 'die with non-2 for wrong repository even with --exit-code' ' @@ -217,14 +220,14 @@ test_expect_success 'protocol v2 supports hiderefs' ' test_expect_success 'ls-remote --symref' ' git fetch origin && - echo "ref: refs/heads/master HEAD" >expect && + echo "ref: refs/heads/main HEAD" >expect && generate_references \ HEAD \ - refs/heads/master >>expect && + refs/heads/main >>expect && oid=$(git rev-parse HEAD) && echo "$oid refs/remotes/origin/HEAD" >>expect && generate_references \ - refs/remotes/origin/master \ + refs/remotes/origin/main \ refs/tags/mark \ refs/tags/mark1.1 \ refs/tags/mark1.10 \ @@ -238,7 +241,7 @@ test_expect_success 'ls-remote --symref' ' test_expect_success 'ls-remote with filtered symref (refname)' ' rev=$(git rev-parse HEAD) && cat >expect <<-EOF && - ref: refs/heads/master HEAD + ref: refs/heads/main HEAD $rev HEAD EOF # Protocol v2 supports sending symrefs for refs other than HEAD, so use @@ -252,7 +255,7 @@ test_expect_failure 'ls-remote with filtered symref (--heads)' ' cat >expect <<-EOF && ref: refs/tags/mark refs/heads/foo $rev refs/heads/foo - $rev refs/heads/master + $rev refs/heads/main EOF # Protocol v2 supports sending symrefs for refs other than HEAD, so use # protocol v0 here. @@ -263,7 +266,7 @@ test_expect_failure 'ls-remote with filtered symref (--heads)' ' test_expect_success 'ls-remote --symref omits filtered-out matches' ' cat >expect <<-EOF && $rev refs/heads/foo - $rev refs/heads/master + $rev refs/heads/main EOF # Protocol v2 supports sending symrefs for refs other than HEAD, so use # protocol v0 here. @@ -330,10 +333,10 @@ test_expect_success 'ls-remote --sort fails gracefully outside repository' ' test_expect_success 'ls-remote patterns work with all protocol versions' ' git for-each-ref --format="%(objectname) %(refname)" \ - refs/heads/master refs/remotes/origin/master >expect && - git -c protocol.version=1 ls-remote . master >actual.v1 && + refs/heads/main refs/remotes/origin/main >expect && + git -c protocol.version=1 ls-remote . main >actual.v1 && test_cmp expect actual.v1 && - git -c protocol.version=2 ls-remote . master >actual.v2 && + git -c protocol.version=2 ls-remote . main >actual.v2 && test_cmp expect actual.v2 ' diff --git a/t/t5514-fetch-multiple.sh b/t/t5514-fetch-multiple.sh index bd202ec6f3..511ba3bd45 100755 --- a/t/t5514-fetch-multiple.sh +++ b/t/t5514-fetch-multiple.sh @@ -2,6 +2,9 @@ test_description='fetch --all works correctly' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh setup_repository () { @@ -17,7 +20,7 @@ setup_repository () { git add elif && test_tick && git commit -m "Second" && - git checkout master + git checkout main ) } @@ -32,16 +35,16 @@ test_expect_success setup ' ' cat > test/expect << EOF - one/master + one/main one/side - origin/HEAD -> origin/master - origin/master + origin/HEAD -> origin/main + origin/main origin/side three/another - three/master + three/main three/side two/another - two/master + two/main two/side EOF @@ -70,15 +73,15 @@ test_expect_success 'git fetch --all should continue if a remote has errors' ' test_expect_success 'git fetch --all does not allow non-option arguments' ' (cd test && test_must_fail git fetch --all origin && - test_must_fail git fetch --all origin master) + test_must_fail git fetch --all origin main) ' cat > expect << EOF - origin/HEAD -> origin/master - origin/master + origin/HEAD -> origin/main + origin/main origin/side three/another - three/master + three/main three/side EOF @@ -92,10 +95,10 @@ test_expect_success 'git fetch --multiple (but only one remote)' ' ' cat > expect << EOF - one/master + one/main one/side two/another - two/master + two/main two/side EOF @@ -133,13 +136,13 @@ test_expect_success 'git fetch --all (skipFetchAll)' ' ' cat > expect << EOF - one/master + one/main one/side three/another - three/master + three/main three/side two/another - two/master + two/main two/side EOF diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index 3ed121d0ce..0916f76302 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -14,6 +14,9 @@ This test checks the following functionality: * reflogs ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh D=$(pwd) @@ -120,13 +123,13 @@ test_expect_success setup ' git add path1 && test_tick && git commit -a -m repo && - the_first_commit=$(git show-ref -s --verify refs/heads/master) && + the_first_commit=$(git show-ref -s --verify refs/heads/main) && >path2 && git add path2 && test_tick && git commit -a -m second && - the_commit=$(git show-ref -s --verify refs/heads/master) + the_commit=$(git show-ref -s --verify refs/heads/main) ' @@ -134,9 +137,9 @@ test_expect_success 'fetch without wildcard' ' mk_empty testrepo && ( cd testrepo && - git fetch .. refs/heads/master:refs/remotes/origin/master && + git fetch .. refs/heads/main:refs/remotes/origin/main && - echo "$the_commit commit refs/remotes/origin/master" >expect && + echo "$the_commit commit refs/remotes/origin/main" >expect && git for-each-ref refs/remotes/origin >actual && test_cmp expect actual ) @@ -150,7 +153,7 @@ test_expect_success 'fetch with wildcard' ' git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" && git fetch up && - echo "$the_commit commit refs/remotes/origin/master" >expect && + echo "$the_commit commit refs/remotes/origin/main" >expect && git for-each-ref refs/remotes/origin >actual && test_cmp expect actual ) @@ -166,7 +169,7 @@ test_expect_success 'fetch with insteadOf' ' git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" && git fetch up && - echo "$the_commit commit refs/remotes/origin/master" >expect && + echo "$the_commit commit refs/remotes/origin/main" >expect && git for-each-ref refs/remotes/origin >actual && test_cmp expect actual ) @@ -182,19 +185,54 @@ test_expect_success 'fetch with pushInsteadOf (should not rewrite)' ' git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" && git fetch up && - echo "$the_commit commit refs/remotes/origin/master" >expect && + echo "$the_commit commit refs/remotes/origin/main" >expect && git for-each-ref refs/remotes/origin >actual && test_cmp expect actual ) ' +grep_wrote () { + object_count=$1 + file_name=$2 + grep 'write_pack_file/wrote.*"value":"'$1'"' $2 +} + +test_expect_success 'push with negotiation' ' + # Without negotiation + mk_empty testrepo && + git push testrepo $the_first_commit:refs/remotes/origin/first_commit && + git -C testrepo config receive.hideRefs refs/remotes/origin/first_commit && + echo now pushing without negotiation && + GIT_TRACE2_EVENT="$(pwd)/event" git -c protocol.version=2 push testrepo refs/heads/main:refs/remotes/origin/main && + grep_wrote 5 event && # 2 commits, 2 trees, 1 blob + + # Same commands, but with negotiation + rm event && + mk_empty testrepo && + git push testrepo $the_first_commit:refs/remotes/origin/first_commit && + git -C testrepo config receive.hideRefs refs/remotes/origin/first_commit && + GIT_TRACE2_EVENT="$(pwd)/event" git -c protocol.version=2 -c push.negotiate=1 push testrepo refs/heads/main:refs/remotes/origin/main && + grep_wrote 2 event # 1 commit, 1 tree +' + +test_expect_success 'push with negotiation proceeds anyway even if negotiation fails' ' + rm event && + mk_empty testrepo && + git push testrepo $the_first_commit:refs/remotes/origin/first_commit && + git -C testrepo config receive.hideRefs refs/remotes/origin/first_commit && + GIT_TEST_PROTOCOL_VERSION=0 GIT_TRACE2_EVENT="$(pwd)/event" \ + git -c push.negotiate=1 push testrepo refs/heads/main:refs/remotes/origin/main 2>err && + grep_wrote 5 event && # 2 commits, 2 trees, 1 blob + test_i18ngrep "push negotiation failed" err +' + test_expect_success 'push without wildcard' ' mk_empty testrepo && - git push testrepo refs/heads/master:refs/remotes/origin/master && + git push testrepo refs/heads/main:refs/remotes/origin/main && ( cd testrepo && - echo "$the_commit commit refs/remotes/origin/master" >expect && + echo "$the_commit commit refs/remotes/origin/main" >expect && git for-each-ref refs/remotes/origin >actual && test_cmp expect actual ) @@ -206,7 +244,7 @@ test_expect_success 'push with wildcard' ' git push testrepo "refs/heads/*:refs/remotes/origin/*" && ( cd testrepo && - echo "$the_commit commit refs/remotes/origin/master" >expect && + echo "$the_commit commit refs/remotes/origin/main" >expect && git for-each-ref refs/remotes/origin >actual && test_cmp expect actual ) @@ -216,10 +254,10 @@ test_expect_success 'push with insteadOf' ' mk_empty testrepo && TRASH="$(pwd)/" && test_config "url.$TRASH.insteadOf" trash/ && - git push trash/testrepo refs/heads/master:refs/remotes/origin/master && + git push trash/testrepo refs/heads/main:refs/remotes/origin/main && ( cd testrepo && - echo "$the_commit commit refs/remotes/origin/master" >expect && + echo "$the_commit commit refs/remotes/origin/main" >expect && git for-each-ref refs/remotes/origin >actual && test_cmp expect actual ) @@ -229,10 +267,10 @@ test_expect_success 'push with pushInsteadOf' ' mk_empty testrepo && TRASH="$(pwd)/" && test_config "url.$TRASH.pushInsteadOf" trash/ && - git push trash/testrepo refs/heads/master:refs/remotes/origin/master && + git push trash/testrepo refs/heads/main:refs/remotes/origin/main && ( cd testrepo && - echo "$the_commit commit refs/remotes/origin/master" >expect && + echo "$the_commit commit refs/remotes/origin/main" >expect && git for-each-ref refs/remotes/origin >actual && test_cmp expect actual ) @@ -244,10 +282,10 @@ test_expect_success 'push with pushInsteadOf and explicit pushurl (pushInsteadOf test_config "url.trash3/.pushInsteadOf" trash/wrong && test_config remote.r.url trash/wrong && test_config remote.r.pushurl "testrepo/" && - git push r refs/heads/master:refs/remotes/origin/master && + git push r refs/heads/main:refs/remotes/origin/main && ( cd testrepo && - echo "$the_commit commit refs/remotes/origin/master" >expect && + echo "$the_commit commit refs/remotes/origin/main" >expect && git for-each-ref refs/remotes/origin >actual && test_cmp expect actual ) @@ -255,101 +293,101 @@ test_expect_success 'push with pushInsteadOf and explicit pushurl (pushInsteadOf test_expect_success 'push with matching heads' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && git push testrepo : && - check_push_result testrepo $the_commit heads/master + check_push_result testrepo $the_commit heads/main ' test_expect_success 'push with matching heads on the command line' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && git push testrepo : && - check_push_result testrepo $the_commit heads/master + check_push_result testrepo $the_commit heads/main ' test_expect_success 'failed (non-fast-forward) push with matching heads' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && git push testrepo : && git commit --amend -massaged && test_must_fail git push testrepo && - check_push_result testrepo $the_commit heads/master && + check_push_result testrepo $the_commit heads/main && git reset --hard $the_commit ' test_expect_success 'push --force with matching heads' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && git push testrepo : && git commit --amend -massaged && git push --force testrepo : && - ! check_push_result testrepo $the_commit heads/master && + ! check_push_result testrepo $the_commit heads/main && git reset --hard $the_commit ' test_expect_success 'push with matching heads and forced update' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && git push testrepo : && git commit --amend -massaged && git push testrepo +: && - ! check_push_result testrepo $the_commit heads/master && + ! check_push_result testrepo $the_commit heads/main && git reset --hard $the_commit ' test_expect_success 'push with no ambiguity (1)' ' - mk_test testrepo heads/master && - git push testrepo master:master && - check_push_result testrepo $the_commit heads/master + mk_test testrepo heads/main && + git push testrepo main:main && + check_push_result testrepo $the_commit heads/main ' test_expect_success 'push with no ambiguity (2)' ' - mk_test testrepo remotes/origin/master && - git push testrepo master:origin/master && - check_push_result testrepo $the_commit remotes/origin/master + mk_test testrepo remotes/origin/main && + git push testrepo main:origin/main && + check_push_result testrepo $the_commit remotes/origin/main ' test_expect_success 'push with colon-less refspec, no ambiguity' ' - mk_test testrepo heads/master heads/t/master && - git branch -f t/master master && - git push testrepo master && - check_push_result testrepo $the_commit heads/master && - check_push_result testrepo $the_first_commit heads/t/master + mk_test testrepo heads/main heads/t/main && + git branch -f t/main main && + git push testrepo main && + check_push_result testrepo $the_commit heads/main && + check_push_result testrepo $the_first_commit heads/t/main ' test_expect_success 'push with weak ambiguity (1)' ' - mk_test testrepo heads/master remotes/origin/master && - git push testrepo master:master && - check_push_result testrepo $the_commit heads/master && - check_push_result testrepo $the_first_commit remotes/origin/master + mk_test testrepo heads/main remotes/origin/main && + git push testrepo main:main && + check_push_result testrepo $the_commit heads/main && + check_push_result testrepo $the_first_commit remotes/origin/main ' test_expect_success 'push with weak ambiguity (2)' ' - mk_test testrepo heads/master remotes/origin/master remotes/another/master && - git push testrepo master:master && - check_push_result testrepo $the_commit heads/master && - check_push_result testrepo $the_first_commit remotes/origin/master remotes/another/master + mk_test testrepo heads/main remotes/origin/main remotes/another/main && + git push testrepo main:main && + check_push_result testrepo $the_commit heads/main && + check_push_result testrepo $the_first_commit remotes/origin/main remotes/another/main ' test_expect_success 'push with ambiguity' ' mk_test testrepo heads/frotz tags/frotz && - test_must_fail git push testrepo master:frotz && + test_must_fail git push testrepo main:frotz && check_push_result testrepo $the_first_commit heads/frotz tags/frotz ' @@ -357,7 +395,7 @@ test_expect_success 'push with ambiguity' ' test_expect_success 'push with colon-less refspec (1)' ' mk_test testrepo heads/frotz tags/frotz && - git branch -f frotz master && + git branch -f frotz main && git push testrepo frotz && check_push_result testrepo $the_commit heads/frotz && check_push_result testrepo $the_first_commit tags/frotz @@ -385,7 +423,7 @@ test_expect_success 'push with colon-less refspec (3)' ' then git tag -d frotz fi && - git branch -f frotz master && + git branch -f frotz main && git push testrepo frotz && check_push_result testrepo $the_commit heads/frotz && test 1 = $( cd testrepo && git show-ref | wc -l ) @@ -408,7 +446,7 @@ test_expect_success 'push with colon-less refspec (4)' ' test_expect_success 'push head with non-existent, incomplete dest' ' mk_test testrepo && - git push testrepo master:branch && + git push testrepo main:branch && check_push_result testrepo $the_commit heads/branch ' @@ -425,14 +463,14 @@ test_expect_success 'push tag with non-existent, incomplete dest' ' test_expect_success 'push sha1 with non-existent, incomplete dest' ' mk_test testrepo && - test_must_fail git push testrepo $(git rev-parse master):foo + test_must_fail git push testrepo $(git rev-parse main):foo ' test_expect_success 'push ref expression with non-existent, incomplete dest' ' mk_test testrepo && - test_must_fail git push testrepo master^:branch + test_must_fail git push testrepo main^:branch ' @@ -440,30 +478,26 @@ for head in HEAD @ do test_expect_success "push with $head" ' - - mk_test testrepo heads/master && - git checkout master && + mk_test testrepo heads/main && + git checkout main && git push testrepo $head && - check_push_result testrepo $the_commit heads/master - + check_push_result testrepo $the_commit heads/main ' test_expect_success "push with $head nonexisting at remote" ' - - mk_test testrepo heads/master && - git checkout -b local master && - test_when_finished "git checkout master; git branch -D local" && + mk_test testrepo heads/main && + git checkout -b local main && + test_when_finished "git checkout main; git branch -D local" && git push testrepo $head && check_push_result testrepo $the_commit heads/local ' test_expect_success "push with +$head" ' - - mk_test testrepo heads/master && - git checkout -b local master && - test_when_finished "git checkout master; git branch -D local" && - git push testrepo master local && - check_push_result testrepo $the_commit heads/master && + mk_test testrepo heads/main && + git checkout -b local main && + test_when_finished "git checkout main; git branch -D local" && + git push testrepo main local && + check_push_result testrepo $the_commit heads/main && check_push_result testrepo $the_commit heads/local && # Without force rewinding should fail @@ -474,22 +508,19 @@ do # With force rewinding should succeed git push testrepo +$head && check_push_result testrepo $the_first_commit heads/local - ' test_expect_success "push $head with non-existent, incomplete dest" ' - mk_test testrepo && - git checkout master && + git checkout main && git push testrepo $head:branch && check_push_result testrepo $the_commit heads/branch ' test_expect_success "push with config remote.*.push = $head" ' - mk_test testrepo heads/local && - git checkout master && + git checkout main && git branch -f local $the_commit && test_when_finished "git branch -D local" && ( @@ -499,168 +530,168 @@ do ) && test_config remote.there.url testrepo && test_config remote.there.push $head && - test_config branch.master.remote there && + test_config branch.main.remote there && git push && - check_push_result testrepo $the_commit heads/master && + check_push_result testrepo $the_commit heads/main && check_push_result testrepo $the_first_commit heads/local ' done test_expect_success 'push with remote.pushdefault' ' - mk_test up_repo heads/master && - mk_test down_repo heads/master && + mk_test up_repo heads/main && + mk_test down_repo heads/main && test_config remote.up.url up_repo && test_config remote.down.url down_repo && - test_config branch.master.remote up && + test_config branch.main.remote up && test_config remote.pushdefault down && test_config push.default matching && git push && - check_push_result up_repo $the_first_commit heads/master && - check_push_result down_repo $the_commit heads/master + check_push_result up_repo $the_first_commit heads/main && + check_push_result down_repo $the_commit heads/main ' test_expect_success 'push with config remote.*.pushurl' ' - mk_test testrepo heads/master && - git checkout master && + mk_test testrepo heads/main && + git checkout main && test_config remote.there.url test2repo && test_config remote.there.pushurl testrepo && git push there : && - check_push_result testrepo $the_commit heads/master + check_push_result testrepo $the_commit heads/main ' test_expect_success 'push with config branch.*.pushremote' ' - mk_test up_repo heads/master && - mk_test side_repo heads/master && - mk_test down_repo heads/master && + mk_test up_repo heads/main && + mk_test side_repo heads/main && + mk_test down_repo heads/main && test_config remote.up.url up_repo && test_config remote.pushdefault side_repo && test_config remote.down.url down_repo && - test_config branch.master.remote up && - test_config branch.master.pushremote down && + test_config branch.main.remote up && + test_config branch.main.pushremote down && test_config push.default matching && git push && - check_push_result up_repo $the_first_commit heads/master && - check_push_result side_repo $the_first_commit heads/master && - check_push_result down_repo $the_commit heads/master + check_push_result up_repo $the_first_commit heads/main && + check_push_result side_repo $the_first_commit heads/main && + check_push_result down_repo $the_commit heads/main ' test_expect_success 'branch.*.pushremote config order is irrelevant' ' - mk_test one_repo heads/master && - mk_test two_repo heads/master && + mk_test one_repo heads/main && + mk_test two_repo heads/main && test_config remote.one.url one_repo && test_config remote.two.url two_repo && - test_config branch.master.pushremote two_repo && + test_config branch.main.pushremote two_repo && test_config remote.pushdefault one_repo && test_config push.default matching && git push && - check_push_result one_repo $the_first_commit heads/master && - check_push_result two_repo $the_commit heads/master + check_push_result one_repo $the_first_commit heads/main && + check_push_result two_repo $the_commit heads/main ' test_expect_success 'push with dry-run' ' - mk_test testrepo heads/master && - old_commit=$(git -C testrepo show-ref -s --verify refs/heads/master) && + mk_test testrepo heads/main && + old_commit=$(git -C testrepo show-ref -s --verify refs/heads/main) && git push --dry-run testrepo : && - check_push_result testrepo $old_commit heads/master + check_push_result testrepo $old_commit heads/main ' test_expect_success 'push updates local refs' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && mk_child testrepo child && ( cd child && - git pull .. master && + git pull .. main && git push && - test $(git rev-parse master) = \ - $(git rev-parse remotes/origin/master) + test $(git rev-parse main) = \ + $(git rev-parse remotes/origin/main) ) ' test_expect_success 'push updates up-to-date local refs' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && mk_child testrepo child1 && mk_child testrepo child2 && - (cd child1 && git pull .. master && git push) && + (cd child1 && git pull .. main && git push) && ( cd child2 && - git pull ../child1 master && + git pull ../child1 main && git push && - test $(git rev-parse master) = \ - $(git rev-parse remotes/origin/master) + test $(git rev-parse main) = \ + $(git rev-parse remotes/origin/main) ) ' test_expect_success 'push preserves up-to-date packed refs' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && mk_child testrepo child && ( cd child && git push && - ! test -f .git/refs/remotes/origin/master + ! test -f .git/refs/remotes/origin/main ) ' test_expect_success 'push does not update local refs on failure' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && mk_child testrepo child && mkdir testrepo/.git/hooks && echo "#!/no/frobnication/today" >testrepo/.git/hooks/pre-receive && chmod +x testrepo/.git/hooks/pre-receive && ( cd child && - git pull .. master && + git pull .. main && test_must_fail git push && - test $(git rev-parse master) != \ - $(git rev-parse remotes/origin/master) + test $(git rev-parse main) != \ + $(git rev-parse remotes/origin/main) ) ' test_expect_success 'allow deleting an invalid remote ref' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && rm -f testrepo/.git/objects/??/* && - git push testrepo :refs/heads/master && - (cd testrepo && test_must_fail git rev-parse --verify refs/heads/master) + git push testrepo :refs/heads/main && + (cd testrepo && test_must_fail git rev-parse --verify refs/heads/main) ' test_expect_success 'pushing valid refs triggers post-receive and post-update hooks' ' - mk_test_with_hooks testrepo heads/master heads/next && - orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) && - newmaster=$(git show-ref -s --verify refs/heads/master) && + mk_test_with_hooks testrepo heads/main heads/next && + orgmain=$(cd testrepo && git show-ref -s --verify refs/heads/main) && + newmain=$(git show-ref -s --verify refs/heads/main) && orgnext=$(cd testrepo && git show-ref -s --verify refs/heads/next) && newnext=$ZERO_OID && - git push testrepo refs/heads/master:refs/heads/master :refs/heads/next && + git push testrepo refs/heads/main:refs/heads/main :refs/heads/next && ( cd testrepo/.git && cat >pre-receive.expect <<-EOF && - $orgmaster $newmaster refs/heads/master + $orgmain $newmain refs/heads/main $orgnext $newnext refs/heads/next EOF cat >update.expect <<-EOF && - refs/heads/master $orgmaster $newmaster + refs/heads/main $orgmain $newmain refs/heads/next $orgnext $newnext EOF cat >post-receive.expect <<-EOF && - $orgmaster $newmaster refs/heads/master + $orgmain $newmain refs/heads/main $orgnext $newnext refs/heads/next EOF cat >post-update.expect <<-EOF && - refs/heads/master + refs/heads/main refs/heads/next EOF @@ -672,25 +703,25 @@ test_expect_success 'pushing valid refs triggers post-receive and post-update ho ' test_expect_success 'deleting dangling ref triggers hooks with correct args' ' - mk_test_with_hooks testrepo heads/master && + mk_test_with_hooks testrepo heads/main && rm -f testrepo/.git/objects/??/* && - git push testrepo :refs/heads/master && + git push testrepo :refs/heads/main && ( cd testrepo/.git && cat >pre-receive.expect <<-EOF && - $ZERO_OID $ZERO_OID refs/heads/master + $ZERO_OID $ZERO_OID refs/heads/main EOF cat >update.expect <<-EOF && - refs/heads/master $ZERO_OID $ZERO_OID + refs/heads/main $ZERO_OID $ZERO_OID EOF cat >post-receive.expect <<-EOF && - $ZERO_OID $ZERO_OID refs/heads/master + $ZERO_OID $ZERO_OID refs/heads/main EOF cat >post-update.expect <<-EOF && - refs/heads/master + refs/heads/main EOF test_cmp pre-receive.expect pre-receive.actual && @@ -701,28 +732,28 @@ test_expect_success 'deleting dangling ref triggers hooks with correct args' ' ' test_expect_success 'deletion of a non-existent ref is not fed to post-receive and post-update hooks' ' - mk_test_with_hooks testrepo heads/master && - orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) && - newmaster=$(git show-ref -s --verify refs/heads/master) && - git push testrepo master :refs/heads/nonexistent && + mk_test_with_hooks testrepo heads/main && + orgmain=$(cd testrepo && git show-ref -s --verify refs/heads/main) && + newmain=$(git show-ref -s --verify refs/heads/main) && + git push testrepo main :refs/heads/nonexistent && ( cd testrepo/.git && cat >pre-receive.expect <<-EOF && - $orgmaster $newmaster refs/heads/master + $orgmain $newmain refs/heads/main $ZERO_OID $ZERO_OID refs/heads/nonexistent EOF cat >update.expect <<-EOF && - refs/heads/master $orgmaster $newmaster + refs/heads/main $orgmain $newmain refs/heads/nonexistent $ZERO_OID $ZERO_OID EOF cat >post-receive.expect <<-EOF && - $orgmaster $newmaster refs/heads/master + $orgmain $newmain refs/heads/main EOF cat >post-update.expect <<-EOF && - refs/heads/master + refs/heads/main EOF test_cmp pre-receive.expect pre-receive.actual && @@ -733,7 +764,7 @@ test_expect_success 'deletion of a non-existent ref is not fed to post-receive a ' test_expect_success 'deletion of a non-existent ref alone does trigger post-receive and post-update hooks' ' - mk_test_with_hooks testrepo heads/master && + mk_test_with_hooks testrepo heads/main && git push testrepo :refs/heads/nonexistent && ( cd testrepo/.git && @@ -753,40 +784,40 @@ test_expect_success 'deletion of a non-existent ref alone does trigger post-rece ' test_expect_success 'mixed ref updates, deletes, invalid deletes trigger hooks with correct input' ' - mk_test_with_hooks testrepo heads/master heads/next heads/seen && - orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) && - newmaster=$(git show-ref -s --verify refs/heads/master) && + mk_test_with_hooks testrepo heads/main heads/next heads/seen && + orgmain=$(cd testrepo && git show-ref -s --verify refs/heads/main) && + newmain=$(git show-ref -s --verify refs/heads/main) && orgnext=$(cd testrepo && git show-ref -s --verify refs/heads/next) && newnext=$ZERO_OID && orgseen=$(cd testrepo && git show-ref -s --verify refs/heads/seen) && - newseen=$(git show-ref -s --verify refs/heads/master) && - git push testrepo refs/heads/master:refs/heads/master \ - refs/heads/master:refs/heads/seen :refs/heads/next \ + newseen=$(git show-ref -s --verify refs/heads/main) && + git push testrepo refs/heads/main:refs/heads/main \ + refs/heads/main:refs/heads/seen :refs/heads/next \ :refs/heads/nonexistent && ( cd testrepo/.git && cat >pre-receive.expect <<-EOF && - $orgmaster $newmaster refs/heads/master + $orgmain $newmain refs/heads/main $orgnext $newnext refs/heads/next $orgseen $newseen refs/heads/seen $ZERO_OID $ZERO_OID refs/heads/nonexistent EOF cat >update.expect <<-EOF && - refs/heads/master $orgmaster $newmaster + refs/heads/main $orgmain $newmain refs/heads/next $orgnext $newnext refs/heads/seen $orgseen $newseen refs/heads/nonexistent $ZERO_OID $ZERO_OID EOF cat >post-receive.expect <<-EOF && - $orgmaster $newmaster refs/heads/master + $orgmain $newmain refs/heads/main $orgnext $newnext refs/heads/next $orgseen $newseen refs/heads/seen EOF cat >post-update.expect <<-EOF && - refs/heads/master + refs/heads/main refs/heads/next refs/heads/seen EOF @@ -799,15 +830,15 @@ test_expect_success 'mixed ref updates, deletes, invalid deletes trigger hooks w ' test_expect_success 'allow deleting a ref using --delete' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && (cd testrepo && git config receive.denyDeleteCurrent warn) && - git push testrepo --delete master && - (cd testrepo && test_must_fail git rev-parse --verify refs/heads/master) + git push testrepo --delete main && + (cd testrepo && test_must_fail git rev-parse --verify refs/heads/main) ' test_expect_success 'allow deleting a tag using --delete' ' - mk_test testrepo heads/master && - git tag -a -m dummy_message deltag heads/master && + mk_test testrepo heads/main && + git tag -a -m dummy_message deltag heads/main && git push testrepo --tags && (cd testrepo && git rev-parse --verify -q refs/tags/deltag) && git push testrepo --delete tag deltag && @@ -815,56 +846,61 @@ test_expect_success 'allow deleting a tag using --delete' ' ' test_expect_success 'push --delete without args aborts' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && test_must_fail git push testrepo --delete ' test_expect_success 'push --delete refuses src:dest refspecs' ' + mk_test testrepo heads/main && + test_must_fail git push testrepo --delete main:foo +' + +test_expect_success 'push --delete refuses empty string' ' mk_test testrepo heads/master && - test_must_fail git push testrepo --delete master:foo + test_must_fail git push testrepo --delete "" ' test_expect_success 'warn on push to HEAD of non-bare repository' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && ( cd testrepo && - git checkout master && + git checkout main && git config receive.denyCurrentBranch warn ) && - git push testrepo master 2>stderr && + git push testrepo main 2>stderr && grep "warning: updating the current branch" stderr ' test_expect_success 'deny push to HEAD of non-bare repository' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && ( cd testrepo && - git checkout master && + git checkout main && git config receive.denyCurrentBranch true ) && - test_must_fail git push testrepo master + test_must_fail git push testrepo main ' test_expect_success 'allow push to HEAD of bare repository (bare)' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && ( cd testrepo && - git checkout master && + git checkout main && git config receive.denyCurrentBranch true && git config core.bare true ) && - git push testrepo master 2>stderr && + git push testrepo main 2>stderr && ! grep "warning: updating the current branch" stderr ' test_expect_success 'allow push to HEAD of non-bare repository (config)' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && ( cd testrepo && - git checkout master && + git checkout main && git config receive.denyCurrentBranch false ) && - git push testrepo master 2>stderr && + git push testrepo main 2>stderr && ! grep "warning: updating the current branch" stderr ' @@ -880,7 +916,7 @@ test_expect_success 'fetch with branches' ' git for-each-ref refs/heads >actual && test_cmp expect actual ) && - git checkout master + git checkout main ' test_expect_success 'fetch with branches containing #' ' @@ -893,7 +929,7 @@ test_expect_success 'fetch with branches containing #' ' git for-each-ref refs/heads >actual && test_cmp expect actual ) && - git checkout master + git checkout main ' test_expect_success 'push with branches' ' @@ -903,7 +939,7 @@ test_expect_success 'push with branches' ' git push branch1 && ( cd testrepo && - echo "$the_first_commit commit refs/heads/master" >expect && + echo "$the_first_commit commit refs/heads/main" >expect && git for-each-ref refs/heads >actual && test_cmp expect actual ) @@ -919,11 +955,11 @@ test_expect_success 'push with branches containing #' ' git for-each-ref refs/heads >actual && test_cmp expect actual ) && - git checkout master + git checkout main ' test_expect_success 'push into aliased refs (consistent)' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && mk_child testrepo child1 && mk_child testrepo child2 && ( @@ -945,7 +981,7 @@ test_expect_success 'push into aliased refs (consistent)' ' ' test_expect_success 'push into aliased refs (inconsistent)' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && mk_child testrepo child1 && mk_child testrepo child2 && ( @@ -976,7 +1012,7 @@ test_force_push_tag () { tag_args=$2 test_expect_success "force pushing required to update $tag_type_description" " - mk_test testrepo heads/master && + mk_test testrepo heads/main && mk_child testrepo child1 && mk_child testrepo child2 && ( @@ -1022,7 +1058,7 @@ test_force_fetch_tag () { tag_args=$2 test_expect_success "fetch will not clobber an existing $tag_type_description without --force" " - mk_test testrepo heads/master && + mk_test testrepo heads/main && mk_child testrepo child1 && mk_child testrepo child2 && ( @@ -1045,12 +1081,12 @@ test_force_fetch_tag "annotated tag" "-f -a -m'tag message'" test_expect_success 'push --porcelain' ' mk_empty testrepo && echo >.git/foo "To testrepo" && - echo >>.git/foo "* refs/heads/master:refs/remotes/origin/master [new reference]" && + echo >>.git/foo "* refs/heads/main:refs/remotes/origin/main [new reference]" && echo >>.git/foo "Done" && - git push >.git/bar --porcelain testrepo refs/heads/master:refs/remotes/origin/master && + git push >.git/bar --porcelain testrepo refs/heads/main:refs/remotes/origin/main && ( cd testrepo && - echo "$the_commit commit refs/remotes/origin/master" >expect && + echo "$the_commit commit refs/remotes/origin/main" >expect && git for-each-ref refs/remotes/origin >actual && test_cmp expect actual ) && @@ -1059,52 +1095,52 @@ test_expect_success 'push --porcelain' ' test_expect_success 'push --porcelain bad url' ' mk_empty testrepo && - test_must_fail git push >.git/bar --porcelain asdfasdfasd refs/heads/master:refs/remotes/origin/master && + test_must_fail git push >.git/bar --porcelain asdfasdfasd refs/heads/main:refs/remotes/origin/main && ! grep -q Done .git/bar ' test_expect_success 'push --porcelain rejected' ' mk_empty testrepo && - git push testrepo refs/heads/master:refs/remotes/origin/master && + git push testrepo refs/heads/main:refs/remotes/origin/main && (cd testrepo && - git reset --hard origin/master^ && + git reset --hard origin/main^ && git config receive.denyCurrentBranch true) && echo >.git/foo "To testrepo" && - echo >>.git/foo "! refs/heads/master:refs/heads/master [remote rejected] (branch is currently checked out)" && + echo >>.git/foo "! refs/heads/main:refs/heads/main [remote rejected] (branch is currently checked out)" && echo >>.git/foo "Done" && - test_must_fail git push >.git/bar --porcelain testrepo refs/heads/master:refs/heads/master && + test_must_fail git push >.git/bar --porcelain testrepo refs/heads/main:refs/heads/main && test_cmp .git/foo .git/bar ' test_expect_success 'push --porcelain --dry-run rejected' ' mk_empty testrepo && - git push testrepo refs/heads/master:refs/remotes/origin/master && + git push testrepo refs/heads/main:refs/remotes/origin/main && (cd testrepo && - git reset --hard origin/master && + git reset --hard origin/main && git config receive.denyCurrentBranch true) && echo >.git/foo "To testrepo" && - echo >>.git/foo "! refs/heads/master^:refs/heads/master [rejected] (non-fast-forward)" && + echo >>.git/foo "! refs/heads/main^:refs/heads/main [rejected] (non-fast-forward)" && echo >>.git/foo "Done" && - test_must_fail git push >.git/bar --porcelain --dry-run testrepo refs/heads/master^:refs/heads/master && + test_must_fail git push >.git/bar --porcelain --dry-run testrepo refs/heads/main^:refs/heads/main && test_cmp .git/foo .git/bar ' test_expect_success 'push --prune' ' - mk_test testrepo heads/master heads/second heads/foo heads/bar && + mk_test testrepo heads/main heads/second heads/foo heads/bar && git push --prune testrepo : && - check_push_result testrepo $the_commit heads/master && + check_push_result testrepo $the_commit heads/main && check_push_result testrepo $the_first_commit heads/second && ! check_push_result testrepo $the_first_commit heads/foo heads/bar ' test_expect_success 'push --prune refspec' ' - mk_test testrepo tmp/master tmp/second tmp/foo tmp/bar && + mk_test testrepo tmp/main tmp/second tmp/foo tmp/bar && git push --prune testrepo "refs/heads/*:refs/tmp/*" && - check_push_result testrepo $the_commit tmp/master && + check_push_result testrepo $the_commit tmp/main && check_push_result testrepo $the_first_commit tmp/second && ! check_push_result testrepo $the_first_commit tmp/foo tmp/bar ' @@ -1112,18 +1148,18 @@ test_expect_success 'push --prune refspec' ' for configsection in transfer receive do test_expect_success "push to update a ref hidden by $configsection.hiderefs" ' - mk_test testrepo heads/master hidden/one hidden/two hidden/three && + mk_test testrepo heads/main hidden/one hidden/two hidden/three && ( cd testrepo && git config $configsection.hiderefs refs/hidden ) && # push to unhidden ref succeeds normally - git push testrepo master:refs/heads/master && - check_push_result testrepo $the_commit heads/master && + git push testrepo main:refs/heads/main && + check_push_result testrepo $the_commit heads/main && # push to update a hidden ref should fail - test_must_fail git push testrepo master:refs/hidden/one && + test_must_fail git push testrepo main:refs/hidden/one && check_push_result testrepo $the_first_commit hidden/one && # push to delete a hidden ref should fail @@ -1137,8 +1173,8 @@ do done test_expect_success 'fetch exact SHA1' ' - mk_test testrepo heads/master hidden/one && - git push testrepo master:refs/hidden/one && + mk_test testrepo heads/main hidden/one && + git push testrepo main:refs/hidden/one && ( cd testrepo && git config transfer.hiderefs refs/hidden @@ -1169,7 +1205,7 @@ test_expect_success 'fetch exact SHA1' ' git config uploadpack.allowtipsha1inwant true ) && - git fetch -v ../testrepo $the_commit:refs/heads/copy master:refs/heads/extra && + git fetch -v ../testrepo $the_commit:refs/heads/copy main:refs/heads/extra && cat >expect <<-EOF && $the_commit $the_first_commit @@ -1183,8 +1219,8 @@ test_expect_success 'fetch exact SHA1' ' ' test_expect_success 'fetch exact SHA1 in protocol v2' ' - mk_test testrepo heads/master hidden/one && - git push testrepo master:refs/hidden/one && + mk_test testrepo heads/main hidden/one && + git push testrepo main:refs/hidden/one && git -C testrepo config transfer.hiderefs refs/hidden && check_push_result testrepo $the_commit hidden/one && @@ -1268,17 +1304,17 @@ do done test_expect_success 'fetch follows tags by default' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && rm -fr src dst && git init src && ( cd src && - git pull ../testrepo master && + git pull ../testrepo main && git tag -m "annotated" tag && git for-each-ref >tmp1 && ( cat tmp1 - sed -n "s|refs/heads/master$|refs/remotes/origin/master|p" tmp1 + sed -n "s|refs/heads/main$|refs/remotes/origin/main|p" tmp1 ) | sort -k 3 >../expect ) && @@ -1286,8 +1322,8 @@ test_expect_success 'fetch follows tags by default' ' ( cd dst && git remote add origin ../src && - git config branch.master.remote origin && - git config branch.master.merge refs/heads/master && + git config branch.main.remote origin && + git config branch.main.merge refs/heads/main && git pull && git for-each-ref >../actual ) && @@ -1306,74 +1342,74 @@ test_expect_success 'peeled advertisements are not considered ref tips' ' ' test_expect_success 'pushing a specific ref applies remote.$name.push as refmap' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && rm -fr src dst && git init src && git init --bare dst && ( cd src && - git pull ../testrepo master && + git pull ../testrepo main && git branch next && git config remote.dst.url ../dst && git config remote.dst.push "+refs/heads/*:refs/remotes/src/*" && - git push dst master && - git show-ref refs/heads/master | + git push dst main && + git show-ref refs/heads/main | sed -e "s|refs/heads/|refs/remotes/src/|" >../dst/expect ) && ( cd dst && test_must_fail git show-ref refs/heads/next && - test_must_fail git show-ref refs/heads/master && - git show-ref refs/remotes/src/master >actual + test_must_fail git show-ref refs/heads/main && + git show-ref refs/remotes/src/main >actual ) && test_cmp dst/expect dst/actual ' test_expect_success 'with no remote.$name.push, it is not used as refmap' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && rm -fr src dst && git init src && git init --bare dst && ( cd src && - git pull ../testrepo master && + git pull ../testrepo main && git branch next && git config remote.dst.url ../dst && git config push.default matching && - git push dst master && - git show-ref refs/heads/master >../dst/expect + git push dst main && + git show-ref refs/heads/main >../dst/expect ) && ( cd dst && test_must_fail git show-ref refs/heads/next && - git show-ref refs/heads/master >actual + git show-ref refs/heads/main >actual ) && test_cmp dst/expect dst/actual ' test_expect_success 'with no remote.$name.push, upstream mapping is used' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && rm -fr src dst && git init src && git init --bare dst && ( cd src && - git pull ../testrepo master && + git pull ../testrepo main && git branch next && git config remote.dst.url ../dst && git config remote.dst.fetch "+refs/heads/*:refs/remotes/dst/*" && git config push.default upstream && - git config branch.master.merge refs/heads/trunk && - git config branch.master.remote dst && + git config branch.main.merge refs/heads/trunk && + git config branch.main.remote dst && - git push dst master && - git show-ref refs/heads/master | - sed -e "s|refs/heads/master|refs/heads/trunk|" >../dst/expect + git push dst main && + git show-ref refs/heads/main | + sed -e "s|refs/heads/main|refs/heads/trunk|" >../dst/expect ) && ( cd dst && - test_must_fail git show-ref refs/heads/master && + test_must_fail git show-ref refs/heads/main && test_must_fail git show-ref refs/heads/next && git show-ref refs/heads/trunk >actual ) && @@ -1381,20 +1417,20 @@ test_expect_success 'with no remote.$name.push, upstream mapping is used' ' ' test_expect_success 'push does not follow tags by default' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && rm -fr src dst && git init src && git init --bare dst && ( cd src && - git pull ../testrepo master && + git pull ../testrepo main && git tag -m "annotated" tag && git checkout -b another && git commit --allow-empty -m "future commit" && git tag -m "future" future && - git checkout master && - git for-each-ref refs/heads/master >../expect && - git push ../dst master + git checkout main && + git for-each-ref refs/heads/main >../expect && + git push ../dst main ) && ( cd dst && @@ -1404,20 +1440,20 @@ test_expect_success 'push does not follow tags by default' ' ' test_expect_success 'push --follow-tags only pushes relevant tags' ' - mk_test testrepo heads/master && + mk_test testrepo heads/main && rm -fr src dst && git init src && git init --bare dst && ( cd src && - git pull ../testrepo master && + git pull ../testrepo main && git tag -m "annotated" tag && git checkout -b another && git commit --allow-empty -m "future commit" && git tag -m "future" future && - git checkout master && - git for-each-ref refs/heads/master refs/tags/tag >../expect && - git push --follow-tags ../dst master + git checkout main && + git for-each-ref refs/heads/main refs/tags/tag >../expect && + git push --follow-tags ../dst main ) && ( cd dst && @@ -1435,12 +1471,12 @@ EOF git commit -am initial && git init no-thin && git --git-dir=no-thin/.git config receive.unpacklimit 0 && - git push no-thin/.git refs/heads/master:refs/heads/foo && + git push no-thin/.git refs/heads/main:refs/heads/foo && echo modified >> path1 && git commit -am modified && git repack -adf && rcvpck="git receive-pack --reject-thin-pack-for-testing" && - git push --no-thin --receive-pack="$rcvpck" no-thin/.git refs/heads/master:refs/heads/foo + git push --no-thin --receive-pack="$rcvpck" no-thin/.git refs/heads/main:refs/heads/foo ' test_expect_success 'pushing a tag pushes the tagged object' ' @@ -1463,12 +1499,12 @@ test_expect_success 'push into bare respects core.logallrefupdates' ' # double push to test both with and without # the actual pack transfer - git push dst.git master:one && + git push dst.git main:one && echo "one@{0} push" >expect && git -C dst.git log -g --format="%gd %gs" one >actual && test_cmp expect actual && - git push dst.git master:two && + git push dst.git main:two && echo "two@{0} push" >expect && git -C dst.git log -g --format="%gd %gs" two >actual && test_cmp expect actual @@ -1483,20 +1519,20 @@ test_expect_success 'fetch into bare respects core.logallrefupdates' ' # as above, we double-fetch to test both # with and without pack transfer - git fetch .. master:one && - echo "one@{0} fetch .. master:one: storing head" >expect && + git fetch .. main:one && + echo "one@{0} fetch .. main:one: storing head" >expect && git log -g --format="%gd %gs" one >actual && test_cmp expect actual && - git fetch .. master:two && - echo "two@{0} fetch .. master:two: storing head" >expect && + git fetch .. main:two && + echo "two@{0} fetch .. main:two: storing head" >expect && git log -g --format="%gd %gs" two >actual && test_cmp expect actual ) ' test_expect_success 'receive.denyCurrentBranch = updateInstead' ' - git push testrepo master && + git push testrepo main && ( cd testrepo && git reset --hard && @@ -1505,7 +1541,7 @@ test_expect_success 'receive.denyCurrentBranch = updateInstead' ' test_commit third path2 && # Try pushing into a repository with pristine working tree - git push testrepo master && + git push testrepo main && ( cd testrepo && git update-index -q --refresh && @@ -1522,7 +1558,7 @@ test_expect_success 'receive.denyCurrentBranch = updateInstead' ' test $(git -C .. rev-parse HEAD^) = $(git rev-parse HEAD) && test-tool chmtime +100 path1 ) && - git push testrepo master && + git push testrepo main && ( cd testrepo && git update-index -q --refresh && @@ -1542,7 +1578,7 @@ test_expect_success 'receive.denyCurrentBranch = updateInstead' ' cd testrepo && echo changed >path1 ) && - test_must_fail git push testrepo master && + test_must_fail git push testrepo main && ( cd testrepo && test $(git -C .. rev-parse HEAD^) = $(git rev-parse HEAD) && @@ -1556,7 +1592,7 @@ test_expect_success 'receive.denyCurrentBranch = updateInstead' ' echo changed >path1 && git add path1 ) && - test_must_fail git push testrepo master && + test_must_fail git push testrepo main && ( cd testrepo && test $(git -C .. rev-parse HEAD^) = $(git rev-parse HEAD) && @@ -1573,7 +1609,7 @@ test_expect_success 'receive.denyCurrentBranch = updateInstead' ' git reset --hard && echo changed >path3 ) && - test_must_fail git push testrepo master && + test_must_fail git push testrepo main && ( cd testrepo && test $(git -C .. rev-parse HEAD^^) = $(git rev-parse HEAD) && @@ -1589,7 +1625,7 @@ test_expect_success 'receive.denyCurrentBranch = updateInstead' ' echo fifth >path3 && git add path3 ) && - test_must_fail git push testrepo master && + test_must_fail git push testrepo main && ( cd testrepo && test $(git -C .. rev-parse HEAD^^) = $(git rev-parse HEAD) && @@ -1604,17 +1640,17 @@ test_expect_success 'receive.denyCurrentBranch = updateInstead' ' cd void && git config receive.denyCurrentBranch updateInstead ) && - git push void master && + git push void main && ( cd void && - test $(git -C .. rev-parse master) = $(git rev-parse HEAD) && + test $(git -C .. rev-parse main) = $(git rev-parse HEAD) && git diff --quiet && git diff --cached --quiet ) && # (6) updateInstead intervened by fast-forward check - test_must_fail git push void master^:master && - test $(git -C void rev-parse HEAD) = $(git rev-parse master) && + test_must_fail git push void main^:main && + test $(git -C void rev-parse HEAD) = $(git rev-parse main) && git -C void diff --quiet && git -C void diff --cached --quiet ' @@ -1624,7 +1660,7 @@ test_expect_success 'updateInstead with push-to-checkout hook' ' git init testrepo && ( cd testrepo && - git pull .. master && + git pull .. main && git reset --hard HEAD^^ && git tag initial && git config receive.denyCurrentBranch updateInstead && @@ -1642,7 +1678,7 @@ test_expect_success 'updateInstead with push-to-checkout hook' ' ) && # Try pushing into a pristine - git push testrepo master && + git push testrepo main && ( cd testrepo && git diff --quiet && @@ -1656,7 +1692,7 @@ test_expect_success 'updateInstead with push-to-checkout hook' ' git reset --hard initial && echo conflicting >path2 ) && - test_must_fail git push testrepo master && + test_must_fail git push testrepo main && ( cd testrepo && test $(git rev-parse initial) = $(git rev-parse HEAD) && @@ -1672,7 +1708,7 @@ test_expect_success 'updateInstead with push-to-checkout hook' ' echo irrelevant >path5 && git add path5 ) && - git push testrepo master && + git push testrepo main && ( cd testrepo && test "$(cat path1)" = unrelated && @@ -1712,7 +1748,7 @@ test_expect_success 'updateInstead with push-to-checkout hook' ' EOF ) && - git push void master && + git push void main && ( cd void && git diff --quiet && diff --git a/t/t5517-push-mirror.sh b/t/t5517-push-mirror.sh index e4edd56404..a448e169bd 100755 --- a/t/t5517-push-mirror.sh +++ b/t/t5517-push-mirror.sh @@ -2,6 +2,9 @@ test_description='pushing to a mirror repository' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh D=$(pwd) @@ -15,16 +18,16 @@ invert () { } mk_repo_pair () { - rm -rf master mirror && + rm -rf main mirror && mkdir mirror && ( cd mirror && git init && git config receive.denyCurrentBranch warn ) && - mkdir master && + mkdir main && ( - cd master && + cd main && git init && git remote add $1 up ../mirror ) @@ -36,13 +39,13 @@ test_expect_success 'push mirror creates new branches' ' mk_repo_pair && ( - cd master && + cd main && echo one >foo && git add foo && git commit -m one && git push --mirror up ) && - master_master=$(cd master && git show-ref -s --verify refs/heads/master) && - mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) && - test "$master_master" = "$mirror_master" + main_main=$(cd main && git show-ref -s --verify refs/heads/main) && + mirror_main=$(cd mirror && git show-ref -s --verify refs/heads/main) && + test "$main_main" = "$mirror_main" ' @@ -50,15 +53,15 @@ test_expect_success 'push mirror updates existing branches' ' mk_repo_pair && ( - cd master && + cd main && echo one >foo && git add foo && git commit -m one && git push --mirror up && echo two >foo && git add foo && git commit -m two && git push --mirror up ) && - master_master=$(cd master && git show-ref -s --verify refs/heads/master) && - mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) && - test "$master_master" = "$mirror_master" + main_main=$(cd main && git show-ref -s --verify refs/heads/main) && + mirror_main=$(cd mirror && git show-ref -s --verify refs/heads/main) && + test "$main_main" = "$mirror_main" ' @@ -66,7 +69,7 @@ test_expect_success 'push mirror force updates existing branches' ' mk_repo_pair && ( - cd master && + cd main && echo one >foo && git add foo && git commit -m one && git push --mirror up && echo two >foo && git add foo && git commit -m two && @@ -74,9 +77,9 @@ test_expect_success 'push mirror force updates existing branches' ' git reset --hard HEAD^ && git push --mirror up ) && - master_master=$(cd master && git show-ref -s --verify refs/heads/master) && - mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) && - test "$master_master" = "$mirror_master" + main_main=$(cd main && git show-ref -s --verify refs/heads/main) && + mirror_main=$(cd mirror && git show-ref -s --verify refs/heads/main) && + test "$main_main" = "$mirror_main" ' @@ -84,9 +87,9 @@ test_expect_success 'push mirror removes branches' ' mk_repo_pair && ( - cd master && + cd main && echo one >foo && git add foo && git commit -m one && - git branch remove master && + git branch remove main && git push --mirror up && git branch -D remove && git push --mirror up @@ -102,21 +105,21 @@ test_expect_success 'push mirror adds, updates and removes branches together' ' mk_repo_pair && ( - cd master && + cd main && echo one >foo && git add foo && git commit -m one && - git branch remove master && + git branch remove main && git push --mirror up && git branch -D remove && - git branch add master && + git branch add main && echo two >foo && git add foo && git commit -m two && git push --mirror up ) && - master_master=$(cd master && git show-ref -s --verify refs/heads/master) && - master_add=$(cd master && git show-ref -s --verify refs/heads/add) && - mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) && + main_main=$(cd main && git show-ref -s --verify refs/heads/main) && + main_add=$(cd main && git show-ref -s --verify refs/heads/add) && + mirror_main=$(cd mirror && git show-ref -s --verify refs/heads/main) && mirror_add=$(cd mirror && git show-ref -s --verify refs/heads/add) && - test "$master_master" = "$mirror_master" && - test "$master_add" = "$mirror_add" && + test "$main_main" = "$mirror_main" && + test "$main_add" = "$mirror_add" && ( cd mirror && invert git show-ref -s --verify refs/heads/remove @@ -130,14 +133,14 @@ test_expect_success 'push mirror creates new tags' ' mk_repo_pair && ( - cd master && + cd main && echo one >foo && git add foo && git commit -m one && - git tag -f tmaster master && + git tag -f tmain main && git push --mirror up ) && - master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) && - mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) && - test "$master_master" = "$mirror_master" + main_main=$(cd main && git show-ref -s --verify refs/tags/tmain) && + mirror_main=$(cd mirror && git show-ref -s --verify refs/tags/tmain) && + test "$main_main" = "$mirror_main" ' @@ -145,17 +148,17 @@ test_expect_success 'push mirror updates existing tags' ' mk_repo_pair && ( - cd master && + cd main && echo one >foo && git add foo && git commit -m one && - git tag -f tmaster master && + git tag -f tmain main && git push --mirror up && echo two >foo && git add foo && git commit -m two && - git tag -f tmaster master && + git tag -f tmain main && git push --mirror up ) && - master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) && - mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) && - test "$master_master" = "$mirror_master" + main_main=$(cd main && git show-ref -s --verify refs/tags/tmain) && + mirror_main=$(cd mirror && git show-ref -s --verify refs/tags/tmain) && + test "$main_main" = "$mirror_main" ' @@ -163,20 +166,20 @@ test_expect_success 'push mirror force updates existing tags' ' mk_repo_pair && ( - cd master && + cd main && echo one >foo && git add foo && git commit -m one && - git tag -f tmaster master && + git tag -f tmain main && git push --mirror up && echo two >foo && git add foo && git commit -m two && - git tag -f tmaster master && + git tag -f tmain main && git push --mirror up && git reset --hard HEAD^ && - git tag -f tmaster master && + git tag -f tmain main && git push --mirror up ) && - master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) && - mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) && - test "$master_master" = "$mirror_master" + main_main=$(cd main && git show-ref -s --verify refs/tags/tmain) && + mirror_main=$(cd mirror && git show-ref -s --verify refs/tags/tmain) && + test "$main_main" = "$mirror_main" ' @@ -184,9 +187,9 @@ test_expect_success 'push mirror removes tags' ' mk_repo_pair && ( - cd master && + cd main && echo one >foo && git add foo && git commit -m one && - git tag -f tremove master && + git tag -f tremove main && git push --mirror up && git tag -d tremove && git push --mirror up @@ -202,23 +205,23 @@ test_expect_success 'push mirror adds, updates and removes tags together' ' mk_repo_pair && ( - cd master && + cd main && echo one >foo && git add foo && git commit -m one && - git tag -f tmaster master && - git tag -f tremove master && + git tag -f tmain main && + git tag -f tremove main && git push --mirror up && git tag -d tremove && - git tag tadd master && + git tag tadd main && echo two >foo && git add foo && git commit -m two && - git tag -f tmaster master && + git tag -f tmain main && git push --mirror up ) && - master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) && - master_add=$(cd master && git show-ref -s --verify refs/tags/tadd) && - mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) && + main_main=$(cd main && git show-ref -s --verify refs/tags/tmain) && + main_add=$(cd main && git show-ref -s --verify refs/tags/tadd) && + mirror_main=$(cd mirror && git show-ref -s --verify refs/tags/tmain) && mirror_add=$(cd mirror && git show-ref -s --verify refs/tags/tadd) && - test "$master_master" = "$mirror_master" && - test "$master_add" = "$mirror_add" && + test "$main_main" = "$mirror_main" && + test "$main_add" = "$mirror_add" && ( cd mirror && invert git show-ref -s --verify refs/tags/tremove @@ -230,10 +233,10 @@ test_expect_success 'remote.foo.mirror adds and removes branches' ' mk_repo_pair --mirror && ( - cd master && + cd main && echo one >foo && git add foo && git commit -m one && - git branch keep master && - git branch remove master && + git branch keep main && + git branch remove main && git push up && git branch -D remove && git push up @@ -250,10 +253,10 @@ test_expect_success 'remote.foo.mirror=no has no effect' ' mk_repo_pair && ( - cd master && + cd main && echo one >foo && git add foo && git commit -m one && git config --add remote.up.mirror no && - git branch keep master && + git branch keep main && git push --mirror up && git branch -D keep && git push up : @@ -268,10 +271,10 @@ test_expect_success 'remote.foo.mirror=no has no effect' ' test_expect_success 'push to mirrored repository with refspec fails' ' mk_repo_pair && ( - cd master && + cd main && echo one >foo && git add foo && git commit -m one && git config --add remote.up.mirror true && - test_must_fail git push up master + test_must_fail git push up main ) ' diff --git a/t/t5518-fetch-exit-status.sh b/t/t5518-fetch-exit-status.sh index c2060bb870..5c4ac2556e 100755 --- a/t/t5518-fetch-exit-status.sh +++ b/t/t5518-fetch-exit-status.sh @@ -5,6 +5,9 @@ test_description='fetch exit status test' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -17,20 +20,20 @@ test_expect_success setup ' echo side >file && git commit -a -m side && - git checkout master && + git checkout main && echo next >file && git commit -a -m next ' test_expect_success 'non-fast-forward fetch' ' - test_must_fail git fetch . master:side + test_must_fail git fetch . main:side ' test_expect_success 'forced update' ' - git fetch . +master:side + git fetch . +main:side ' diff --git a/t/t5519-push-alternates.sh b/t/t5519-push-alternates.sh index 11fcd37700..20ba604dfd 100755 --- a/t/t5519-push-alternates.sh +++ b/t/t5519-push-alternates.sh @@ -2,6 +2,9 @@ test_description='push to a repository that borrows from elsewhere' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -17,7 +20,7 @@ test_expect_success setup ' >file && git add . && git commit -m initial && - git push ../alice-pub master + git push ../alice-pub main ) && # Project Bob is a fork of project Alice @@ -31,7 +34,7 @@ test_expect_success setup ' git clone alice-pub bob-work && ( cd bob-work && - git push ../bob-pub master + git push ../bob-pub main ) ' @@ -54,7 +57,7 @@ test_expect_success 'bob fetches from alice, works and pushes' ' # has at her public repository are available to it # via its alternates. cd bob-work && - git pull ../alice-pub master && + git pull ../alice-pub main && echo more bob >file && git commit -a -m third && git push ../bob-pub : @@ -93,7 +96,7 @@ test_expect_success 'alice works and pushes again' ' test_expect_success 'bob works and pushes' ' ( # This time Bob does not pull from Alice, and - # the master branch at her public repository points + # the main branch at her public repository points # at a commit Bob does not know about. This should # not prevent the push by Bob from succeeding. cd bob-work && @@ -122,11 +125,11 @@ test_expect_success 'alice works and pushes yet again' ' test_expect_success 'bob works and pushes again' ' ( cd alice-pub && - git cat-file commit master >../bob-work/commit + git cat-file commit main >../bob-work/commit ) && ( # This time Bob does not pull from Alice, and - # the master branch at her public repository points + # the main branch at her public repository points # at a commit Bob does not fully know about, but # he happens to have the commit object (but not the # necessary tree) in his repository from Alice. diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index 9fae07cdfa..a09411327f 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -2,6 +2,9 @@ test_description='pulling into void' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh modify () { @@ -48,11 +51,11 @@ test_expect_success 'pulling into void' ' test_cmp file cloned/file ' -test_expect_success 'pulling into void using master:master' ' +test_expect_success 'pulling into void using main:main' ' git init cloned-uho && ( cd cloned-uho && - git pull .. master:master + git pull .. main:main ) && test_path_is_file file && test_path_is_file cloned-uho/file && @@ -64,7 +67,7 @@ test_expect_success 'pulling into void does not overwrite untracked files' ' ( cd cloned-untracked && echo untracked >file && - test_must_fail git pull .. master && + test_must_fail git pull .. main && echo untracked >expect && test_cmp expect file ) @@ -76,7 +79,7 @@ test_expect_success 'pulling into void does not overwrite staged files' ' cd cloned-staged-colliding && echo "alternate content" >file && git add file && - test_must_fail git pull .. master && + test_must_fail git pull .. main && echo "alternate content" >expect && test_cmp expect file && git cat-file blob :file >file.index && @@ -90,7 +93,7 @@ test_expect_success 'pulling into void does not remove new staged files' ' cd cloned-staged-new && echo "new tracked file" >newfile && git add newfile && - git pull .. master && + git pull .. main && echo "new tracked file" >expect && test_cmp expect newfile && git cat-file blob :newfile >newfile.index && @@ -102,15 +105,15 @@ test_expect_success 'pulling into void must not create an octopus' ' git init cloned-octopus && ( cd cloned-octopus && - test_must_fail git pull .. master master && + test_must_fail git pull .. main main && test_path_is_missing file ) ' test_expect_success 'test . as a remote' ' - git branch copy master && + git branch copy main && git config branch.copy.remote . && - git config branch.copy.merge refs/heads/master && + git config branch.copy.merge refs/heads/main && echo updated >file && git commit -a -m updated && git checkout copy && @@ -126,7 +129,7 @@ test_expect_success 'test . as a remote' ' ' test_expect_success 'the default remote . should not break explicit pull' ' - git checkout -b second master^ && + git checkout -b second main^ && echo modified >file && git commit -a -m modified && git checkout copy && @@ -361,7 +364,7 @@ test_expect_success 'failed --rebase shows advice' ' test_expect_success '--rebase fails with multiple branches' ' git reset --hard before-rebase && - test_must_fail git pull --rebase . copy master 2>err && + test_must_fail git pull --rebase . copy main 2>err && test_cmp_rev HEAD before-rebase && test_i18ngrep "Cannot rebase onto multiple branches" err && echo modified >expect && @@ -500,7 +503,7 @@ test_expect_success 'pull --rebase does not warn on --no-verify-signatures' ' test_i18ngrep ! "verify-signatures" err ' -# add a feature branch, keep-merge, that is merged into master, so the +# add a feature branch, keep-merge, that is merged into main, so the # test can try preserving the merge commit (or not) with various # --rebase flags/pull.rebase settings. test_expect_success 'preserve merge setup' ' @@ -699,12 +702,12 @@ test_expect_success 'pull --rebase dies early with dirty working directory' ' ' test_expect_success 'pull --rebase works on branch yet to be born' ' - git rev-parse master >expect && + git rev-parse main >expect && mkdir empty_repo && ( cd empty_repo && git init && - git pull --rebase .. master && + git pull --rebase .. main && git rev-parse HEAD >../actual ) && test_cmp expect actual @@ -720,7 +723,7 @@ test_expect_success 'pull --rebase fails on unborn branch with staged changes' ' echo staged-file >expect && git ls-files >actual && test_cmp expect actual && - test_must_fail git pull --rebase .. master 2>err && + test_must_fail git pull --rebase .. main 2>err && git ls-files >actual && test_cmp expect actual && git show :staged-file >actual && @@ -779,7 +782,7 @@ test_expect_success 'setup for avoiding reapplying old patches' ' ( cd dst && test_might_fail git rebase --abort && - git reset --hard origin/master + git reset --hard origin/main ) && git clone --bare src src-replace.git && rm -rf src && diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh index db1a381cd9..63a688bdbf 100755 --- a/t/t5521-pull-options.sh +++ b/t/t5521-pull-options.sh @@ -2,6 +2,9 @@ test_description='pull options' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -99,13 +102,13 @@ test_expect_success 'git pull --force' ' cat >>.git/config <<-\EOF && [remote "one"] url = ../parent - fetch = refs/heads/master:refs/heads/mirror + fetch = refs/heads/main:refs/heads/mirror [remote "two"] url = ../parent - fetch = refs/heads/master:refs/heads/origin - [branch "master"] + fetch = refs/heads/main:refs/heads/origin + [branch "main"] remote = two - merge = refs/heads/master + merge = refs/heads/main EOF git pull two && test_commit A && @@ -124,9 +127,9 @@ test_expect_success 'git pull --all' ' [remote "two"] url = ../parent fetch = refs/heads/*:refs/remotes/two/* - [branch "master"] + [branch "main"] remote = one - merge = refs/heads/master + merge = refs/heads/main EOF git pull --all ) @@ -139,7 +142,7 @@ test_expect_success 'git pull --dry-run' ' cd clonedry && git pull --dry-run ../parent && test_path_is_missing .git/FETCH_HEAD && - test_path_is_missing .git/refs/heads/master && + test_path_is_missing .git/refs/heads/main && test_path_is_missing .git/index && test_path_is_missing file ) @@ -153,7 +156,7 @@ test_expect_success 'git pull --all --dry-run' ' git remote add origin ../parent && git pull --all --dry-run && test_path_is_missing .git/FETCH_HEAD && - test_path_is_missing .git/refs/remotes/origin/master && + test_path_is_missing .git/refs/remotes/origin/main && test_path_is_missing .git/index && test_path_is_missing file ) diff --git a/t/t5523-push-upstream.sh b/t/t5523-push-upstream.sh index e47b5db5d6..fdb4292056 100755 --- a/t/t5523-push-upstream.sh +++ b/t/t5523-push-upstream.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='push with --set-upstream' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-terminal.sh @@ -26,19 +29,19 @@ check_config() { test_cmp expect.$1 actual.$1 } -test_expect_success 'push -u master:master' ' - git push -u upstream master:master && - check_config master upstream refs/heads/master +test_expect_success 'push -u main:main' ' + git push -u upstream main:main && + check_config main upstream refs/heads/main ' -test_expect_success 'push -u master:other' ' - git push -u upstream master:other && - check_config master upstream refs/heads/other +test_expect_success 'push -u main:other' ' + git push -u upstream main:other && + check_config main upstream refs/heads/other ' -test_expect_success 'push -u --dry-run master:otherX' ' - git push -u --dry-run upstream master:otherX && - check_config master upstream refs/heads/other +test_expect_success 'push -u --dry-run main:otherX' ' + git push -u --dry-run upstream main:otherX && + check_config main upstream refs/heads/other ' test_expect_success 'push -u topic_2:topic_2' ' @@ -74,7 +77,7 @@ test_expect_success 'push -u HEAD' ' test_expect_success TTY 'progress messages go to tty' ' ensure_fresh_upstream && - test_terminal git push -u upstream master >out 2>err && + test_terminal git push -u upstream main >out 2>err && test_i18ngrep "Writing objects" err ' @@ -82,7 +85,7 @@ test_expect_success 'progress messages do not go to non-tty' ' ensure_fresh_upstream && # skip progress messages, since stderr is non-tty - git push -u upstream master >out 2>err && + git push -u upstream main >out 2>err && test_i18ngrep ! "Writing objects" err ' @@ -90,21 +93,21 @@ test_expect_success 'progress messages go to non-tty (forced)' ' ensure_fresh_upstream && # force progress messages to stderr, even though it is non-tty - git push -u --progress upstream master >out 2>err && + git push -u --progress upstream main >out 2>err && test_i18ngrep "Writing objects" err ' test_expect_success TTY 'push -q suppresses progress' ' ensure_fresh_upstream && - test_terminal git push -u -q upstream master >out 2>err && + test_terminal git push -u -q upstream main >out 2>err && test_i18ngrep ! "Writing objects" err ' test_expect_success TTY 'push --no-progress suppresses progress' ' ensure_fresh_upstream && - test_terminal git push -u --no-progress upstream master >out 2>err && + test_terminal git push -u --no-progress upstream main >out 2>err && test_i18ngrep ! "Unpacking objects" err && test_i18ngrep ! "Writing objects" err ' @@ -112,7 +115,14 @@ test_expect_success TTY 'push --no-progress suppresses progress' ' test_expect_success TTY 'quiet push' ' ensure_fresh_upstream && - test_terminal git push --quiet --no-progress upstream master 2>&1 | tee output && + test_terminal git push --quiet --no-progress upstream main 2>&1 | tee output && + test_must_be_empty output +' + +test_expect_success TTY 'quiet push -u' ' + ensure_fresh_upstream && + + test_terminal git push --quiet -u --no-progress upstream main 2>&1 | tee output && test_must_be_empty output ' diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh index 53d7b8ed75..ed11569d8d 100755 --- a/t/t5526-fetch-submodules.sh +++ b/t/t5526-fetch-submodules.sh @@ -3,6 +3,9 @@ test_description='Recursive "git fetch" for submodules' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh pwd=$(pwd) @@ -71,7 +74,7 @@ test_expect_success "fetch --recurse-submodules recurses into submodules" ' git fetch --recurse-submodules >../actual.out 2>../actual.err ) && test_must_be_empty actual.out && - test_i18ncmp expect.err actual.err + test_cmp expect.err actual.err ' test_expect_success "submodule.recurse option triggers recursive fetch" ' @@ -81,7 +84,7 @@ test_expect_success "submodule.recurse option triggers recursive fetch" ' git -c submodule.recurse fetch >../actual.out 2>../actual.err ) && test_must_be_empty actual.out && - test_i18ncmp expect.err actual.err + test_cmp expect.err actual.err ' test_expect_success "fetch --recurse-submodules -j2 has the same output behaviour" ' @@ -91,7 +94,7 @@ test_expect_success "fetch --recurse-submodules -j2 has the same output behaviou GIT_TRACE="$TRASH_DIRECTORY/trace.out" git fetch --recurse-submodules -j2 2>../actual.err ) && test_must_be_empty actual.out && - test_i18ncmp expect.err actual.err && + test_cmp expect.err actual.err && grep "2 tasks" trace.out ' @@ -121,7 +124,7 @@ test_expect_success "using fetchRecurseSubmodules=true in .gitmodules recurses i git fetch >../actual.out 2>../actual.err ) && test_must_be_empty actual.out && - test_i18ncmp expect.err actual.err + test_cmp expect.err actual.err ' test_expect_success "--no-recurse-submodules overrides .gitmodules config" ' @@ -152,7 +155,7 @@ test_expect_success "--recurse-submodules overrides fetchRecurseSubmodules setti git config --unset submodule.submodule.fetchRecurseSubmodules ) && test_must_be_empty actual.out && - test_i18ncmp expect.err actual.err + test_cmp expect.err actual.err ' test_expect_success "--quiet propagates to submodules" ' @@ -180,7 +183,7 @@ test_expect_success "--dry-run propagates to submodules" ' git fetch --recurse-submodules --dry-run >../actual.out 2>../actual.err ) && test_must_be_empty actual.out && - test_i18ncmp expect.err actual.err + test_cmp expect.err actual.err ' test_expect_success "Without --dry-run propagates to submodules" ' @@ -189,7 +192,7 @@ test_expect_success "Without --dry-run propagates to submodules" ' git fetch --recurse-submodules >../actual.out 2>../actual.err ) && test_must_be_empty actual.out && - test_i18ncmp expect.err actual.err + test_cmp expect.err actual.err ' test_expect_success "recurseSubmodules=true propagates into submodules" ' @@ -200,7 +203,7 @@ test_expect_success "recurseSubmodules=true propagates into submodules" ' git fetch >../actual.out 2>../actual.err ) && test_must_be_empty actual.out && - test_i18ncmp expect.err actual.err + test_cmp expect.err actual.err ' test_expect_success "--recurse-submodules overrides config in submodule" ' @@ -214,7 +217,7 @@ test_expect_success "--recurse-submodules overrides config in submodule" ' git fetch --recurse-submodules >../actual.out 2>../actual.err ) && test_must_be_empty actual.out && - test_i18ncmp expect.err actual.err + test_cmp expect.err actual.err ' test_expect_success "--no-recurse-submodules overrides config setting" ' @@ -254,7 +257,7 @@ test_expect_success "Recursion stops when no new submodule commits are fetched" cd downstream && git fetch >../actual.out 2>../actual.err ) && - test_i18ncmp expect.err.sub actual.err && + test_cmp expect.err.sub actual.err && test_must_be_empty actual.out ' @@ -272,7 +275,7 @@ test_expect_success "Recursion doesn't happen when new superproject commits don' git fetch >../actual.out 2>../actual.err ) && test_must_be_empty actual.out && - test_i18ncmp expect.err.file actual.err + test_cmp expect.err.file actual.err ' test_expect_success "Recursion picks up config in submodule" ' @@ -300,7 +303,7 @@ test_expect_success "Recursion picks up config in submodule" ' git config --unset fetch.recurseSubmodules ) ) && - test_i18ncmp expect.err.sub actual.err && + test_cmp expect.err.sub actual.err && test_must_be_empty actual.out ' @@ -333,7 +336,7 @@ test_expect_success "Recursion picks up all submodules when necessary" ' cd downstream && git fetch >../actual.out 2>../actual.err ) && - test_i18ncmp expect.err.2 actual.err && + test_cmp expect.err.2 actual.err && test_must_be_empty actual.out ' @@ -389,7 +392,7 @@ test_expect_success "'--recurse-submodules=on-demand' recurses as deep as necess ) ) && test_must_be_empty actual.out && - test_i18ncmp expect.err actual.err + test_cmp expect.err actual.err ' test_expect_success "'--recurse-submodules=on-demand' stops when no new submodule commits are found in the superproject (and ignores config)" ' @@ -406,7 +409,7 @@ test_expect_success "'--recurse-submodules=on-demand' stops when no new submodul git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err ) && test_must_be_empty actual.out && - test_i18ncmp expect.err.file actual.err + test_cmp expect.err.file actual.err ' test_expect_success "'fetch.recurseSubmodules=on-demand' overrides global config" ' @@ -434,7 +437,7 @@ test_expect_success "'fetch.recurseSubmodules=on-demand' overrides global config git config --unset fetch.recurseSubmodules ) && test_must_be_empty actual.out && - test_i18ncmp expect.err.2 actual.err + test_cmp expect.err.2 actual.err ' test_expect_success "'submodule.<sub>.fetchRecurseSubmodules=on-demand' overrides fetch.recurseSubmodules" ' @@ -462,7 +465,7 @@ test_expect_success "'submodule.<sub>.fetchRecurseSubmodules=on-demand' override git config --unset submodule.submodule.fetchRecurseSubmodules ) && test_must_be_empty actual.out && - test_i18ncmp expect.err.2 actual.err + test_cmp expect.err.2 actual.err ' test_expect_success "don't fetch submodule when newly recorded commits are already present" ' @@ -481,7 +484,7 @@ test_expect_success "don't fetch submodule when newly recorded commits are alrea git fetch >../actual.out 2>../actual.err ) && test_must_be_empty actual.out && - test_i18ncmp expect.err actual.err && + test_cmp expect.err actual.err && ( cd submodule && git checkout -q sub @@ -517,7 +520,7 @@ test_expect_success "'fetch.recurseSubmodules=on-demand' works also without .git git reset --hard ) && test_must_be_empty actual.out && - test_i18ncmp expect.err.2 actual.err && + test_cmp expect.err.2 actual.err && git checkout HEAD^ -- .gitmodules && git add .gitmodules && git commit -m "new submodule restored .gitmodules" diff --git a/t/t5527-fetch-odd-refs.sh b/t/t5527-fetch-odd-refs.sh index 3b0cb98422..e2770e4541 100755 --- a/t/t5527-fetch-odd-refs.sh +++ b/t/t5527-fetch-odd-refs.sh @@ -1,17 +1,20 @@ #!/bin/sh test_description='test fetching of oddly-named refs' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # afterwards we will have: # HEAD - two -# refs/for/refs/heads/master - one -# refs/heads/master - three +# refs/for/refs/heads/main - one +# refs/heads/main - three test_expect_success 'setup repo with odd suffix ref' ' echo content >file && git add . && git commit -m one && - git update-ref refs/for/refs/heads/master HEAD && + git update-ref refs/for/refs/heads/main HEAD && echo content >>file && git commit -a -m two && echo content >>file && @@ -22,7 +25,7 @@ test_expect_success 'setup repo with odd suffix ref' ' test_expect_success 'suffix ref is ignored during fetch' ' git clone --bare file://"$PWD" suffix && echo three >expect && - git --git-dir=suffix log -1 --format=%s refs/heads/master >actual && + git --git-dir=suffix log -1 --format=%s refs/heads/main >actual && test_cmp expect actual ' @@ -33,7 +36,7 @@ test_expect_success 'try to create repo with absurdly long refname' ' ( cd long && test_commit long && - test_commit master + test_commit main ) && if git -C long update-ref refs/heads/$ref1440 long; then test_set_prereq LONG_REF @@ -46,7 +49,7 @@ test_expect_success LONG_REF 'fetch handles extremely long refname' ' git fetch long refs/heads/*:refs/remotes/long/* && cat >expect <<-\EOF && long - master + main EOF git for-each-ref --format="%(subject)" refs/remotes/long >actual && test_cmp expect actual @@ -55,7 +58,7 @@ test_expect_success LONG_REF 'fetch handles extremely long refname' ' test_expect_success LONG_REF 'push handles extremely long refname' ' git push long :refs/heads/$ref1440 && git -C long for-each-ref --format="%(subject)" refs/heads >actual && - echo master >expect && + echo main >expect && test_cmp expect actual ' diff --git a/t/t5528-push-default.sh b/t/t5528-push-default.sh index f0a287d97d..f280e00eb7 100755 --- a/t/t5528-push-default.sh +++ b/t/t5528-push-default.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='check various push.default settings' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup bare remotes' ' @@ -41,7 +44,7 @@ test_push_failure () { # $1 = success or failure # $2 = push.default value -# $3 = branch to check for actual output (master or foo) +# $3 = branch to check for actual output (main or foo) # $4 = [optional] switch to triangular workflow test_pushdefault_workflow () { workflow=central @@ -51,8 +54,8 @@ test_pushdefault_workflow () { pushdefault=parent2 fi test_expect_success "push.default = $2 $1 in $workflow workflows" " - test_config branch.master.remote parent1 && - test_config branch.master.merge refs/heads/foo && + test_config branch.main.remote parent1 && + test_config branch.main.merge refs/heads/foo && test_config remote.pushdefault $pushdefault && test_commit commit-for-$2${4+-triangular} && test_push_$1 $2 $3 ${4+repo2} @@ -60,32 +63,32 @@ test_pushdefault_workflow () { } test_expect_success '"upstream" pushes to configured upstream' ' - git checkout master && - test_config branch.master.remote parent1 && - test_config branch.master.merge refs/heads/foo && + git checkout main && + test_config branch.main.remote parent1 && + test_config branch.main.merge refs/heads/foo && test_commit two && test_push_success upstream foo ' test_expect_success '"upstream" does not push on unconfigured remote' ' - git checkout master && - test_unconfig branch.master.remote && + git checkout main && + test_unconfig branch.main.remote && test_commit three && test_push_failure upstream ' test_expect_success '"upstream" does not push on unconfigured branch' ' - git checkout master && - test_config branch.master.remote parent1 && - test_unconfig branch.master.merge && + git checkout main && + test_config branch.main.remote parent1 && + test_unconfig branch.main.merge && test_commit four && test_push_failure upstream ' test_expect_success '"upstream" does not push when remotes do not match' ' - git checkout master && - test_config branch.master.remote parent1 && - test_config branch.master.merge refs/heads/foo && + git checkout main && + test_config branch.main.remote parent1 && + test_config branch.main.merge refs/heads/foo && test_config push.default upstream && test_commit five && test_must_fail git push parent2 @@ -121,99 +124,99 @@ test_expect_success 'push from/to new branch with current creates remote branch' ' test_expect_success 'push to existing branch, with no upstream configured' ' - test_config branch.master.remote repo1 && - git checkout master && + test_config branch.main.remote repo1 && + git checkout main && test_push_failure simple && test_push_failure upstream ' test_expect_success 'push to existing branch, upstream configured with same name' ' - test_config branch.master.remote repo1 && - test_config branch.master.merge refs/heads/master && - git checkout master && + test_config branch.main.remote repo1 && + test_config branch.main.merge refs/heads/main && + git checkout main && test_commit six && - test_push_success upstream master && + test_push_success upstream main && test_commit seven && - test_push_success simple master + test_push_success simple main ' test_expect_success 'push to existing branch, upstream configured with different name' ' - test_config branch.master.remote repo1 && - test_config branch.master.merge refs/heads/other-name && - git checkout master && + test_config branch.main.remote repo1 && + test_config branch.main.merge refs/heads/other-name && + git checkout main && test_commit eight && test_push_success upstream other-name && test_commit nine && test_push_failure simple && git --git-dir=repo1 log -1 --format="%h %s" "other-name" >expect-other-name && - test_push_success current master && + test_push_success current main && git --git-dir=repo1 log -1 --format="%h %s" "other-name" >actual-other-name && test_cmp expect-other-name actual-other-name ' -# We are on 'master', which integrates with 'foo' from parent1 +# We are on 'main', which integrates with 'foo' from parent1 # remote (set in test_pushdefault_workflow helper). Push to # parent1 in centralized, and push to parent2 in triangular workflow. -# The parent1 repository has 'master' and 'foo' branches, while -# the parent2 repository has only 'master' branch. +# The parent1 repository has 'main' and 'foo' branches, while +# the parent2 repository has only 'main' branch. # # test_pushdefault_workflow() arguments: # $1 = success or failure # $2 = push.default value -# $3 = branch to check for actual output (master or foo) +# $3 = branch to check for actual output (main or foo) # $4 = [optional] switch to triangular workflow -# update parent1's master (which is not our upstream) -test_pushdefault_workflow success current master +# update parent1's main (which is not our upstream) +test_pushdefault_workflow success current main # update parent1's foo (which is our upstream) test_pushdefault_workflow success upstream foo # upstream is foo which is not the name of the current branch -test_pushdefault_workflow failure simple master +test_pushdefault_workflow failure simple main -# master and foo are updated -test_pushdefault_workflow success matching master +# main and foo are updated +test_pushdefault_workflow success matching main -# master is updated -test_pushdefault_workflow success current master triangular +# main is updated +test_pushdefault_workflow success current main triangular # upstream mode cannot be used in triangular test_pushdefault_workflow failure upstream foo triangular # in triangular, 'simple' works as 'current' and update the branch # with the same name. -test_pushdefault_workflow success simple master triangular +test_pushdefault_workflow success simple main triangular -# master is updated (parent2 does not have foo) -test_pushdefault_workflow success matching master triangular +# main is updated (parent2 does not have foo) +test_pushdefault_workflow success matching main triangular # default tests, when no push-default is specified. This # should behave the same as "simple" in non-triangular # settings, and as "current" otherwise. test_expect_success 'default behavior allows "simple" push' ' - test_config branch.master.remote parent1 && - test_config branch.master.merge refs/heads/master && + test_config branch.main.remote parent1 && + test_config branch.main.merge refs/heads/main && test_config remote.pushdefault parent1 && - test_commit default-master-master && - test_push_success "" master + test_commit default-main-main && + test_push_success "" main ' test_expect_success 'default behavior rejects non-simple push' ' - test_config branch.master.remote parent1 && - test_config branch.master.merge refs/heads/foo && + test_config branch.main.remote parent1 && + test_config branch.main.merge refs/heads/foo && test_config remote.pushdefault parent1 && - test_commit default-master-foo && + test_commit default-main-foo && test_push_failure "" ' test_expect_success 'default triangular behavior acts like "current"' ' - test_config branch.master.remote parent1 && - test_config branch.master.merge refs/heads/foo && + test_config branch.main.remote parent1 && + test_config branch.main.merge refs/heads/foo && test_config remote.pushdefault parent2 && test_commit default-triangular && - test_push_success "" master repo2 + test_push_success "" main repo2 ' test_done diff --git a/t/t5529-push-errors.sh b/t/t5529-push-errors.sh index 9871307fd4..ce85fd30ad 100755 --- a/t/t5529-push-errors.sh +++ b/t/t5529-push-errors.sh @@ -32,7 +32,7 @@ test_expect_success 'detect missing branches early' ' test_expect_success 'detect missing sha1 expressions early' ' echo no >rp-ran && echo no >expect && - test_must_fail git push origin master~2:master && + test_must_fail git push origin main~2:main && test_cmp expect rp-ran ' diff --git a/t/t5530-upload-pack-error.sh b/t/t5530-upload-pack-error.sh index 9dd2d2457a..7c1460eaa9 100755 --- a/t/t5530-upload-pack-error.sh +++ b/t/t5530-upload-pack-error.sh @@ -115,7 +115,7 @@ test_expect_success 'create empty repository' ' test_expect_success 'fetch fails' ' - test_must_fail git fetch .. master + test_must_fail git fetch .. main ' diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh index 4ad059e6be..d573ca496a 100755 --- a/t/t5531-deep-submodule-push.sh +++ b/t/t5531-deep-submodule-push.sh @@ -2,6 +2,9 @@ test_description='test push with submodules' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -30,7 +33,7 @@ test_expect_success setup ' test_expect_success 'push works with recorded gitlink' ' ( cd work && - git push ../pub.git master + git push ../pub.git main ) ' @@ -45,7 +48,7 @@ test_expect_success 'push if submodule has no remote' ' cd work && git add gar/bage && git commit -m "Second commit for gar/bage" && - git push --recurse-submodules=check ../pub.git master + git push --recurse-submodules=check ../pub.git main ) ' @@ -66,21 +69,21 @@ test_expect_success 'push fails if submodule commit not on remote' ' git commit -m "Third commit for gar/bage" && # the push should fail with --recurse-submodules=check # on the command line... - test_must_fail git push --recurse-submodules=check ../pub.git master && + test_must_fail git push --recurse-submodules=check ../pub.git main && # ...or if specified in the configuration.. - test_must_fail git -c push.recurseSubmodules=check push ../pub.git master + test_must_fail git -c push.recurseSubmodules=check push ../pub.git main ) ' test_expect_success 'push succeeds after commit was pushed to remote' ' ( cd work/gar/bage && - git push origin master + git push origin main ) && ( cd work && - git push --recurse-submodules=check ../pub.git master + git push --recurse-submodules=check ../pub.git main ) ' @@ -95,13 +98,13 @@ test_expect_success 'push succeeds if submodule commit not on remote but using o cd work && git add gar/bage && git commit -m "Recurse on-demand on command line for gar/bage" && - git push --recurse-submodules=on-demand ../pub.git master && + git push --recurse-submodules=on-demand ../pub.git main && # Check that the supermodule commit got there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && + git diff --quiet FETCH_HEAD main && # Check that the submodule commit got there too cd gar/bage && - git diff --quiet origin/master master + git diff --quiet origin/main main ) ' @@ -116,13 +119,13 @@ test_expect_success 'push succeeds if submodule commit not on remote but using o cd work && git add gar/bage && git commit -m "Recurse on-demand from config for gar/bage" && - git -c push.recurseSubmodules=on-demand push ../pub.git master && + git -c push.recurseSubmodules=on-demand push ../pub.git main && # Check that the supermodule commit got there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && + git diff --quiet FETCH_HEAD main && # Check that the submodule commit got there too cd gar/bage && - git diff --quiet origin/master master + git diff --quiet origin/main main ) ' @@ -137,13 +140,13 @@ test_expect_success 'push succeeds if submodule commit not on remote but using a cd work && git add gar/bage && git commit -m "Recurse submodule.recurse from config for gar/bage" && - git -c submodule.recurse push ../pub.git master && + git -c submodule.recurse push ../pub.git main && # Check that the supermodule commit got there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && + git diff --quiet FETCH_HEAD main && # Check that the submodule commit got there too cd gar/bage && - git diff --quiet origin/master master + git diff --quiet origin/main main ) ' @@ -161,34 +164,34 @@ test_expect_success 'push recurse-submodules on command line overrides config' ' # Ensure that we can override on-demand in the config # to just check submodules - test_must_fail git -c push.recurseSubmodules=on-demand push --recurse-submodules=check ../pub.git master && + test_must_fail git -c push.recurseSubmodules=on-demand push --recurse-submodules=check ../pub.git main && # Check that the supermodule commit did not get there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master^ && + git diff --quiet FETCH_HEAD main^ && # Check that the submodule commit did not get there - (cd gar/bage && git diff --quiet origin/master master^) && + (cd gar/bage && git diff --quiet origin/main main^) && # Ensure that we can override check in the config to # disable submodule recursion entirely - (cd gar/bage && git diff --quiet origin/master master^) && - git -c push.recurseSubmodules=on-demand push --recurse-submodules=no ../pub.git master && + (cd gar/bage && git diff --quiet origin/main main^) && + git -c push.recurseSubmodules=on-demand push --recurse-submodules=no ../pub.git main && git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && - (cd gar/bage && git diff --quiet origin/master master^) && + git diff --quiet FETCH_HEAD main && + (cd gar/bage && git diff --quiet origin/main main^) && # Ensure that we can override check in the config to # disable submodule recursion entirely (alternative form) - git -c push.recurseSubmodules=on-demand push --no-recurse-submodules ../pub.git master && + git -c push.recurseSubmodules=on-demand push --no-recurse-submodules ../pub.git main && git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && - (cd gar/bage && git diff --quiet origin/master master^) && + git diff --quiet FETCH_HEAD main && + (cd gar/bage && git diff --quiet origin/main main^) && # Ensure that we can override check in the config to # push the submodule too - git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../pub.git master && + git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../pub.git main && git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && - (cd gar/bage && git diff --quiet origin/master master) + git diff --quiet FETCH_HEAD main && + (cd gar/bage && git diff --quiet origin/main main) ) ' @@ -205,31 +208,31 @@ test_expect_success 'push recurse-submodules last one wins on command line' ' git commit -m "Recurse on command-line overriding earlier command-line for gar/bage" && # should result in "check" - test_must_fail git push --recurse-submodules=on-demand --recurse-submodules=check ../pub.git master && + test_must_fail git push --recurse-submodules=on-demand --recurse-submodules=check ../pub.git main && # Check that the supermodule commit did not get there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master^ && + git diff --quiet FETCH_HEAD main^ && # Check that the submodule commit did not get there - (cd gar/bage && git diff --quiet origin/master master^) && + (cd gar/bage && git diff --quiet origin/main main^) && # should result in "no" - git push --recurse-submodules=on-demand --recurse-submodules=no ../pub.git master && + git push --recurse-submodules=on-demand --recurse-submodules=no ../pub.git main && # Check that the supermodule commit did get there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && + git diff --quiet FETCH_HEAD main && # Check that the submodule commit did not get there - (cd gar/bage && git diff --quiet origin/master master^) && + (cd gar/bage && git diff --quiet origin/main main^) && # should result in "no" - git push --recurse-submodules=on-demand --no-recurse-submodules ../pub.git master && + git push --recurse-submodules=on-demand --no-recurse-submodules ../pub.git main && # Check that the submodule commit did not get there - (cd gar/bage && git diff --quiet origin/master master^) && + (cd gar/bage && git diff --quiet origin/main main^) && # But the options in the other order should push the submodule - git push --recurse-submodules=check --recurse-submodules=on-demand ../pub.git master && + git push --recurse-submodules=check --recurse-submodules=on-demand ../pub.git main && # Check that the submodule commit did get there git fetch ../pub.git && - (cd gar/bage && git diff --quiet origin/master master) + (cd gar/bage && git diff --quiet origin/main main) ) ' @@ -244,13 +247,13 @@ test_expect_success 'push succeeds if submodule commit not on remote using on-de cd work && git add gar/bage && git commit -m "Recurse on-demand on command-line overriding config for gar/bage" && - git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../pub.git master && + git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../pub.git main && # Check that the supermodule commit got there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && + git diff --quiet FETCH_HEAD main && # Check that the submodule commit got there cd gar/bage && - git diff --quiet origin/master master + git diff --quiet origin/main main ) ' @@ -265,14 +268,14 @@ test_expect_success 'push succeeds if submodule commit disabling recursion from cd work && git add gar/bage && git commit -m "Recurse disable on command-line overriding config for gar/bage" && - git -c push.recurseSubmodules=check push --recurse-submodules=no ../pub.git master && + git -c push.recurseSubmodules=check push --recurse-submodules=no ../pub.git main && # Check that the supermodule commit got there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && + git diff --quiet FETCH_HEAD main && # But that the submodule commit did not - ( cd gar/bage && git diff --quiet origin/master master^ ) && + ( cd gar/bage && git diff --quiet origin/main main^ ) && # Now push it to avoid confusing future tests - git push --recurse-submodules=on-demand ../pub.git master + git push --recurse-submodules=on-demand ../pub.git main ) ' @@ -287,14 +290,14 @@ test_expect_success 'push succeeds if submodule commit disabling recursion from cd work && git add gar/bage && git commit -m "Recurse disable on command-line alternative overriding config for gar/bage" && - git -c push.recurseSubmodules=check push --no-recurse-submodules ../pub.git master && + git -c push.recurseSubmodules=check push --no-recurse-submodules ../pub.git main && # Check that the supermodule commit got there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && + git diff --quiet FETCH_HEAD main && # But that the submodule commit did not - ( cd gar/bage && git diff --quiet origin/master master^ ) && + ( cd gar/bage && git diff --quiet origin/main main^ ) && # Now push it to avoid confusing future tests - git push --recurse-submodules=on-demand ../pub.git master + git push --recurse-submodules=on-demand ../pub.git main ) ' @@ -304,7 +307,7 @@ test_expect_success 'submodule entry pointing at a tag is error' ' git -C work update-index --cacheinfo 160000 "$tag" gar/bage && git -C work commit -m "bad commit" && test_when_finished "git -C work reset --hard HEAD^" && - test_must_fail git -C work push --recurse-submodules=on-demand ../pub.git master 2>err && + test_must_fail git -C work push --recurse-submodules=on-demand ../pub.git main 2>err && test_i18ngrep "is a tag, not a commit" err ' @@ -319,9 +322,9 @@ test_expect_success 'push fails if recurse submodules option passed as yes' ' cd work && git add gar/bage && git commit -m "Recurse push fails if recurse submodules option passed as yes for gar/bage" && - test_must_fail git push --recurse-submodules=yes ../pub.git master && - test_must_fail git -c push.recurseSubmodules=yes push ../pub.git master && - git push --recurse-submodules=on-demand ../pub.git master + test_must_fail git push --recurse-submodules=yes ../pub.git main && + test_must_fail git -c push.recurseSubmodules=yes push ../pub.git main && + git push --recurse-submodules=on-demand ../pub.git main ) ' @@ -363,7 +366,7 @@ test_expect_success 'push succeeds if submodule has no remote and is on the firs ) && git add b && git commit -m "added submodule" && - git push --recurse-submodules=check origin master + git push --recurse-submodules=check origin main ) ' @@ -372,21 +375,21 @@ test_expect_success 'push unpushed submodules when not needed' ' cd work && ( cd gar/bage && - git checkout master && + git checkout main && >junk5 && git add junk5 && git commit -m "Fifth junk" && git push && - git rev-parse origin/master >../../../expected + git rev-parse origin/main >../../../expected ) && - git checkout master && + git checkout main && git add gar/bage && git commit -m "Fifth commit for gar/bage" && - git push --recurse-submodules=on-demand ../pub.git master + git push --recurse-submodules=on-demand ../pub.git main ) && ( cd submodule.git && - git rev-parse master >../actual + git rev-parse main >../actual ) && test_cmp expected actual ' @@ -394,7 +397,7 @@ test_expect_success 'push unpushed submodules when not needed' ' test_expect_success 'push unpushed submodules when not needed 2' ' ( cd submodule.git && - git rev-parse master >../expected + git rev-parse main >../expected ) && ( cd work && @@ -407,11 +410,11 @@ test_expect_success 'push unpushed submodules when not needed 2' ' >junk2 && git add junk2 && git commit -m "Second junk for work" && - git push --recurse-submodules=on-demand ../pub.git master + git push --recurse-submodules=on-demand ../pub.git main ) && ( cd submodule.git && - git rev-parse master >../actual + git rev-parse main >../actual ) && test_cmp expected actual ' @@ -421,20 +424,20 @@ test_expect_success 'push unpushed submodules recursively' ' cd work && ( cd gar/bage && - git checkout master && + git checkout main && > junk7 && git add junk7 && git commit -m "Seventh junk" && - git rev-parse master >../../../expected + git rev-parse main >../../../expected ) && - git checkout master && + git checkout main && git add gar/bage && git commit -m "Seventh commit for gar/bage" && - git push --recurse-submodules=on-demand ../pub.git master + git push --recurse-submodules=on-demand ../pub.git main ) && ( cd submodule.git && - git rev-parse master >../actual + git rev-parse main >../actual ) && test_cmp expected actual ' @@ -444,64 +447,64 @@ test_expect_success 'push unpushable submodule recursively fails' ' cd work && ( cd gar/bage && - git rev-parse origin/master >../../../expected && - git checkout master~0 && + git rev-parse origin/main >../../../expected && + git checkout main~0 && > junk8 && git add junk8 && git commit -m "Eighth junk" ) && git add gar/bage && git commit -m "Eighth commit for gar/bage" && - test_must_fail git push --recurse-submodules=on-demand ../pub.git master + test_must_fail git push --recurse-submodules=on-demand ../pub.git main ) && ( cd submodule.git && - git rev-parse master >../actual + git rev-parse main >../actual ) && - test_when_finished git -C work reset --hard master^ && + test_when_finished git -C work reset --hard main^ && test_cmp expected actual ' test_expect_success 'push --dry-run does not recursively update submodules' ' ( cd work/gar/bage && - git checkout master && - git rev-parse master >../../../expected_submodule && + git checkout main && + git rev-parse main >../../../expected_submodule && > junk9 && git add junk9 && git commit -m "Ninth junk" && # Go up to 'work' directory cd ../.. && - git checkout master && - git rev-parse master >../expected_pub && + git checkout main && + git rev-parse main >../expected_pub && git add gar/bage && git commit -m "Ninth commit for gar/bage" && - git push --dry-run --recurse-submodules=on-demand ../pub.git master + git push --dry-run --recurse-submodules=on-demand ../pub.git main ) && - git -C submodule.git rev-parse master >actual_submodule && - git -C pub.git rev-parse master >actual_pub && + git -C submodule.git rev-parse main >actual_submodule && + git -C pub.git rev-parse main >actual_pub && test_cmp expected_pub actual_pub && test_cmp expected_submodule actual_submodule ' test_expect_success 'push --dry-run does not recursively update submodules' ' - git -C work push --dry-run --recurse-submodules=only ../pub.git master && + git -C work push --dry-run --recurse-submodules=only ../pub.git main && - git -C submodule.git rev-parse master >actual_submodule && - git -C pub.git rev-parse master >actual_pub && + git -C submodule.git rev-parse main >actual_submodule && + git -C pub.git rev-parse main >actual_pub && test_cmp expected_pub actual_pub && test_cmp expected_submodule actual_submodule ' test_expect_success 'push only unpushed submodules recursively' ' - git -C work/gar/bage rev-parse master >expected_submodule && - git -C pub.git rev-parse master >expected_pub && + git -C work/gar/bage rev-parse main >expected_submodule && + git -C pub.git rev-parse main >expected_pub && - git -C work push --recurse-submodules=only ../pub.git master && + git -C work push --recurse-submodules=only ../pub.git main && - git -C submodule.git rev-parse master >actual_submodule && - git -C pub.git rev-parse master >actual_pub && + git -C submodule.git rev-parse main >actual_submodule && + git -C pub.git rev-parse main >actual_pub && test_cmp expected_submodule actual_submodule && test_cmp expected_pub actual_pub ' @@ -517,14 +520,14 @@ test_expect_success 'push propagating the remotes name to a submodule' ' git -C work commit -m "Tenth junk added to gar/bage" && # Fails when submodule does not have a matching remote - test_must_fail git -C work push --recurse-submodules=on-demand pub master && + test_must_fail git -C work push --recurse-submodules=on-demand pub main && # Succeeds when submodules has matching remote and refspec - git -C work push --recurse-submodules=on-demand origin master && + git -C work push --recurse-submodules=on-demand origin main && - git -C submodule.git rev-parse master >actual_submodule && - git -C pub.git rev-parse master >actual_pub && - git -C work/gar/bage rev-parse master >expected_submodule && - git -C work rev-parse master >expected_pub && + git -C submodule.git rev-parse main >actual_submodule && + git -C pub.git rev-parse main >actual_pub && + git -C work/gar/bage rev-parse main >expected_submodule && + git -C work rev-parse main >expected_pub && test_cmp expected_submodule actual_submodule && test_cmp expected_pub actual_pub ' @@ -548,7 +551,7 @@ test_expect_success 'push propagating refspec to a submodule' ' test_must_fail git -C work push --recurse-submodules=on-demand origin \ HEAD:refs/heads/branch2 && - git -C work/gar/bage branch branch2 master && + git -C work/gar/bage branch branch2 main && git -C work push --recurse-submodules=on-demand origin branch2 && git -C submodule.git rev-parse branch2 >actual_submodule && diff --git a/t/t5533-push-cas.sh b/t/t5533-push-cas.sh index 7813e8470e..cba26a872d 100755 --- a/t/t5533-push-cas.sh +++ b/t/t5533-push-cas.sh @@ -2,6 +2,9 @@ test_description='compare & swap push force/delete safety' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh setup_srcdst_basic () { @@ -29,22 +32,22 @@ setup_src_dup_dst () { ( cd dup && git fetch && - git merge origin/master && - git switch -c branch master~2 && + git merge origin/main && + git switch -c branch main~2 && test_commit D && test_commit E && git push origin --all ) && ( cd src && - git switch master && + git switch main && git fetch --all && git branch branch --track origin/branch && - git rebase origin/master + git rebase origin/main ) && ( cd dup && - git switch master && + git switch main && test_commit F && test_commit G && git switch branch && @@ -65,11 +68,11 @@ test_expect_success 'push to update (protected)' ' ( cd dst && test_commit D && - test_must_fail git push --force-with-lease=master:master origin master 2>err && + test_must_fail git push --force-with-lease=main:main origin main 2>err && grep "stale info" err ) && - git ls-remote . refs/heads/master >expect && - git ls-remote src refs/heads/master >actual && + git ls-remote . refs/heads/main >expect && + git ls-remote src refs/heads/main >actual && test_cmp expect actual ' @@ -78,11 +81,11 @@ test_expect_success 'push to update (protected, forced)' ' ( cd dst && test_commit D && - git push --force --force-with-lease=master:master origin master 2>err && + git push --force --force-with-lease=main:main origin main 2>err && grep "forced update" err ) && - git ls-remote dst refs/heads/master >expect && - git ls-remote src refs/heads/master >actual && + git ls-remote dst refs/heads/main >expect && + git ls-remote src refs/heads/main >actual && test_cmp expect actual ' @@ -90,20 +93,20 @@ test_expect_success 'push to update (protected, tracking)' ' setup_srcdst_basic && ( cd src && - git checkout master && + git checkout main && test_commit D && git checkout HEAD^0 ) && - git ls-remote src refs/heads/master >expect && + git ls-remote src refs/heads/main >expect && ( cd dst && test_commit E && - git ls-remote . refs/remotes/origin/master >expect && - test_must_fail git push --force-with-lease=master origin master && - git ls-remote . refs/remotes/origin/master >actual && + git ls-remote . refs/remotes/origin/main >expect && + test_must_fail git push --force-with-lease=main origin main && + git ls-remote . refs/remotes/origin/main >actual && test_cmp expect actual ) && - git ls-remote src refs/heads/master >actual && + git ls-remote src refs/heads/main >actual && test_cmp expect actual ' @@ -111,18 +114,18 @@ test_expect_success 'push to update (protected, tracking, forced)' ' setup_srcdst_basic && ( cd src && - git checkout master && + git checkout main && test_commit D && git checkout HEAD^0 ) && ( cd dst && test_commit E && - git ls-remote . refs/remotes/origin/master >expect && - git push --force --force-with-lease=master origin master + git ls-remote . refs/remotes/origin/main >expect && + git push --force --force-with-lease=main origin main ) && - git ls-remote dst refs/heads/master >expect && - git ls-remote src refs/heads/master >actual && + git ls-remote dst refs/heads/main >expect && + git ls-remote src refs/heads/main >actual && test_cmp expect actual ' @@ -131,10 +134,10 @@ test_expect_success 'push to update (allowed)' ' ( cd dst && test_commit D && - git push --force-with-lease=master:master^ origin master + git push --force-with-lease=main:main^ origin main ) && - git ls-remote dst refs/heads/master >expect && - git ls-remote src refs/heads/master >actual && + git ls-remote dst refs/heads/main >expect && + git ls-remote src refs/heads/main >actual && test_cmp expect actual ' @@ -143,11 +146,11 @@ test_expect_success 'push to update (allowed, tracking)' ' ( cd dst && test_commit D && - git push --force-with-lease=master origin master 2>err && + git push --force-with-lease=main origin main 2>err && ! grep "forced update" err ) && - git ls-remote dst refs/heads/master >expect && - git ls-remote src refs/heads/master >actual && + git ls-remote dst refs/heads/main >expect && + git ls-remote src refs/heads/main >actual && test_cmp expect actual ' @@ -157,22 +160,22 @@ test_expect_success 'push to update (allowed even though no-ff)' ' cd dst && git reset --hard HEAD^ && test_commit D && - git push --force-with-lease=master origin master 2>err && + git push --force-with-lease=main origin main 2>err && grep "forced update" err ) && - git ls-remote dst refs/heads/master >expect && - git ls-remote src refs/heads/master >actual && + git ls-remote dst refs/heads/main >expect && + git ls-remote src refs/heads/main >actual && test_cmp expect actual ' test_expect_success 'push to delete (protected)' ' setup_srcdst_basic && - git ls-remote src refs/heads/master >expect && + git ls-remote src refs/heads/main >expect && ( cd dst && - test_must_fail git push --force-with-lease=master:master^ origin :master + test_must_fail git push --force-with-lease=main:main^ origin :main ) && - git ls-remote src refs/heads/master >actual && + git ls-remote src refs/heads/main >actual && test_cmp expect actual ' @@ -180,9 +183,9 @@ test_expect_success 'push to delete (protected, forced)' ' setup_srcdst_basic && ( cd dst && - git push --force --force-with-lease=master:master^ origin :master + git push --force --force-with-lease=main:main^ origin :main ) && - git ls-remote src refs/heads/master >actual && + git ls-remote src refs/heads/main >actual && test_must_be_empty actual ' @@ -190,10 +193,10 @@ test_expect_success 'push to delete (allowed)' ' setup_srcdst_basic && ( cd dst && - git push --force-with-lease=master origin :master 2>err && + git push --force-with-lease=main origin :main 2>err && grep deleted err ) && - git ls-remote src refs/heads/master >actual && + git ls-remote src refs/heads/main >actual && test_must_be_empty actual ' @@ -201,12 +204,12 @@ test_expect_success 'cover everything with default force-with-lease (protected)' setup_srcdst_basic && ( cd src && - git branch naster master^ + git branch nain main^ ) && git ls-remote src refs/heads/\* >expect && ( cd dst && - test_must_fail git push --force-with-lease origin master master:naster + test_must_fail git push --force-with-lease origin main main:nain ) && git ls-remote src refs/heads/\* >actual && test_cmp expect actual @@ -216,16 +219,16 @@ test_expect_success 'cover everything with default force-with-lease (allowed)' ' setup_srcdst_basic && ( cd src && - git branch naster master^ + git branch nain main^ ) && ( cd dst && git fetch && - git push --force-with-lease origin master master:naster + git push --force-with-lease origin main main:nain ) && - git ls-remote dst refs/heads/master | - sed -e "s/master/naster/" >expect && - git ls-remote src refs/heads/naster >actual && + git ls-remote dst refs/heads/main | + sed -e "s/main/nain/" >expect && + git ls-remote src refs/heads/nain >actual && test_cmp expect actual ' @@ -233,7 +236,7 @@ test_expect_success 'new branch covered by force-with-lease' ' setup_srcdst_basic && ( cd dst && - git branch branch master && + git branch branch main && git push --force-with-lease=branch origin branch ) && git ls-remote dst refs/heads/branch >expect && @@ -245,7 +248,7 @@ test_expect_success 'new branch covered by force-with-lease (explicit)' ' setup_srcdst_basic && ( cd dst && - git branch branch master && + git branch branch main && git push --force-with-lease=branch: origin branch ) && git ls-remote dst refs/heads/branch >expect && @@ -257,12 +260,12 @@ test_expect_success 'new branch already exists' ' setup_srcdst_basic && ( cd src && - git checkout -b branch master && + git checkout -b branch main && test_commit F ) && ( cd dst && - git branch branch master && + git branch branch main && test_must_fail git push --force-with-lease=branch: origin branch ) ' @@ -277,7 +280,7 @@ test_expect_success 'background updates of REMOTE can be mitigated with a non-up cd dst && test_commit G && git remote add origin-push ../src.bare && - git push origin-push master:master + git push origin-push main:main ) && git clone --no-local src.bare dst2 && test_when_finished "rm -rf dst2" && @@ -299,58 +302,58 @@ test_expect_success 'background updates of REMOTE can be mitigated with a non-up test_expect_success 'background updates to remote can be mitigated with "--force-if-includes"' ' setup_src_dup_dst && test_when_finished "rm -fr dst src dup" && - git ls-remote dst refs/heads/master >expect.master && + git ls-remote dst refs/heads/main >expect.main && git ls-remote dst refs/heads/branch >expect.branch && ( cd src && git switch branch && test_commit I && - git switch master && + git switch main && test_commit J && git fetch --all && test_must_fail git push --force-with-lease --force-if-includes --all ) && - git ls-remote dst refs/heads/master >actual.master && + git ls-remote dst refs/heads/main >actual.main && git ls-remote dst refs/heads/branch >actual.branch && - test_cmp expect.master actual.master && + test_cmp expect.main actual.main && test_cmp expect.branch actual.branch ' test_expect_success 'background updates to remote can be mitigated with "push.useForceIfIncludes"' ' setup_src_dup_dst && test_when_finished "rm -fr dst src dup" && - git ls-remote dst refs/heads/master >expect.master && + git ls-remote dst refs/heads/main >expect.main && ( cd src && git switch branch && test_commit I && - git switch master && + git switch main && test_commit J && git fetch --all && git config --local push.useForceIfIncludes true && - test_must_fail git push --force-with-lease=master origin master + test_must_fail git push --force-with-lease=main origin main ) && - git ls-remote dst refs/heads/master >actual.master && - test_cmp expect.master actual.master + git ls-remote dst refs/heads/main >actual.main && + test_cmp expect.main actual.main ' test_expect_success '"--force-if-includes" should be disabled for --force-with-lease="<refname>:<expect>"' ' setup_src_dup_dst && test_when_finished "rm -fr dst src dup" && - git ls-remote dst refs/heads/master >expect.master && + git ls-remote dst refs/heads/main >expect.main && ( cd src && git switch branch && test_commit I && - git switch master && + git switch main && test_commit J && - remote_head="$(git rev-parse refs/remotes/origin/master)" && + remote_head="$(git rev-parse refs/remotes/origin/main)" && git fetch --all && - test_must_fail git push --force-if-includes --force-with-lease="master:$remote_head" 2>err && + test_must_fail git push --force-if-includes --force-with-lease="main:$remote_head" 2>err && grep "stale info" err ) && - git ls-remote dst refs/heads/master >actual.master && - test_cmp expect.master actual.master + git ls-remote dst refs/heads/main >actual.main && + test_cmp expect.main actual.main ' test_expect_success '"--force-if-includes" should allow forced update after a rebase ("pull --rebase")' ' @@ -360,10 +363,10 @@ test_expect_success '"--force-if-includes" should allow forced update after a re cd src && git switch branch && test_commit I && - git switch master && + git switch main && test_commit J && - git pull --rebase origin master && - git push --force-if-includes --force-with-lease="master" + git pull --rebase origin main && + git push --force-if-includes --force-with-lease="main" ) ' @@ -374,11 +377,11 @@ test_expect_success '"--force-if-includes" should allow forced update after a re cd src && git switch branch && test_commit I && - git switch master && + git switch main && test_commit J && - git pull --rebase origin master && + git pull --rebase origin main && git rebase --onto HEAD~4 HEAD~1 && - git push --force-if-includes --force-with-lease="master" + git push --force-if-includes --force-with-lease="main" ) ' diff --git a/t/t5534-push-signed.sh b/t/t5534-push-signed.sh index af0385fb89..bba768f5de 100755 --- a/t/t5534-push-signed.sh +++ b/t/t5534-push-signed.sh @@ -2,6 +2,9 @@ test_description='signed push' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-gpg.sh @@ -9,11 +12,11 @@ prepare_dst () { rm -fr dst && test_create_repo dst && - git push dst master:noop master:ff master:noff + git push dst main:noop main:ff main:noff } test_expect_success setup ' - # master, ff and noff branches pointing at the same commit + # main, ff and noff branches pointing at the same commit test_tick && git commit --allow-empty -m initial && diff --git a/t/t5537-fetch-shallow.sh b/t/t5537-fetch-shallow.sh index a55202d2d3..11d5ea54a9 100755 --- a/t/t5537-fetch-shallow.sh +++ b/t/t5537-fetch-shallow.sh @@ -2,6 +2,9 @@ test_description='fetch/clone from a shallow clone' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh commit() { @@ -49,7 +52,7 @@ test_expect_success 'fetch from shallow clone' ' cd shallow2 && git fetch && git fsck && - git log --format=%s origin/master >actual && + git log --format=%s origin/main >actual && test_write_lines 5 4 3 >expect && test_cmp expect actual ) @@ -64,7 +67,7 @@ test_expect_success 'fetch --depth from shallow clone' ' cd shallow2 && git fetch --depth=2 && git fsck && - git log --format=%s origin/master >actual && + git log --format=%s origin/main >actual && test_write_lines 6 5 >expect && test_cmp expect actual ) @@ -75,7 +78,7 @@ test_expect_success 'fetch --unshallow from shallow clone' ' cd shallow2 && git fetch --unshallow && git fsck && - git log --format=%s origin/master >actual && + git log --format=%s origin/main >actual && test_write_lines 6 5 4 3 >expect && test_cmp expect actual ) @@ -89,7 +92,7 @@ test_expect_success 'fetch --unshallow from a full clone' ' test_write_lines 4 3 >expect && test_cmp expect actual && git -c fetch.writeCommitGraph fetch --unshallow && - git log origin/master --format=%s >actual && + git log origin/main --format=%s >actual && test_write_lines 4 3 2 1 >expect && test_cmp expect actual ) @@ -104,9 +107,9 @@ test_expect_success 'fetch something upstream has but hidden by clients shallow git commit -m add-1-back && ( cd shallow2 && - git fetch ../.git +refs/heads/master:refs/remotes/top/master && + git fetch ../.git +refs/heads/main:refs/remotes/top/main && git fsck && - git log --format=%s top/master >actual && + git log --format=%s top/main >actual && test_write_lines add-1-back 4 3 >expect && test_cmp expect actual ) && @@ -135,7 +138,7 @@ test_expect_success 'fetch that requires changes in .git/shallow is filtered' ' test_expect_success 'fetch --update-shallow' ' ( cd shallow && - git checkout master && + git checkout main && commit 7 && git tag -m foo heavy-tag HEAD^ && git tag light-tag HEAD^:tracked @@ -146,13 +149,13 @@ test_expect_success 'fetch --update-shallow' ' git fsck && git for-each-ref --sort=refname --format="%(refname)" >actual.refs && cat <<-\EOF >expect.refs && - refs/remotes/shallow/master + refs/remotes/shallow/main refs/remotes/shallow/no-shallow refs/tags/heavy-tag refs/tags/light-tag EOF test_cmp expect.refs actual.refs && - git log --format=%s shallow/master >actual && + git log --format=%s shallow/main >actual && test_write_lines 7 6 5 4 3 >expect && test_cmp expect actual ) @@ -161,7 +164,7 @@ test_expect_success 'fetch --update-shallow' ' test_expect_success 'fetch --update-shallow (with fetch.writeCommitGraph)' ' ( cd shallow && - git checkout master && + git checkout main && commit 8 && git tag -m foo heavy-tag-for-graph HEAD^ && git tag light-tag-for-graph HEAD^:tracked @@ -173,7 +176,7 @@ test_expect_success 'fetch --update-shallow (with fetch.writeCommitGraph)' ' git fsck && git for-each-ref --sort=refname --format="%(refname)" >actual.refs && cat <<-EOF >expect.refs && - refs/remotes/shallow/master + refs/remotes/shallow/main refs/remotes/shallow/no-shallow refs/tags/heavy-tag refs/tags/heavy-tag-for-graph @@ -181,7 +184,7 @@ test_expect_success 'fetch --update-shallow (with fetch.writeCommitGraph)' ' refs/tags/light-tag-for-graph EOF test_cmp expect.refs actual.refs && - git log --format=%s shallow/master >actual && + git log --format=%s shallow/main >actual && test_write_lines 8 7 6 5 4 3 >expect && test_cmp expect actual ) @@ -206,7 +209,7 @@ test_expect_success '.git/shallow is edited by repack' ' test_commit -C shallow-server E && test_commit -C shallow-server D && d="$(git -C shallow-server rev-parse --verify D^0)" && - git -C shallow-server checkout master && + git -C shallow-server checkout main && git clone --depth=1 --no-tags --no-single-branch \ "file://$PWD/shallow-server" shallow-client && @@ -244,7 +247,7 @@ test_expect_success 'shallow fetches check connectivity before writing shallow f git -C "$REPO" config protocol.version 2 && git -C client config protocol.version 2 && - git -C client fetch --depth=2 "$HTTPD_URL/one_time_perl/repo" master:a_branch && + git -C client fetch --depth=2 "$HTTPD_URL/one_time_perl/repo" main:a_branch && # Craft a situation in which the server sends back an unshallow request # with an empty packfile. This is done by refetching with a shorter @@ -256,7 +259,7 @@ test_expect_success 'shallow fetches check connectivity before writing shallow f >"$HTTPD_ROOT_PATH/one-time-perl" && test_must_fail env GIT_TEST_SIDEBAND_ALL=0 git -C client \ fetch --depth=1 "$HTTPD_URL/one_time_perl/repo" \ - master:a_branch && + main:a_branch && # Ensure that the one-time-perl script was used. ! test -e "$HTTPD_ROOT_PATH/one-time-perl" && diff --git a/t/t5538-push-shallow.sh b/t/t5538-push-shallow.sh index ecbf84d21c..e91fcc173e 100755 --- a/t/t5538-push-shallow.sh +++ b/t/t5538-push-shallow.sh @@ -2,6 +2,9 @@ test_description='push from/to a shallow clone' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh commit() { @@ -44,9 +47,9 @@ test_expect_success 'push from shallow clone' ' ( cd shallow && commit 5 && - git push ../.git +master:refs/remotes/shallow/master + git push ../.git +main:refs/remotes/shallow/main ) && - git log --format=%s shallow/master >actual && + git log --format=%s shallow/main >actual && git fsck && cat <<EOF >expect && 5 @@ -61,10 +64,10 @@ EOF test_expect_success 'push from shallow clone, with grafted roots' ' ( cd shallow2 && - test_must_fail git push ../.git +master:refs/remotes/shallow2/master 2>err && - grep "shallow2/master.*shallow update not allowed" err + test_must_fail git push ../.git +main:refs/remotes/shallow2/main 2>err && + grep "shallow2/main.*shallow update not allowed" err ) && - test_must_fail git rev-parse shallow2/master && + test_must_fail git rev-parse shallow2/main && git fsck ' @@ -72,9 +75,9 @@ test_expect_success 'add new shallow root with receive.updateshallow on' ' test_config receive.shallowupdate true && ( cd shallow2 && - git push ../.git +master:refs/remotes/shallow2/master + git push ../.git +main:refs/remotes/shallow2/main ) && - git log --format=%s shallow2/master >actual && + git log --format=%s shallow2/main >actual && git fsck && cat <<EOF >expect && c @@ -87,12 +90,12 @@ test_expect_success 'push from shallow to shallow' ' ( cd shallow && git --git-dir=../shallow2/.git config receive.shallowupdate true && - git push ../shallow2/.git +master:refs/remotes/shallow/master && + git push ../shallow2/.git +main:refs/remotes/shallow/main && git --git-dir=../shallow2/.git config receive.shallowupdate false ) && ( cd shallow2 && - git log --format=%s shallow/master >actual && + git log --format=%s shallow/main >actual && git fsck && cat <<EOF >expect && 5 @@ -106,10 +109,10 @@ EOF test_expect_success 'push from full to shallow' ' ! git --git-dir=shallow2/.git cat-file blob $(echo 1|git hash-object --stdin) && commit 1 && - git push shallow2/.git +master:refs/remotes/top/master && + git push shallow2/.git +main:refs/remotes/top/main && ( cd shallow2 && - git log --format=%s top/master >actual && + git log --format=%s top/main >actual && git fsck && cat <<EOF >expect && 1 diff --git a/t/t5539-fetch-http-shallow.sh b/t/t5539-fetch-http-shallow.sh index 82aa99ae87..3ea75d34ca 100755 --- a/t/t5539-fetch-http-shallow.sh +++ b/t/t5539-fetch-http-shallow.sh @@ -2,6 +2,9 @@ test_description='fetch/clone from a shallow clone over http' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd @@ -32,7 +35,7 @@ test_expect_success 'clone http repository' ' ( cd clone && git fsck && - git log --format=%s origin/master >actual && + git log --format=%s origin/main >actual && cat <<EOF >expect && 7 6 @@ -60,9 +63,9 @@ test_expect_success 'no shallow lines after receiving ACK ready' ' refs/heads/unrelated$i:refs/heads/unrelated$i || exit 1 done && - git checkout master && + git checkout main && test_commit new && - git push "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" master + git push "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" main ) && ( cd clone && @@ -95,7 +98,7 @@ test_expect_success 'clone shallow since ...' ' test_expect_success 'fetch shallow since ...' ' git -C shallow11 fetch --shallow-since "200000000 +0700" origin && - git -C shallow11 log --pretty=tformat:%s origin/master >actual && + git -C shallow11 log --pretty=tformat:%s origin/main >actual && cat >expected <<-\EOF && three two @@ -120,7 +123,7 @@ test_expect_success 'shallow clone exclude tag two' ' test_expect_success 'fetch exclude tag one' ' git -C shallow12 fetch --shallow-exclude one origin && - git -C shallow12 log --pretty=tformat:%s origin/master >actual && + git -C shallow12 log --pretty=tformat:%s origin/main >actual && test_write_lines three two >expected && test_cmp expected actual ' @@ -136,12 +139,12 @@ test_expect_success 'fetching deepen' ' git clone --depth 1 $HTTPD_URL/smart/shallow-deepen.git deepen && mv "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" .git && test_commit four && - git -C deepen log --pretty=tformat:%s master >actual && + git -C deepen log --pretty=tformat:%s main >actual && echo three >expected && test_cmp expected actual && mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" && git -C deepen fetch --deepen=1 && - git -C deepen log --pretty=tformat:%s origin/master >actual && + git -C deepen log --pretty=tformat:%s origin/main >actual && cat >expected <<-\EOF && four three diff --git a/t/t5540-http-push-webdav.sh b/t/t5540-http-push-webdav.sh index 450321fddb..8b68bb38a4 100755 --- a/t/t5540-http-push-webdav.sh +++ b/t/t5540-http-push-webdav.sh @@ -7,6 +7,9 @@ test_description='test WebDAV http-push This test runs various sanity checks on http-push.' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh if git http-push > /dev/null 2>&1 || [ $? -eq 128 ] @@ -71,7 +74,7 @@ test_expect_success 'push already up-to-date' ' test_expect_success 'push to remote repository with unpacked refs' ' (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git && rm packed-refs && - git update-ref refs/heads/master $ORIG_HEAD && + git update-ref refs/heads/main $ORIG_HEAD && git --bare update-server-info) && git push && (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git && @@ -91,7 +94,7 @@ test_expect_success 'http-push fetches unpacked objects' ' git remote rm origin && git reflog expire --expire=0 --all && git prune && - git push -f -v $HTTPD_URL/dumb/test_repo_unpacked.git master) + git push -f -v $HTTPD_URL/dumb/test_repo_unpacked.git main) ' test_expect_success 'http-push fetches packed objects' ' @@ -111,7 +114,7 @@ test_expect_success 'http-push fetches packed objects' ' git remote remove origin && git reflog expire --expire=0 --all && git prune && - git push -f -v $HTTPD_URL/dumb/test_repo_packed.git master) + git push -f -v $HTTPD_URL/dumb/test_repo_packed.git main) ' test_expect_success 'create and delete remote branch' ' @@ -163,7 +166,7 @@ test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' ' ' test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \ - "$ROOT_PATH"/test_repo_clone master + "$ROOT_PATH"/test_repo_clone main test_expect_success 'push to password-protected repository (user in URL)' ' test_commit pw-user && diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh index 187454f5dd..c024fa2818 100755 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@ -4,6 +4,9 @@ # test_description='test smart pushing over http via http-backend' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh ROOT_PATH="$PWD" @@ -115,7 +118,7 @@ test_expect_success 'rejected update prints status' ' git commit -m dev2 && test_must_fail git push origin dev2 2>act && sed -e "/^remote: /s/ *$//" <act >cmp && - test_i18ncmp exp cmp + test_cmp exp cmp ' rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update" @@ -142,23 +145,23 @@ test_expect_success 'used receive-pack service' ' ' test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \ - "$ROOT_PATH"/test_repo_clone master success + "$ROOT_PATH"/test_repo_clone main success test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper' ' # create a dissimilarly-named remote ref so that git is unable to match the # two refs (viz. local, remote) unless an explicit refspec is provided. - git push origin master:retsam && + git push origin main:niam && echo "change changed" > path2 && git commit -a -m path2 --amend && - # push master too; this ensures there is at least one '"'push'"' command to + # push main too; this ensures there is at least one '"'push'"' command to # the remote helper and triggers interaction with the helper. - test_must_fail git push -v origin +master master:retsam >output 2>&1' + test_must_fail git push -v origin +main main:niam >output 2>&1' test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper: remote output' ' - grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *master -> master (forced update)$" output && - grep "^ ! \[rejected\] *master -> retsam (non-fast-forward)$" output + grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *main -> main (forced update)$" output && + grep "^ ! \[rejected\] *main -> niam (non-fast-forward)$" output ' test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper: our output' ' @@ -167,7 +170,7 @@ test_expect_success 'push fails for non-fast-forward refs unmatched by remote he ' test_expect_success 'push (chunked)' ' - git checkout master && + git checkout main && test_commit commit path3 && HEAD=$(git rev-parse --verify HEAD) && test_config http.postbuffer 4 && @@ -177,9 +180,9 @@ test_expect_success 'push (chunked)' ' test $HEAD = $(git rev-parse --verify HEAD)) ' -## References of remote: atomic1(1) master(2) collateral(2) other(2) -## References of local : atomic2(2) master(1) collateral(3) other(2) collateral1(3) atomic(1) -## Atomic push : master(1) collateral(3) atomic(1) +## References of remote: atomic1(1) main(2) collateral(2) other(2) +## References of local : atomic2(2) main(1) collateral(3) other(2) collateral1(3) atomic(1) +## Atomic push : main(1) collateral(3) atomic(1) test_expect_success 'push --atomic also prevents branch creation, reports collateral' ' # Setup upstream repo - empty for now d=$HTTPD_DOCUMENT_ROOT_PATH/atomic-branches.git && @@ -192,15 +195,15 @@ test_expect_success 'push --atomic also prevents branch creation, reports collat test_commit atomic2 && git branch collateral && git branch other && - git push "$up" atomic1 master collateral other && + git push "$up" atomic1 main collateral other && git tag -d atomic1 && # collateral is a valid push, but should be failed by atomic push git checkout collateral && test_commit collateral1 && - # Make master incompatible with upstream to provoke atomic - git checkout master && + # Make main incompatible with upstream to provoke atomic + git checkout main && git reset --hard HEAD^ && # Add a new branch which should be failed by atomic push. This is a @@ -208,7 +211,7 @@ test_expect_success 'push --atomic also prevents branch creation, reports collat git branch atomic && # --atomic should cause entire push to be rejected - test_must_fail git push --atomic "$up" master atomic collateral 2>output && + test_must_fail git push --atomic "$up" main atomic collateral 2>output && # the new branch should not have been created upstream test_must_fail git -C "$d" show-ref --verify refs/heads/atomic && @@ -216,15 +219,15 @@ test_expect_success 'push --atomic also prevents branch creation, reports collat # upstream should still reflect atomic2, the last thing we pushed # successfully git rev-parse atomic2 >expected && - # on master... - git -C "$d" rev-parse refs/heads/master >actual && + # on main... + git -C "$d" rev-parse refs/heads/main >actual && test_cmp expected actual && # ...and collateral. git -C "$d" rev-parse refs/heads/collateral >actual && test_cmp expected actual && # the failed refs should be indicated to the user - grep "^ ! .*rejected.* master -> master" output && + grep "^ ! .*rejected.* main -> main" output && # the collateral failure refs should be indicated to the user grep "^ ! .*rejected.* atomic -> atomic .*atomic push failed" output && @@ -472,9 +475,9 @@ test_expect_success 'clone/fetch scrubs password from reflogs' ' test_commit prepare-for-force-fetch && git switch -c away && git fetch "$HTTPD_URL_USER_PASS/smart/test_repo.git" \ - +master:master && + +main:main && # should have been scrubbed down to vanilla URL - git log -g master >reflog && + git log -g main >reflog && grep "$HTTPD_URL" reflog && ! grep "$HTTPD_URL_USER_PASS" reflog ' @@ -498,7 +501,7 @@ test_expect_success 'colorize errors/hints' ' cd "$ROOT_PATH"/test_repo_clone && test_must_fail git -c color.transport=always -c color.advice=always \ -c color.push=always \ - push origin origin/master^:master 2>act && + push origin origin/main^:main 2>act && test_decode_color <act >decoded && test_i18ngrep "<RED>.*rejected.*<RESET>" decoded && test_i18ngrep "<RED>error: failed to push some refs" decoded && diff --git a/t/t5542-push-http-shallow.sh b/t/t5542-push-http-shallow.sh index ddc1db722d..c2cc83182f 100755 --- a/t/t5542-push-http-shallow.sh +++ b/t/t5542-push-http-shallow.sh @@ -2,6 +2,9 @@ test_description='push from/to a shallow clone over http' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd @@ -51,12 +54,12 @@ test_expect_success 'push to shallow repo via http' ' ( cd full && commit 9 && - git push $HTTPD_URL/smart/repo.git +master:refs/remotes/top/master + git push $HTTPD_URL/smart/repo.git +main:refs/remotes/top/main ) && ( cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && git fsck && - git log --format=%s top/master >actual && + git log --format=%s top/main >actual && cat <<EOF >expect && 9 4 @@ -74,11 +77,11 @@ test_expect_success 'push from shallow repo via http' ' git config http.receivepack true ) && commit 10 && - git push $HTTPD_URL/smart/repo.git +master:refs/remotes/top/master && + git push $HTTPD_URL/smart/repo.git +main:refs/remotes/top/main && ( cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && git fsck && - git log --format=%s top/master >actual && + git log --format=%s top/main >actual && cat <<EOF >expect && 10 4 diff --git a/t/t5543-atomic-push.sh b/t/t5543-atomic-push.sh index 620c30d58f..bfee461861 100755 --- a/t/t5543-atomic-push.sh +++ b/t/t5543-atomic-push.sh @@ -2,6 +2,9 @@ test_description='pushing to a repository using the atomic push option' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh mk_repo_pair () { @@ -40,9 +43,9 @@ test_expect_success 'atomic push works for a single branch' ' test_commit one && git push --mirror up && test_commit two && - git push --atomic up master + git push --atomic up main ) && - test_refs master master + test_refs main main ' test_expect_success 'atomic push works for two branches' ' @@ -55,9 +58,9 @@ test_expect_success 'atomic push works for two branches' ' test_commit two && git checkout second && test_commit three && - git push --atomic up master second + git push --atomic up main second ) && - test_refs master master && + test_refs main main && test_refs second second ' @@ -70,7 +73,7 @@ test_expect_success 'atomic push works in combination with --mirror' ' test_commit two && git push --atomic --mirror up ) && - test_refs master master && + test_refs main main && test_refs second second ' @@ -79,7 +82,7 @@ test_expect_success 'atomic push works in combination with --force' ' ( cd workbench && test_commit one && - git branch second master && + git branch second main && test_commit two_a && git checkout second && test_commit two_b && @@ -87,36 +90,36 @@ test_expect_success 'atomic push works in combination with --force' ' test_commit four && git push --mirror up && # The actual test is below - git checkout master && + git checkout main && test_commit three_a && git checkout second && git reset --hard HEAD^ && - git push --force --atomic up master second + git push --force --atomic up main second ) && - test_refs master master && + test_refs main main && test_refs second second ' -# set up two branches where master can be pushed but second can not +# set up two branches where main can be pushed but second can not # (non-fast-forward). Since second can not be pushed the whole operation -# will fail and leave master untouched. +# will fail and leave main untouched. test_expect_success 'atomic push fails if one branch fails' ' mk_repo_pair && ( cd workbench && test_commit one && - git checkout -b second master && + git checkout -b second main && test_commit two && test_commit three && test_commit four && git push --mirror up && git reset --hard HEAD~2 && test_commit five && - git checkout master && + git checkout main && test_commit six && test_must_fail git push --atomic --all up ) && - test_refs master HEAD@{7} && + test_refs main HEAD@{7} && test_refs second HEAD@{4} ' @@ -126,7 +129,7 @@ test_expect_success 'atomic push fails if one tag fails remotely' ' ( cd workbench && test_commit one && - git checkout -b second master && + git checkout -b second main && test_commit two && git push --mirror up ) && @@ -139,14 +142,14 @@ test_expect_success 'atomic push fails if one tag fails remotely' ' # see if we can now push both branches. ( cd workbench && - git checkout master && + git checkout main && test_commit three && git checkout second && test_commit four && git tag test_tag && - test_must_fail git push --tags --atomic up master second + test_must_fail git push --tags --atomic up main second ) && - test_refs master HEAD@{3} && + test_refs main HEAD@{3} && test_refs second HEAD@{1} ' @@ -155,7 +158,7 @@ test_expect_success 'atomic push obeys update hook preventing a branch to be pus ( cd workbench && test_commit one && - git checkout -b second master && + git checkout -b second main && test_commit two && git push --mirror up ) && @@ -165,19 +168,19 @@ test_expect_success 'atomic push obeys update hook preventing a branch to be pus HOOK="$HOOKDIR/update" && mkdir -p "$HOOKDIR" && write_script "$HOOK" <<-\EOF - # only allow update to master from now on - test "$1" = "refs/heads/master" + # only allow update to main from now on + test "$1" = "refs/heads/main" EOF ) && ( cd workbench && - git checkout master && + git checkout main && test_commit three && git checkout second && test_commit four && - test_must_fail git push --atomic up master second + test_must_fail git push --atomic up main second ) && - test_refs master HEAD@{3} && + test_refs main HEAD@{3} && test_refs second HEAD@{1} ' @@ -192,21 +195,21 @@ test_expect_success 'atomic push is not advertised if configured' ' test_commit one && git push --mirror up && test_commit two && - test_must_fail git push --atomic up master + test_must_fail git push --atomic up main ) && - test_refs master HEAD@{1} + test_refs main HEAD@{1} ' -# References in upstream : master(1) one(1) foo(1) -# References in workbench: master(2) foo(1) two(2) bar(2) -# Atomic push : master(2) two(2) bar(2) +# References in upstream : main(1) one(1) foo(1) +# References in workbench: main(2) foo(1) two(2) bar(2) +# Atomic push : main(2) two(2) bar(2) test_expect_success 'atomic push reports (reject by update hook)' ' mk_repo_pair && ( cd workbench && test_commit one && git branch foo && - git push up master one foo && + git push up main one foo && git tag -d one ) && ( @@ -228,19 +231,19 @@ test_expect_success 'atomic push reports (reject by update hook)' ' git branch bar ) && test_must_fail git -C workbench \ - push --atomic up master two bar >out 2>&1 && + push --atomic up main two bar >out 2>&1 && fmt_status_report <out >actual && cat >expect <<-EOF && To ../upstream - ! [remote rejected] master -> master (atomic push failure) + ! [remote rejected] main -> main (atomic push failure) ! [remote rejected] two -> two (atomic push failure) ! [remote rejected] bar -> bar (hook declined) EOF test_cmp expect actual ' -# References in upstream : master(1) one(1) foo(1) -# References in workbench: master(2) foo(1) two(2) bar(2) +# References in upstream : main(1) one(1) foo(1) +# References in workbench: main(2) foo(1) two(2) bar(2) test_expect_success 'atomic push reports (mirror, but reject by update hook)' ' ( cd workbench && @@ -252,7 +255,7 @@ test_expect_success 'atomic push reports (mirror, but reject by update hook)' ' fmt_status_report <out >actual && cat >expect <<-EOF && To ../upstream - ! [remote rejected] master -> master (atomic push failure) + ! [remote rejected] main -> main (atomic push failure) ! [remote rejected] one (atomic push failure) ! [remote rejected] bar -> bar (hook declined) ! [remote rejected] two -> two (atomic push failure) @@ -260,21 +263,21 @@ test_expect_success 'atomic push reports (mirror, but reject by update hook)' ' test_cmp expect actual ' -# References in upstream : master(2) one(1) foo(1) -# References in workbench: master(1) foo(1) two(2) bar(2) +# References in upstream : main(2) one(1) foo(1) +# References in workbench: main(1) foo(1) two(2) bar(2) test_expect_success 'atomic push reports (reject by non-ff)' ' rm upstream/.git/hooks/update && ( cd workbench && - git push up master && + git push up main && git reset --hard HEAD^ ) && test_must_fail git -C workbench \ - push --atomic up master foo bar >out 2>&1 && + push --atomic up main foo bar >out 2>&1 && fmt_status_report <out >actual && cat >expect <<-EOF && To ../upstream - ! [rejected] master -> master (non-fast-forward) + ! [rejected] main -> main (non-fast-forward) ! [rejected] bar -> bar (atomic push failed) EOF test_cmp expect actual diff --git a/t/t5544-pack-objects-hook.sh b/t/t5544-pack-objects-hook.sh index 4357af1525..dd5f44d986 100755 --- a/t/t5544-pack-objects-hook.sh +++ b/t/t5544-pack-objects-hook.sh @@ -59,4 +59,14 @@ test_expect_success 'hook does not run from repo config' ' test_path_is_missing .git/hook.stdout ' +test_expect_success 'hook works with partial clone' ' + clear_hook_results && + test_config_global uploadpack.packObjectsHook ./hook && + test_config_global uploadpack.allowFilter true && + git clone --bare --no-local --filter=blob:none . dst.git && + git -C dst.git rev-list --objects --missing=allow-any --no-object-names --all >objects && + git -C dst.git cat-file --batch-check="%(objecttype)" <objects >types && + ! grep blob types +' + test_done diff --git a/t/t5545-push-options.sh b/t/t5545-push-options.sh index 38e6f7340e..58c7add7ee 100755 --- a/t/t5545-push-options.sh +++ b/t/t5545-push-options.sh @@ -2,6 +2,9 @@ test_description='pushing to a repository using push options' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh mk_repo_pair () { @@ -63,9 +66,9 @@ test_expect_success 'one push option works for a single branch' ' test_commit one && git push --mirror up && test_commit two && - git push --push-option=asdf up master + git push --push-option=asdf up main ) && - test_refs master master && + test_refs main main && echo "asdf" >expect && test_cmp expect upstream/.git/hooks/pre-receive.push_options && test_cmp expect upstream/.git/hooks/post-receive.push_options @@ -79,9 +82,9 @@ test_expect_success 'push option denied by remote' ' test_commit one && git push --mirror up && test_commit two && - test_must_fail git push --push-option=asdf up master + test_must_fail git push --push-option=asdf up main ) && - test_refs master HEAD@{1} + test_refs main HEAD@{1} ' test_expect_success 'two push options work' ' @@ -92,9 +95,9 @@ test_expect_success 'two push options work' ' test_commit one && git push --mirror up && test_commit two && - git push --push-option=asdf --push-option="more structured text" up master + git push --push-option=asdf --push-option="more structured text" up main ) && - test_refs master master && + test_refs main main && printf "asdf\nmore structured text\n" >expect && test_cmp expect upstream/.git/hooks/pre-receive.push_options && test_cmp expect upstream/.git/hooks/post-receive.push_options @@ -123,14 +126,14 @@ test_expect_success 'push options and submodules' ' git -C parent push \ --push-option=asdf --push-option="more structured text" \ - --recurse-submodules=on-demand up master && + --recurse-submodules=on-demand up main && - git -C upstream rev-parse --verify master >expect && - git -C parent/workbench rev-parse --verify master >actual && + git -C upstream rev-parse --verify main >expect && + git -C parent/workbench rev-parse --verify main >actual && test_cmp expect actual && - git -C parent_upstream rev-parse --verify master >expect && - git -C parent rev-parse --verify master >actual && + git -C parent_upstream rev-parse --verify main >expect && + git -C parent rev-parse --verify main >actual && test_cmp expect actual && printf "asdf\nmore structured text\n" >expect && @@ -148,9 +151,9 @@ test_expect_success 'default push option' ' test_commit one && git push --mirror up && test_commit two && - git -c push.pushOption=default push up master + git -c push.pushOption=default push up main ) && - test_refs master master && + test_refs main main && echo "default" >expect && test_cmp expect upstream/.git/hooks/pre-receive.push_options && test_cmp expect upstream/.git/hooks/post-receive.push_options @@ -164,9 +167,9 @@ test_expect_success 'two default push options' ' test_commit one && git push --mirror up && test_commit two && - git -c push.pushOption=default1 -c push.pushOption=default2 push up master + git -c push.pushOption=default1 -c push.pushOption=default2 push up main ) && - test_refs master master && + test_refs main main && printf "default1\ndefault2\n" >expect && test_cmp expect upstream/.git/hooks/pre-receive.push_options && test_cmp expect upstream/.git/hooks/post-receive.push_options @@ -180,9 +183,9 @@ test_expect_success 'push option from command line overrides from-config push op test_commit one && git push --mirror up && test_commit two && - git -c push.pushOption=default push --push-option=manual up master + git -c push.pushOption=default push --push-option=manual up main ) && - test_refs master master && + test_refs main main && echo "manual" >expect && test_cmp expect upstream/.git/hooks/pre-receive.push_options && test_cmp expect upstream/.git/hooks/post-receive.push_options @@ -196,9 +199,9 @@ test_expect_success 'empty value of push.pushOption in config clears the list' ' test_commit one && git push --mirror up && test_commit two && - git -c push.pushOption=default1 -c push.pushOption= -c push.pushOption=default2 push up master + git -c push.pushOption=default1 -c push.pushOption= -c push.pushOption=default2 push up main ) && - test_refs master master && + test_refs main main && echo "default2" >expect && test_cmp expect upstream/.git/hooks/pre-receive.push_options && test_cmp expect upstream/.git/hooks/post-receive.push_options @@ -212,16 +215,16 @@ test_expect_success 'invalid push option in config' ' test_commit one && git push --mirror up && test_commit two && - test_must_fail git -c push.pushOption push up master + test_must_fail git -c push.pushOption push up main ) && - test_refs master HEAD@{1} + test_refs main HEAD@{1} ' test_expect_success 'push options keep quoted characters intact (direct)' ' mk_repo_pair && git -C upstream config receive.advertisePushOptions true && test_commit -C workbench one && - git -C workbench push --push-option="\"embedded quotes\"" up master && + git -C workbench push --push-option="\"embedded quotes\"" up main && echo "\"embedded quotes\"" >expect && test_cmp expect upstream/.git/hooks/pre-receive.push_options ' @@ -244,28 +247,28 @@ mk_http_pair () { test_expect_success 'push option denied properly by http server' ' mk_http_pair false && test_commit -C test_http_clone one && - test_must_fail git -C test_http_clone push --push-option=asdf origin master 2>actual && + test_must_fail git -C test_http_clone push --push-option=asdf origin main 2>actual && test_i18ngrep "the receiving end does not support push options" actual && - git -C test_http_clone push origin master + git -C test_http_clone push origin main ' test_expect_success 'push options work properly across http' ' mk_http_pair true && test_commit -C test_http_clone one && - git -C test_http_clone push origin master && - git -C "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git rev-parse --verify master >expect && - git -C test_http_clone rev-parse --verify master >actual && + git -C test_http_clone push origin main && + git -C "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git rev-parse --verify main >expect && + git -C test_http_clone rev-parse --verify main >actual && test_cmp expect actual && test_commit -C test_http_clone two && - git -C test_http_clone push --push-option=asdf --push-option="more structured text" origin master && + git -C test_http_clone push --push-option=asdf --push-option="more structured text" origin main && printf "asdf\nmore structured text\n" >expect && test_cmp expect "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git/hooks/pre-receive.push_options && test_cmp expect "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git/hooks/post-receive.push_options && - git -C "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git rev-parse --verify master >expect && - git -C test_http_clone rev-parse --verify master >actual && + git -C "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git rev-parse --verify main >expect && + git -C test_http_clone rev-parse --verify main >actual && test_cmp expect actual ' @@ -273,7 +276,7 @@ test_expect_success 'push options keep quoted characters intact (http)' ' mk_http_pair true && test_commit -C test_http_clone one && - git -C test_http_clone push --push-option="\"embedded quotes\"" origin master && + git -C test_http_clone push --push-option="\"embedded quotes\"" origin main && echo "\"embedded quotes\"" >expect && test_cmp expect "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git/hooks/pre-receive.push_options ' diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh index 1b19b3ef55..5a761f3642 100755 --- a/t/t5548-push-porcelain.sh +++ b/t/t5548-push-porcelain.sh @@ -36,7 +36,7 @@ create_commits_in () { shift || return 1 done && - git -C "$repo" update-ref refs/heads/master $oid + git -C "$repo" update-ref refs/heads/main $oid } # Format the output of git-push, git-show-ref and other commands to make a @@ -57,8 +57,8 @@ make_user_friendly_and_stable_output () { } setup_upstream_and_workbench () { - # Upstream after setup : master(B) foo(A) bar(A) baz(A) - # Workbench after setup : master(A) + # Upstream after setup : main(B) foo(A) bar(A) baz(A) + # Workbench after setup : main(A) test_expect_success "setup upstream repository and workbench" ' rm -rf upstream.git workbench && git init --bare upstream.git && @@ -70,9 +70,9 @@ setup_upstream_and_workbench () { # this fixed-width oid will be replaced with "<OID>". git config core.abbrev 7 && git remote add origin ../upstream.git && - git update-ref refs/heads/master $A && + git update-ref refs/heads/main $A && git push origin \ - $B:refs/heads/master \ + $B:refs/heads/main \ $A:refs/heads/foo \ $A:refs/heads/bar \ $A:refs/heads/baz @@ -94,17 +94,17 @@ run_git_push_porcelain_output_test() { ;; esac - # Refs of upstream : master(B) foo(A) bar(A) baz(A) - # Refs of workbench: master(A) baz(A) next(A) - # git-push : master(A) NULL (B) baz(A) next(A) + # Refs of upstream : main(B) foo(A) bar(A) baz(A) + # Refs of workbench: main(A) baz(A) next(A) + # git-push : main(A) NULL (B) baz(A) next(A) test_expect_success "porcelain output of successful git-push ($PROTOCOL)" ' ( cd workbench && - git update-ref refs/heads/master $A && + git update-ref refs/heads/main $A && git update-ref refs/heads/baz $A && git update-ref refs/heads/next $A && git push --porcelain --force origin \ - master \ + main \ :refs/heads/foo \ $B:bar \ baz \ @@ -116,7 +116,7 @@ run_git_push_porcelain_output_test() { = refs/heads/baz:refs/heads/baz [up to date] <COMMIT-B>:refs/heads/bar <OID-A>..<OID-B> - :refs/heads/foo [deleted] - + refs/heads/master:refs/heads/master <OID-B>...<OID-A> (forced update) + + refs/heads/main:refs/heads/main <OID-B>...<OID-A> (forced update) * refs/heads/next:refs/heads/next [new branch] Done EOF @@ -127,22 +127,22 @@ run_git_push_porcelain_output_test() { cat >expect <<-EOF && <COMMIT-B> refs/heads/bar <COMMIT-A> refs/heads/baz - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF test_cmp expect actual ' - # Refs of upstream : master(A) bar(B) baz(A) next(A) - # Refs of workbench: master(B) bar(A) baz(A) next(A) - # git-push : master(B) bar(A) NULL next(A) + # Refs of upstream : main(A) bar(B) baz(A) next(A) + # Refs of workbench: main(B) bar(A) baz(A) next(A) + # git-push : main(B) bar(A) NULL next(A) test_expect_success "atomic push failed ($PROTOCOL)" ' ( cd workbench && - git update-ref refs/heads/master $B && + git update-ref refs/heads/main $B && git update-ref refs/heads/bar $A && test_must_fail git push --atomic --porcelain origin \ - master \ + main \ bar \ :baz \ next @@ -153,7 +153,7 @@ run_git_push_porcelain_output_test() { = refs/heads/next:refs/heads/next [up to date] ! refs/heads/bar:refs/heads/bar [rejected] (non-fast-forward) ! (delete):refs/heads/baz [rejected] (atomic push failed) - ! refs/heads/master:refs/heads/master [rejected] (atomic push failed) + ! refs/heads/main:refs/heads/main [rejected] (atomic push failed) Done EOF test_cmp expect actual && @@ -163,7 +163,7 @@ run_git_push_porcelain_output_test() { cat >expect <<-EOF && <COMMIT-B> refs/heads/bar <COMMIT-A> refs/heads/baz - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF test_cmp expect actual @@ -174,16 +174,16 @@ run_git_push_porcelain_output_test() { EOF ' - # Refs of upstream : master(A) bar(B) baz(A) next(A) - # Refs of workbench: master(B) bar(A) baz(A) next(A) - # git-push : master(B) bar(A) NULL next(A) + # Refs of upstream : main(A) bar(B) baz(A) next(A) + # Refs of workbench: main(B) bar(A) baz(A) next(A) + # git-push : main(B) bar(A) NULL next(A) test_expect_success "pre-receive hook declined ($PROTOCOL)" ' ( cd workbench && - git update-ref refs/heads/master $B && + git update-ref refs/heads/main $B && git update-ref refs/heads/bar $A && test_must_fail git push --porcelain --force origin \ - master \ + main \ bar \ :baz \ next @@ -194,7 +194,7 @@ run_git_push_porcelain_output_test() { = refs/heads/next:refs/heads/next [up to date] ! refs/heads/bar:refs/heads/bar [remote rejected] (pre-receive hook declined) ! :refs/heads/baz [remote rejected] (pre-receive hook declined) - ! refs/heads/master:refs/heads/master [remote rejected] (pre-receive hook declined) + ! refs/heads/main:refs/heads/main [remote rejected] (pre-receive hook declined) Done EOF test_cmp expect actual && @@ -204,7 +204,7 @@ run_git_push_porcelain_output_test() { cat >expect <<-EOF && <COMMIT-B> refs/heads/bar <COMMIT-A> refs/heads/baz - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF test_cmp expect actual @@ -214,14 +214,14 @@ run_git_push_porcelain_output_test() { rm "$upstream/hooks/pre-receive" ' - # Refs of upstream : master(A) bar(B) baz(A) next(A) - # Refs of workbench: master(B) bar(A) baz(A) next(A) - # git-push : master(B) bar(A) NULL next(A) + # Refs of upstream : main(A) bar(B) baz(A) next(A) + # Refs of workbench: main(B) bar(A) baz(A) next(A) + # git-push : main(B) bar(A) NULL next(A) test_expect_success "non-fastforward push ($PROTOCOL)" ' ( cd workbench && test_must_fail git push --porcelain origin \ - master \ + main \ bar \ :baz \ next @@ -231,7 +231,7 @@ run_git_push_porcelain_output_test() { To <URL/of/upstream.git> = refs/heads/next:refs/heads/next [up to date] - :refs/heads/baz [deleted] - refs/heads/master:refs/heads/master <OID-A>..<OID-B> + refs/heads/main:refs/heads/main <OID-A>..<OID-B> ! refs/heads/bar:refs/heads/bar [rejected] (non-fast-forward) Done EOF @@ -241,7 +241,7 @@ run_git_push_porcelain_output_test() { make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && <COMMIT-B> refs/heads/bar - <COMMIT-B> refs/heads/master + <COMMIT-B> refs/heads/main <COMMIT-A> refs/heads/next EOF test_cmp expect actual diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh index 483578b2d7..6d9142afc3 100755 --- a/t/t5550-http-fetch-dumb.sh +++ b/t/t5550-http-fetch-dumb.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='test dumb fetching over http via static file' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd @@ -26,7 +29,7 @@ test_expect_success 'create http-accessible bare repository with loose objects' hooks/post-update ) && git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && - git push public master:master + git push public main:main ' test_expect_success 'clone http repository' ' @@ -37,8 +40,8 @@ test_expect_success 'clone http repository' ' test_expect_success 'list refs from outside any repository' ' cat >expect <<-EOF && - $(git rev-parse master) HEAD - $(git rev-parse master) refs/heads/master + $(git rev-parse main) HEAD + $(git rev-parse main) refs/heads/main EOF nongit git ls-remote "$HTTPD_URL/dumb/repo.git" >actual && test_cmp expect actual @@ -181,8 +184,8 @@ test_expect_success 'fetch changes via manual http-fetch' ' HEAD=$(git rev-parse --verify HEAD) && (cd clone2 && - git http-fetch -a -w heads/master-new $HEAD $(git config remote.origin.url) && - git checkout master-new && + git http-fetch -a -w heads/main-new $HEAD $(git config remote.origin.url) && + git checkout main-new && test $HEAD = $(git rev-parse --verify HEAD)) && test_cmp file clone2/file ' @@ -192,19 +195,19 @@ test_expect_success 'manual http-fetch without -a works just as well' ' HEAD=$(git rev-parse --verify HEAD) && (cd clone3 && - git http-fetch -w heads/master-new $HEAD $(git config remote.origin.url) && - git checkout master-new && + git http-fetch -w heads/main-new $HEAD $(git config remote.origin.url) && + git checkout main-new && test $HEAD = $(git rev-parse --verify HEAD)) && test_cmp file clone3/file ' test_expect_success 'http remote detects correct HEAD' ' - git push public master:other && + git push public main:other && (cd clone && git remote set-head origin -d && git remote set-head origin -a && git symbolic-ref refs/remotes/origin/HEAD > output && - echo refs/remotes/origin/master > expect && + echo refs/remotes/origin/main > expect && test_cmp expect output ) ' @@ -224,7 +227,10 @@ test_expect_success 'http-fetch --packfile' ' git init packfileclient && p=$(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git && ls objects/pack/pack-*.pack) && - git -C packfileclient http-fetch --packfile=$ARBITRARY "$HTTPD_URL"/dumb/repo_pack.git/$p >out && + git -C packfileclient http-fetch --packfile=$ARBITRARY \ + --index-pack-arg=index-pack --index-pack-arg=--stdin \ + --index-pack-arg=--keep \ + "$HTTPD_URL"/dumb/repo_pack.git/$p >out && grep "^keep.[0-9a-f]\{16,\}$" out && cut -c6- out >packhash && @@ -416,7 +422,7 @@ test_expect_success 'set up evil alternates scheme' ' evil=$HTTPD_DOCUMENT_ROOT_PATH/evil.git && git init --bare "$evil" && # do this by hand to avoid object existence check - printf "%s\\t%s\\n" $sha1 refs/heads/master >"$evil/info/refs" + printf "%s\\t%s\\n" $sha1 refs/heads/main >"$evil/info/refs" ' # Here we'll just redirect via HTTP. In a real-world attack these would be on diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh index e40e9ed52f..4f87d90c5b 100755 --- a/t/t5551-http-fetch-smart.sh +++ b/t/t5551-http-fetch-smart.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='test smart fetching over http via http-backend' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd @@ -18,7 +21,7 @@ test_expect_success 'create http-accessible bare repository' ' git --bare init ) && git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && - git push public master:master + git push public main:main ' setup_askpass_helper @@ -238,9 +241,9 @@ test_expect_success 'invalid Content-Type rejected' ' test_expect_success 'create namespaced refs' ' test_commit namespaced && - git push public HEAD:refs/namespaces/ns/refs/heads/master && + git push public HEAD:refs/namespaces/ns/refs/heads/main && git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \ - symbolic-ref refs/namespaces/ns/HEAD refs/namespaces/ns/refs/heads/master + symbolic-ref refs/namespaces/ns/HEAD refs/namespaces/ns/refs/heads/main ' test_expect_success 'smart clone respects namespace' ' @@ -271,7 +274,7 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set EOF git config http.cookiefile cookies.txt && git config http.savecookies true && - git ls-remote $HTTPD_URL/smart_cookies/repo.git master && + git ls-remote $HTTPD_URL/smart_cookies/repo.git main && # NEEDSWORK: If the overspecification of the expected result is reduced, we # might be able to run this test in all protocol versions. @@ -344,12 +347,12 @@ test_expect_success 'large fetch-pack requests can be sent using chunked encodin test_expect_success 'test allowreachablesha1inwant' ' test_when_finished "rm -rf test_reachable.git" && server="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && - master_sha=$(git -C "$server" rev-parse refs/heads/master) && + main_sha=$(git -C "$server" rev-parse refs/heads/main) && git -C "$server" config uploadpack.allowreachablesha1inwant 1 && git init --bare test_reachable.git && git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" && - git -C test_reachable.git fetch origin "$master_sha" + git -C test_reachable.git fetch origin "$main_sha" ' test_expect_success 'test allowreachablesha1inwant with unreachable' ' @@ -363,7 +366,7 @@ test_expect_success 'test allowreachablesha1inwant with unreachable' ' git push public :refs/heads/doomed && server="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && - master_sha=$(git -C "$server" rev-parse refs/heads/master) && + main_sha=$(git -C "$server" rev-parse refs/heads/main) && git -C "$server" config uploadpack.allowreachablesha1inwant 1 && git init --bare test_reachable.git && @@ -385,7 +388,7 @@ test_expect_success 'test allowanysha1inwant with unreachable' ' git push public :refs/heads/doomed && server="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && - master_sha=$(git -C "$server" rev-parse refs/heads/master) && + main_sha=$(git -C "$server" rev-parse refs/heads/main) && git -C "$server" config uploadpack.allowreachablesha1inwant 1 && git init --bare test_reachable.git && @@ -444,8 +447,8 @@ test_expect_success 'using fetch command in remote-curl updates refs' ' test_commit -C "$SERVER" bar && git -C client -c protocol.version=0 fetch && - git -C "$SERVER" rev-parse master >expect && - git -C client rev-parse origin/master >actual && + git -C "$SERVER" rev-parse main >expect && + git -C client rev-parse origin/main >actual && test_cmp expect actual ' @@ -514,4 +517,45 @@ test_expect_success 'server-side error detected' ' test_i18ngrep "server-side error" actual ' +test_expect_success 'http auth remembers successful credentials' ' + rm -f .git-credentials && + test_config credential.helper store && + + # the first request prompts the user... + set_askpass user@host pass@host && + git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null && + expect_askpass both user@host && + + # ...and the second one uses the stored value rather than + # prompting the user. + set_askpass bogus-user bogus-pass && + git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null && + expect_askpass none +' + +test_expect_success 'http auth forgets bogus credentials' ' + # seed credential store with bogus values. In real life, + # this would probably come from a password which worked + # for a previous request. + rm -f .git-credentials && + test_config credential.helper store && + { + echo "url=$HTTPD_URL" && + echo "username=bogus" && + echo "password=bogus" + } | git credential approve && + + # we expect this to use the bogus values and fail, never even + # prompting the user... + set_askpass user@host pass@host && + test_must_fail git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null && + expect_askpass none && + + # ...but now we should have forgotten the bad value, causing + # us to prompt the user again. + set_askpass user@host pass@host && + git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null && + expect_askpass both user@host +' + test_done diff --git a/t/t5552-skipping-fetch-negotiator.sh b/t/t5552-skipping-fetch-negotiator.sh index 156c704040..7b9fb4ff02 100755 --- a/t/t5552-skipping-fetch-negotiator.sh +++ b/t/t5552-skipping-fetch-negotiator.sh @@ -100,7 +100,7 @@ test_expect_success 'use ref advertisement to filter out commits' ' git -C server checkout --orphan anotherbranch && test_commit -C server to_fetch && - # The server advertising "c3" (as "refs/heads/master") means that we do + # The server advertising "c3" (as "refs/heads/main") means that we do # not need to send any ancestors of "c3", but we still need to send "c3" # itself. test_config -C client fetch.negotiationalgorithm skipping && diff --git a/t/t5553-set-upstream.sh b/t/t5553-set-upstream.sh index 7622981cbf..b1d614ce18 100755 --- a/t/t5553-set-upstream.sh +++ b/t/t5553-set-upstream.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='"git fetch/pull --set-upstream" basic tests.' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh check_config () { @@ -32,9 +35,9 @@ test_expect_success 'setup bare parent fetch' ' git remote add upstream parent ' -test_expect_success 'setup commit on master and other fetch' ' +test_expect_success 'setup commit on main and other fetch' ' test_commit one && - git push upstream master && + git push upstream main && git checkout -b other && test_commit two && git push upstream other @@ -43,38 +46,38 @@ test_expect_success 'setup commit on master and other fetch' ' # tests for fetch --set-upstream test_expect_success 'fetch --set-upstream does not set upstream w/o branch' ' - clear_config master other && - git checkout master && + clear_config main other && + git checkout main && git fetch --set-upstream upstream && - check_config_missing master && + check_config_missing main && check_config_missing other ' -test_expect_success 'fetch --set-upstream upstream master sets branch master but not other' ' - clear_config master other && - git fetch --set-upstream upstream master && - check_config master upstream refs/heads/master && +test_expect_success 'fetch --set-upstream upstream main sets branch main but not other' ' + clear_config main other && + git fetch --set-upstream upstream main && + check_config main upstream refs/heads/main && check_config_missing other ' test_expect_success 'fetch --set-upstream upstream other sets branch other' ' - clear_config master other && + clear_config main other && git fetch --set-upstream upstream other && - check_config master upstream refs/heads/other && + check_config main upstream refs/heads/other && check_config_missing other ' -test_expect_success 'fetch --set-upstream master:other does not set the branch other2' ' +test_expect_success 'fetch --set-upstream main:other does not set the branch other2' ' clear_config other2 && - git fetch --set-upstream upstream master:other2 && + git fetch --set-upstream upstream main:other2 && check_config_missing other2 ' test_expect_success 'fetch --set-upstream http://nosuchdomain.example.com fails with invalid url' ' - # master explicitly not cleared, we check that it is not touched from previous value + # main explicitly not cleared, we check that it is not touched from previous value clear_config other other2 && test_must_fail git fetch --set-upstream http://nosuchdomain.example.com && - check_config master upstream refs/heads/other && + check_config main upstream refs/heads/other && check_config_missing other && check_config_missing other2 ' @@ -83,7 +86,7 @@ test_expect_success 'fetch --set-upstream with valid URL sets upstream to URL' ' clear_config other other2 && url="file://$PWD" && git fetch --set-upstream "$url" && - check_config master "$url" HEAD && + check_config main "$url" HEAD && check_config_missing other && check_config_missing other2 ' @@ -96,30 +99,30 @@ test_expect_success 'setup bare parent pull' ' git remote add upstream parent ' -test_expect_success 'setup commit on master and other pull' ' +test_expect_success 'setup commit on main and other pull' ' test_commit three && - git push --tags upstream master && + git push --tags upstream main && test_commit four && git push upstream other ' -test_expect_success 'pull --set-upstream upstream master sets branch master but not other' ' - clear_config master other && - git pull --set-upstream upstream master && - check_config master upstream refs/heads/master && +test_expect_success 'pull --set-upstream upstream main sets branch main but not other' ' + clear_config main other && + git pull --set-upstream upstream main && + check_config main upstream refs/heads/main && check_config_missing other ' -test_expect_success 'pull --set-upstream master:other2 does not set the branch other2' ' +test_expect_success 'pull --set-upstream main:other2 does not set the branch other2' ' clear_config other2 && - git pull --set-upstream upstream master:other2 && + git pull --set-upstream upstream main:other2 && check_config_missing other2 ' -test_expect_success 'pull --set-upstream upstream other sets branch master' ' - clear_config master other && +test_expect_success 'pull --set-upstream upstream other sets branch main' ' + clear_config main other && git pull --set-upstream upstream other && - check_config master upstream refs/heads/other && + check_config main upstream refs/heads/other && check_config_missing other ' @@ -130,47 +133,47 @@ test_expect_success 'pull --set-upstream upstream tag does not set the tag' ' ' test_expect_success 'pull --set-upstream http://nosuchdomain.example.com fails with invalid url' ' - # master explicitly not cleared, we check that it is not touched from previous value + # main explicitly not cleared, we check that it is not touched from previous value clear_config other other2 three && test_must_fail git pull --set-upstream http://nosuchdomain.example.com && - check_config master upstream refs/heads/other && + check_config main upstream refs/heads/other && check_config_missing other && check_config_missing other2 && check_config_missing three ' test_expect_success 'pull --set-upstream upstream HEAD sets branch HEAD' ' - clear_config master other && + clear_config main other && git pull --set-upstream upstream HEAD && - check_config master upstream HEAD && + check_config main upstream HEAD && git checkout other && git pull --set-upstream upstream HEAD && check_config other upstream HEAD ' test_expect_success 'pull --set-upstream upstream with more than one branch does nothing' ' - clear_config master three && - git pull --set-upstream upstream master three && - check_config_missing master && + clear_config main three && + git pull --set-upstream upstream main three && + check_config_missing main && check_config_missing three ' test_expect_success 'pull --set-upstream with valid URL sets upstream to URL' ' - clear_config master other other2 && - git checkout master && + clear_config main other other2 && + git checkout main && url="file://$PWD" && git pull --set-upstream "$url" && - check_config master "$url" HEAD && + check_config main "$url" HEAD && check_config_missing other && check_config_missing other2 ' test_expect_success 'pull --set-upstream with valid URL and branch sets branch' ' - clear_config master other other2 && - git checkout master && + clear_config main other other2 && + git checkout main && url="file://$PWD" && - git pull --set-upstream "$url" master && - check_config master "$url" refs/heads/master && + git pull --set-upstream "$url" main && + check_config main "$url" refs/heads/main && check_config_missing other && check_config_missing other2 ' diff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh index 9fafcf1945..d30cf4f5b8 100755 --- a/t/t5560-http-backend-noserver.sh +++ b/t/t5560-http-backend-noserver.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='test git-http-backend-noserver' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY" diff --git a/t/t5561-http-backend.sh b/t/t5561-http-backend.sh index 6eb0294978..9c57d84315 100755 --- a/t/t5561-http-backend.sh +++ b/t/t5561-http-backend.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='test git-http-backend' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-httpd.sh @@ -39,9 +42,9 @@ POST() { grep '^[^#]' >exp <<EOF -### refs/heads/master +### refs/heads/main ### -GET /smart/repo.git/refs/heads/master HTTP/1.1 404 - +GET /smart/repo.git/refs/heads/main HTTP/1.1 404 - ### getanyfile default ### diff --git a/t/t556x_common b/t/t556x_common index 359fcfe32b..670fb89477 100755 --- a/t/t556x_common +++ b/t/t556x_common @@ -22,7 +22,7 @@ test_expect_success 'setup repository' ' : >objects/info/http-alternates ) && git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && - git push public master:master && + git push public main:main && (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && git repack -a -d @@ -31,7 +31,7 @@ test_expect_success 'setup repository' ' echo other >file && git add file && git commit -m two && - git push public master:master && + git push public main:main && LOOSE_URL=$(find_file objects/??) && PACK_URL=$(find_file objects/pack/*.pack) && @@ -51,8 +51,8 @@ get_static_files() { SMART=smart GIT_HTTP_EXPORT_ALL=1 && export GIT_HTTP_EXPORT_ALL -test_expect_success 'direct refs/heads/master not found' ' - GET refs/heads/master "404 Not Found" +test_expect_success 'direct refs/heads/main not found' ' + GET refs/heads/main "404 Not Found" ' test_expect_success 'static file is ok' ' get_static_files "200 OK" diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh index 0fbb194810..82c31ab6cd 100755 --- a/t/t5570-git-daemon.sh +++ b/t/t5570-git-daemon.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='test fetching over git protocol' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-git-daemon.sh @@ -26,7 +29,7 @@ test_expect_success 'create git-accessible bare repository' ' : >git-daemon-export-ok ) && git remote add public "$GIT_DAEMON_DOCUMENT_ROOT_PATH/repo.git" && - git push public master:master + git push public main:main ' test_expect_success 'clone git repository' ' @@ -55,12 +58,12 @@ test_expect_success 'no-op fetch without "-v" is quiet' ' ' test_expect_success 'remote detects correct HEAD' ' - git push public master:other && + git push public main:other && (cd clone && git remote set-head -d origin && git remote set-head -a origin && git symbolic-ref refs/remotes/origin/HEAD > output && - echo refs/remotes/origin/master > expect && + echo refs/remotes/origin/main > expect && test_cmp expect output ) ' @@ -153,7 +156,7 @@ test_remote_error() msg="access denied or repository not exported" test_expect_success 'clone non-existent' "test_remote_error '$msg' clone nowhere.git" -test_expect_success 'push disabled' "test_remote_error '$msg' push repo.git master" +test_expect_success 'push disabled' "test_remote_error '$msg' push repo.git main" test_expect_success 'read access denied' "test_remote_error -x '$msg' fetch repo.git" test_expect_success 'not exported' "test_remote_error -n '$msg' fetch repo.git" @@ -161,7 +164,7 @@ stop_git_daemon start_git_daemon --informative-errors test_expect_success 'clone non-existent' "test_remote_error 'no such repository' clone nowhere.git" -test_expect_success 'push disabled' "test_remote_error 'service not enabled' push repo.git master" +test_expect_success 'push disabled' "test_remote_error 'service not enabled' push repo.git main" test_expect_success 'read access denied' "test_remote_error -x 'no such repository' fetch repo.git" test_expect_success 'not exported' "test_remote_error -n 'repository not exported' fetch repo.git" @@ -197,10 +200,10 @@ test_expect_success FAKENC 'hostname interpolation works after LF-stripping' ' fake_nc "$GIT_DAEMON_HOST_PORT" <input >output && depacketize <output >output.raw && - # just pick out the value of master, which avoids any protocol + # just pick out the value of main, which avoids any protocol # particulars - perl -lne "print \$1 if m{^(\\S+) refs/heads/master}" <output.raw >actual && - git -C "$repo" rev-parse master >expect && + perl -lne "print \$1 if m{^(\\S+) refs/heads/main}" <output.raw >actual && + git -C "$repo" rev-parse main >expect && test_cmp expect actual ' diff --git a/t/t5571-pre-push-hook.sh b/t/t5571-pre-push-hook.sh index ac53d63869..ad8d5804f7 100755 --- a/t/t5571-pre-push-hook.sh +++ b/t/t5571-pre-push-hook.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='check pre-push hooks' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # Setup hook that always succeeds @@ -48,11 +51,11 @@ EOF cat >expected <<EOF parent1 repo1 -refs/heads/master $COMMIT2 refs/heads/foreign $COMMIT1 +refs/heads/main $COMMIT2 refs/heads/foreign $COMMIT1 EOF test_expect_success 'push with hook' ' - git push parent1 master:foreign && + git push parent1 main:foreign && diff expected actual ' diff --git a/t/t5572-pull-submodule.sh b/t/t5572-pull-submodule.sh index 37fd06b0be..4f92a116e1 100755 --- a/t/t5572-pull-submodule.sh +++ b/t/t5572-pull-submodule.sh @@ -42,8 +42,11 @@ git_pull_noff () { $2 git pull --no-ff } -KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 -KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1 +if test "$GIT_TEST_MERGE_ALGORITHM" != ort +then + KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 + KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1 +fi test_submodule_switch_func "git_pull_noff" test_expect_success 'pull --recurse-submodule setup' ' @@ -170,7 +173,7 @@ test_expect_success 'pull --rebase --recurse-submodules (no submodule changes, n # create topic branch in clone, not based on any remote-tracking branch git -C superclone checkout -b feat HEAD~1 && test_commit -C superclone first_on_feat && - git -C superclone pull --rebase --recurse-submodules origin master + git -C superclone pull --rebase --recurse-submodules origin HEAD ' # NOTE: @@ -200,8 +203,8 @@ test_expect_success 'branch has no merge base with remote-tracking counterpart' git clone parent child && - # Reset master so that it has no merge base with - # refs/remotes/origin/master. + # Reset the current branch so that it has no merge base with + # the remote-tracking branch. OTHER=$(git -C child commit-tree -m bar \ $(git -C child rev-parse HEAD^{tree})) && git -C child reset --hard "$OTHER" && diff --git a/t/t5580-unc-paths.sh b/t/t5580-unc-paths.sh index cf768b3a27..cd803ae8bf 100755 --- a/t/t5580-unc-paths.sh +++ b/t/t5580-unc-paths.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='various Windows-only path tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh if test_have_prereq CYGWIN @@ -53,7 +56,7 @@ test_expect_success fetch ' git init to-fetch && ( cd to-fetch && - git fetch "$UNCPATH" master + git fetch "$UNCPATH" main ) ' diff --git a/t/t5581-http-curl-verbose.sh b/t/t5581-http-curl-verbose.sh index 927aad0820..cded79c16b 100755 --- a/t/t5581-http-curl-verbose.sh +++ b/t/t5581-http-curl-verbose.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='test GIT_CURL_VERBOSE' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd @@ -13,7 +16,7 @@ test_expect_success 'setup repository' ' git add file && git commit -m one && git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && - git push public master:master + git push public main:main ' test_expect_success 'failure in git-upload-pack is shown' ' diff --git a/t/t5582-fetch-negative-refspec.sh b/t/t5582-fetch-negative-refspec.sh index 2f3b064d0e..e5d2e79ad3 100755 --- a/t/t5582-fetch-negative-refspec.sh +++ b/t/t5582-fetch-negative-refspec.sh @@ -5,6 +5,9 @@ test_description='"git fetch" with negative refspecs. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -22,12 +25,12 @@ test_expect_success "clone and setup child repos" ' git switch -c alternate && echo >file updated again by one && git commit -a -m "updated by one again" && - git switch master + git switch main ) && git clone . two && ( cd two && - git config branch.master.remote one && + git config branch.main.remote one && git config remote.one.url ../one/.git/ && git config remote.one.fetch +refs/heads/*:refs/remotes/one/* && git config --add remote.one.fetch ^refs/heads/alternate @@ -43,9 +46,9 @@ test_expect_success "fetch one" ' test_must_fail git rev-parse --verify refs/remotes/one/alternate && git fetch one && test_must_fail git rev-parse --verify refs/remotes/one/alternate && - git rev-parse --verify refs/remotes/one/master && - mine=$(git rev-parse refs/remotes/one/master) && - his=$(cd ../one && git rev-parse refs/heads/master) && + git rev-parse --verify refs/remotes/one/main && + mine=$(git rev-parse refs/remotes/one/main) && + his=$(cd ../one && git rev-parse refs/heads/main) && test "z$mine" = "z$his" ) ' @@ -57,7 +60,7 @@ test_expect_success "fetch with negative refspec on commandline" ' cd three && alternate_in_one=$(cd ../one && git rev-parse refs/heads/alternate) && echo $alternate_in_one >expect && - git fetch ../one/.git refs/heads/*:refs/remotes/one/* ^refs/heads/master && + git fetch ../one/.git refs/heads/*:refs/remotes/one/* ^refs/heads/main && cut -f -1 .git/FETCH_HEAD >actual && test_cmp expect actual ) @@ -68,8 +71,8 @@ test_expect_success "fetch with negative sha1 refspec fails" ' git commit -a -m "updated by origin yet again" && ( cd three && - master_in_one=$(cd ../one && git rev-parse refs/heads/master) && - test_must_fail git fetch ../one/.git refs/heads/*:refs/remotes/one/* ^$master_in_one + main_in_one=$(cd ../one && git rev-parse refs/heads/main) && + test_must_fail git fetch ../one/.git refs/heads/*:refs/remotes/one/* ^$main_in_one ) ' @@ -92,10 +95,10 @@ test_expect_success "fetch with negative pattern refspec does not expand prefix" ( cd three && alternate_in_one=$(cd ../one && git rev-parse refs/heads/alternate) && - master_in_one=$(cd ../one && git rev-parse refs/heads/master) && + main_in_one=$(cd ../one && git rev-parse refs/heads/main) && echo $alternate_in_one >expect && - echo $master_in_one >>expect && - git fetch ../one/.git refs/heads/*:refs/remotes/one/* ^master && + echo $main_in_one >>expect && + git fetch ../one/.git refs/heads/*:refs/remotes/one/* ^main && cut -f -1 .git/FETCH_HEAD >actual && test_cmp expect actual ) @@ -237,4 +240,47 @@ test_expect_success "push with matching +: and negative refspec" ' git -C two push -v one ' +test_expect_success '--prefetch correctly modifies refspecs' ' + git -C one config --unset-all remote.origin.fetch && + git -C one config --add remote.origin.fetch ^refs/heads/bogus/ignore && + git -C one config --add remote.origin.fetch "refs/tags/*:refs/tags/*" && + git -C one config --add remote.origin.fetch "refs/heads/bogus/*:bogus/*" && + + git tag -a -m never never-fetch-tag HEAD && + + git branch bogus/fetched HEAD~1 && + git branch bogus/ignore HEAD && + + git -C one fetch --prefetch --no-tags && + test_must_fail git -C one rev-parse never-fetch-tag && + git -C one rev-parse refs/prefetch/bogus/fetched && + test_must_fail git -C one rev-parse refs/prefetch/bogus/ignore && + + # correctly handle when refspec set becomes empty + # after removing the refs/tags/* refspec. + git -C one config --unset-all remote.origin.fetch && + git -C one config --add remote.origin.fetch "refs/tags/*:refs/tags/*" && + + git -C one fetch --prefetch --no-tags && + test_must_fail git -C one rev-parse never-fetch-tag && + + # The refspec for refs that are not fully qualified + # are filtered multiple times. + git -C one rev-parse refs/prefetch/bogus/fetched && + test_must_fail git -C one rev-parse refs/prefetch/bogus/ignore +' + +test_expect_success '--prefetch succeeds when refspec becomes empty' ' + git checkout bogus/fetched && + test_commit extra && + + git -C one config --unset-all remote.origin.fetch && + git -C one config --unset branch.main.remote && + git -C one config remote.origin.fetch "+refs/tags/extra" && + git -C one config remote.origin.skipfetchall true && + git -C one config remote.origin.tagopt "--no-tags" && + + git -C one fetch --prefetch +' + test_done diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh index 7df3c5373a..c0688467e7 100755 --- a/t/t5601-clone.sh +++ b/t/t5601-clone.sh @@ -2,6 +2,9 @@ test_description=clone +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh X= @@ -37,7 +40,7 @@ test_expect_success 'clone with excess parameters (2)' ' ' -test_expect_success C_LOCALE_OUTPUT 'output from clone' ' +test_expect_success 'output from clone' ' rm -fr dst && git clone -n "file://$(pwd)/src" dst >output 2>&1 && test $(grep Clon output | wc -l) = 1 @@ -217,7 +220,7 @@ test_expect_success 'clone respects global branch.autosetuprebase' ' rm -fr dst && git clone src dst && cd dst && - actual="z$(git config branch.master.rebase)" && + actual="z$(git config branch.main.rebase)" && test ztrue = $actual ) ' @@ -591,7 +594,7 @@ test_expect_success 'clone from a repository with two identical branches' ' ( cd src && - git checkout -b another master + git checkout -b another main ) && git clone src target-11 && test "z$( cd target-11 && git symbolic-ref HEAD )" = zrefs/heads/another @@ -756,6 +759,15 @@ test_expect_success 'partial clone using HTTP' ' partial_clone "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server" ' +test_expect_success 'reject cloning shallow repository using HTTP' ' + test_when_finished "rm -rf repo" && + git clone --bare --no-local --depth=1 src "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && + test_must_fail git -c protocol.version=2 clone --reject-shallow $HTTPD_URL/smart/repo.git repo 2>err && + test_i18ngrep -e "source repository is shallow, reject to clone." err && + + git clone --no-reject-shallow $HTTPD_URL/smart/repo.git repo +' + # 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. diff --git a/t/t5604-clone-reference.sh b/t/t5604-clone-reference.sh index 2f7be23044..e845d621f6 100755 --- a/t/t5604-clone-reference.sh +++ b/t/t5604-clone-reference.sh @@ -4,6 +4,9 @@ # test_description='test clone --reference' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh base_dir=$(pwd) @@ -49,7 +52,7 @@ test_expect_success 'existence of info/alternates' ' ' test_expect_success 'pulling from reference' ' - git -C C pull ../B master + git -C C pull ../B main ' test_expect_success 'that reference gets used' ' @@ -70,7 +73,7 @@ test_expect_success 'existence of info/alternates' ' ' test_expect_success 'pulling from reference' ' - git -C D pull ../B master + git -C D pull ../B main ' test_expect_success 'that reference gets used' ' @@ -136,11 +139,11 @@ test_expect_success 'prepare branched repository' ' git clone A J && ( cd J && - git checkout -b other master^ && + git checkout -b other main^ && echo other >otherfile && git add otherfile && git commit -m other && - git checkout master + git checkout main ) ' @@ -152,9 +155,9 @@ test_expect_success 'fetch with incomplete alternates' ' git remote add J "file://$base_dir/J" && GIT_TRACE_PACKET=$U.K git fetch J ) && - master_object=$(cd A && git for-each-ref --format="%(objectname)" refs/heads/master) && + main_object=$(cd A && git for-each-ref --format="%(objectname)" refs/heads/main) && test -s "$U.K" && - ! grep " want $master_object" "$U.K" && + ! grep " want $main_object" "$U.K" && tag_object=$(cd A && git for-each-ref --format="%(objectname)" refs/tags/HEAD) && ! grep " want $tag_object" "$U.K" ' @@ -326,7 +329,7 @@ test_expect_success SYMLINKS 'clone repo with symlinked or unknown files at obje for raw in $(ls T*.raw) do sed -e "s!/../!/Y/!; s![0-9a-f]\{38,\}!Z!" -e "/commit-graph/d" \ - -e "/multi-pack-index/d" <$raw >$raw.de-sha-1 && + -e "/multi-pack-index/d" -e "/rev/d" <$raw >$raw.de-sha-1 && sort $raw.de-sha-1 >$raw.de-sha || return 1 done && diff --git a/t/t5605-clone-local.sh b/t/t5605-clone-local.sh index af23419ebf..7d63365f93 100755 --- a/t/t5605-clone-local.sh +++ b/t/t5605-clone-local.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='test local clone' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh repo_is_hardlinked() { @@ -15,7 +18,7 @@ test_expect_success 'preparing origin repository' ' test "$(cd a.git && git config --bool core.bare)" = true && test "$(cd x && git config --bool core.bare)" = true && git bundle create b1.bundle --all && - git bundle create b2.bundle master && + git bundle create b2.bundle main && mkdir dir && cp b1.bundle dir/b3 && cp b1.bundle b4 @@ -84,7 +87,7 @@ test_expect_success 'bundle clone with nonexistent HEAD' ' git clone b2.bundle b2 && (cd b2 && git fetch && - test_must_fail git rev-parse --verify refs/heads/master) + test_must_fail git rev-parse --verify refs/heads/main) ' test_expect_success 'clone empty repository' ' @@ -98,9 +101,9 @@ test_expect_success 'clone empty repository' ' echo "content" >> foo && git add foo && git commit -m "Initial commit" && - git push origin master && - expected=$(git rev-parse master) && - actual=$(git --git-dir=../empty/.git rev-parse master) && + git push origin main && + expected=$(git rev-parse main) && + actual=$(git --git-dir=../empty/.git rev-parse main) && test $actual = $expected) ' diff --git a/t/t5606-clone-options.sh b/t/t5606-clone-options.sh index 7f082fb23b..3a595c0f82 100755 --- a/t/t5606-clone-options.sh +++ b/t/t5606-clone-options.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='basic clone options' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -8,14 +11,15 @@ test_expect_success 'setup' ' mkdir parent && (cd parent && git init && echo one >file && git add file && - git commit -m one) + git commit -m one) && + git clone --depth=1 --no-local parent shallow-repo ' test_expect_success 'clone -o' ' git clone -o foo parent clone-o && - git -C clone-o rev-parse --verify refs/remotes/foo/master + git -C clone-o rev-parse --verify refs/remotes/foo/main ' @@ -42,10 +46,34 @@ test_expect_success 'disallows --bare with --separate-git-dir' ' ' +test_expect_success 'reject cloning shallow repository' ' + test_when_finished "rm -rf repo" && + test_must_fail git clone --reject-shallow shallow-repo out 2>err && + test_i18ngrep -e "source repository is shallow, reject to clone." err && + + git clone --no-reject-shallow shallow-repo repo +' + +test_expect_success 'reject cloning non-local shallow repository' ' + test_when_finished "rm -rf repo" && + test_must_fail git clone --reject-shallow --no-local shallow-repo out 2>err && + test_i18ngrep -e "source repository is shallow, reject to clone." err && + + git clone --no-reject-shallow --no-local shallow-repo repo +' + +test_expect_success 'succeed cloning normal repository' ' + test_when_finished "rm -rf chilad1 child2 child3 child4 " && + git clone --reject-shallow parent child1 && + git clone --reject-shallow --no-local parent child2 && + git clone --no-reject-shallow parent child3 && + git clone --no-reject-shallow --no-local parent child4 +' + test_expect_success 'uses "origin" for default remote name' ' git clone parent clone-default-origin && - git -C clone-default-origin rev-parse --verify refs/remotes/origin/master + git -C clone-default-origin rev-parse --verify refs/remotes/origin/main ' @@ -74,14 +102,14 @@ test_expect_success 'prefers config "clone.defaultRemoteName" over default' ' test_config_global clone.defaultRemoteName from_config && git clone parent clone-config-origin && - git -C clone-config-origin rev-parse --verify refs/remotes/from_config/master + git -C clone-config-origin rev-parse --verify refs/remotes/from_config/main ' test_expect_success 'prefers --origin over -c config' ' git clone -c clone.defaultRemoteName=inline --origin from_option parent clone-o-and-inline-config && - git -C clone-o-and-inline-config rev-parse --verify refs/remotes/from_option/master + git -C clone-o-and-inline-config rev-parse --verify refs/remotes/from_option/main ' @@ -101,12 +129,22 @@ test_expect_success 'redirected clone -v does show progress' ' ' +test_expect_success 'clone does not segfault with --bare and core.bare=false' ' + test_config_global core.bare false && + git clone --bare parent clone-bare && + echo true >expect && + git -C clone-bare rev-parse --is-bare-repository >actual && + test_cmp expect actual +' + test_expect_success 'chooses correct default initial branch name' ' - git init --bare empty && GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \ - git -c init.defaultBranch=up clone empty whats-up && - test refs/heads/up = $(git -C whats-up symbolic-ref HEAD) && - test refs/heads/up = $(git -C whats-up config branch.up.merge) + git -c init.defaultBranch=foo init --bare empty && + test_config -C empty lsrefs.unborn advertise && + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \ + git -c init.defaultBranch=up -c protocol.version=2 clone empty whats-up && + test refs/heads/foo = $(git -C whats-up symbolic-ref HEAD) && + test refs/heads/foo = $(git -C whats-up config branch.foo.merge) ' test_expect_success 'guesses initial branch name correctly' ' diff --git a/t/t5607-clone-bundle.sh b/t/t5607-clone-bundle.sh index 26985f4b44..f4c383cd5c 100755 --- a/t/t5607-clone-bundle.sh +++ b/t/t5607-clone-bundle.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='some bundle related tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -19,7 +22,7 @@ test_expect_success 'setup' ' ' test_expect_success '"verify" needs a worktree' ' - git bundle create tip.bundle -1 master && + git bundle create tip.bundle -1 main && nongit test_must_fail git bundle verify ../tip.bundle 2>err && test_i18ngrep "need a repository" err ' @@ -38,16 +41,16 @@ test_expect_success 'die if bundle file cannot be created' ' test_must_fail git bundle create adir --all ' -test_expect_failure 'bundle --stdin' ' - echo master | git bundle create stdin-bundle.bdl --stdin && +test_expect_success 'bundle --stdin' ' + echo main | git bundle create stdin-bundle.bdl --stdin && git ls-remote stdin-bundle.bdl >output && - grep master output + grep main output ' -test_expect_failure 'bundle --stdin <rev-list options>' ' - echo master | git bundle create hybrid-bundle.bdl --stdin tag && +test_expect_success 'bundle --stdin <rev-list options>' ' + echo main | git bundle create hybrid-bundle.bdl --stdin tag && git ls-remote hybrid-bundle.bdl >output && - grep master output + grep main output ' test_expect_success 'empty bundle file is rejected' ' @@ -83,14 +86,14 @@ test_expect_success 'prerequisites with an empty commit message' ' test_expect_success 'failed bundle creation does not leave cruft' ' # This fails because the bundle would be empty. - test_must_fail git bundle create fail.bundle master..master && + test_must_fail git bundle create fail.bundle main..main && test_path_is_missing fail.bundle.lock ' test_expect_success 'fetch SHA-1 from bundle' ' test_create_repo foo && test_commit -C foo x && - git -C foo bundle create tip.bundle -1 master && + git -C foo bundle create tip.bundle -1 main && git -C foo rev-parse HEAD >hash && # Exercise to ensure that fetching a SHA-1 from a bundle works with no diff --git a/t/t5608-clone-2gb.sh b/t/t5608-clone-2gb.sh index 4c476d2fa1..87a8cd9f98 100755 --- a/t/t5608-clone-2gb.sh +++ b/t/t5608-clone-2gb.sh @@ -26,7 +26,7 @@ test_expect_success 'setup' ' i=$(($i+1)) || echo $? > exit-status done && - echo "commit refs/heads/master" && + echo "commit refs/heads/main" && echo "author A U Thor <author@email.com> 123456789 +0000" && echo "committer C O Mitter <committer@email.com> 123456789 +0000" && echo "data 5" && diff --git a/t/t5609-clone-branch.sh b/t/t5609-clone-branch.sh index 6e7a7be052..f86a674a03 100755 --- a/t/t5609-clone-branch.sh +++ b/t/t5609-clone-branch.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='clone --branch option' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh check_HEAD() { @@ -20,7 +23,7 @@ test_expect_success 'setup' ' echo one >file && git add file && git commit -m one && git checkout -b two && echo two >file && git add file && git commit -m two && - git checkout master) && + git checkout main) && mkdir empty && (cd empty && git init) ' @@ -28,7 +31,7 @@ test_expect_success 'setup' ' test_expect_success 'vanilla clone chooses HEAD' ' git clone parent clone && (cd clone && - check_HEAD master && + check_HEAD main && check_file one ) ' @@ -53,7 +56,7 @@ test_expect_success 'clone -b sets up tracking' ' test_expect_success 'clone -b does not munge remotes/origin/HEAD' ' (cd clone-two && - echo refs/remotes/origin/master >expect && + echo refs/remotes/origin/main >expect && git symbolic-ref refs/remotes/origin/HEAD >actual && test_cmp expect actual ) diff --git a/t/t5610-clone-detached.sh b/t/t5610-clone-detached.sh index 8b0d607df1..a7ec21eda5 100755 --- a/t/t5610-clone-detached.sh +++ b/t/t5610-clone-detached.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='test cloning a repository with detached HEAD' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh head_is_detached() { @@ -20,7 +23,7 @@ test_expect_success 'setup' ' ' test_expect_success 'clone repo (detached HEAD points to branch)' ' - git checkout master^0 && + git checkout main^0 && git clone "file://$PWD" detached-branch ' test_expect_success 'cloned HEAD matches' ' @@ -59,7 +62,7 @@ test_expect_success 'cloned HEAD is detached' ' ' test_expect_success 'clone repo (orphan detached HEAD)' ' - git checkout master^0 && + git checkout main^0 && echo four >file && git commit -a -m four && git clone "file://$PWD" detached-orphan diff --git a/t/t5611-clone-config.sh b/t/t5611-clone-config.sh index 8e0fd39823..f8625f9158 100755 --- a/t/t5611-clone-config.sh +++ b/t/t5611-clone-config.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='tests for git clone -c key=value' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'clone -c sets config in cloned repo' ' @@ -47,16 +50,16 @@ test_expect_success 'clone -c config is available during clone' ' test_expect_success 'clone -c remote.origin.fetch=<refspec> works' ' rm -rf child && - git update-ref refs/grab/it refs/heads/master && - git update-ref refs/leave/out refs/heads/master && + git update-ref refs/grab/it refs/heads/main && + git update-ref refs/leave/out refs/heads/main && git clone -c "remote.origin.fetch=+refs/grab/*:refs/grab/*" . child && git -C child for-each-ref --format="%(refname)" >actual && cat >expect <<-\EOF && refs/grab/it - refs/heads/master + refs/heads/main refs/remotes/origin/HEAD - refs/remotes/origin/master + refs/remotes/origin/main EOF test_cmp expect actual ' @@ -68,9 +71,9 @@ test_expect_success 'git -c remote.origin.fetch=<refspec> clone works' ' cat >expect <<-\EOF && refs/grab/it - refs/heads/master + refs/heads/main refs/remotes/origin/HEAD - refs/remotes/origin/master + refs/remotes/origin/main EOF test_cmp expect actual ' @@ -85,13 +88,38 @@ test_expect_success 'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' ' cat >expect <<-\EOF && refs/grab/it - refs/heads/master + refs/heads/main refs/remotes/upstream/HEAD - refs/remotes/upstream/master + refs/remotes/upstream/main EOF test_cmp expect actual ' +test_expect_success 'set up shallow repository' ' + git clone --depth=1 --no-local . shallow-repo +' + +test_expect_success 'clone.rejectshallow=true should reject cloning shallow repo' ' + test_when_finished "rm -rf out" && + test_must_fail git -c clone.rejectshallow=true clone --no-local shallow-repo out 2>err && + test_i18ngrep -e "source repository is shallow, reject to clone." err && + + git -c clone.rejectshallow=false clone --no-local shallow-repo out +' + +test_expect_success 'option --[no-]reject-shallow override clone.rejectshallow config' ' + test_when_finished "rm -rf out" && + test_must_fail git -c clone.rejectshallow=false clone --reject-shallow --no-local shallow-repo out 2>err && + test_i18ngrep -e "source repository is shallow, reject to clone." err && + + git -c clone.rejectshallow=true clone --no-reject-shallow --no-local shallow-repo out +' + +test_expect_success 'clone.rejectshallow=true should succeed cloning normal repo' ' + test_when_finished "rm -rf out" && + git -c clone.rejectshallow=true clone --no-local . out +' + test_expect_success MINGW 'clone -c core.hideDotFiles' ' test_commit attributes .gitattributes "" && rm -rf child && diff --git a/t/t5612-clone-refspec.sh b/t/t5612-clone-refspec.sh index e3b436d8ae..3126cfd7e9 100755 --- a/t/t5612-clone-refspec.sh +++ b/t/t5612-clone-refspec.sh @@ -1,10 +1,13 @@ #!/bin/sh test_description='test refspec written by clone-command' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' - # Make two branches, "master" and "side" + # Make two branches, "main" and "side" echo one >file && git add file && git commit -m one && @@ -16,7 +19,7 @@ test_expect_success 'setup' ' git checkout -b side && echo four >file && git commit -a -m four && - git checkout master && + git checkout main && git tag five && # default clone @@ -25,18 +28,18 @@ test_expect_success 'setup' ' # default clone --no-tags git clone --no-tags . dir_all_no_tags && - # default --single that follows HEAD=master - git clone --single-branch . dir_master && + # default --single that follows HEAD=main + git clone --single-branch . dir_main && - # default --single that follows HEAD=master with no tags - git clone --single-branch --no-tags . dir_master_no_tags && + # default --single that follows HEAD=main with no tags + git clone --single-branch --no-tags . dir_main_no_tags && # default --single that follows HEAD=side git checkout side && git clone --single-branch . dir_side && # explicit --single that follows side - git checkout master && + git checkout main && git clone --single-branch --branch side . dir_side2 && # default --single with --mirror @@ -55,11 +58,11 @@ test_expect_success 'setup' ' # explicit --single with tag and --no-tags git clone --single-branch --no-tags --branch two . dir_tag_no_tags && - # advance both "master" and "side" branches + # advance both "main" and "side" branches git checkout side && echo five >file && git commit -a -m five && - git checkout master && + git checkout main && echo six >file && git commit -a -m six && @@ -75,7 +78,7 @@ test_expect_success 'by default all branches will be kept updated' ' sed -e "/HEAD$/d" \ -e "s|/remotes/origin/|/heads/|" refs >../actual ) && - # follow both master and side + # follow both main and side git for-each-ref refs/heads >expect && test_cmp expect actual ' @@ -94,26 +97,27 @@ test_expect_success 'by default no tags will be kept updated' ' test_expect_success 'clone with --no-tags' ' ( cd dir_all_no_tags && + grep tagOpt .git/config && git fetch && git for-each-ref refs/tags >../actual ) && test_must_be_empty actual ' -test_expect_success '--single-branch while HEAD pointing at master' ' +test_expect_success '--single-branch while HEAD pointing at main' ' ( - cd dir_master && + cd dir_main && git fetch --force && git for-each-ref refs/remotes/origin >refs && sed -e "/HEAD$/d" \ -e "s|/remotes/origin/|/heads/|" refs >../actual ) && - # only follow master - git for-each-ref refs/heads/master >expect && + # only follow main + git for-each-ref refs/heads/main >expect && # get & check latest tags test_cmp expect actual && ( - cd dir_master && + cd dir_main && git fetch --tags --force && git for-each-ref refs/tags >../actual ) && @@ -122,20 +126,20 @@ test_expect_success '--single-branch while HEAD pointing at master' ' test_line_count = 2 actual ' -test_expect_success '--single-branch while HEAD pointing at master and --no-tags' ' +test_expect_success '--single-branch while HEAD pointing at main and --no-tags' ' ( - cd dir_master_no_tags && + cd dir_main_no_tags && git fetch && git for-each-ref refs/remotes/origin >refs && sed -e "/HEAD$/d" \ -e "s|/remotes/origin/|/heads/|" refs >../actual ) && - # only follow master - git for-each-ref refs/heads/master >expect && + # only follow main + git for-each-ref refs/heads/main >expect && test_cmp expect actual && # get tags (noop) ( - cd dir_master_no_tags && + cd dir_main_no_tags && git fetch && git for-each-ref refs/tags >../actual ) && @@ -143,7 +147,7 @@ test_expect_success '--single-branch while HEAD pointing at master and --no-tags test_line_count = 0 actual && # get tags with --tags overrides tagOpt ( - cd dir_master_no_tags && + cd dir_main_no_tags && git fetch --tags && git for-each-ref refs/tags >../actual ) && diff --git a/t/t5614-clone-submodules-shallow.sh b/t/t5614-clone-submodules-shallow.sh index e4e6ea4d52..5504b519c7 100755 --- a/t/t5614-clone-submodules-shallow.sh +++ b/t/t5614-clone-submodules-shallow.sh @@ -7,7 +7,7 @@ test_description='Test shallow cloning of repos with submodules' pwd=$(pwd) test_expect_success 'setup' ' - git checkout -b master && + git checkout -b main && test_commit commit1 && test_commit commit2 && mkdir sub && diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh index d98c550267..cf3e82bdf5 100755 --- a/t/t5616-partial-clone.sh +++ b/t/t5616-partial-clone.sh @@ -2,6 +2,9 @@ test_description='git partial clone' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # create a normal "src" repo where we can later create new commits. @@ -51,14 +54,14 @@ test_expect_success 'verify that .promisor file contains refs fetched' ' test_line_count = 1 promisorlist && git -C srv.bare rev-parse --verify HEAD >headhash && grep "$(cat headhash) HEAD" $(cat promisorlist) && - grep "$(cat headhash) refs/heads/master" $(cat promisorlist) + grep "$(cat headhash) refs/heads/main" $(cat promisorlist) ' -# checkout master to force dynamic object fetch of blobs at HEAD. +# checkout main to force dynamic object fetch of blobs at HEAD. test_expect_success 'verify checkout with dynamic object fetch' ' git -C pc1 rev-list --quiet --objects --missing=print HEAD >observed && test_line_count = 4 observed && - git -C pc1 checkout master && + git -C pc1 checkout main && git -C pc1 rev-list --quiet --objects --missing=print HEAD >observed && test_line_count = 0 observed ' @@ -73,8 +76,8 @@ test_expect_success 'push new commits to server' ' git -C src add file.1.txt git -C src commit -m "mod $x" done && - git -C src blame master -- file.1.txt >expect.blame && - git -C src push -u srv master + git -C src blame main -- file.1.txt >expect.blame && + git -C src push -u srv main ' # (partial) fetch in the partial clone repo from the promisor remote. @@ -83,26 +86,26 @@ test_expect_success 'push new commits to server' ' test_expect_success 'partial fetch inherits filter settings' ' git -C pc1 fetch origin && git -C pc1 rev-list --quiet --objects --missing=print \ - master..origin/master >observed && + main..origin/main >observed && test_line_count = 5 observed ' # force dynamic object fetch using diff. -# we should only get 1 new blob (for the file in origin/master). +# we should only get 1 new blob (for the file in origin/main). test_expect_success 'verify diff causes dynamic object fetch' ' - git -C pc1 diff master..origin/master -- file.1.txt && + git -C pc1 diff main..origin/main -- file.1.txt && git -C pc1 rev-list --quiet --objects --missing=print \ - master..origin/master >observed && + main..origin/main >observed && test_line_count = 4 observed ' # force full dynamic object fetch of the file's history using blame. # we should get the intermediate blobs for the file. test_expect_success 'verify blame causes dynamic object fetch' ' - git -C pc1 blame origin/master -- file.1.txt >observed.blame && + git -C pc1 blame origin/main -- file.1.txt >observed.blame && test_cmp expect.blame observed.blame && git -C pc1 rev-list --quiet --objects --missing=print \ - master..origin/master >observed && + main..origin/main >observed && test_line_count = 0 observed ' @@ -115,7 +118,7 @@ test_expect_success 'push new commits to server for file.2.txt' ' git -C src add file.2.txt git -C src commit -m "mod $x" done && - git -C src push -u srv master + git -C src push -u srv main ' # Do FULL fetch by disabling inherited filter-spec using --no-filter. @@ -123,7 +126,7 @@ test_expect_success 'push new commits to server for file.2.txt' ' test_expect_success 'override inherited filter-spec using --no-filter' ' git -C pc1 fetch --no-filter origin && git -C pc1 rev-list --quiet --objects --missing=print \ - master..origin/master >observed && + main..origin/main >observed && test_line_count = 0 observed ' @@ -136,7 +139,7 @@ test_expect_success 'push new commits to server for file.3.txt' ' git -C src add file.3.txt git -C src commit -m "mod $x" done && - git -C src push -u srv master + git -C src push -u srv main ' # Do a partial fetch and then try to manually fetch the missing objects. @@ -146,7 +149,7 @@ test_expect_success 'manual prefetch of missing objects' ' git -C pc1 fetch --filter=blob:none origin && git -C pc1 rev-list --quiet --objects --missing=print \ - master..origin/master >revs && + main..origin/main >revs && awk -f print_1.awk revs | sed "s/?//" | sort >observed.oids && @@ -155,7 +158,7 @@ test_expect_success 'manual prefetch of missing objects' ' git -C pc1 fetch-pack --stdin "file://$(pwd)/srv.bare" <observed.oids && git -C pc1 rev-list --quiet --objects --missing=print \ - master..origin/master >revs && + main..origin/main >revs && awk -f print_1.awk revs | sed "s/?//" | sort >observed.oids && @@ -196,7 +199,7 @@ test_expect_success 'use fsck before and after manually fetching a missing subtr echo "in dir" >src/dir/file.txt && git -C src add dir/file.txt && git -C src commit -m "file in dir" && - git -C src push -u srv master && + git -C src push -u srv main && SUBTREE=$(git -C src rev-parse HEAD:dir) && rm -rf dst && @@ -204,7 +207,7 @@ test_expect_success 'use fsck before and after manually fetching a missing subtr git -C dst fsck && # Make sure we only have commits, and all trees and blobs are missing. - git -C dst rev-list --missing=allow-any --objects master \ + git -C dst rev-list --missing=allow-any --objects main \ >fetched_objects && awk -f print_1.awk fetched_objects | xargs -n1 git -C dst cat-file -t >fetched_types && @@ -221,7 +224,7 @@ test_expect_success 'use fsck before and after manually fetching a missing subtr git -C dst fsck && # Auto-fetch all remaining trees and blobs with --missing=error - git -C dst rev-list --missing=error --objects master >fetched_objects && + git -C dst rev-list --missing=error --objects main >fetched_objects && test_line_count = 70 fetched_objects && awk -f print_1.awk fetched_objects | @@ -347,7 +350,7 @@ test_expect_success 'setup src repo for sparse filter' ' test_expect_success 'partial clone with sparse filter succeeds' ' rm -rf dst.git && git clone --no-local --bare \ - --filter=sparse:oid=master:only-one \ + --filter=sparse:oid=main:only-one \ sparse-src dst.git && ( cd dst.git && @@ -360,11 +363,11 @@ test_expect_success 'partial clone with sparse filter succeeds' ' test_expect_success 'partial clone with unresolvable sparse filter fails cleanly' ' rm -rf dst.git && test_must_fail git clone --no-local --bare \ - --filter=sparse:oid=master:no-such-name \ + --filter=sparse:oid=main:no-such-name \ sparse-src dst.git 2>err && - test_i18ngrep "unable to access sparse blob in .master:no-such-name" err && + test_i18ngrep "unable to access sparse blob in .main:no-such-name" err && test_must_fail git clone --no-local --bare \ - --filter=sparse:oid=master \ + --filter=sparse:oid=main \ sparse-src dst.git 2>err && test_i18ngrep "unable to parse sparse filter data in" err ' @@ -419,7 +422,7 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas' ' # promisor remote other than for the big tree (because it needs to # resolve the delta). GIT_TRACE_PACKET="$(pwd)/trace" git -C client \ - fetch "file://$(pwd)/server" master && + fetch "file://$(pwd)/server" main && # Verify the assumption that the client needed to fetch the delta base # to resolve the delta. @@ -438,7 +441,7 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas, protocol v2' ' # promisor remote other than for the big blob (because it needs to # resolve the delta). GIT_TRACE_PACKET="$(pwd)/trace" git -C client \ - fetch "file://$(pwd)/server" master && + fetch "file://$(pwd)/server" main && # Verify that protocol version 2 was used. grep "fetch< version 2" trace && @@ -545,6 +548,14 @@ test_expect_success 'fetch from a partial clone, protocol v2' ' grep "version 2" trace ' +test_expect_success 'repack does not loosen promisor objects' ' + rm -rf client trace && + git clone --bare --filter=blob:none "file://$(pwd)/srv.bare" client && + test_when_finished "rm -rf client trace" && + GIT_TRACE2_PERF="$(pwd)/trace" git -C client repack -A -d && + grep "loosen_unused_packed_objects/loosened:0" trace +' + . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd diff --git a/t/t5617-clone-submodules-remote.sh b/t/t5617-clone-submodules-remote.sh index 1a041df10b..e2dbb4eaba 100755 --- a/t/t5617-clone-submodules-remote.sh +++ b/t/t5617-clone-submodules-remote.sh @@ -2,12 +2,15 @@ test_description='Test cloning repos with submodules using remote-tracking branches' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh pwd=$(pwd) test_expect_success 'setup' ' - git checkout -b master && + git checkout -b main && test_commit commit1 && mkdir sub && ( @@ -39,7 +42,7 @@ test_expect_success 'clone with --remote-submodules' ' git clone --recurse-submodules --remote-submodules "file://$pwd/." super_clone && ( cd super_clone/sub && - git diff --exit-code remotes/origin/master + git diff --exit-code remotes/origin/main ) ' @@ -57,7 +60,7 @@ test_expect_success 'clone with --single-branch' ' git clone --recurse-submodules --single-branch "file://$pwd/." super_clone && ( cd super_clone/sub && - git rev-parse --verify origin/master && + git rev-parse --verify origin/main && test_must_fail git rev-parse --verify origin/other ) ' diff --git a/t/t5700-protocol-v1.sh b/t/t5700-protocol-v1.sh index 022901b9eb..468bd3e13e 100755 --- a/t/t5700-protocol-v1.sh +++ b/t/t5700-protocol-v1.sh @@ -8,6 +8,9 @@ TEST_NO_CREATE_REPO=1 GIT_TEST_PROTOCOL_VERSION=0 export GIT_TEST_PROTOCOL_VERSION +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # Test protocol v1 with 'git://' transport @@ -41,7 +44,7 @@ test_expect_success 'fetch with git:// using protocol v1' ' GIT_TRACE_PACKET=1 git -C daemon_child -c protocol.version=1 \ fetch 2>log && - git -C daemon_child log -1 --format=%s origin/master >actual && + git -C daemon_child log -1 --format=%s origin/main >actual && git -C "$daemon_parent" log -1 --format=%s >expect && test_cmp expect actual && @@ -69,7 +72,7 @@ test_expect_success 'push with git:// using protocol v1' ' test_commit -C daemon_child three && # Push to another branch, as the target repository has the - # master branch checked out and we cannot push into it. + # main branch checked out and we cannot push into it. GIT_TRACE_PACKET=1 git -C daemon_child -c protocol.version=1 \ push origin HEAD:client_branch 2>log && @@ -110,7 +113,7 @@ test_expect_success 'fetch with file:// using protocol v1' ' GIT_TRACE_PACKET=1 git -C file_child -c protocol.version=1 \ fetch 2>log && - git -C file_child log -1 --format=%s origin/master >actual && + git -C file_child log -1 --format=%s origin/main >actual && git -C file_parent log -1 --format=%s >expect && test_cmp expect actual && @@ -134,7 +137,7 @@ test_expect_success 'push with file:// using protocol v1' ' test_commit -C file_child three && # Push to another branch, as the target repository has the - # master branch checked out and we cannot push into it. + # main branch checked out and we cannot push into it. GIT_TRACE_PACKET=1 git -C file_child -c protocol.version=1 \ push origin HEAD:client_branch 2>log && @@ -188,7 +191,7 @@ test_expect_success 'fetch with ssh:// using protocol v1' ' fetch 2>log && expect_ssh git-upload-pack && - git -C ssh_child log -1 --format=%s origin/master >actual && + git -C ssh_child log -1 --format=%s origin/main >actual && git -C ssh_parent log -1 --format=%s >expect && test_cmp expect actual && @@ -213,7 +216,7 @@ test_expect_success 'push with ssh:// using protocol v1' ' test_commit -C ssh_child three && # Push to another branch, as the target repository has the - # master branch checked out and we cannot push into it. + # main branch checked out and we cannot push into it. GIT_TRACE_PACKET=1 git -C ssh_child -c protocol.version=1 \ push origin HEAD:client_branch 2>log && expect_ssh git-receive-pack && @@ -257,7 +260,7 @@ test_expect_success 'fetch with http:// using protocol v1' ' GIT_TRACE_PACKET=1 git -C http_child -c protocol.version=1 \ fetch 2>log && - git -C http_child log -1 --format=%s origin/master >actual && + git -C http_child log -1 --format=%s origin/main >actual && git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect && test_cmp expect actual && @@ -281,7 +284,7 @@ test_expect_success 'push with http:// using protocol v1' ' test_commit -C http_child three && # Push to another branch, as the target repository has the - # master branch checked out and we cannot push into it. + # main branch checked out and we cannot push into it. GIT_TRACE_PACKET=1 git -C http_child -c protocol.version=1 \ push origin HEAD:client_branch && #2>log && diff --git a/t/t5701-git-serve.sh b/t/t5701-git-serve.sh index a1f5fdc9fd..930721f053 100755 --- a/t/t5701-git-serve.sh +++ b/t/t5701-git-serve.sh @@ -2,6 +2,9 @@ test_description='test protocol v2 server commands' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'test capability advertisement' ' @@ -12,10 +15,11 @@ test_expect_success 'test capability advertisement' ' cat >expect <<-EOF && version 2 agent=git/$(git version | cut -d" " -f3) - ls-refs - fetch=shallow + ls-refs=unborn + fetch=shallow wait-for-done server-option object-format=$(test_oid algo) + object-info 0000 EOF @@ -83,9 +87,9 @@ test_expect_success 'wrong object-format' ' # test_expect_success 'setup some refs and tags' ' test_commit one && - git branch dev master && + git branch dev main && test_commit two && - git symbolic-ref refs/heads/release refs/heads/master && + git symbolic-ref refs/heads/release refs/heads/main && git tag -a -m "annotated tag" annotated-tag ' @@ -99,7 +103,7 @@ test_expect_success 'basics of ls-refs' ' cat >expect <<-EOF && $(git rev-parse HEAD) HEAD $(git rev-parse refs/heads/dev) refs/heads/dev - $(git rev-parse refs/heads/master) refs/heads/master + $(git rev-parse refs/heads/main) refs/heads/main $(git rev-parse refs/heads/release) refs/heads/release $(git rev-parse refs/tags/annotated-tag) refs/tags/annotated-tag $(git rev-parse refs/tags/one) refs/tags/one @@ -117,13 +121,13 @@ test_expect_success 'basic ref-prefixes' ' command=ls-refs object-format=$(test_oid algo) 0001 - ref-prefix refs/heads/master + ref-prefix refs/heads/main ref-prefix refs/tags/one 0000 EOF cat >expect <<-EOF && - $(git rev-parse refs/heads/master) refs/heads/master + $(git rev-parse refs/heads/main) refs/heads/main $(git rev-parse refs/tags/one) refs/tags/one 0000 EOF @@ -144,7 +148,7 @@ test_expect_success 'refs/heads prefix' ' cat >expect <<-EOF && $(git rev-parse refs/heads/dev) refs/heads/dev - $(git rev-parse refs/heads/master) refs/heads/master + $(git rev-parse refs/heads/main) refs/heads/main $(git rev-parse refs/heads/release) refs/heads/release 0000 EOF @@ -188,8 +192,8 @@ test_expect_success 'symrefs parameter' ' cat >expect <<-EOF && $(git rev-parse refs/heads/dev) refs/heads/dev - $(git rev-parse refs/heads/master) refs/heads/master - $(git rev-parse refs/heads/release) refs/heads/release symref-target:refs/heads/master + $(git rev-parse refs/heads/main) refs/heads/main + $(git rev-parse refs/heads/release) refs/heads/release symref-target:refs/heads/main 0000 EOF @@ -237,4 +241,29 @@ test_expect_success 'unexpected lines are not allowed in fetch request' ' grep "unexpected line: .this-is-not-a-command." err ' +# Test the basics of object-info +# +test_expect_success 'basics of object-info' ' + test-tool pkt-line pack >in <<-EOF && + command=object-info + object-format=$(test_oid algo) + 0001 + size + oid $(git rev-parse two:two.t) + oid $(git rev-parse two:two.t) + 0000 + EOF + + cat >expect <<-EOF && + size + $(git rev-parse two:two.t) $(wc -c <two.t | xargs) + $(git rev-parse two:two.t) $(wc -c <two.t | xargs) + 0000 + EOF + + test-tool serve-v2 --stateless-rpc <in >out && + test-tool pkt-line unpack <out >actual && + test_cmp expect actual +' + test_done diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 7d5b17909b..66af411057 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -4,6 +4,9 @@ test_description='test git wire-protocol version 2' TEST_NO_CREATE_REPO=1 +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # Test protocol v2 with 'git://' transport @@ -36,10 +39,10 @@ test_expect_success 'ref advertisement is filtered with ls-remote using protocol test_when_finished "rm -f log" && GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \ - ls-remote "$GIT_DAEMON_URL/parent" master >actual && + ls-remote "$GIT_DAEMON_URL/parent" main >actual && cat >expect <<-EOF && - $(git -C "$daemon_parent" rev-parse refs/heads/master)$(printf "\t")refs/heads/master + $(git -C "$daemon_parent" rev-parse refs/heads/main)$(printf "\t")refs/heads/main EOF test_cmp expect actual @@ -69,7 +72,7 @@ test_expect_success 'fetch with git:// using protocol v2' ' GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \ fetch && - git -C daemon_child log -1 --format=%s origin/master >actual && + git -C daemon_child log -1 --format=%s origin/main >actual && git -C "$daemon_parent" log -1 --format=%s >expect && test_cmp expect actual && @@ -118,7 +121,7 @@ test_expect_success 'push with git:// and a config of v2 does not request v2' ' test_commit -C daemon_child three && # Push to another branch, as the target repository has the - # master branch checked out and we cannot push into it. + # main branch checked out and we cannot push into it. GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \ push origin HEAD:client_branch && @@ -158,10 +161,10 @@ test_expect_success 'ref advertisement is filtered with ls-remote using protocol test_when_finished "rm -f log" && GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \ - ls-remote "file://$(pwd)/file_parent" master >actual && + ls-remote "file://$(pwd)/file_parent" main >actual && cat >expect <<-EOF && - $(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master + $(git -C file_parent rev-parse refs/heads/main)$(printf "\t")refs/heads/main EOF test_cmp expect actual @@ -171,10 +174,10 @@ test_expect_success 'server-options are sent when using ls-remote' ' test_when_finished "rm -f log" && GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \ - ls-remote -o hello -o world "file://$(pwd)/file_parent" master >actual && + ls-remote -o hello -o world "file://$(pwd)/file_parent" main >actual && cat >expect <<-EOF && - $(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master + $(git -C file_parent rev-parse refs/heads/main)$(printf "\t")refs/heads/main EOF test_cmp expect actual && @@ -184,7 +187,7 @@ test_expect_success 'server-options are sent when using ls-remote' ' test_expect_success 'warn if using server-option with ls-remote with legacy protocol' ' test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -c protocol.version=0 \ - ls-remote -o hello -o world "file://$(pwd)/file_parent" master 2>err && + ls-remote -o hello -o world "file://$(pwd)/file_parent" main 2>err && test_i18ngrep "see protocol.version in" err && test_i18ngrep "server options require protocol version 2 or later" err @@ -209,6 +212,31 @@ test_expect_success 'clone with file:// using protocol v2' ' grep "ref-prefix refs/tags/" log ' +test_expect_success 'clone of empty repo propagates name of default branch' ' + test_when_finished "rm -rf file_empty_parent file_empty_child" && + + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \ + git -c init.defaultBranch=mydefaultbranch init file_empty_parent && + + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \ + git -c init.defaultBranch=main -c protocol.version=2 \ + clone "file://$(pwd)/file_empty_parent" file_empty_child && + grep "refs/heads/mydefaultbranch" file_empty_child/.git/HEAD +' + +test_expect_success '...but not if explicitly forbidden by config' ' + test_when_finished "rm -rf file_empty_parent file_empty_child" && + + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \ + git -c init.defaultBranch=mydefaultbranch init file_empty_parent && + test_config -C file_empty_parent lsrefs.unborn ignore && + + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \ + git -c init.defaultBranch=main -c protocol.version=2 \ + clone "file://$(pwd)/file_empty_parent" file_empty_child && + ! grep "refs/heads/mydefaultbranch" file_empty_child/.git/HEAD +' + test_expect_success 'fetch with file:// using protocol v2' ' test_when_finished "rm -f log" && @@ -217,7 +245,7 @@ test_expect_success 'fetch with file:// using protocol v2' ' GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \ fetch origin && - git -C file_child log -1 --format=%s origin/master >actual && + git -C file_child log -1 --format=%s origin/main >actual && git -C file_parent log -1 --format=%s >expect && test_cmp expect actual && @@ -232,13 +260,13 @@ test_expect_success 'ref advertisement is filtered during fetch using protocol v git -C file_parent branch unwanted-branch three && GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \ - fetch origin master && + fetch origin main && - git -C file_child log -1 --format=%s origin/master >actual && + git -C file_child log -1 --format=%s origin/main >actual && git -C file_parent log -1 --format=%s >expect && test_cmp expect actual && - grep "refs/heads/master" log && + grep "refs/heads/main" log && ! grep "refs/heads/unwanted-branch" log ' @@ -248,9 +276,9 @@ test_expect_success 'server-options are sent when fetching' ' test_commit -C file_parent four && GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \ - fetch -o hello -o world origin master && + fetch -o hello -o world origin main && - git -C file_child log -1 --format=%s origin/master >actual && + git -C file_child log -1 --format=%s origin/main >actual && git -C file_parent log -1 --format=%s >expect && test_cmp expect actual && @@ -264,7 +292,7 @@ test_expect_success 'warn if using server-option with fetch with legacy protocol git init temp_child && test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -C temp_child -c protocol.version=0 \ - fetch -o hello -o world "file://$(pwd)/file_parent" master 2>err && + fetch -o hello -o world "file://$(pwd)/file_parent" main 2>err && test_i18ngrep "see protocol.version in" err && test_i18ngrep "server options require protocol version 2 or later" err @@ -325,7 +353,7 @@ test_expect_success 'partial clone' ' grep "version 2" trace && # Ensure that the old version of the file is missing - git -C client rev-list --quiet --objects --missing=print master \ + git -C client rev-list --quiet --objects --missing=print main \ >observed.oids && grep "$(git -C server rev-parse message1:a.txt)" observed.oids && @@ -350,7 +378,7 @@ test_expect_success 'partial fetch' ' SERVER="file://$(pwd)/server" && GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \ - fetch --filter=blob:none "$SERVER" master:refs/heads/other && + fetch --filter=blob:none "$SERVER" main:refs/heads/other && grep "version 2" trace && # Ensure that the old version of the file is missing @@ -395,7 +423,7 @@ test_expect_success 'even with handcrafted request, filter does not work if not command=fetch object-format=$(test_oid algo) 0001 - want $(git -C server rev-parse master) + want $(git -C server rev-parse main) filter blob:none 0000 EOF @@ -539,7 +567,7 @@ test_expect_success 'deepen-relative' ' test_commit -C server four && # Sanity check that only "three" is downloaded - git -C client log --pretty=tformat:%s master >actual && + git -C client log --pretty=tformat:%s main >actual && echo three >expected && test_cmp expected actual && @@ -548,7 +576,7 @@ test_expect_success 'deepen-relative' ' # Ensure that protocol v2 is used grep "fetch< version 2" trace && - git -C client log --pretty=tformat:%s origin/master >actual && + git -C client log --pretty=tformat:%s origin/main >actual && cat >expected <<-\EOF && four three @@ -557,6 +585,49 @@ test_expect_success 'deepen-relative' ' test_cmp expected actual ' +setup_negotiate_only () { + SERVER="$1" + URI="$2" + + rm -rf "$SERVER" client + + git init "$SERVER" + test_commit -C "$SERVER" one + test_commit -C "$SERVER" two + + git clone "$URI" client + test_commit -C client three +} + +test_expect_success 'file:// --negotiate-only' ' + SERVER="server" && + URI="file://$(pwd)/server" && + + setup_negotiate_only "$SERVER" "$URI" && + + git -c protocol.version=2 -C client fetch \ + --no-tags \ + --negotiate-only \ + --negotiation-tip=$(git -C client rev-parse HEAD) \ + origin >out && + COMMON=$(git -C "$SERVER" rev-parse two) && + grep "$COMMON" out +' + +test_expect_success 'file:// --negotiate-only with protocol v0' ' + SERVER="server" && + URI="file://$(pwd)/server" && + + setup_negotiate_only "$SERVER" "$URI" && + + test_must_fail git -c protocol.version=0 -C client fetch \ + --no-tags \ + --negotiate-only \ + --negotiation-tip=$(git -C client rev-parse HEAD) \ + origin 2>err && + test_i18ngrep "negotiate-only requires protocol v2" err +' + # Test protocol v2 with 'http://' transport # . "$TEST_DIRECTORY"/lib-httpd.sh @@ -670,7 +741,7 @@ test_expect_success 'fetch with http:// using protocol v2' ' GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \ fetch && - git -C http_child log -1 --format=%s origin/master >actual && + git -C http_child log -1 --format=%s origin/main >actual && git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect && test_cmp expect actual && @@ -698,11 +769,11 @@ test_expect_success 'fetch from namespaced repo respects namespaces' ' test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" one && test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" two && git -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" \ - update-ref refs/namespaces/ns/refs/heads/master one && + update-ref refs/namespaces/ns/refs/heads/main one && GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \ fetch "$HTTPD_URL/smart_namespace/nsrepo" \ - refs/heads/master:refs/heads/theirs && + refs/heads/main:refs/heads/theirs && # Server responded using protocol v2 grep "fetch< version 2" log && @@ -733,7 +804,7 @@ test_expect_success 'push with http:// and a config of v2 does not request v2' ' test_commit -C http_child three && # Push to another branch, as the target repository has the - # master branch checked out and we cannot push into it. + # main branch checked out and we cannot push into it. GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \ push origin HEAD:client_branch && @@ -847,11 +918,33 @@ test_expect_success 'part of packfile response provided as URI' ' test -f hfound && test -f h2found && - # Ensure that there are exactly 6 files (3 .pack and 3 .idx). - ls http_child/.git/objects/pack/* >filelist && + # Ensure that there are exactly 3 packfiles with associated .idx + ls http_child/.git/objects/pack/*.pack \ + http_child/.git/objects/pack/*.idx >filelist && test_line_count = 6 filelist ' +test_expect_success 'packfile URIs with fetch instead of clone' ' + P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && + rm -rf "$P" http_child log && + + git init "$P" && + git -C "$P" config "uploadpack.allowsidebandall" "true" && + + echo my-blob >"$P/my-blob" && + git -C "$P" add my-blob && + git -C "$P" commit -m x && + + configure_exclusion "$P" my-blob >h && + + git init http_child && + + GIT_TEST_SIDEBAND_ALL=1 \ + git -C http_child -c protocol.version=2 \ + -c fetch.uriprotocols=http,https \ + fetch "$HTTPD_URL/smart/http_parent" +' + test_expect_success 'fetching with valid packfile URI but invalid hash fails' ' P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && rm -rf "$P" http_child log && @@ -901,8 +994,9 @@ test_expect_success 'packfile-uri with transfer.fsckobjects' ' -c fetch.uriprotocols=http,https \ clone "$HTTPD_URL/smart/http_parent" http_child && - # Ensure that there are exactly 4 files (2 .pack and 2 .idx). - ls http_child/.git/objects/pack/* >filelist && + # Ensure that there are exactly 2 packfiles with associated .idx + ls http_child/.git/objects/pack/*.pack \ + http_child/.git/objects/pack/*.idx >filelist && test_line_count = 4 filelist ' @@ -936,6 +1030,100 @@ test_expect_success 'packfile-uri with transfer.fsckobjects fails on bad object' test_i18ngrep "invalid author/committer line - missing email" error ' +test_expect_success 'packfile-uri with transfer.fsckobjects succeeds when .gitmodules is separate from tree' ' + P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && + rm -rf "$P" http_child && + + git init "$P" && + git -C "$P" config "uploadpack.allowsidebandall" "true" && + + echo "[submodule libfoo]" >"$P/.gitmodules" && + echo "path = include/foo" >>"$P/.gitmodules" && + echo "url = git://example.com/git/lib.git" >>"$P/.gitmodules" && + git -C "$P" add .gitmodules && + git -C "$P" commit -m x && + + configure_exclusion "$P" .gitmodules >h && + + sane_unset GIT_TEST_SIDEBAND_ALL && + git -c protocol.version=2 -c transfer.fsckobjects=1 \ + -c fetch.uriprotocols=http,https \ + clone "$HTTPD_URL/smart/http_parent" http_child && + + # Ensure that there are exactly 2 packfiles with associated .idx + ls http_child/.git/objects/pack/*.pack \ + http_child/.git/objects/pack/*.idx >filelist && + test_line_count = 4 filelist +' + +test_expect_success 'packfile-uri with transfer.fsckobjects fails when .gitmodules separate from tree is invalid' ' + P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && + rm -rf "$P" http_child err && + + git init "$P" && + git -C "$P" config "uploadpack.allowsidebandall" "true" && + + echo "[submodule \"..\"]" >"$P/.gitmodules" && + echo "path = include/foo" >>"$P/.gitmodules" && + echo "url = git://example.com/git/lib.git" >>"$P/.gitmodules" && + git -C "$P" add .gitmodules && + git -C "$P" commit -m x && + + configure_exclusion "$P" .gitmodules >h && + + sane_unset GIT_TEST_SIDEBAND_ALL && + test_must_fail git -c protocol.version=2 -c transfer.fsckobjects=1 \ + -c fetch.uriprotocols=http,https \ + clone "$HTTPD_URL/smart/http_parent" http_child 2>err && + test_i18ngrep "disallowed submodule name" err +' + +test_expect_success 'http:// --negotiate-only' ' + SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" && + URI="$HTTPD_URL/smart/server" && + + setup_negotiate_only "$SERVER" "$URI" && + + git -c protocol.version=2 -C client fetch \ + --no-tags \ + --negotiate-only \ + --negotiation-tip=$(git -C client rev-parse HEAD) \ + origin >out && + COMMON=$(git -C "$SERVER" rev-parse two) && + grep "$COMMON" out +' + +test_expect_success 'http:// --negotiate-only without wait-for-done support' ' + SERVER="server" && + URI="$HTTPD_URL/one_time_perl/server" && + + setup_negotiate_only "$SERVER" "$URI" && + + echo "s/ wait-for-done/ xxxx-xxx-xxxx/" \ + >"$HTTPD_ROOT_PATH/one-time-perl" && + + test_must_fail git -c protocol.version=2 -C client fetch \ + --no-tags \ + --negotiate-only \ + --negotiation-tip=$(git -C client rev-parse HEAD) \ + origin 2>err && + test_i18ngrep "server does not support wait-for-done" err +' + +test_expect_success 'http:// --negotiate-only with protocol v0' ' + SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" && + URI="$HTTPD_URL/smart/server" && + + setup_negotiate_only "$SERVER" "$URI" && + + test_must_fail git -c protocol.version=0 -C client fetch \ + --no-tags \ + --negotiate-only \ + --negotiation-tip=$(git -C client rev-parse HEAD) \ + origin 2>err && + test_i18ngrep "negotiate-only requires protocol v2" err +' + # 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. diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh index eab966985b..e9e471621d 100755 --- a/t/t5703-upload-pack-ref-in-want.sh +++ b/t/t5703-upload-pack-ref-in-want.sh @@ -2,6 +2,9 @@ test_description='upload-pack ref-in-want' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh get_actual_refs () { @@ -16,7 +19,8 @@ get_actual_commits () { test-tool pkt-line unpack-sideband <out >o.pack && git index-pack o.pack && git verify-pack -v o.idx >objs && - grep commit objs | cut -d" " -f1 | sort >actual_commits + sed -n -e 's/\([0-9a-f][0-9a-f]*\) commit .*/\1/p' objs >objs.sed && + sort >actual_commits <objs.sed } check_output () { diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh index 0f04b6cddb..d386076dbd 100755 --- a/t/t5801-remote-helpers.sh +++ b/t/t5801-remote-helpers.sh @@ -5,6 +5,9 @@ test_description='Test remote-helper import and export commands' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-gpg.sh @@ -71,18 +74,18 @@ test_expect_success 'fetch multiple branches' ' (cd local && git fetch ) && - compare_refs server master local refs/remotes/origin/master && + compare_refs server main local refs/remotes/origin/main && compare_refs server new local refs/remotes/origin/new ' test_expect_success 'push when remote has extra refs' ' (cd local && - git reset --hard origin/master && + git reset --hard origin/main && echo content >>file && git commit -a -m six && git push ) && - compare_refs local master server master + compare_refs local main server main ' test_expect_success 'push new branch by name' ' @@ -174,7 +177,7 @@ test_expect_failure 'pushing without marks' ' test_expect_success 'push all with existing object' ' (cd local && - git branch dup2 master && + git branch dup2 main && git push origin --all ) && compare_refs local dup2 server dup2 @@ -182,7 +185,7 @@ test_expect_success 'push all with existing object' ' test_expect_success 'push ref with existing object' ' (cd local && - git branch dup master && + git branch dup main && git push origin dup ) && compare_refs local dup server dup @@ -190,7 +193,7 @@ test_expect_success 'push ref with existing object' ' test_expect_success GPG 'push signed tag' ' (cd local && - git checkout master && + git checkout main && git tag -s -m signed-tag signed-tag && git push origin signed-tag ) && @@ -200,7 +203,7 @@ test_expect_success GPG 'push signed tag' ' test_expect_success GPG 'push signed tag with signed-tags capability' ' (cd local && - git checkout master && + git checkout main && git tag -s -m signed-tag signed-tag-2 && GIT_REMOTE_TESTGIT_SIGNED_TAGS=1 git push origin signed-tag-2 ) && @@ -209,7 +212,7 @@ test_expect_success GPG 'push signed tag with signed-tags capability' ' test_expect_success 'push update refs' ' (cd local && - git checkout -b update master && + git checkout -b update main && echo update >>file && git commit -a -m update && git push origin update && @@ -260,7 +263,7 @@ test_expect_success 'proper failure checks for fetching' ' test_expect_success 'proper failure checks for pushing' ' test_when_finished "rm -rf local/git.marks local/testgit.marks" && (cd local && - git checkout -b crash master && + git checkout -b crash main && echo crash >>file && git commit -a -m crash && test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git push --all && @@ -272,7 +275,7 @@ test_expect_success 'proper failure checks for pushing' ' test_expect_success 'push messages' ' (cd local && - git checkout -b new_branch master && + git checkout -b new_branch main && echo new >>file && git commit -a -m new && git push origin new_branch && @@ -286,7 +289,7 @@ test_expect_success 'push messages' ' test_expect_success 'fetch HEAD' ' (cd server && - git checkout master && + git checkout main && echo more >>file && git commit -a -m more ) && @@ -298,7 +301,7 @@ test_expect_success 'fetch HEAD' ' test_expect_success 'fetch url' ' (cd server && - git checkout master && + git checkout main && echo more >>file && git commit -a -m more ) && diff --git a/t/t6000-rev-list-misc.sh b/t/t6000-rev-list-misc.sh index fc4d55dcb2..12def7bcbf 100755 --- a/t/t6000-rev-list-misc.sh +++ b/t/t6000-rev-list-misc.sh @@ -2,6 +2,9 @@ test_description='miscellaneous rev-list tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -85,7 +88,7 @@ test_expect_success 'propagate uninteresting flag down correctly' ' ' test_expect_success 'symleft flag bit is propagated down from tag' ' - git log --format="%m %s" --left-right v1.0...master >actual && + git log --format="%m %s" --left-right v1.0...main >actual && cat >expect <<-\EOF && < another < that diff --git a/t/t6001-rev-list-graft.sh b/t/t6001-rev-list-graft.sh index 7504ba4751..90d93f77fa 100755 --- a/t/t6001-rev-list-graft.sh +++ b/t/t6001-rev-list-graft.sh @@ -2,6 +2,9 @@ test_description='Revision traversal vs grafts and path limiter' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -20,7 +23,7 @@ test_expect_success setup ' git commit -a -m "Third in one history." && A2=$(git rev-parse --verify HEAD) && - rm -f .git/refs/heads/master .git/index && + rm -f .git/refs/heads/main .git/index && echo >fileA fileA again && echo >subdir/fileB fileB again && diff --git a/t/t6004-rev-list-path-optim.sh b/t/t6004-rev-list-path-optim.sh index 3e8c42ee0b..cd4f420e2a 100755 --- a/t/t6004-rev-list-path-optim.sh +++ b/t/t6004-rev-list-path-optim.sh @@ -4,7 +4,7 @@ test_description='git rev-list trivial path optimization test d/z1 b0 b1 - o------------------------*----o master + o------------------------*----o main / / o---------o----o----o----o side a0 c0 c1 a1 c2 @@ -13,6 +13,9 @@ test_description='git rev-list trivial path optimization test ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -55,18 +58,18 @@ test_expect_success 'further setup' ' git add c && test_tick && git commit -m "Side makes yet another irrelevant commit" && - git checkout master && + git checkout main && echo Another >b && echo Munged >d/z && git add b d/z && test_tick && - git commit -m "Master touches b" && - git tag master_b0 && + git commit -m "Main touches b" && + git tag main_b0 && git merge side && echo Touched >b && git add b && test_tick && - git commit -m "Master touches b again" + git commit -m "Main touches b again" ' test_expect_success 'path optimization 2' ' @@ -76,13 +79,13 @@ test_expect_success 'path optimization 2' ' ' test_expect_success 'pathspec with leading path' ' - git rev-parse master^ master_b0 side_c0 initial >expected && + git rev-parse main^ main_b0 side_c0 initial >expected && git rev-list HEAD -- d >actual && test_cmp expected actual ' test_expect_success 'pathspec with glob (1)' ' - git rev-parse master^ master_b0 side_c0 initial >expected && + git rev-parse main^ main_b0 side_c0 initial >expected && git rev-list HEAD -- "d/*" >actual && test_cmp expected actual ' diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index 99a1eaf332..35a2f62392 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -5,6 +5,9 @@ test_description='git rev-list --pretty=format test' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-terminal.sh @@ -53,7 +56,7 @@ test_expect_success 'setup' ' test_format () { cat >expect.$1 test_expect_${3:-success} "format $1" " - git rev-list --pretty=format:'$2' master >output.$1 && + git rev-list --pretty=format:'$2' main >output.$1 && test_cmp expect.$1 output.$1 " } @@ -184,13 +187,13 @@ test_expect_success 'basic colors' ' <RED>foo<GREEN>bar<BLUE>baz<RESET>xyzzy EOF format="%Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy" && - git rev-list --color --format="$format" -1 master >actual.raw && + git rev-list --color --format="$format" -1 main >actual.raw && test_decode_color <actual.raw >actual && test_cmp expect actual ' test_expect_success '%S is not a placeholder for rev-list yet' ' - git rev-list --format="%S" -1 master | grep "%S" + git rev-list --format="%S" -1 main | grep "%S" ' test_expect_success 'advanced colors' ' @@ -199,7 +202,7 @@ test_expect_success 'advanced colors' ' <BOLD;RED;BYELLOW>foo<RESET> EOF format="%C(red yellow bold)foo%C(reset)" && - git rev-list --color --format="$format" -1 master >actual.raw && + git rev-list --color --format="$format" -1 main >actual.raw && test_decode_color <actual.raw >actual && test_cmp expect actual ' @@ -406,7 +409,7 @@ test_expect_success '%x00 shows NUL' ' test_expect_success '%ad respects --date=' ' echo 2005-04-07 >expect.ad-short && - git log -1 --date=short --pretty=tformat:%ad >output.ad-short master && + git log -1 --date=short --pretty=tformat:%ad >output.ad-short main && test_cmp expect.ad-short output.ad-short ' @@ -494,8 +497,8 @@ test_expect_success '"%h %gD: %gs" is same as git-reflog (with --abbrev)' ' ' test_expect_success '%gd shortens ref name' ' - echo "master@{0}" >expect.gd-short && - git log -g -1 --format=%gd refs/heads/master >actual.gd-short && + echo "main@{0}" >expect.gd-short && + git log -g -1 --format=%gd refs/heads/main >actual.gd-short && test_cmp expect.gd-short actual.gd-short ' diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh index 8bf5ae23c2..aebe4b69e1 100755 --- a/t/t6007-rev-list-cherry-pick-file.sh +++ b/t/t6007-rev-list-cherry-pick-file.sh @@ -2,6 +2,9 @@ test_description='test git rev-list --cherry-pick -- file' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # A---B---D---F @@ -31,7 +34,7 @@ test_expect_success setup ' test_tick && git commit -m "E" && git tag E && - git checkout master && + git checkout main && git checkout branch foo && test_tick && git commit -m "B" && @@ -233,7 +236,7 @@ test_expect_success '--cherry-pick with independent, but identical branches' ' test_tick && git commit -m "independent, too" foo && test -z "$(git rev-list --left-right --cherry-pick \ - HEAD...master -- foo)" + HEAD...main -- foo)" ' cat >expect <<EOF diff --git a/t/t6008-rev-list-submodule.sh b/t/t6008-rev-list-submodule.sh index c4af9ca0a7..3153a0d891 100755 --- a/t/t6008-rev-list-submodule.sh +++ b/t/t6008-rev-list-submodule.sh @@ -5,6 +5,9 @@ test_description='git rev-list involving submodules that this repo has' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -36,7 +39,7 @@ test_expect_success 'setup' ' ' test_expect_success "Ilari's test" ' - git rev-list --objects super master ^super^ + git rev-list --objects super main ^super^ ' test_done diff --git a/t/t6009-rev-list-parent.sh b/t/t6009-rev-list-parent.sh index 916d9692bc..63fa7c8313 100755 --- a/t/t6009-rev-list-parent.sh +++ b/t/t6009-rev-list-parent.sh @@ -2,6 +2,9 @@ test_description='ancestor culling and limiting by parent number' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh check_revlist () { @@ -45,7 +48,7 @@ test_expect_success 'setup roots, merges and octopuses' ' test_commit seven && git checkout -b yetanotherbranch four && test_commit eight && - git checkout master && + git checkout main && test_tick && git merge --allow-unrelated-histories -m normalmerge newroot && git tag normalmerge && @@ -56,7 +59,7 @@ test_expect_success 'setup roots, merges and octopuses' ' test_tick && git merge -m tetrapus sidebranch anotherbranch yetanotherbranch && git tag tetrapus && - git checkout master + git checkout main ' test_expect_success 'rev-list roots' ' @@ -123,7 +126,7 @@ test_expect_success 'dodecapus' ' roots="$roots root$i" || return done && - git checkout master && + git checkout main && test_tick && git merge -m dodecapus $roots && git tag dodecapus && diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh index fd202fcb94..4f7fa8b6c0 100755 --- a/t/t6012-rev-list-simplify.sh +++ b/t/t6012-rev-list-simplify.sh @@ -2,6 +2,9 @@ test_description='merge simplification' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh note () { @@ -43,7 +46,7 @@ test_expect_success setup ' git add side && test_tick && git commit -m "Side root" && note J && - git checkout master && + git checkout main && echo "Hello" >file && echo "second" >lost && @@ -65,7 +68,7 @@ test_expect_success setup ' note D && test_tick && - test_must_fail git merge -m "merge" master && + test_must_fail git merge -m "merge" main && >lost && git commit -a -m "merge" && note E && @@ -74,7 +77,7 @@ test_expect_success setup ' test_tick && git commit -m "Irrelevant change" && note F && - git checkout master && + git checkout main && echo "Yet another" >elif && git add elif && test_tick && git commit -m "Another irrelevant change" && @@ -87,7 +90,7 @@ test_expect_success setup ' test_tick && git commit -a -m "Final change" && note I && - git checkout master && + git checkout main && test_tick && git merge --allow-unrelated-histories -m "Coolest" unrelated && note K && diff --git a/t/t6013-rev-list-reverse-parents.sh b/t/t6013-rev-list-reverse-parents.sh index 89458d370f..39793cbbd6 100755 --- a/t/t6013-rev-list-reverse-parents.sh +++ b/t/t6013-rev-list-reverse-parents.sh @@ -2,6 +2,9 @@ test_description='--reverse combines with --parents' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh @@ -18,24 +21,24 @@ test_expect_success 'set up --reverse example' ' commit two && git checkout -b side HEAD^ && commit three && - git checkout master && + git checkout main && git merge -s ours side && commit five ' test_expect_success '--reverse --parents --full-history combines correctly' ' - git rev-list --parents --full-history master -- foo | + git rev-list --parents --full-history main -- foo | perl -e "print reverse <>" > expected && - git rev-list --reverse --parents --full-history master -- foo \ + git rev-list --reverse --parents --full-history main -- foo \ > actual && test_cmp expected actual ' test_expect_success '--boundary does too' ' - git rev-list --boundary --parents --full-history master ^root -- foo | + git rev-list --boundary --parents --full-history main ^root -- foo | perl -e "print reverse <>" > expected && git rev-list --boundary --reverse --parents --full-history \ - master ^root -- foo > actual && + main ^root -- foo > actual && test_cmp expected actual ' diff --git a/t/t6016-rev-list-graph-simplify-history.sh b/t/t6016-rev-list-graph-simplify-history.sh index f79df8b6d1..54b0a6f5f8 100755 --- a/t/t6016-rev-list-graph-simplify-history.sh +++ b/t/t6016-rev-list-graph-simplify-history.sh @@ -7,6 +7,9 @@ test_description='--graph and simplified history' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-log-graph.sh @@ -20,7 +23,7 @@ test_expect_success 'set up rev-list --graph test' ' test_commit A1 foo.txt && test_commit A2 bar.txt && test_commit A3 bar.txt && - git branch -m master A && + git branch -m main A && # 2 commits on branch B, started from A1 git checkout -b B A1 && diff --git a/t/t6017-rev-list-stdin.sh b/t/t6017-rev-list-stdin.sh index 667b37564e..05162512a0 100755 --- a/t/t6017-rev-list-stdin.sh +++ b/t/t6017-rev-list-stdin.sh @@ -5,6 +5,9 @@ test_description='log family learns --stdin' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh check () { @@ -40,7 +43,7 @@ test_expect_success setup ' done && for i in $them do - git checkout -b side-$i master~$i && + git checkout -b side-$i main~$i && echo updated $i >file-$i && git add file-$i && test_tick && @@ -49,7 +52,7 @@ test_expect_success setup ' ) ' -check master +check main check side-1 ^side-4 check side-1 ^side-7 -- check side-1 ^side-7 -- file-1 @@ -66,11 +69,11 @@ test_expect_success 'not only --stdin' ' file-2 EOF cat >input <<-EOF && - ^master^ + ^main^ -- file-2 EOF - git log --pretty=tformat:%s --name-only --stdin master -- file-1 \ + git log --pretty=tformat:%s --name-only --stdin main -- file-1 \ <input >actual && test_cmp expect actual ' diff --git a/t/t6018-rev-list-glob.sh b/t/t6018-rev-list-glob.sh index fe2f3cec3d..24b34add83 100755 --- a/t/t6018-rev-list-glob.sh +++ b/t/t6018-rev-list-glob.sh @@ -2,6 +2,9 @@ test_description='rev-list/rev-parse --glob' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh commit () { @@ -20,22 +23,22 @@ compare () { test_expect_success 'setup' ' - commit master && - git checkout -b subspace/one master && + commit main && + git checkout -b subspace/one main && commit one && - git checkout -b subspace/two master && + git checkout -b subspace/two main && commit two && - git checkout -b subspace-x master && + git checkout -b subspace-x main && commit subspace-x && - git checkout -b other/three master && + git checkout -b other/three main && commit three && - git checkout -b someref master && + git checkout -b someref main && commit some && - git checkout master && + git checkout main && commit topic_2 && - git tag foo/bar master && + git tag foo/bar main && commit topic_3 && - git update-ref refs/remotes/foo/baz master && + git update-ref refs/remotes/foo/baz main && commit topic_4 && git update-ref refs/remotes/upstream/one subspace/one && git update-ref refs/remotes/upstream/two subspace/two && @@ -83,7 +86,7 @@ test_expect_failure 'rev-parse accepts --glob as detached option' ' test_expect_failure 'rev-parse is not confused by option-like glob' ' - compare rev-parse "master" "--glob --symbolic master" + compare rev-parse "main" "--glob --symbolic main" ' @@ -111,15 +114,15 @@ test_expect_success 'rev-parse --glob=heads/subspace/* --glob=heads/other/*' ' ' -test_expect_success 'rev-parse --glob=heads/someref/* master' ' +test_expect_success 'rev-parse --glob=heads/someref/* main' ' - compare rev-parse "master" "--glob=heads/someref/* master" + compare rev-parse "main" "--glob=heads/someref/* main" ' test_expect_success 'rev-parse --glob=heads/*' ' - compare rev-parse "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*" + compare rev-parse "main other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*" ' @@ -136,7 +139,7 @@ test_expect_success 'rev-parse --remotes=foo' ' ' test_expect_success 'rev-parse --exclude with --branches' ' - compare rev-parse "--exclude=*/* --branches" "master someref subspace-x" + compare rev-parse "--exclude=*/* --branches" "main someref subspace-x" ' test_expect_success 'rev-parse --exclude with --all' ' @@ -221,7 +224,7 @@ test_expect_success 'rev-list --glob refs/heads/subspace/*' ' test_expect_success 'rev-list not confused by option-like --glob arg' ' - compare rev-list "master" "--glob -0 master" + compare rev-list "main" "--glob -0 main" ' @@ -269,13 +272,13 @@ test_expect_success 'rev-list --branches=subspace' ' test_expect_success 'rev-list --branches' ' - compare rev-list "master subspace-x someref other/three subspace/one subspace/two" "--branches" + compare rev-list "main subspace-x someref other/three subspace/one subspace/two" "--branches" ' -test_expect_success 'rev-list --glob=heads/someref/* master' ' +test_expect_success 'rev-list --glob=heads/someref/* main' ' - compare rev-list "master" "--glob=heads/someref/* master" + compare rev-list "main" "--glob=heads/someref/* main" ' @@ -287,7 +290,7 @@ test_expect_success 'rev-list --glob=heads/subspace/* --glob=heads/other/*' ' test_expect_success 'rev-list --glob=heads/*' ' - compare rev-list "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*" + compare rev-list "main other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*" ' @@ -310,7 +313,7 @@ test_expect_success 'rev-list --remotes=foo' ' ' test_expect_success 'rev-list --exclude with --branches' ' - compare rev-list "--exclude=*/* --branches" "master someref subspace-x" + compare rev-list "--exclude=*/* --branches" "main someref subspace-x" ' test_expect_success 'rev-list --exclude with --all' ' @@ -354,13 +357,13 @@ test_expect_success 'shortlog accepts --glob/--tags/--remotes' ' compare shortlog "subspace/one subspace/two" --branches=subspace && compare shortlog \ - "master subspace-x someref other/three subspace/one subspace/two" \ + "main subspace-x someref other/three subspace/one subspace/two" \ --branches && - compare shortlog master "--glob=heads/someref/* master" && + compare shortlog main "--glob=heads/someref/* main" && compare shortlog "subspace/one subspace/two other/three" \ "--glob=heads/subspace/* --glob=heads/other/*" && compare shortlog \ - "master other/three someref subspace-x subspace/one subspace/two" \ + "main other/three someref subspace-x subspace/one subspace/two" \ "--glob=heads/*" && compare shortlog foo/bar --tags=foo && compare shortlog "foo/bar qux/one qux/two qux/x" --tags && @@ -371,14 +374,14 @@ test_expect_success 'shortlog accepts --glob/--tags/--remotes' ' test_expect_failure 'shortlog accepts --glob as detached option' ' compare shortlog \ - "master other/three someref subspace-x subspace/one subspace/two" \ + "main other/three someref subspace-x subspace/one subspace/two" \ "--glob heads/*" ' test_expect_failure 'shortlog --glob is not confused by option-like argument' ' - compare shortlog master "--glob -e master" + compare shortlog main "--glob -e main" ' diff --git a/t/t6019-rev-list-ancestry-path.sh b/t/t6019-rev-list-ancestry-path.sh index 353f84313f..20adbece65 100755 --- a/t/t6019-rev-list-ancestry-path.sh +++ b/t/t6019-rev-list-ancestry-path.sh @@ -21,6 +21,9 @@ test_description='--ancestry-path' # --ancestry-path G..M -- G.t == L # --ancestry-path --simplify-merges G^..M -- G.t == G L +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_merge () { @@ -128,15 +131,15 @@ test_expect_success 'setup criss-cross' ' (cd criss-cross && git init && test_commit A && - git checkout -b xb master && + git checkout -b xb main && test_commit B && - git checkout -b xc master && + git checkout -b xc main && test_commit C && git checkout -b xbc xb -- && git merge xc && git checkout -b xcb xc -- && git merge xb && - git checkout master) + git checkout main) ' # no commits in bc descend from cb diff --git a/t/t6020-bundle-misc.sh b/t/t6020-bundle-misc.sh new file mode 100755 index 0000000000..881f72fd44 --- /dev/null +++ b/t/t6020-bundle-misc.sh @@ -0,0 +1,463 @@ +#!/bin/sh +# +# Copyright (c) 2021 Jiang Xin +# + +test_description='Test git-bundle' + +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + +. ./test-lib.sh +. "$TEST_DIRECTORY"/lib-bundle.sh + +# Create a commit or tag and set the variable with the object ID. +test_commit_setvar () { + notick= + signoff= + indir= + merge= + tag= + var= + + while test $# != 0 + do + case "$1" in + --merge) + merge=t + ;; + --tag) + tag=t + ;; + --notick) + notick=t + ;; + --signoff) + signoff="$1" + ;; + -C) + shift + indir="$1" + ;; + -*) + echo >&2 "error: unknown option $1" + return 1 + ;; + *) + break + ;; + esac + shift + done + if test $# -lt 2 + then + echo >&2 "error: test_commit_setvar must have at least 2 arguments" + return 1 + fi + var=$1 + shift + indir=${indir:+"$indir"/} + if test -z "$notick" + then + test_tick + fi && + if test -n "$merge" + then + git ${indir:+ -C "$indir"} merge --no-edit --no-ff \ + ${2:+-m "$2"} "$1" && + oid=$(git ${indir:+ -C "$indir"} rev-parse HEAD) + elif test -n "$tag" + then + git ${indir:+ -C "$indir"} tag -m "$1" "$1" "${2:-HEAD}" && + oid=$(git ${indir:+ -C "$indir"} rev-parse "$1") + else + file=${2:-"$1.t"} && + echo "${3-$1}" >"$indir$file" && + git ${indir:+ -C "$indir"} add "$file" && + git ${indir:+ -C "$indir"} commit $signoff -m "$1" && + oid=$(git ${indir:+ -C "$indir"} rev-parse HEAD) + fi && + eval $var=$oid +} + +# Format the output of git commands to make a user-friendly and stable +# text. We can easily prepare the expect text without having to worry +# about future changes of the commit ID and spaces of the output. +make_user_friendly_and_stable_output () { + sed \ + -e "s/${A%${A#???????}}[0-9a-f]*/<COMMIT-A>/g" \ + -e "s/${B%${B#???????}}[0-9a-f]*/<COMMIT-B>/g" \ + -e "s/${C%${C#???????}}[0-9a-f]*/<COMMIT-C>/g" \ + -e "s/${D%${D#???????}}[0-9a-f]*/<COMMIT-D>/g" \ + -e "s/${E%${E#???????}}[0-9a-f]*/<COMMIT-E>/g" \ + -e "s/${F%${F#???????}}[0-9a-f]*/<COMMIT-F>/g" \ + -e "s/${G%${G#???????}}[0-9a-f]*/<COMMIT-G>/g" \ + -e "s/${H%${H#???????}}[0-9a-f]*/<COMMIT-H>/g" \ + -e "s/${I%${I#???????}}[0-9a-f]*/<COMMIT-I>/g" \ + -e "s/${J%${J#???????}}[0-9a-f]*/<COMMIT-J>/g" \ + -e "s/${K%${K#???????}}[0-9a-f]*/<COMMIT-K>/g" \ + -e "s/${L%${L#???????}}[0-9a-f]*/<COMMIT-L>/g" \ + -e "s/${M%${M#???????}}[0-9a-f]*/<COMMIT-M>/g" \ + -e "s/${N%${N#???????}}[0-9a-f]*/<COMMIT-N>/g" \ + -e "s/${O%${O#???????}}[0-9a-f]*/<COMMIT-O>/g" \ + -e "s/${P%${P#???????}}[0-9a-f]*/<COMMIT-P>/g" \ + -e "s/${TAG1%${TAG1#???????}}[0-9a-f]*/<TAG-1>/g" \ + -e "s/${TAG2%${TAG2#???????}}[0-9a-f]*/<TAG-2>/g" \ + -e "s/${TAG3%${TAG3#???????}}[0-9a-f]*/<TAG-3>/g" \ + -e "s/ *\$//" +} + +# (C) (D, pull/1/head, topic/1) +# o --- o +# / \ (L) +# / \ o (H, topic/2) (M, tag:v2) +# / (F) \ / (N, tag:v3) +# / o --------- o (G, pull/2/head) o --- o --- o (release) +# / / \ \ / \ +# o --- o --- o -------- o -- o ------------------ o ------- o --- o (main) +# (A) (B) (E, tag:v1) (I) (J) (K) (O) (P) +# +test_expect_success 'setup' ' + # Try to make a stable fixed width for abbreviated commit ID, + # this fixed-width oid will be replaced with "<OID>". + git config core.abbrev 7 && + + # branch main: commit A & B + test_commit_setvar A "Commit A" main.txt && + test_commit_setvar B "Commit B" main.txt && + + # branch topic/1: commit C & D, refs/pull/1/head + git checkout -b topic/1 && + test_commit_setvar C "Commit C" topic-1.txt && + test_commit_setvar D "Commit D" topic-1.txt && + git update-ref refs/pull/1/head HEAD && + + # branch topic/1: commit E, tag v1 + git checkout main && + test_commit_setvar E "Commit E" main.txt && + test_commit_setvar --tag TAG1 v1 && + + # branch topic/2: commit F & G, refs/pull/2/head + git checkout -b topic/2 && + test_commit_setvar F "Commit F" topic-2.txt && + test_commit_setvar G "Commit G" topic-2.txt && + git update-ref refs/pull/2/head HEAD && + test_commit_setvar H "Commit H" topic-2.txt && + + # branch main: merge commit I & J + git checkout main && + test_commit_setvar --merge I topic/1 "Merge commit I" && + test_commit_setvar --merge J refs/pull/2/head "Merge commit J" && + + # branch main: commit K + git checkout main && + test_commit_setvar K "Commit K" main.txt && + + # branch release: + git checkout -b release && + test_commit_setvar L "Commit L" release.txt && + test_commit_setvar M "Commit M" release.txt && + test_commit_setvar --tag TAG2 v2 && + test_commit_setvar N "Commit N" release.txt && + test_commit_setvar --tag TAG3 v3 && + + # branch main: merge commit O, commit P + git checkout main && + test_commit_setvar --merge O tags/v2 "Merge commit O" && + test_commit_setvar P "Commit P" main.txt +' + +test_expect_success 'create bundle from special rev: main^!' ' + git bundle create special-rev.bdl "main^!" && + + git bundle list-heads special-rev.bdl | + make_user_friendly_and_stable_output >actual && + cat >expect <<-\EOF && + <COMMIT-P> refs/heads/main + EOF + test_cmp expect actual && + + git bundle verify special-rev.bdl | + make_user_friendly_and_stable_output >actual && + cat >expect <<-\EOF && + The bundle contains this ref: + <COMMIT-P> refs/heads/main + The bundle requires this ref: + <COMMIT-O> + EOF + test_cmp expect actual && + + test_bundle_object_count special-rev.bdl 3 +' + +test_expect_success 'create bundle with --max-count option' ' + git bundle create max-count.bdl --max-count 1 \ + main \ + "^release" \ + refs/tags/v1 \ + refs/pull/1/head \ + refs/pull/2/head && + + git bundle verify max-count.bdl | + make_user_friendly_and_stable_output >actual && + cat >expect <<-\EOF && + The bundle contains these 2 refs: + <COMMIT-P> refs/heads/main + <TAG-1> refs/tags/v1 + The bundle requires this ref: + <COMMIT-O> + EOF + test_cmp expect actual && + + test_bundle_object_count max-count.bdl 4 +' + +test_expect_success 'create bundle with --since option' ' + git log -1 --pretty="%ad" $M >actual && + cat >expect <<-\EOF && + Thu Apr 7 15:26:13 2005 -0700 + EOF + test_cmp expect actual && + + git bundle create since.bdl \ + --since "Thu Apr 7 15:27:00 2005 -0700" \ + --all && + + git bundle verify since.bdl | + make_user_friendly_and_stable_output >actual && + cat >expect <<-\EOF && + The bundle contains these 5 refs: + <COMMIT-P> refs/heads/main + <COMMIT-N> refs/heads/release + <TAG-2> refs/tags/v2 + <TAG-3> refs/tags/v3 + <COMMIT-P> HEAD + The bundle requires these 2 refs: + <COMMIT-M> + <COMMIT-K> + EOF + test_cmp expect actual && + + test_bundle_object_count --thin since.bdl 13 +' + +test_expect_success 'create bundle 1 - no prerequisites' ' + # create bundle from args + git bundle create 1.bdl topic/1 topic/2 && + + # create bundle from stdin + cat >input <<-\EOF && + topic/1 + topic/2 + EOF + git bundle create stdin-1.bdl --stdin <input && + + cat >expect <<-\EOF && + The bundle contains these 2 refs: + <COMMIT-D> refs/heads/topic/1 + <COMMIT-H> refs/heads/topic/2 + The bundle records a complete history. + EOF + + # verify bundle, which has no prerequisites + git bundle verify 1.bdl | + make_user_friendly_and_stable_output >actual && + test_cmp expect actual && + + git bundle verify stdin-1.bdl | + make_user_friendly_and_stable_output >actual && + test_cmp expect actual && + + test_bundle_object_count 1.bdl 24 && + test_bundle_object_count stdin-1.bdl 24 +' + +test_expect_success 'create bundle 2 - has prerequisites' ' + # create bundle from args + git bundle create 2.bdl \ + --ignore-missing \ + ^topic/deleted \ + ^$D \ + ^topic/2 \ + release && + + # create bundle from stdin + # input has a non-exist reference: "topic/deleted" + cat >input <<-EOF && + ^topic/deleted + ^$D + ^topic/2 + EOF + git bundle create stdin-2.bdl \ + --ignore-missing \ + --stdin \ + release <input && + + cat >expect <<-\EOF && + The bundle contains this ref: + <COMMIT-N> refs/heads/release + The bundle requires these 3 refs: + <COMMIT-D> + <COMMIT-E> + <COMMIT-G> + EOF + + git bundle verify 2.bdl | + make_user_friendly_and_stable_output >actual && + test_cmp expect actual && + + git bundle verify stdin-2.bdl | + make_user_friendly_and_stable_output >actual && + test_cmp expect actual && + + test_bundle_object_count 2.bdl 16 && + test_bundle_object_count stdin-2.bdl 16 +' + +test_expect_success 'fail to verify bundle without prerequisites' ' + git init --bare test1.git && + + cat >expect <<-\EOF && + error: Repository lacks these prerequisite commits: + error: <COMMIT-D> + error: <COMMIT-E> + error: <COMMIT-G> + EOF + + test_must_fail git -C test1.git bundle verify ../2.bdl 2>&1 | + make_user_friendly_and_stable_output >actual && + test_cmp expect actual && + + test_must_fail git -C test1.git bundle verify ../stdin-2.bdl 2>&1 | + make_user_friendly_and_stable_output >actual && + test_cmp expect actual +' + +test_expect_success 'create bundle 3 - two refs, same object' ' + # create bundle from args + git bundle create --version=3 3.bdl \ + ^release \ + ^topic/1 \ + ^topic/2 \ + main \ + HEAD && + + # create bundle from stdin + cat >input <<-\EOF && + ^release + ^topic/1 + ^topic/2 + EOF + git bundle create --version=3 stdin-3.bdl \ + --stdin \ + main HEAD <input && + + cat >expect <<-\EOF && + The bundle contains these 2 refs: + <COMMIT-P> refs/heads/main + <COMMIT-P> HEAD + The bundle requires these 2 refs: + <COMMIT-M> + <COMMIT-K> + EOF + + git bundle verify 3.bdl | + make_user_friendly_and_stable_output >actual && + test_cmp expect actual && + + git bundle verify stdin-3.bdl | + make_user_friendly_and_stable_output >actual && + test_cmp expect actual && + + test_bundle_object_count 3.bdl 4 && + test_bundle_object_count stdin-3.bdl 4 +' + +test_expect_success 'create bundle 4 - with tags' ' + # create bundle from args + git bundle create 4.bdl \ + ^main \ + ^release \ + ^topic/1 \ + ^topic/2 \ + --all && + + # create bundle from stdin + cat >input <<-\EOF && + ^main + ^release + ^topic/1 + ^topic/2 + EOF + git bundle create stdin-4.bdl \ + --ignore-missing \ + --stdin \ + --all <input && + + cat >expect <<-\EOF && + The bundle contains these 3 refs: + <TAG-1> refs/tags/v1 + <TAG-2> refs/tags/v2 + <TAG-3> refs/tags/v3 + The bundle records a complete history. + EOF + + git bundle verify 4.bdl | + make_user_friendly_and_stable_output >actual && + test_cmp expect actual && + + git bundle verify stdin-4.bdl | + make_user_friendly_and_stable_output >actual && + test_cmp expect actual && + + test_bundle_object_count 4.bdl 3 && + test_bundle_object_count stdin-4.bdl 3 +' + +test_expect_success 'clone from bundle' ' + git clone --mirror 1.bdl mirror.git && + git -C mirror.git show-ref | + make_user_friendly_and_stable_output >actual && + cat >expect <<-\EOF && + <COMMIT-D> refs/heads/topic/1 + <COMMIT-H> refs/heads/topic/2 + EOF + test_cmp expect actual && + + git -C mirror.git fetch ../2.bdl "+refs/*:refs/*" && + git -C mirror.git show-ref | + make_user_friendly_and_stable_output >actual && + cat >expect <<-\EOF && + <COMMIT-N> refs/heads/release + <COMMIT-D> refs/heads/topic/1 + <COMMIT-H> refs/heads/topic/2 + EOF + test_cmp expect actual && + + git -C mirror.git fetch ../3.bdl "+refs/*:refs/*" && + git -C mirror.git show-ref | + make_user_friendly_and_stable_output >actual && + cat >expect <<-\EOF && + <COMMIT-P> refs/heads/main + <COMMIT-N> refs/heads/release + <COMMIT-D> refs/heads/topic/1 + <COMMIT-H> refs/heads/topic/2 + EOF + test_cmp expect actual && + + git -C mirror.git fetch ../4.bdl "+refs/*:refs/*" && + git -C mirror.git show-ref | + make_user_friendly_and_stable_output >actual && + cat >expect <<-\EOF && + <COMMIT-P> refs/heads/main + <COMMIT-N> refs/heads/release + <COMMIT-D> refs/heads/topic/1 + <COMMIT-H> refs/heads/topic/2 + <TAG-1> refs/tags/v1 + <TAG-2> refs/tags/v2 + <TAG-3> refs/tags/v3 + EOF + test_cmp expect actual +' + +test_done diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 52614eefc7..a1baf4e451 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -6,6 +6,9 @@ test_description='Tests git bisect functionality' exec </dev/null +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh add_line_into_file() @@ -89,9 +92,9 @@ test_expect_success 'bisect start without -- takes unknown arg as pathspec' ' grep bar ".git/BISECT_NAMES" ' -test_expect_success 'bisect reset: back in the master branch' ' +test_expect_success 'bisect reset: back in the main branch' ' git bisect reset && - echo "* master" > branch.expect && + echo "* main" > branch.expect && git branch > branch.output && cmp branch.expect branch.output ' @@ -102,7 +105,7 @@ test_expect_success 'bisect reset: back in another branch' ' git bisect good $HASH1 && git bisect bad $HASH3 && git bisect reset && - echo " master" > branch.expect && + echo " main" > branch.expect && echo "* other" >> branch.expect && git branch > branch.output && cmp branch.expect branch.output @@ -348,7 +351,7 @@ test_expect_success 'bisect skip many ranges' ' test_expect_success 'bisect starting with a detached HEAD' ' git bisect reset && - git checkout master^ && + git checkout main^ && HEAD=$(git rev-parse --verify HEAD) && git bisect start && test $HEAD = $(cat .git/BISECT_START) && @@ -575,9 +578,9 @@ test_expect_success 'skipping away from skipped commit' ' test "$para3" = "$PARA_HASH3" ' -test_expect_success 'erroring out when using bad path parameters' ' +test_expect_success 'erroring out when using bad path arguments' ' test_must_fail git bisect start $PARA_HASH7 $HASH1 -- foobar 2> error.txt && - test_i18ngrep "bad path parameters" error.txt + test_i18ngrep "bad path arguments" error.txt ' test_expect_success 'test bisection on bare repo - --no-checkout specified' ' @@ -716,7 +719,7 @@ test_expect_success 'bisect: --no-checkout - target after breakage' ' test_expect_success 'bisect: demonstrate identification of damage boundary' " git bisect reset && git checkout broken && - git bisect start broken master --no-checkout && + git bisect start broken main --no-checkout && test_must_fail git bisect run \"\$SHELL_PATH\" -c ' GOOD=\$(git for-each-ref \"--format=%(objectname)\" refs/bisect/good-*) && git rev-list --objects BISECT_HEAD --not \$GOOD >tmp.\$\$ && @@ -826,7 +829,7 @@ test_expect_success 'bisect terms needs 0 or 1 argument' ' test_must_fail git bisect terms 1 2 && test_must_fail git bisect terms 2>actual && echo "error: no terms defined" >expected && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'bisect terms shows good/bad after start' ' @@ -900,7 +903,7 @@ test_expect_success 'bisect start --term-* does store terms' ' Your current terms are two for the old state and one for the new state. EOF - test_i18ncmp expected actual && + test_cmp expected actual && git bisect terms --term-bad >actual && echo one >expected && test_cmp expected actual && @@ -919,6 +922,17 @@ test_expect_success 'bisect start takes options and revs in any order' ' test_cmp expected actual ' +# Bisect is started with --term-new and --term-old arguments, +# then skip. The HEAD should be changed. +test_expect_success 'bisect skip works with --term*' ' + git bisect reset && + git bisect start --term-new=fixed --term-old=unfixed HEAD $HASH1 && + hash_skipped_from=$(git rev-parse --verify HEAD) && + git bisect skip && + hash_skipped_to=$(git rev-parse --verify HEAD) && + test "$hash_skipped_from" != "$hash_skipped_to" +' + test_expect_success 'git bisect reset cleans bisection state properly' ' git bisect reset && git bisect start && @@ -936,4 +950,16 @@ test_expect_success 'git bisect reset cleans bisection state properly' ' test_path_is_missing ".git/BISECT_START" ' +test_expect_success 'bisect handles annotated tags' ' + test_commit commit-one && + git tag -m foo tag-one && + test_commit commit-two && + git tag -m foo tag-two && + git bisect start && + git bisect good tag-one && + git bisect bad tag-two >output && + bad=$(git rev-parse --verify tag-two^{commit}) && + grep "$bad is the first bad commit" output +' + test_done diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh index 50a934e1b2..a313849406 100755 --- a/t/t6040-tracking-info.sh +++ b/t/t6040-tracking-info.sh @@ -2,6 +2,9 @@ test_description='remote tracking stats' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh advance () { @@ -34,7 +37,7 @@ test_expect_success setup ' git branch -d brokenbase && git checkout -b b6 origin ) && - git checkout -b follower --track master && + git checkout -b follower --track main && advance h ' @@ -54,16 +57,16 @@ test_expect_success 'branch -v' ' git branch -v ) | sed -n -e "$t6040_script" >actual && - test_i18ncmp expect actual + test_cmp expect actual ' cat >expect <<\EOF -b1 [origin/master: ahead 1, behind 1] d -b2 [origin/master: ahead 1, behind 1] d -b3 [origin/master: behind 1] b -b4 [origin/master: ahead 2] f +b1 [origin/main: ahead 1, behind 1] d +b2 [origin/main: ahead 1, behind 1] d +b3 [origin/main: behind 1] b +b4 [origin/main: ahead 2] f b5 [brokenbase: gone] g -b6 [origin/master] c +b6 [origin/main] c EOF test_expect_success 'branch -vv' ' @@ -72,7 +75,7 @@ test_expect_success 'branch -vv' ' git branch -vv ) | sed -n -e "$t6040_script" >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'checkout (diverged from upstream)' ' @@ -83,7 +86,7 @@ test_expect_success 'checkout (diverged from upstream)' ' ' test_expect_success 'checkout with local tracked branch' ' - git checkout master && + git checkout main && git checkout follower >actual && test_i18ngrep "is ahead of" actual ' @@ -100,7 +103,7 @@ test_expect_success 'checkout (up-to-date with upstream)' ' ( cd test && git checkout b6 ) >actual && - test_i18ngrep "Your branch is up to date with .origin/master" actual + test_i18ngrep "Your branch is up to date with .origin/main" actual ' test_expect_success 'status (diverged from upstream)' ' @@ -130,11 +133,11 @@ test_expect_success 'status (up-to-date with upstream)' ' # reports nothing to commit test_must_fail git commit --dry-run ) >actual && - test_i18ngrep "Your branch is up to date with .origin/master" actual + test_i18ngrep "Your branch is up to date with .origin/main" actual ' cat >expect <<\EOF -## b1...origin/master [ahead 1, behind 1] +## b1...origin/main [ahead 1, behind 1] EOF test_expect_success 'status -s -b (diverged from upstream)' ' @@ -143,11 +146,11 @@ test_expect_success 'status -s -b (diverged from upstream)' ' git checkout b1 >/dev/null && git status -s -b | head -1 ) >actual && - test_i18ncmp expect actual + test_cmp expect actual ' cat >expect <<\EOF -## b1...origin/master [different] +## b1...origin/main [different] EOF test_expect_success 'status -s -b --no-ahead-behind (diverged from upstream)' ' @@ -156,11 +159,11 @@ test_expect_success 'status -s -b --no-ahead-behind (diverged from upstream)' ' git checkout b1 >/dev/null && git status -s -b --no-ahead-behind | head -1 ) >actual && - test_i18ncmp expect actual + test_cmp expect actual ' cat >expect <<\EOF -## b1...origin/master [different] +## b1...origin/main [different] EOF test_expect_success 'status.aheadbehind=false status -s -b (diverged from upstream)' ' @@ -169,12 +172,12 @@ test_expect_success 'status.aheadbehind=false status -s -b (diverged from upstre git checkout b1 >/dev/null && git -c status.aheadbehind=false status -s -b | head -1 ) >actual && - test_i18ncmp expect actual + test_cmp expect actual ' cat >expect <<\EOF On branch b1 -Your branch and 'origin/master' have diverged, +Your branch and 'origin/main' have diverged, and have 1 and 1 different commits each, respectively. EOF @@ -184,7 +187,7 @@ test_expect_success 'status --long --branch' ' git checkout b1 >/dev/null && git status --long -b | head -3 ) >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'status --long --branch' ' @@ -193,12 +196,12 @@ test_expect_success 'status --long --branch' ' git checkout b1 >/dev/null && git -c status.aheadbehind=true status --long -b | head -3 ) >actual && - test_i18ncmp expect actual + test_cmp expect actual ' cat >expect <<\EOF On branch b1 -Your branch and 'origin/master' refer to different commits. +Your branch and 'origin/main' refer to different commits. EOF test_expect_success 'status --long --branch --no-ahead-behind' ' @@ -207,7 +210,7 @@ test_expect_success 'status --long --branch --no-ahead-behind' ' git checkout b1 >/dev/null && git status --long -b --no-ahead-behind | head -2 ) >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'status.aheadbehind=false status --long --branch' ' @@ -216,7 +219,7 @@ test_expect_success 'status.aheadbehind=false status --long --branch' ' git checkout b1 >/dev/null && git -c status.aheadbehind=false status --long -b | head -2 ) >actual && - test_i18ncmp expect actual + test_cmp expect actual ' cat >expect <<\EOF @@ -229,11 +232,11 @@ test_expect_success 'status -s -b (upstream is gone)' ' git checkout b5 >/dev/null && git status -s -b | head -1 ) >actual && - test_i18ncmp expect actual + test_cmp expect actual ' cat >expect <<\EOF -## b6...origin/master +## b6...origin/main EOF test_expect_success 'status -s -b (up-to-date with upstream)' ' @@ -242,11 +245,11 @@ test_expect_success 'status -s -b (up-to-date with upstream)' ' git checkout b6 >/dev/null && git status -s -b | head -1 ) >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'fail to track lightweight tags' ' - git checkout master && + git checkout main && git tag light && test_must_fail git branch --track lighttrack light >actual && test_i18ngrep ! "set up to track" actual && @@ -254,7 +257,7 @@ test_expect_success 'fail to track lightweight tags' ' ' test_expect_success 'fail to track annotated tags' ' - git checkout master && + git checkout main && git tag -m heavy heavy && test_must_fail git branch --track heavytrack heavy >actual && test_i18ngrep ! "set up to track" actual && @@ -262,17 +265,17 @@ test_expect_success 'fail to track annotated tags' ' ' test_expect_success '--set-upstream-to does not change branch' ' - git branch from-master master && - git branch --set-upstream-to master from-master && - git branch from-topic_2 master && + git branch from-main main && + git branch --set-upstream-to main from-main && + git branch from-topic_2 main && test_must_fail git config branch.from-topic_2.merge > actual && git rev-list from-topic_2 && git update-ref refs/heads/from-topic_2 from-topic_2^ && git rev-parse from-topic_2 >expect2 && - git branch --set-upstream-to master from-topic_2 && - git config branch.from-master.merge > actual && + git branch --set-upstream-to main from-topic_2 && + git config branch.from-main.merge > actual && git rev-parse from-topic_2 >actual2 && - grep -q "^refs/heads/master$" actual && + grep -q "^refs/heads/main$" actual && cmp expect2 actual2 ' @@ -280,11 +283,11 @@ test_expect_success '--set-upstream-to @{-1}' ' git checkout follower && git checkout from-topic_2 && git config branch.from-topic_2.merge > expect2 && - git branch --set-upstream-to @{-1} from-master && - git config branch.from-master.merge > actual && + git branch --set-upstream-to @{-1} from-main && + git config branch.from-main.merge > actual && git config branch.from-topic_2.merge > actual2 && - git branch --set-upstream-to follower from-master && - git config branch.from-master.merge > expect && + git branch --set-upstream-to follower from-main && + git config branch.from-main.merge > expect && test_cmp expect2 actual2 && test_cmp expect actual ' diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh index c80dc10b8f..e33d512ec1 100755 --- a/t/t6050-replace.sh +++ b/t/t6050-replace.sh @@ -4,6 +4,9 @@ # test_description='Tests replace refs functionality' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY/lib-gpg.sh" @@ -129,13 +132,13 @@ tagger T A Gger <> 0 +0000 EOF test_expect_success 'tag replaced commit' ' - git mktag <tag.sig >.git/refs/tags/mytag 2>message + git mktag <tag.sig >.git/refs/tags/mytag ' test_expect_success '"git fsck" works' ' - git fsck master >fsck_master.out && - test_i18ngrep "dangling commit $R" fsck_master.out && - test_i18ngrep "dangling tag $(git show-ref -s refs/tags/mytag)" fsck_master.out && + git fsck main >fsck_main.out && + test_i18ngrep "dangling commit $R" fsck_main.out && + test_i18ngrep "dangling tag $(git show-ref -s refs/tags/mytag)" fsck_main.out && test -z "$(git fsck)" ' @@ -218,7 +221,7 @@ test_expect_success 'create parallel branch without the bug' ' git cherry-pick $HASH6 && PARA6=$(git rev-parse --verify HEAD) && git replace $HASH6 $PARA6 && - git checkout master && + git checkout main && cur=$(git rev-parse --verify HEAD) && test "$cur" = "$HASH7" && git log --pretty=oneline | grep $PARA2 && @@ -461,7 +464,7 @@ test_expect_success GPG 'set up a merge commit with a mergetag' ' git commit -m "hello: 2 more lines from a test branch" && HASH9=$(git rev-parse --verify HEAD) && git tag -s -m "tag for testing with a mergetag" test_tag HEAD && - git checkout master && + git checkout main && git merge -s ours test_tag && HASH10=$(git rev-parse --verify HEAD) && git cat-file commit $HASH10 | grep "^mergetag object" diff --git a/t/t6101-rev-parse-parents.sh b/t/t6101-rev-parse-parents.sh index 7531262a5e..78b5851780 100755 --- a/t/t6101-rev-parse-parents.sh +++ b/t/t6101-rev-parse-parents.sh @@ -5,6 +5,9 @@ test_description='Test git rev-parse with different parent options' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_cmp_rev_output () { @@ -18,7 +21,7 @@ test_expect_success 'setup' ' test_commit second && git checkout --orphan tmp && test_commit start2 && - git checkout master && + git checkout main && git merge -m next --allow-unrelated-histories start2 && test_commit final && diff --git a/t/t6110-rev-list-sparse.sh b/t/t6110-rev-list-sparse.sh index 656ac7fe9d..13c1da5352 100755 --- a/t/t6110-rev-list-sparse.sh +++ b/t/t6110-rev-list-sparse.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='operations that cull histories in unusual ways' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -10,7 +13,7 @@ test_expect_success setup ' git checkout -b side HEAD^ && test_commit D && test_commit E && - git merge master + git merge main ' test_expect_success 'rev-list --first-parent --boundary' ' diff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh index 4244638285..e07b6070e0 100755 --- a/t/t6111-rev-list-treesame.sh +++ b/t/t6111-rev-list-treesame.sh @@ -13,6 +13,9 @@ test_description='TREESAME and limiting' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh note () { @@ -33,13 +36,13 @@ test_expect_success setup ' git checkout other-branch && test_commit "Added other" other "Hello" C && - git checkout master && + git checkout main && test_merge D other-branch && git checkout third-branch && test_commit "Third file" third "Nothing" E && - git checkout master && + git checkout main && test_commit "file=Blah" file "Blah" F && test_tick && git merge --no-commit third-branch && @@ -56,7 +59,7 @@ test_expect_success setup ' test_tick && git revert I && note J && - git checkout master && + git checkout main && test_tick && git merge --no-ff fiddler-branch && note K && diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh index de0e5a5d36..4ade105db3 100755 --- a/t/t6112-rev-list-filters-objects.sh +++ b/t/t6112-rev-list-filters-objects.sh @@ -2,6 +2,9 @@ test_description='git rev-list using object filtering' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # Test the blob:none filter. @@ -156,6 +159,78 @@ test_expect_success 'verify blob:limit=1m' ' test_must_be_empty observed ' +# Test object:type=<type> filter. + +test_expect_success 'setup object-type' ' + test_create_repo object-type && + test_commit --no-tag -C object-type message blob && + git -C object-type tag tag -m tag-message +' + +test_expect_success 'verify object:type= fails with invalid type' ' + test_must_fail git -C object-type rev-list --objects --filter=object:type= HEAD && + test_must_fail git -C object-type rev-list --objects --filter=object:type=invalid HEAD +' + +test_expect_success 'verify object:type=blob prints blob and commit' ' + git -C object-type rev-parse HEAD >expected && + printf "%s blob\n" $(git -C object-type rev-parse HEAD:blob) >>expected && + git -C object-type rev-list --objects --filter=object:type=blob HEAD >actual && + test_cmp expected actual +' + +test_expect_success 'verify object:type=tree prints tree and commit' ' + ( + git -C object-type rev-parse HEAD && + printf "%s \n" $(git -C object-type rev-parse HEAD^{tree}) + ) >expected && + git -C object-type rev-list --objects --filter=object:type=tree HEAD >actual && + test_cmp expected actual +' + +test_expect_success 'verify object:type=commit prints commit' ' + git -C object-type rev-parse HEAD >expected && + git -C object-type rev-list --objects --filter=object:type=commit HEAD >actual && + test_cmp expected actual +' + +test_expect_success 'verify object:type=tag prints tag' ' + ( + git -C object-type rev-parse HEAD && + printf "%s tag\n" $(git -C object-type rev-parse tag) + ) >expected && + git -C object-type rev-list --objects --filter=object:type=tag tag >actual && + test_cmp expected actual +' + +test_expect_success 'verify object:type=blob prints only blob with --filter-provided-objects' ' + printf "%s blob\n" $(git -C object-type rev-parse HEAD:blob) >expected && + git -C object-type rev-list --objects \ + --filter=object:type=blob --filter-provided-objects HEAD >actual && + test_cmp expected actual +' + +test_expect_success 'verify object:type=tree prints only tree with --filter-provided-objects' ' + printf "%s \n" $(git -C object-type rev-parse HEAD^{tree}) >expected && + git -C object-type rev-list --objects \ + --filter=object:type=tree HEAD --filter-provided-objects >actual && + test_cmp expected actual +' + +test_expect_success 'verify object:type=commit prints only commit with --filter-provided-objects' ' + git -C object-type rev-parse HEAD >expected && + git -C object-type rev-list --objects \ + --filter=object:type=commit --filter-provided-objects HEAD >actual && + test_cmp expected actual +' + +test_expect_success 'verify object:type=tag prints only tag with --filter-provided-objects' ' + printf "%s tag\n" $(git -C object-type rev-parse tag) >expected && + git -C object-type rev-list --objects \ + --filter=object:type=tag --filter-provided-objects tag >actual && + test_cmp expected actual +' + # Test sparse:path=<path> filter. # !!!! # NOTE: sparse:path filter support has been dropped for security reasons, @@ -223,7 +298,7 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' ' sort >expected && git -C r3 rev-list --quiet --objects --filter-print-omitted \ - --filter=sparse:oid=master:pattern HEAD >revs && + --filter=sparse:oid=main:pattern HEAD >revs && awk -f print_1.awk revs | sed "s/~//" | sort >observed && @@ -436,7 +511,7 @@ test_expect_success 'add sparse pattern blobs whose paths have reserved chars' ' test_expect_success 'combine:... with more than two sub-filters' ' git -C r3 rev-list --objects \ - --filter=combine:tree:3+blob:limit=40+sparse:oid=master:pattern \ + --filter=combine:tree:3+blob:limit=40+sparse:oid=main:pattern \ HEAD >actual && expect_has HEAD "" && @@ -454,7 +529,7 @@ test_expect_success 'combine:... with more than two sub-filters' ' cp actual expect && git -C r3 rev-list --objects \ - --filter=combine:tree:3+blob:limit=40+sparse:oid=master:pattern1%2brenamed%25 \ + --filter=combine:tree:3+blob:limit=40+sparse:oid=main:pattern1%2brenamed%25 \ HEAD >actual && test_cmp expect actual && @@ -464,23 +539,23 @@ test_expect_success 'combine:... with more than two sub-filters' ' test_when_finished "rm -f trace1" && GIT_TRACE=$(pwd)/trace1 git -C r3 rev-list --objects \ --filter=tree:3 --filter=blob:limit=40 \ - --filter=sparse:oid="master:p;at%ter+n" \ + --filter=sparse:oid="main:p;at%ter+n" \ HEAD >actual && test_cmp expect actual && - grep "Add to combine filter-spec: sparse:oid=master:p%3bat%25ter%2bn" \ + grep "Add to combine filter-spec: sparse:oid=main:p%3bat%25ter%2bn" \ trace1 && # Repeat the above test, but this time, the characters to encode are in # the LHS of the combined filter. test_when_finished "rm -f trace2" && GIT_TRACE=$(pwd)/trace2 git -C r3 rev-list --objects \ - --filter=sparse:oid=master:^~pattern \ + --filter=sparse:oid=main:^~pattern \ --filter=tree:3 --filter=blob:limit=40 \ HEAD >actual && test_cmp expect actual && - grep "Add to combine filter-spec: sparse:oid=master:%5e%7epattern" \ + grep "Add to combine filter-spec: sparse:oid=main:%5e%7epattern" \ trace2 ' diff --git a/t/t6113-rev-list-bitmap-filters.sh b/t/t6113-rev-list-bitmap-filters.sh index 2b551e6fd0..4d8e09167e 100755 --- a/t/t6113-rev-list-bitmap-filters.sh +++ b/t/t6113-rev-list-bitmap-filters.sh @@ -2,6 +2,7 @@ test_description='rev-list combining bitmaps and filters' . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-bitmap.sh test_expect_success 'set up bitmapped repo' ' # one commit will have bitmaps, the other will not @@ -9,7 +10,8 @@ test_expect_success 'set up bitmapped repo' ' test_commit much-larger-blob-one && git repack -adb && test_commit two && - test_commit much-larger-blob-two + test_commit much-larger-blob-two && + git tag tag ' test_expect_success 'filters fallback to non-bitmap traversal' ' @@ -74,4 +76,69 @@ test_expect_success 'tree:1 filter' ' test_cmp expect actual ' +test_expect_success 'object:type filter' ' + git rev-list --objects --filter=object:type=tag tag >expect && + git rev-list --use-bitmap-index \ + --objects --filter=object:type=tag tag >actual && + test_cmp expect actual && + + git rev-list --objects --filter=object:type=commit tag >expect && + git rev-list --use-bitmap-index \ + --objects --filter=object:type=commit tag >actual && + test_bitmap_traversal expect actual && + + git rev-list --objects --filter=object:type=tree tag >expect && + git rev-list --use-bitmap-index \ + --objects --filter=object:type=tree tag >actual && + test_bitmap_traversal expect actual && + + git rev-list --objects --filter=object:type=blob tag >expect && + git rev-list --use-bitmap-index \ + --objects --filter=object:type=blob tag >actual && + test_bitmap_traversal expect actual +' + +test_expect_success 'object:type filter with --filter-provided-objects' ' + git rev-list --objects --filter-provided-objects --filter=object:type=tag tag >expect && + git rev-list --use-bitmap-index \ + --objects --filter-provided-objects --filter=object:type=tag tag >actual && + test_cmp expect actual && + + git rev-list --objects --filter-provided-objects --filter=object:type=commit tag >expect && + git rev-list --use-bitmap-index \ + --objects --filter-provided-objects --filter=object:type=commit tag >actual && + test_bitmap_traversal expect actual && + + git rev-list --objects --filter-provided-objects --filter=object:type=tree tag >expect && + git rev-list --use-bitmap-index \ + --objects --filter-provided-objects --filter=object:type=tree tag >actual && + test_bitmap_traversal expect actual && + + git rev-list --objects --filter-provided-objects --filter=object:type=blob tag >expect && + git rev-list --use-bitmap-index \ + --objects --filter-provided-objects --filter=object:type=blob tag >actual && + test_bitmap_traversal expect actual +' + +test_expect_success 'combine filter' ' + git rev-list --objects --filter=blob:limit=1000 --filter=object:type=blob tag >expect && + git rev-list --use-bitmap-index \ + --objects --filter=blob:limit=1000 --filter=object:type=blob tag >actual && + test_bitmap_traversal expect actual +' + +test_expect_success 'combine filter with --filter-provided-objects' ' + git rev-list --objects --filter-provided-objects --filter=blob:limit=1000 --filter=object:type=blob tag >expect && + git rev-list --use-bitmap-index \ + --objects --filter-provided-objects --filter=blob:limit=1000 --filter=object:type=blob tag >actual && + test_bitmap_traversal expect actual && + + git cat-file --batch-check="%(objecttype) %(objectsize)" <actual >objects && + while read objecttype objectsize + do + test "$objecttype" = blob || return 1 + test "$objectsize" -le 1000 || return 1 + done <objects +' + test_done diff --git a/t/t6114-keep-packs.sh b/t/t6114-keep-packs.sh new file mode 100755 index 0000000000..9239d8aa46 --- /dev/null +++ b/t/t6114-keep-packs.sh @@ -0,0 +1,69 @@ +#!/bin/sh + +test_description='rev-list with .keep packs' +. ./test-lib.sh + +test_expect_success 'setup' ' + test_commit loose && + test_commit packed && + test_commit kept && + + KEPT_PACK=$(git pack-objects --revs .git/objects/pack/pack <<-EOF + refs/tags/kept + ^refs/tags/packed + EOF + ) && + MISC_PACK=$(git pack-objects --revs .git/objects/pack/pack <<-EOF + refs/tags/packed + ^refs/tags/loose + EOF + ) && + + touch .git/objects/pack/pack-$KEPT_PACK.keep +' + +rev_list_objects () { + git rev-list "$@" >out && + sort out +} + +idx_objects () { + git show-index <$1 >expect-idx && + cut -d" " -f2 <expect-idx | sort +} + +test_expect_success '--no-kept-objects excludes trees and blobs in .keep packs' ' + rev_list_objects --objects --all --no-object-names >kept && + rev_list_objects --objects --all --no-object-names --no-kept-objects >no-kept && + + idx_objects .git/objects/pack/pack-$KEPT_PACK.idx >expect && + comm -3 kept no-kept >actual && + + test_cmp expect actual +' + +test_expect_success '--no-kept-objects excludes kept non-MIDX object' ' + test_config core.multiPackIndex true && + + # Create a pack with just the commit object in pack, and do not mark it + # as kept (even though it appears in $KEPT_PACK, which does have a .keep + # file). + MIDX_PACK=$(git pack-objects .git/objects/pack/pack <<-EOF + $(git rev-parse kept) + EOF + ) && + + # Write a MIDX containing all packs, but use the version of the commit + # at "kept" in a non-kept pack by touching $MIDX_PACK. + touch .git/objects/pack/pack-$MIDX_PACK.pack && + git multi-pack-index write && + + rev_list_objects --objects --no-object-names --no-kept-objects HEAD >actual && + ( + idx_objects .git/objects/pack/pack-$MISC_PACK.idx && + git rev-list --objects --no-object-names refs/tags/loose + ) | sort >expect && + test_cmp expect actual +' + +test_done diff --git a/t/t6115-rev-list-du.sh b/t/t6115-rev-list-du.sh new file mode 100755 index 0000000000..b4aef32b71 --- /dev/null +++ b/t/t6115-rev-list-du.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +test_description='basic tests of rev-list --disk-usage' +. ./test-lib.sh + +# we want a mix of reachable and unreachable, as well as +# objects in the bitmapped pack and some outside of it +test_expect_success 'set up repository' ' + test_commit --no-tag one && + test_commit --no-tag two && + git repack -adb && + git reset --hard HEAD^ && + test_commit --no-tag three && + test_commit --no-tag four && + git reset --hard HEAD^ +' + +# We don't want to hardcode sizes, because they depend on the exact details of +# packing, zlib, etc. We'll assume that the regular rev-list and cat-file +# machinery works and compare the --disk-usage output to that. +disk_usage_slow () { + git rev-list --no-object-names "$@" | + git cat-file --batch-check="%(objectsize:disk)" | + perl -lne '$total += $_; END { print $total}' +} + +# check behavior with given rev-list options; note that +# whitespace is not preserved in args +check_du () { + args=$* + + test_expect_success "generate expected size ($args)" " + disk_usage_slow $args >expect + " + + test_expect_success "rev-list --disk-usage without bitmaps ($args)" " + git rev-list --disk-usage $args >actual && + test_cmp expect actual + " + + test_expect_success "rev-list --disk-usage with bitmaps ($args)" " + git rev-list --disk-usage --use-bitmap-index $args >actual && + test_cmp expect actual + " +} + +check_du HEAD +check_du --objects HEAD +check_du --objects HEAD^..HEAD + +test_done diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index f822d5d328..e89b6747be 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -11,6 +11,9 @@ test_description='test describe' # # First parent of a merge commit is on the same line, second parent below. +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh check_describe () { @@ -102,7 +105,7 @@ check_describe c-* --tags HEAD^^2 check_describe B --tags HEAD^^2^ check_describe e --tags HEAD^^^ -check_describe heads/master --all HEAD +check_describe heads/main --all HEAD check_describe tags/c-* --all HEAD^ check_describe tags/e --all HEAD^^^ @@ -133,7 +136,7 @@ warning: tag 'Q' is externally known as 'A' EOF check_describe A-* HEAD test_expect_success 'warning was displayed for Q' ' - test_i18ncmp err.expect err.actual + test_cmp err.expect err.actual ' test_expect_success 'misnamed annotated tag forces long output' ' description=$(git describe --no-long Q^0) && @@ -403,15 +406,15 @@ test_expect_success ULIMIT_STACK_SIZE 'name-rev works in a deep repo' ' i=1 && while test $i -lt 8000 do - echo "commit refs/heads/master + echo "commit refs/heads/main committer A U Thor <author@example.com> $((1000000000 + $i * 100)) +0200 data <<EOF commit #$i EOF" - test $i = 1 && echo "from refs/heads/master^0" + test $i = 1 && echo "from refs/heads/main^0" i=$(($i + 1)) done | git fast-import && - git checkout master && + git checkout main && git tag far-far-away HEAD^ && echo "HEAD~4000 tags/far-far-away~3999" >expect && git name-rev HEAD~4000 >actual && @@ -442,7 +445,7 @@ test_expect_success 'describe complains about missing object' ' ' test_expect_success 'name-rev a rev shortly after epoch' ' - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && git checkout --orphan no-timestamp-underflow && # Any date closer to epoch than the CUTOFF_DATE_SLOP constant @@ -456,7 +459,7 @@ test_expect_success 'name-rev a rev shortly after epoch' ' test_cmp expect actual ' -# A--------------master +# A--------------main # \ / # \----------M2 # \ / @@ -487,10 +490,10 @@ test_expect_success 'name-rev covers all conditions while looking at parents' ' git checkout $A && git merge --no-ff HEAD@{1} && # M2 - git checkout master && + git checkout main && git merge --no-ff HEAD@{1} && - echo "$B master^2^2~1^2" >expect && + echo "$B main^2^2~1^2" >expect && git name-rev $B >actual && test_cmp expect actual @@ -516,7 +519,7 @@ test_expect_success 'describe commits with disjoint bases' ' git checkout --orphan branch && rm file && echo B > file2 && git add file2 && git commit -m B && git tag B -a -m B && - git merge --no-ff --allow-unrelated-histories master -m x && + git merge --no-ff --allow-unrelated-histories main -m x && check_describe "A-3-*" HEAD ) @@ -542,7 +545,7 @@ test_expect_success 'describe commits with disjoint bases 2' ' echo o >> file2 && git add file2 && GIT_COMMITTER_DATE="2020-01-01 15:01" git commit -m o && echo B >> file2 && git add file2 && GIT_COMMITTER_DATE="2020-01-01 15:02" git commit -m B && git tag B -a -m B && - git merge --no-ff --allow-unrelated-histories master -m x && + git merge --no-ff --allow-unrelated-histories main -m x && check_describe "B-3-*" HEAD ) diff --git a/t/t6134-pathspec-in-submodule.sh b/t/t6134-pathspec-in-submodule.sh index c670668409..0f1cb49ced 100755 --- a/t/t6134-pathspec-in-submodule.sh +++ b/t/t6134-pathspec-in-submodule.sh @@ -21,7 +21,7 @@ EOF test_expect_success 'error message for path inside submodule' ' echo a >sub/a && test_must_fail git add sub/a 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'error message for path inside submodule from within submodule' ' diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh index f3e66eaf9b..44f55d93fe 100755 --- a/t/t6200-fmt-merge-msg.sh +++ b/t/t6200-fmt-merge-msg.sh @@ -5,6 +5,9 @@ test_description='fmt-merge-msg test' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY/lib-gpg.sh" @@ -81,7 +84,7 @@ test_expect_success GPG 'set up a signed tag' ' test_expect_success 'message for merging local branch' ' echo "Merge branch ${apos}left${apos}" >expected && - git checkout master && + git checkout main && git fetch . left && git fmt-merge-msg <.git/FETCH_HEAD >actual && @@ -89,7 +92,7 @@ test_expect_success 'message for merging local branch' ' ' test_expect_success GPG 'message for merging local tag signed by good key' ' - git checkout master && + git checkout main && git fetch . signed-good-tag && git fmt-merge-msg <.git/FETCH_HEAD >actual 2>&1 && grep "^Merge tag ${apos}signed-good-tag${apos}" actual && @@ -98,7 +101,7 @@ test_expect_success GPG 'message for merging local tag signed by good key' ' ' test_expect_success GPG 'message for merging local tag signed by unknown key' ' - git checkout master && + git checkout main && git fetch . signed-good-tag && GNUPGHOME=. git fmt-merge-msg <.git/FETCH_HEAD >actual 2>&1 && grep "^Merge tag ${apos}signed-good-tag${apos}" actual && @@ -109,7 +112,7 @@ test_expect_success GPG 'message for merging local tag signed by unknown key' ' test_expect_success 'message for merging external branch' ' echo "Merge branch ${apos}left${apos} of $(pwd)" >expected && - git checkout master && + git checkout main && git fetch "$(pwd)" left && git fmt-merge-msg <.git/FETCH_HEAD >actual && @@ -133,7 +136,7 @@ test_expect_success '[merge] summary/log configuration' ' test_config merge.log true && test_unconfig merge.summary && - git checkout master && + git checkout main && test_tick && git fetch . left && @@ -142,7 +145,7 @@ test_expect_success '[merge] summary/log configuration' ' test_unconfig merge.log && test_config merge.summary true && - git checkout master && + git checkout main && test_tick && git fetch . left && @@ -153,7 +156,7 @@ test_expect_success '[merge] summary/log configuration' ' ' test_expect_success 'setup FETCH_HEAD' ' - git checkout master && + git checkout main && test_tick && git fetch . left ' @@ -281,7 +284,7 @@ test_expect_success 'fmt-merge-msg -m' ' test_unconfig merge.log && test_unconfig merge.summary && - git checkout master && + git checkout main && git fetch "$(pwd)" left && git fmt-merge-msg -m "Sync with left" <.git/FETCH_HEAD >actual && git fmt-merge-msg --log -m "Sync with left" \ @@ -323,28 +326,28 @@ test_expect_success 'setup: expected shortlog for two branches' ' test_expect_success 'shortlog for two branches' ' test_config merge.log true && test_unconfig merge.summary && - git checkout master && + git checkout main && test_tick && git fetch . left right && git fmt-merge-msg <.git/FETCH_HEAD >actual1 && test_unconfig merge.log && test_config merge.summary true && - git checkout master && + git checkout main && test_tick && git fetch . left right && git fmt-merge-msg <.git/FETCH_HEAD >actual2 && test_config merge.log yes && test_unconfig merge.summary && - git checkout master && + git checkout main && test_tick && git fetch . left right && git fmt-merge-msg <.git/FETCH_HEAD >actual3 && test_unconfig merge.log && test_config merge.summary yes && - git checkout master && + git checkout main && test_tick && git fetch . left right && git fmt-merge-msg <.git/FETCH_HEAD >actual4 && @@ -358,7 +361,7 @@ test_expect_success 'shortlog for two branches' ' test_expect_success 'merge-msg -F' ' test_unconfig merge.log && test_config merge.summary yes && - git checkout master && + git checkout main && test_tick && git fetch . left right && git fmt-merge-msg -F .git/FETCH_HEAD >actual && @@ -368,7 +371,7 @@ test_expect_success 'merge-msg -F' ' test_expect_success 'merge-msg -F in subdirectory' ' test_unconfig merge.log && test_config merge.summary yes && - git checkout master && + git checkout main && test_tick && git fetch . left right && mkdir sub && @@ -408,7 +411,7 @@ test_expect_success 'merge-msg tag' ' test_unconfig merge.log && test_config merge.summary yes && - git checkout master && + git checkout main && test_tick && git fetch . tag tag-r3 && @@ -438,7 +441,7 @@ test_expect_success 'merge-msg two tags' ' test_unconfig merge.log && test_config merge.summary yes && - git checkout master && + git checkout main && test_tick && git fetch . tag tag-r3 tag tag-l5 && @@ -468,7 +471,7 @@ test_expect_success 'merge-msg tag and branch' ' test_unconfig merge.log && test_config merge.summary yes && - git checkout master && + git checkout main && test_tick && git fetch . tag tag-r3 left && @@ -495,7 +498,7 @@ test_expect_success 'merge-msg lots of commits' ' test_config merge.summary yes && - git checkout master && + git checkout main && test_tick && git fetch . long && @@ -506,11 +509,11 @@ test_expect_success 'merge-msg lots of commits' ' test_expect_success 'merge-msg with "merging" an annotated tag' ' test_config merge.log true && - git checkout master^0 && + git checkout main^0 && git commit --allow-empty -m "One step ahead" && git tag -a -m "An annotated one" annote HEAD && - git checkout master && + git checkout main && git fetch . annote && git fmt-merge-msg <.git/FETCH_HEAD >actual && @@ -543,23 +546,23 @@ test_expect_success 'merge-msg with "merging" an annotated tag' ' ' test_expect_success 'merge.suppressDest configuration' ' - git checkout -B side master && + git checkout -B side main && git commit --allow-empty -m "One step ahead" && - git checkout master && + git checkout main && git fetch . side && git -c merge.suppressDest="" fmt-merge-msg <.git/FETCH_HEAD >full.1 && head -n1 full.1 >actual && - grep -e "Merge branch .side. into master" actual && + grep -e "Merge branch .side. into main" actual && git -c merge.suppressDest="mast" fmt-merge-msg <.git/FETCH_HEAD >full.2 && head -n1 full.2 >actual && - grep -e "Merge branch .side. into master$" actual && + grep -e "Merge branch .side. into main$" actual && git -c merge.suppressDest="ma?*[rn]" fmt-merge-msg <.git/FETCH_HEAD >full.3 && head -n1 full.3 >actual && grep -e "Merge branch .side." actual && - ! grep -e " into master$" actual + ! grep -e " into main$" actual ' test_done diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index 810cdbb6f8..9e0214076b 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -5,6 +5,9 @@ test_description='for-each-ref test' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-gpg.sh . "$TEST_DIRECTORY"/lib-terminal.sh @@ -811,60 +814,159 @@ test_expect_success 'set up trailers for next test' ' EOF ' -test_expect_success '%(trailers:unfold) unfolds trailers' ' - { - unfold <trailers - echo - } >expect && - git for-each-ref --format="%(trailers:unfold)" refs/heads/main >actual && - test_cmp expect actual && - git for-each-ref --format="%(contents:trailers:unfold)" refs/heads/main >actual && - test_cmp expect actual -' +test_trailer_option () { + title=$1 option=$2 + cat >expect + test_expect_success "$title" ' + git for-each-ref --format="%($option)" refs/heads/main >actual && + test_cmp expect actual && + git for-each-ref --format="%(contents:$option)" refs/heads/main >actual && + test_cmp expect actual + ' +} -test_expect_success '%(trailers:only) shows only "key: value" trailers' ' - { - grep -v patch.description <trailers && - echo - } >expect && - git for-each-ref --format="%(trailers:only)" refs/heads/main >actual && - test_cmp expect actual && - git for-each-ref --format="%(contents:trailers:only)" refs/heads/main >actual && - test_cmp expect actual -' +test_trailer_option '%(trailers:unfold) unfolds trailers' \ + 'trailers:unfold' <<-EOF + $(unfold <trailers) -test_expect_success '%(trailers:only) and %(trailers:unfold) work together' ' - { - grep -v patch.description <trailers | unfold && - echo - } >expect && - git for-each-ref --format="%(trailers:only,unfold)" refs/heads/main >actual && - test_cmp expect actual && - git for-each-ref --format="%(trailers:unfold,only)" refs/heads/main >actual && - test_cmp actual actual && - git for-each-ref --format="%(contents:trailers:only,unfold)" refs/heads/main >actual && - test_cmp expect actual && - git for-each-ref --format="%(contents:trailers:unfold,only)" refs/heads/main >actual && - test_cmp actual actual -' - -test_expect_success '%(trailers) rejects unknown trailers arguments' ' - # error message cannot be checked under i18n - cat >expect <<-EOF && + EOF + +test_trailer_option '%(trailers:only) shows only "key: value" trailers' \ + 'trailers:only' <<-EOF + $(grep -v patch.description <trailers) + + EOF + +test_trailer_option '%(trailers:only=no,only=true) shows only "key: value" trailers' \ + 'trailers:only=no,only=true' <<-EOF + $(grep -v patch.description <trailers) + + EOF + +test_trailer_option '%(trailers:only=yes) shows only "key: value" trailers' \ + 'trailers:only=yes' <<-EOF + $(grep -v patch.description <trailers) + + EOF + +test_trailer_option '%(trailers:only=no) shows all trailers' \ + 'trailers:only=no' <<-EOF + $(cat trailers) + + EOF + +test_trailer_option '%(trailers:only) and %(trailers:unfold) work together' \ + 'trailers:only,unfold' <<-EOF + $(grep -v patch.description <trailers | unfold) + + EOF + +test_trailer_option '%(trailers:unfold) and %(trailers:only) work together' \ + 'trailers:unfold,only' <<-EOF + $(grep -v patch.description <trailers | unfold) + + EOF + +test_trailer_option '%(trailers:key=foo) shows that trailer' \ + 'trailers:key=Signed-off-by' <<-EOF + Signed-off-by: A U Thor <author@example.com> + + EOF + +test_trailer_option '%(trailers:key=foo) is case insensitive' \ + 'trailers:key=SiGned-oFf-bY' <<-EOF + Signed-off-by: A U Thor <author@example.com> + + EOF + +test_trailer_option '%(trailers:key=foo:) trailing colon also works' \ + 'trailers:key=Signed-off-by:' <<-EOF + Signed-off-by: A U Thor <author@example.com> + + EOF + +test_trailer_option '%(trailers:key=foo) multiple keys' \ + 'trailers:key=Reviewed-by:,key=Signed-off-by' <<-EOF + Reviewed-by: A U Thor <author@example.com> + Signed-off-by: A U Thor <author@example.com> + + EOF + +test_trailer_option '%(trailers:key=nonexistent) becomes empty' \ + 'trailers:key=Shined-off-by:' <<-EOF + + EOF + +test_trailer_option '%(trailers:key=foo) handles multiple lines even if folded' \ + 'trailers:key=Acked-by' <<-EOF + $(grep -v patch.description <trailers | grep -v Signed-off-by | grep -v Reviewed-by) + + EOF + +test_trailer_option '%(trailers:key=foo,unfold) properly unfolds' \ + 'trailers:key=Signed-Off-by,unfold' <<-EOF + $(unfold <trailers | grep Signed-off-by) + + EOF + +test_trailer_option '%(trailers:key=foo,only=no) also includes nontrailer lines' \ + 'trailers:key=Signed-off-by,only=no' <<-EOF + Signed-off-by: A U Thor <author@example.com> + $(grep patch.description <trailers) + + EOF + +test_trailer_option '%(trailers:key=foo,valueonly) shows only value' \ + 'trailers:key=Signed-off-by,valueonly' <<-EOF + A U Thor <author@example.com> + + EOF + +test_trailer_option '%(trailers:separator) changes separator' \ + 'trailers:separator=%x2C,key=Reviewed-by,key=Signed-off-by:' <<-EOF + Reviewed-by: A U Thor <author@example.com>,Signed-off-by: A U Thor <author@example.com> + EOF + +test_trailer_option '%(trailers:key_value_separator) changes key-value separator' \ + 'trailers:key_value_separator=%x2C,key=Reviewed-by,key=Signed-off-by:' <<-EOF + Reviewed-by,A U Thor <author@example.com> + Signed-off-by,A U Thor <author@example.com> + + EOF + +test_trailer_option '%(trailers:separator,key_value_separator) changes both separators' \ + 'trailers:separator=%x2C,key_value_separator=%x2C,key=Reviewed-by,key=Signed-off-by:' <<-EOF + Reviewed-by,A U Thor <author@example.com>,Signed-off-by,A U Thor <author@example.com> + EOF + +test_failing_trailer_option () { + title=$1 option=$2 + cat >expect + test_expect_success "$title" ' + # error message cannot be checked under i18n + test_must_fail git for-each-ref --format="%($option)" refs/heads/main 2>actual && + test_cmp expect actual && + test_must_fail git for-each-ref --format="%(contents:$option)" refs/heads/main 2>actual && + test_cmp expect actual + ' +} + +test_failing_trailer_option '%(trailers) rejects unknown trailers arguments' \ + 'trailers:unsupported' <<-\EOF fatal: unknown %(trailers) argument: unsupported EOF - test_must_fail git for-each-ref --format="%(trailers:unsupported)" 2>actual && - test_i18ncmp expect actual && - test_must_fail git for-each-ref --format="%(contents:trailers:unsupported)" 2>actual && - test_i18ncmp expect actual -' + +test_failing_trailer_option '%(trailers:key) without value is error' \ + 'trailers:key' <<-\EOF + fatal: expected %(trailers:key=<value>) + EOF test_expect_success 'if arguments, %(contents:trailers) shows error if colon is missing' ' cat >expect <<-EOF && fatal: unrecognized %(contents) argument: trailersonly EOF test_must_fail git for-each-ref --format="%(contents:trailersonly)" 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'basic atom: head contents:trailers' ' @@ -1032,4 +1134,14 @@ test_expect_success 'for-each-ref --ignore-case works on multiple sort keys' ' test_cmp expect actual ' +test_expect_success 'for-each-ref reports broken tags' ' + git tag -m "good tag" broken-tag-good HEAD && + git cat-file tag broken-tag-good >good && + sed s/commit/blob/ <good >bad && + bad=$(git hash-object -w -t tag bad) && + git update-ref refs/tags/broken-tag-bad $bad && + test_must_fail git for-each-ref --format="%(*objectname)" \ + refs/tags/broken-tag-* +' + test_done diff --git a/t/t6301-for-each-ref-errors.sh b/t/t6301-for-each-ref-errors.sh index 809854fc0c..40edf9dab5 100755 --- a/t/t6301-for-each-ref-errors.sh +++ b/t/t6301-for-each-ref-errors.sh @@ -20,8 +20,8 @@ test_expect_success 'Broken refs are reported correctly' ' test_when_finished "rm -f .git/$r" && echo "warning: ignoring broken ref $r" >broken-err && git for-each-ref >out 2>err && - test_i18ncmp full-list out && - test_i18ncmp broken-err err + test_cmp full-list out && + test_cmp broken-err err ' test_expect_success 'NULL_SHA1 refs are reported correctly' ' @@ -31,10 +31,10 @@ test_expect_success 'NULL_SHA1 refs are reported correctly' ' echo "warning: ignoring broken ref $r" >zeros-err && git for-each-ref >out 2>err && test_cmp full-list out && - test_i18ncmp zeros-err err && + test_cmp zeros-err err && git for-each-ref --format="%(objectname) %(refname)" >brief-out 2>brief-err && test_cmp brief-list brief-out && - test_i18ncmp zeros-err brief-err + test_cmp zeros-err brief-err ' test_expect_success 'Missing objects are reported correctly' ' @@ -43,7 +43,7 @@ test_expect_success 'Missing objects are reported correctly' ' test_when_finished "rm -f .git/$r" && echo "fatal: missing object $MISSING for $r" >missing-err && test_must_fail git for-each-ref 2>err && - test_i18ncmp missing-err err && + test_cmp missing-err err && ( cat brief-list && echo "$MISSING $r" diff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh index 9b8c8b2842..1537aa2179 100755 --- a/t/t6302-for-each-ref-filter.sh +++ b/t/t6302-for-each-ref-filter.sh @@ -2,6 +2,9 @@ test_description='test for-each-refs usage of ref-filter APIs' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-gpg.sh @@ -114,6 +117,25 @@ test_expect_success '%(color) must fail' ' test_must_fail git for-each-ref --format="%(color)%(refname)" ' +test_expect_success '%(color:#aa22ac) must succeed' ' + test_when_finished rm -rf test && + git init test && + ( + cd test && + test_commit initial && + git branch -M main && + cat >expect <<-\EOF && + refs/heads/main + refs/tags/initial + EOF + git remote add origin nowhere && + git config branch.main.remote origin && + git config branch.main.merge refs/heads/main && + git for-each-ref --format="%(color:#aa22ac)%(refname)" >actual && + test_cmp expect actual + ) +' + test_expect_success 'left alignment is default' ' cat >expect <<-\EOF && refname is refs/heads/main |refs/heads/main diff --git a/t/t6400-merge-df.sh b/t/t6400-merge-df.sh index 9da0838216..38700d29b5 100755 --- a/t/t6400-merge-df.sh +++ b/t/t6400-merge-df.sh @@ -4,6 +4,9 @@ # test_description='Test merge with directory/file conflicts' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'prepare repository' ' @@ -24,12 +27,12 @@ test_expect_success 'prepare repository' ' ' test_expect_success 'Merge with d/f conflicts' ' - test_expect_code 1 git merge -m "merge msg" master + test_expect_code 1 git merge -m "merge msg" main ' test_expect_success 'F/D conflict' ' git reset --hard && - git checkout master && + git checkout main && rm .git/index && mkdir before && @@ -47,7 +50,7 @@ test_expect_success 'F/D conflict' ' git add . && git commit -m para && - git merge master + git merge main ' test_expect_success 'setup modify/delete + directory/file conflict' ' diff --git a/t/t6402-merge-rename.sh b/t/t6402-merge-rename.sh index 3f64f62224..425dad97d5 100755 --- a/t/t6402-merge-rename.sh +++ b/t/t6402-merge-rename.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='Merge-recursive merging renames' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh modify () { @@ -54,9 +57,9 @@ test_expect_success 'setup' ' git branch change && git branch change+rename && - sed -e "/^g /s/.*/g : master changes a line/" <A >A+ && + sed -e "/^g /s/.*/g : main changes a line/" <A >A+ && mv A+ A && - git commit -a -m "master updates A" && + git commit -a -m "main updates A" && git checkout yellow && rm -f M && @@ -94,7 +97,7 @@ test_expect_success 'setup' ' git update-index --add B && git commit -q -a -m "changed and renamed" && - git checkout master + git checkout main ' test_expect_success 'pull renaming branch into unrenaming one' \ @@ -109,7 +112,7 @@ test_expect_success 'pull renaming branch into unrenaming one' \ sed -ne "/^g/{ p q - }" B | grep master && + }" B | grep main && git diff --exit-code white N ' @@ -134,7 +137,7 @@ test_expect_success 'pull unrenaming branch into renaming one' \ ' git reset --hard && git show-branch && - test_expect_code 1 git pull . master && + test_expect_code 1 git pull . main && git ls-files -u B >b.stages && test_line_count = 3 b.stages && git ls-files -s N >n.stages && @@ -187,7 +190,7 @@ test_expect_success 'interference with untracked working tree file' ' test_expect_success 'interference with untracked working tree file' ' git reset --hard && rm -f A M && - git checkout -f master && + git checkout -f main && git tag -f anchor && git show-branch && git pull . yellow && @@ -198,7 +201,7 @@ test_expect_success 'interference with untracked working tree file' ' test_expect_success 'updated working tree file should prevent the merge' ' git reset --hard && rm -f A M && - git checkout -f master && + git checkout -f main && git tag -f anchor && git show-branch && echo >>M one line addition && @@ -211,7 +214,7 @@ test_expect_success 'updated working tree file should prevent the merge' ' test_expect_success 'updated working tree file should prevent the merge' ' git reset --hard && rm -f A M && - git checkout -f master && + git checkout -f main && git tag -f anchor && git show-branch && echo >>M one line addition && @@ -229,7 +232,7 @@ test_expect_success 'interference with untracked working tree file' ' git tag -f anchor && git show-branch && echo >M this file should not matter && - git pull . master && + git pull . main && test_path_is_file M && ! { git ls-files -s | @@ -764,7 +767,7 @@ test_expect_success 'setup avoid unnecessary update, dir->(file,nothing)' ' git rm -rf df && git commit -mB && - git checkout master && + git checkout main && git rm -rf df && echo bla >df && git add -A && @@ -772,7 +775,7 @@ test_expect_success 'setup avoid unnecessary update, dir->(file,nothing)' ' ' test_expect_success 'avoid unnecessary update, dir->(file,nothing)' ' - git checkout -q master^0 && + git checkout -q main^0 && test-tool chmtime --get -3600 df >expect && git merge side && test-tool chmtime --get df >actual && @@ -794,14 +797,14 @@ test_expect_success 'setup avoid unnecessary update, modify/delete' ' git rm -f file && git commit -m "Delete file" && - git checkout master && + git checkout main && echo bla >file && git add -A && git commit -m "Modify file" ' test_expect_success 'avoid unnecessary update, modify/delete' ' - git checkout -q master^0 && + git checkout -q main^0 && test-tool chmtime --get -3600 file >expect && test_must_fail git merge side && test-tool chmtime --get file >actual && @@ -823,13 +826,13 @@ test_expect_success 'setup avoid unnecessary update, rename/add-dest' ' git add -A && git commit -m "Add file copy" && - git checkout master && + git checkout main && git mv file newfile && git commit -m "Rename file" ' test_expect_success 'avoid unnecessary update, rename/add-dest' ' - git checkout -q master^0 && + git checkout -q main^0 && test-tool chmtime --get -3600 newfile >expect && git merge side && test-tool chmtime --get newfile >actual && @@ -879,15 +882,15 @@ test_expect_success 'setup for use of extended merge markers' ' git mv original_file renamed_file && git commit -mB && - git checkout master && + git checkout main && echo 8.5 >>original_file && git add original_file && git commit -mC ' -test_expect_success 'merge master into rename has correct extended markers' ' +test_expect_success 'merge main into rename has correct extended markers' ' git checkout rename^0 && - test_must_fail git merge -s recursive master^0 && + test_must_fail git merge -s recursive main^0 && cat >expected <<-\EOF && 1 @@ -902,14 +905,14 @@ test_expect_success 'merge master into rename has correct extended markers' ' 9 ======= 8.5 - >>>>>>> master^0:original_file + >>>>>>> main^0:original_file EOF test_cmp expected renamed_file ' -test_expect_success 'merge rename into master has correct extended markers' ' +test_expect_success 'merge rename into main has correct extended markers' ' git reset --hard && - git checkout master^0 && + git checkout main^0 && test_must_fail git merge -s recursive rename^0 && cat >expected <<-\EOF && @@ -945,13 +948,13 @@ test_expect_success 'setup spurious "refusing to lose untracked" message' ' git mv original_file renamed_file && git commit -mB && - git checkout master && + git checkout main && git rm original_file && git commit -mC ' test_expect_success 'no spurious "refusing to lose untracked" message' ' - git checkout master^0 && + git checkout main^0 && test_must_fail git merge rename^0 2>errors.txt && ! grep "refusing to lose untracked file" errors.txt ' diff --git a/t/t6404-recursive-merge.sh b/t/t6404-recursive-merge.sh index b1c3d4dda4..eaf48e941e 100755 --- a/t/t6404-recursive-merge.sh +++ b/t/t6404-recursive-merge.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='Test merge without common ancestors' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # This scenario is based on a real-world repository of Shawn Pearce. @@ -15,15 +18,17 @@ GIT_COMMITTER_DATE="2006-12-12 23:28:00 +0100" export GIT_COMMITTER_DATE test_expect_success 'setup tests' ' + GIT_TEST_COMMIT_GRAPH=0 && + export GIT_TEST_COMMIT_GRAPH && echo 1 >a1 && git add a1 && GIT_AUTHOR_DATE="2006-12-12 23:00:00" git commit -m 1 a1 && - git checkout -b A master && + git checkout -b A main && echo A >a1 && GIT_AUTHOR_DATE="2006-12-12 23:00:01" git commit -m A a1 && - git checkout -b B master && + git checkout -b B main && echo B >a1 && GIT_AUTHOR_DATE="2006-12-12 23:00:02" git commit -m B a1 && @@ -66,7 +71,7 @@ test_expect_success 'setup tests' ' ' test_expect_success 'combined merge conflicts' ' - test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git merge -m final G + test_must_fail git merge -m final G ' test_expect_success 'result contains a conflict' ' @@ -82,6 +87,7 @@ test_expect_success 'result contains a conflict' ' ' test_expect_success 'virtual trees were processed' ' + # TODO: fragile test, relies on ambigious merge-base resolution git ls-files --stage >out && cat >expect <<-EOF && diff --git a/t/t6405-merge-symlinks.sh b/t/t6405-merge-symlinks.sh index 6c0a90d044..7435fce71e 100755 --- a/t/t6405-merge-symlinks.sh +++ b/t/t6405-merge-symlinks.sh @@ -8,6 +8,9 @@ test_description='merging symlinks on filesystem w/o symlink support. This tests that git merge-recursive writes merge results as plain files if core.symlinks is false.' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -19,7 +22,7 @@ test_expect_success 'setup' ' git branch b-file && l=$(printf file | git hash-object -t blob -w --stdin) && echo "120000 $l symlink" | git update-index --index-info && - git commit -m master && + git commit -m main && git checkout b-symlink && l=$(printf file-different | git hash-object -t blob -w --stdin) && echo "120000 $l symlink" | git update-index --index-info && @@ -30,28 +33,28 @@ test_expect_success 'setup' ' git commit -m b-file ' -test_expect_success 'merge master into b-symlink, which has a different symbolic link' ' +test_expect_success 'merge main into b-symlink, which has a different symbolic link' ' git checkout b-symlink && - test_must_fail git merge master + test_must_fail git merge main ' test_expect_success 'the merge result must be a file' ' test_path_is_file symlink ' -test_expect_success 'merge master into b-file, which has a file instead of a symbolic link' ' +test_expect_success 'merge main into b-file, which has a file instead of a symbolic link' ' git reset --hard && git checkout b-file && - test_must_fail git merge master + test_must_fail git merge main ' test_expect_success 'the merge result must be a file' ' test_path_is_file symlink ' -test_expect_success 'merge b-file, which has a file instead of a symbolic link, into master' ' +test_expect_success 'merge b-file, which has a file instead of a symbolic link, into main' ' git reset --hard && - git checkout master && + git checkout main && test_must_fail git merge b-file ' diff --git a/t/t6406-merge-attr.sh b/t/t6406-merge-attr.sh index 76a55f838c..d5a4ac2d81 100755 --- a/t/t6406-merge-attr.sh +++ b/t/t6406-merge-attr.sh @@ -5,6 +5,9 @@ test_description='per path merge controlled by merge attribute' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -19,10 +22,10 @@ test_expect_success setup ' git branch side && for f in text binary union do - echo Master >>$f && git add $f || return 1 + echo Main >>$f && git add $f || return 1 done && test_tick && - git commit -m Master && + git commit -m Main && git checkout side && for f in text binary union @@ -64,7 +67,7 @@ test_expect_success merge ' echo "union merge=union" } >.gitattributes && - if git merge master + if git merge main then echo Gaah, should have conflicted false @@ -87,7 +90,7 @@ test_expect_success 'check merge result in working tree' ' grep "<<<<<<<" text && cmp binary-orig binary && ! grep "<<<<<<<" union && - grep Master union && + grep Main union && grep Side union ' @@ -115,13 +118,13 @@ test_expect_success 'custom merge backend' ' git config --replace-all \ merge.custom.name "custom merge driver for testing" && - git merge master && + git merge main && cmp binary union && sed -e 1,3d text >check-1 && - o=$(git unpack-file master^:text) && + o=$(git unpack-file main^:text) && a=$(git unpack-file side^:text) && - b=$(git unpack-file master:text) && + b=$(git unpack-file main:text) && sh -c "./custom-merge $o $a $b 0 text" && sed -e 1,3d $a >check-2 && cmp check-1 check-2 && @@ -136,7 +139,7 @@ test_expect_success 'custom merge backend' ' git config --replace-all \ merge.custom.name "custom merge driver for testing" && - if git merge master + if git merge main then echo "Eh? should have conflicted" false @@ -146,9 +149,9 @@ test_expect_success 'custom merge backend' ' cmp binary union && sed -e 1,3d text >check-1 && - o=$(git unpack-file master^:text) && + o=$(git unpack-file main^:text) && a=$(git unpack-file anchor:text) && - b=$(git unpack-file master:text) && + b=$(git unpack-file main:text) && sh -c "./custom-merge $o $a $b 0 text" && sed -e 1,3d $a >check-2 && cmp check-1 check-2 && @@ -176,7 +179,7 @@ test_expect_success 'up-to-date merge without common ancestor' ' test_tick && ( cd repo1 && - git fetch ../repo2 master && + git fetch ../repo2 main && git merge --allow-unrelated-histories FETCH_HEAD ) ' @@ -201,7 +204,7 @@ test_expect_success 'custom merge does not lock index' ' # By packaging the command in test_when_finished, we get both # the correctness check and the clean-up. test_when_finished "kill \$(cat sleep.pid)" && - git merge master + git merge main ' test_done diff --git a/t/t6407-merge-binary.sh b/t/t6407-merge-binary.sh index 4e6c7cb77e..d4273f2575 100755 --- a/t/t6407-merge-binary.sh +++ b/t/t6407-merge-binary.sh @@ -2,6 +2,9 @@ test_description='ask merge-recursive to merge binary files' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -20,7 +23,7 @@ test_expect_success setup ' git ls-files -s a >E0 && git ls-files -s m | sed -e "s/ 0 / 3 /" >E3 && test_tick && - git commit -m "master adds some" && + git commit -m "main adds some" && git checkout side && echo rezrov >>m && @@ -39,7 +42,7 @@ test_expect_success resolve ' rm -f a* m* && git reset --hard anchor && - if git merge -s resolve master + if git merge -s resolve main then echo Oops, should not have succeeded false @@ -54,7 +57,7 @@ test_expect_success recursive ' rm -f a* m* && git reset --hard anchor && - if git merge -s recursive master + if git merge -s recursive main then echo Oops, should not have succeeded false diff --git a/t/t6409-merge-subtree.sh b/t/t6409-merge-subtree.sh index b8e8b6f642..d406b2343c 100755 --- a/t/t6409-merge-subtree.sh +++ b/t/t6409-merge-subtree.sh @@ -2,6 +2,9 @@ test_description='subtree merge strategy' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -14,10 +17,10 @@ test_expect_success setup ' echo >>hello world && git add hello && git commit -m second && - git checkout master && + git checkout main && for i in mundo $s; do echo $i; done >hello && git add hello && - git commit -m master + git commit -m main ' @@ -36,7 +39,7 @@ test_expect_success 'setup branch sub' ' ' test_expect_success 'setup topic branch' ' - git checkout -b topic master && + git checkout -b topic main && git merge -s ours --no-commit --allow-unrelated-histories sub && git read-tree --prefix=dir/ -u sub && git commit -m "initial merge of sub into topic" && @@ -77,8 +80,8 @@ test_expect_success 'setup' ' test_expect_success 'initial merge' ' git remote add -f gui ../git-gui && - git merge -s ours --no-commit --allow-unrelated-histories gui/master && - git read-tree --prefix=git-gui/ -u gui/master && + git merge -s ours --no-commit --allow-unrelated-histories gui/main && + git read-tree --prefix=git-gui/ -u gui/main && git commit -m "Merge git-gui as our subdirectory" && git checkout -b work && git ls-files -s >actual && @@ -108,10 +111,10 @@ test_expect_success 'merge update' ' test_expect_success 'initial ambiguous subtree' ' cd ../git && - git reset --hard master && + git reset --hard main && git checkout -b topic_2 && - git merge -s ours --no-commit gui/master && - git read-tree --prefix=git-gui2/ -u gui/master && + git merge -s ours --no-commit gui/main && + git read-tree --prefix=git-gui2/ -u gui/main && git commit -m "Merge git-gui2 as our subdirectory" && git checkout -b work2 && git ls-files -s >actual && diff --git a/t/t6411-merge-filemode.sh b/t/t6411-merge-filemode.sh index 87741efad3..f54c915d6a 100755 --- a/t/t6411-merge-filemode.sh +++ b/t/t6411-merge-filemode.sh @@ -1,17 +1,20 @@ #!/bin/sh test_description='merge: handle file mode' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'set up mode change in one branch' ' : >file1 && git add file1 && git commit -m initial && - git checkout -b a1 master && + git checkout -b a1 main && : >dummy && git add dummy && git commit -m a && - git checkout -b b1 master && + git checkout -b b1 main && test_chmod +x file1 && git add file1 && git commit -m b1 @@ -39,12 +42,12 @@ do_one_mode resolve b1 a1 test_expect_success 'set up mode change in both branches' ' git reset --hard HEAD && - git checkout -b a2 master && + git checkout -b a2 main && : >file2 && H=$(git hash-object file2) && test_chmod +x file2 && git commit -m a2 && - git checkout -b b2 master && + git checkout -b b2 main && : >file2 && git add file2 && git commit -m b2 && @@ -76,7 +79,7 @@ do_both_modes resolve test_expect_success 'set up delete/modechange scenario' ' git reset --hard && - git checkout -b deletion master && + git checkout -b deletion main && git rm file1 && git commit -m deletion ' diff --git a/t/t6412-merge-large-rename.sh b/t/t6412-merge-large-rename.sh index 80777386dc..c50d315722 100755 --- a/t/t6412-merge-large-rename.sh +++ b/t/t6412-merge-large-rename.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='merging with large rename matrix' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh count() { @@ -30,7 +33,7 @@ test_rename() { test_expect_success "rename ($1, $2)" ' n='$1' && expect='$2' && - git checkout -f master && + git checkout -f main && test_might_fail git branch -D test$n && git reset --hard initial && for i in $(count $n); do @@ -50,8 +53,8 @@ test_rename() { git add . && git commit -m change+rename=$n && case "$expect" in - ok) git merge master ;; - *) test_must_fail git merge master ;; + ok) git merge main ;; + *) test_must_fail git merge main ;; esac ' } diff --git a/t/t6413-merge-crlf.sh b/t/t6413-merge-crlf.sh index e8d65eefb5..affea255fe 100755 --- a/t/t6413-merge-crlf.sh +++ b/t/t6413-merge-crlf.sh @@ -8,6 +8,9 @@ test_description='merge conflict in crlf repo ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -24,7 +27,7 @@ test_expect_success setup ' echo line from b | append_cr >file && git commit -m "add line from b" file && git tag b && - git checkout master + git checkout main ' test_expect_success 'Check "ours" is CRLF' ' diff --git a/t/t6414-merge-rename-nocruft.sh b/t/t6414-merge-rename-nocruft.sh index a25e730460..d7e3c1fa6e 100755 --- a/t/t6414-merge-rename-nocruft.sh +++ b/t/t6414-merge-rename-nocruft.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='Merge-recursive merging renames' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -65,7 +68,7 @@ test_expect_success 'setup' ' git update-index A && git commit -m "blue modify A" && - git checkout master + git checkout main ' # This test broke in 65ac6e9c3f47807cb603af07a6a9e1a43bc119ae diff --git a/t/t6415-merge-dir-to-symlink.sh b/t/t6415-merge-dir-to-symlink.sh index 2eddcc7664..2ce104aca7 100755 --- a/t/t6415-merge-dir-to-symlink.sh +++ b/t/t6415-merge-dir-to-symlink.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='merging when a directory was replaced with a symlink' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'create a commit where dir a/b changed to symlink' ' @@ -19,7 +22,7 @@ test_expect_success 'create a commit where dir a/b changed to symlink' ' test_expect_success 'checkout does not clobber untracked symlink' ' git checkout HEAD^0 && - git reset --hard master && + git reset --hard main && git rm --cached a/b && git commit -m "untracked symlink remains" && test_must_fail git checkout start^0 @@ -27,7 +30,7 @@ test_expect_success 'checkout does not clobber untracked symlink' ' test_expect_success 'a/b-2/c/d is kept when clobbering symlink b' ' git checkout HEAD^0 && - git reset --hard master && + git reset --hard main && git rm --cached a/b && git commit -m "untracked symlink remains" && git checkout -f start^0 && @@ -36,7 +39,7 @@ test_expect_success 'a/b-2/c/d is kept when clobbering symlink b' ' test_expect_success 'checkout should not have deleted a/b-2/c/d' ' git checkout HEAD^0 && - git reset --hard master && + git reset --hard main && git checkout start^0 && test_path_is_file a/b-2/c/d ' @@ -53,7 +56,7 @@ test_expect_success 'setup for merge test' ' test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (resolve)' ' git reset --hard && git checkout baseline^0 && - git merge -s resolve master && + git merge -s resolve main && test_path_is_file a/b-2/c/d ' @@ -64,7 +67,7 @@ test_expect_success SYMLINKS 'a/b was resolved as symlink' ' test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (recursive)' ' git reset --hard && git checkout baseline^0 && - git merge -s recursive master && + git merge -s recursive main && test_path_is_file a/b-2/c/d ' @@ -74,7 +77,7 @@ test_expect_success SYMLINKS 'a/b was resolved as symlink' ' test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (resolve)' ' git reset --hard && - git checkout master^0 && + git checkout main^0 && git merge -s resolve baseline^0 && test_path_is_file a/b-2/c/d ' @@ -85,7 +88,7 @@ test_expect_success SYMLINKS 'a/b was resolved as symlink' ' test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (recursive)' ' git reset --hard && - git checkout master^0 && + git checkout main^0 && git merge -s recursive baseline^0 && test_path_is_file a/b-2/c/d ' @@ -98,7 +101,7 @@ test_expect_failure 'do not lose untracked in merge (resolve)' ' git reset --hard && git checkout baseline^0 && >a/b/c/e && - test_must_fail git merge -s resolve master && + test_must_fail git merge -s resolve main && test_path_is_file a/b/c/e && test_path_is_file a/b-2/c/d ' @@ -107,7 +110,7 @@ test_expect_success 'do not lose untracked in merge (recursive)' ' git reset --hard && git checkout baseline^0 && >a/b/c/e && - test_must_fail git merge -s recursive master && + test_must_fail git merge -s recursive main && test_path_is_file a/b/c/e && test_path_is_file a/b-2/c/d ' @@ -116,14 +119,14 @@ test_expect_success 'do not lose modifications in merge (resolve)' ' git reset --hard && git checkout baseline^0 && echo more content >>a/b/c/d && - test_must_fail git merge -s resolve master + test_must_fail git merge -s resolve main ' test_expect_success 'do not lose modifications in merge (recursive)' ' git reset --hard && git checkout baseline^0 && echo more content >>a/b/c/d && - test_must_fail git merge -s recursive master + test_must_fail git merge -s recursive main ' test_expect_success 'setup a merge where dir a/b-2 changed to symlink' ' diff --git a/t/t6416-recursive-corner-cases.sh b/t/t6416-recursive-corner-cases.sh index 887c2195a9..84f5082366 100755 --- a/t/t6416-recursive-corner-cases.sh +++ b/t/t6416-recursive-corner-cases.sh @@ -2,6 +2,9 @@ test_description='recursive merge corner cases involving criss-cross merges' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-merge.sh @@ -385,7 +388,7 @@ test_expect_success 'git detects conflict merging criss-cross+modify/delete' ' test_line_count = 2 out && git rev-parse >expect \ - master:file B:file && + main:file B:file && git rev-parse >actual \ :1:file :2:file && test_cmp expect actual @@ -407,7 +410,7 @@ test_expect_success 'git detects conflict merging criss-cross+modify/delete, rev test_line_count = 2 out && git rev-parse >expect \ - master:file B:file && + main:file B:file && git rev-parse >actual \ :1:file :3:file && test_cmp expect actual @@ -1553,12 +1556,12 @@ test_expect_failure 'check conflicting modes for regular file' ' # Setup: # L1---L2 # / \ / \ -# master X ? +# main X ? # \ / \ / # R1---R2 # # Where: -# master has two files, named 'b' and 'a' +# main has two files, named 'b' and 'a' # branches L1 and R1 both modify each of the two files in conflicting ways # # L2 is a merge of R1 into L1; more on it later. @@ -1663,7 +1666,7 @@ test_expect_success 'check nested conflicts' ' cd nested_conflicts && git clean -f && - MASTER=$(git rev-parse --short master) && + MAIN=$(git rev-parse --short main) && git checkout L2^0 && # Merge must fail; there is a conflict @@ -1679,24 +1682,24 @@ test_expect_success 'check nested conflicts' ' test_line_count = 1 out && # Create a and b from virtual merge base X - git cat-file -p master:a >base && + git cat-file -p main:a >base && git cat-file -p L1:a >ours && git cat-file -p R1:a >theirs && test_must_fail git merge-file --diff3 \ -L "Temporary merge branch 1" \ - -L "$MASTER" \ + -L "$MAIN" \ -L "Temporary merge branch 2" \ ours \ base \ theirs && sed -e "s/^\([<|=>]\)/\1\1/" ours >vmb_a && - git cat-file -p master:b >base && + git cat-file -p main:b >base && git cat-file -p L1:b >ours && git cat-file -p R1:b >theirs && test_must_fail git merge-file --diff3 \ -L "Temporary merge branch 1" \ - -L "$MASTER" \ + -L "$MAIN" \ -L "Temporary merge branch 2" \ ours \ base \ @@ -1748,12 +1751,12 @@ test_expect_success 'check nested conflicts' ' # Setup: # L1---L2---L3 # / \ / \ / \ -# master X1 X2 ? +# main X1 X2 ? # \ / \ / \ / # R1---R2---R3 # # Where: -# master has one file named 'content' +# main has one file named 'content' # branches L1 and R1 both modify each of the two files in conflicting ways # # L<n> (n>1) is a merge of R<n-1> into L<n-1> @@ -1834,7 +1837,7 @@ test_expect_success 'check virtual merge base with nested conflicts' ' ( cd virtual_merge_base_has_nested_conflicts && - MASTER=$(git rev-parse --short master) && + MAIN=$(git rev-parse --short main) && git checkout L3^0 && # Merge must fail; there is a conflict @@ -1857,13 +1860,13 @@ test_expect_success 'check virtual merge base with nested conflicts' ' # Imitate X1 merge base, except without long enough conflict # markers because a subsequent sed will modify them. Put # result into vmb. - git cat-file -p master:content >base && + git cat-file -p main:content >base && git cat-file -p L:content >left && git cat-file -p R:content >right && cp left merged-once && test_must_fail git merge-file --diff3 \ -L "Temporary merge branch 1" \ - -L "$MASTER" \ + -L "$MAIN" \ -L "Temporary merge branch 2" \ merged-once \ base \ diff --git a/t/t6417-merge-ours-theirs.sh b/t/t6417-merge-ours-theirs.sh index 0aebc6c028..ac9aee9a66 100755 --- a/t/t6417-merge-ours-theirs.sh +++ b/t/t6417-merge-ours-theirs.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='Merge-recursive ours and theirs variants' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -20,11 +23,11 @@ test_expect_success setup ' sed -e "s/9/nueve/" >file <elif && git commit -a -m theirs && - git checkout master^0 + git checkout main^0 ' test_expect_success 'plain recursive - should conflict' ' - git reset --hard master && + git reset --hard main && test_must_fail git merge -s recursive side && grep nine file && grep nueve file && @@ -34,7 +37,7 @@ test_expect_success 'plain recursive - should conflict' ' ' test_expect_success 'recursive favouring theirs' ' - git reset --hard master && + git reset --hard main && git merge -s recursive -Xtheirs side && ! grep nine file && grep nueve file && @@ -44,7 +47,7 @@ test_expect_success 'recursive favouring theirs' ' ' test_expect_success 'recursive favouring ours' ' - git reset --hard master && + git reset --hard main && git merge -s recursive -X ours side && grep nine file && ! grep nueve file && @@ -56,26 +59,26 @@ test_expect_success 'recursive favouring ours' ' test_expect_success 'binary file with -Xours/-Xtheirs' ' echo file binary >.gitattributes && - git reset --hard master && + git reset --hard main && git merge -s recursive -X theirs side && git diff --exit-code side HEAD -- file && - git reset --hard master && + git reset --hard main && git merge -s recursive -X ours side && - git diff --exit-code master HEAD -- file + git diff --exit-code main HEAD -- file ' test_expect_success 'pull passes -X to underlying merge' ' - git reset --hard master && git pull -s recursive -Xours . side && - git reset --hard master && git pull -s recursive -X ours . side && - git reset --hard master && git pull -s recursive -Xtheirs . side && - git reset --hard master && git pull -s recursive -X theirs . side && - git reset --hard master && test_must_fail git pull -s recursive -X bork . side + git reset --hard main && git pull -s recursive -Xours . side && + git reset --hard main && git pull -s recursive -X ours . side && + git reset --hard main && git pull -s recursive -Xtheirs . side && + git reset --hard main && git pull -s recursive -X theirs . side && + git reset --hard main && test_must_fail git pull -s recursive -X bork . side ' test_expect_success SYMLINKS 'symlink with -Xours/-Xtheirs' ' - git reset --hard master && - git checkout -b two master && + git reset --hard main && + git checkout -b two main && ln -s target-zero link && git add link && git commit -m "add link pointing to zero" && diff --git a/t/t6418-merge-text-auto.sh b/t/t6418-merge-text-auto.sh index 30983d18b1..1e0296dd17 100755 --- a/t/t6418-merge-text-auto.sh +++ b/t/t6418-merge-text-auto.sh @@ -2,16 +2,19 @@ test_description='CRLF merge conflict across text=auto change -* [master] remove .gitattributes +* [main] remove .gitattributes ! [side] add line from b -- + [side] add line from b -* [master] remove .gitattributes -* [master^] add line from a -* [master~2] normalize file +* [main] remove .gitattributes +* [main^] add line from a +* [main~2] normalize file *+ [side^] Initial ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_have_prereq SED_STRIPS_CR && SED_OPTIONS=-b @@ -64,7 +67,7 @@ test_expect_success setup ' git commit -m "add line from b" && git tag b && - git checkout master + git checkout main ' test_expect_success 'set up fuzz_conflict() helper' ' @@ -195,7 +198,7 @@ test_expect_success 'Test delete/normalize conflict' ' git reset --hard initial && git rm file && git commit -m "remove file" && - git checkout master && + git checkout main && git reset --hard a^ && git merge side && test_path_is_missing file diff --git a/t/t6419-merge-ignorecase.sh b/t/t6419-merge-ignorecase.sh index 531850d834..b64b75acf5 100755 --- a/t/t6419-merge-ignorecase.sh +++ b/t/t6419-merge-ignorecase.sh @@ -2,6 +2,9 @@ test_description='git-merge with case-changing rename on case-insensitive file system' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh if ! test_have_prereq CASE_INSENSITIVE_FS @@ -20,18 +23,18 @@ test_expect_success 'merge with case-changing rename' ' >foo && git add foo && git commit -m "intervening commit" && - git checkout master && + git checkout main && git rm TestCase && >testcase && git add testcase && git commit -m "rename to testcase" && git checkout with-camel && - git merge master -m "merge" && + git merge main -m "merge" && test_path_is_file testcase ' test_expect_success 'merge with case-changing rename on both sides' ' - git checkout master && + git checkout main && git reset --hard baseline && git branch -D with-camel && git checkout -b with-camel && @@ -40,13 +43,13 @@ test_expect_success 'merge with case-changing rename on both sides' ' >foo && git add foo && git commit -m "intervening commit" && - git checkout master && + git checkout main && git rm TestCase && >testcase && git add testcase && git commit -m "rename to testcase" && git checkout with-camel && - git merge master -m "merge" && + git merge main -m "merge" && test_path_is_file testcase ' diff --git a/t/t6422-merge-rename-corner-cases.sh b/t/t6422-merge-rename-corner-cases.sh index 78bfaf17f0..bf4ce3c63d 100755 --- a/t/t6422-merge-rename-corner-cases.sh +++ b/t/t6422-merge-rename-corner-cases.sh @@ -3,6 +3,9 @@ test_description="recursive merge corner cases w/ renames but not criss-crosses" # t6036 has corner cases that involve both criss-cross merges and renames +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-merge.sh @@ -1130,7 +1133,7 @@ test_conflicts_with_adds_and_renames() { # Setup: # L # / \ - # master ? + # main ? # \ / # R # @@ -1260,7 +1263,7 @@ test_conflicts_with_adds_and_renames() { :2:three \ :3:three && git rev-parse >expected \ - master:irrelevant_file \ + main:irrelevant_file \ file_v2 \ file_v4 && test_cmp expected actual && @@ -1290,12 +1293,12 @@ test_conflicts_with_adds_and_renames add add # Setup: # L # / \ -# master ? +# main ? # \ / # R # # Where: -# master has two files, named 'one' and 'two'. +# main has two files, named 'one' and 'two'. # branches L and R both modify 'one', in conflicting ways. # branches L and R both modify 'two', in conflicting ways. # branch L also renames 'one' to 'three'. @@ -1376,7 +1379,7 @@ test_expect_success 'check nested conflicts from rename/rename(2to1)' ' test_line_count = 1 out && # Compare :2:three to expected values - git cat-file -p master:one >base && + git cat-file -p main:one >base && git cat-file -p L:three >ours && git cat-file -p R:one >theirs && test_must_fail git merge-file \ @@ -1387,7 +1390,7 @@ test_expect_success 'check nested conflicts from rename/rename(2to1)' ' test_cmp expect L-three && # Compare :2:three to expected values - git cat-file -p master:two >base && + git cat-file -p main:two >base && git cat-file -p L:two >ours && git cat-file -p R:three >theirs && test_must_fail git merge-file \ diff --git a/t/t6423-merge-rename-directories.sh b/t/t6423-merge-rename-directories.sh index 4ab133f489..7134769149 100755 --- a/t/t6423-merge-rename-directories.sh +++ b/t/t6423-merge-rename-directories.sh @@ -2905,7 +2905,7 @@ test_setup_9e () { ) } -test_expect_success C_LOCALE_OUTPUT '9e: N-to-1 whammo' ' +test_expect_success '9e: N-to-1 whammo' ' test_setup_9e && ( cd 9e && @@ -4797,7 +4797,7 @@ test_setup_12f () { ) } -test_expect_merge_algorithm failure success '12f: Trivial directory resolve, caching, all kinds of fun' ' +test_expect_merge_algorithm failure failure '12f: Trivial directory resolve, caching, all kinds of fun' ' test_setup_12f && ( cd 12f && @@ -4895,6 +4895,77 @@ test_expect_merge_algorithm failure success '12f: Trivial directory resolve, cac ) ' +# Testcase 12g, Testcase with two kinds of "relevant" renames +# Commit O: somefile_O, subdir/{a_O,b_O} +# Commit A: somefile_A, subdir/{a_O,b_O,c_A} +# Commit B: newfile_B, newdir/{a_B,b_B} +# Expected: newfile_{merged}, newdir/{a_B,b_B,c_A} + +test_setup_12g () { + test_create_repo 12g && + ( + cd 12g && + + mkdir -p subdir && + test_write_lines upon a time there was a >somefile && + test_write_lines 1 2 3 4 5 6 7 8 9 10 >subdir/a && + test_write_lines one two three four five six >subdir/b && + git add . && + test_tick && + git commit -m "O" && + + git branch O && + git branch A && + git branch B && + + git switch A && + test_write_lines once upon a time there was a >somefile && + > subdir/c && + git add somefile subdir/c && + test_tick && + git commit -m "A" && + + git checkout B && + git mv somefile newfile && + git mv subdir newdir && + echo repo >>newfile && + test_write_lines 1 2 3 4 5 6 7 8 9 10 11 >newdir/a && + test_write_lines one two three four five six seven >newdir/b && + git add newfile newdir && + test_tick && + git commit -m "B" + ) +} + +test_expect_success '12g: Testcase with two kinds of "relevant" renames' ' + test_setup_12g && + ( + cd 12g && + + git checkout A^0 && + + git -c merge.directoryRenames=true merge -s recursive B^0 && + + test_write_lines once upon a time there was a repo >expect && + test_cmp expect newfile && + + git ls-files -s >out && + test_line_count = 4 out && + + git rev-parse >actual \ + HEAD:newdir/a HEAD:newdir/b HEAD:newdir/c && + git rev-parse >expect \ + B:newdir/a B:newdir/b A:subdir/c && + test_cmp expect actual && + + test_must_fail git rev-parse HEAD:subdir/a && + test_must_fail git rev-parse HEAD:subdir/b && + test_must_fail git rev-parse HEAD:subdir/c && + test_path_is_missing subdir/ && + test_path_is_file newdir/c + ) +' + ########################################################################### # SECTION 13: Checking informational and conflict messages # diff --git a/t/t6425-merge-rename-delete.sh b/t/t6425-merge-rename-delete.sh index f79d021590..459b431a60 100755 --- a/t/t6425-merge-rename-delete.sh +++ b/t/t6425-merge-rename-delete.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='Merge-recursive rename/delete conflict message' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'rename/delete' ' @@ -12,7 +15,7 @@ test_expect_success 'rename/delete' ' git mv A B && git commit -m "rename" && - git checkout master && + git checkout main && git rm A && git commit -m "delete" && diff --git a/t/t6426-merge-skip-unneeded-updates.sh b/t/t6426-merge-skip-unneeded-updates.sh index d7eeee4310..7b5f1c1dcd 100755 --- a/t/t6426-merge-skip-unneeded-updates.sh +++ b/t/t6426-merge-skip-unneeded-updates.sh @@ -492,7 +492,9 @@ test_expect_success '3a-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' test_cmp expect actual && test_must_fail git rev-parse HEAD:bq HEAD:foo/bq && - test_path_is_missing bq foo/bq foo/whatever + test_path_is_missing bq && + test_path_is_missing foo/bq && + test_path_is_missing foo/whatever ) ' @@ -522,7 +524,9 @@ test_expect_success '3a-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' test_cmp expect actual && test_must_fail git rev-parse HEAD:bq HEAD:foo/bq && - test_path_is_missing bq foo/bq foo/whatever + test_path_is_missing bq && + test_path_is_missing foo/bq && + test_path_is_missing foo/whatever ) ' @@ -588,7 +592,9 @@ test_expect_success '3b-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' test_cmp expect actual && test_must_fail git rev-parse HEAD:bq HEAD:foo/bq && - test_path_is_missing bq foo/bq foo/whatever + test_path_is_missing bq && + test_path_is_missing foo/bq && + test_path_is_missing foo/whatever ) ' @@ -618,7 +624,9 @@ test_expect_success '3b-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' test_cmp expect actual && test_must_fail git rev-parse HEAD:bq HEAD:foo/bq && - test_path_is_missing bq foo/bq foo/whatever + test_path_is_missing bq && + test_path_is_missing foo/bq && + test_path_is_missing foo/whatever ) ' diff --git a/t/t6427-diff3-conflict-markers.sh b/t/t6427-diff3-conflict-markers.sh index f4655bb358..25c4b720e7 100755 --- a/t/t6427-diff3-conflict-markers.sh +++ b/t/t6427-diff3-conflict-markers.sh @@ -2,6 +2,9 @@ test_description='recursive merge diff3 style conflict markers' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # Setup: @@ -43,7 +46,7 @@ test_expect_success 'check no merge base' ' # Setup: # L1 # / \ -# master ? +# main ? # \ / # R1 # @@ -90,18 +93,18 @@ test_expect_success 'check unique merge base' ' cd unique_merge_base && git checkout L^0 && - MASTER=$(git rev-parse --short master) && + MAIN=$(git rev-parse --short main) && test_must_fail git -c merge.conflictstyle=diff3 merge -s recursive R^0 && - grep "|||||| $MASTER:content" renamed + grep "|||||| $MAIN:content" renamed ) ' # Setup: # L1---L2--L3 # / \ / \ -# master X1 ? +# main X1 ? # \ / \ / # R1---R2--R3 # @@ -191,10 +194,10 @@ test_expect_success 'rebase --merge describes parent of commit being picked' ' ( cd rebase && test_commit base file && - test_commit master file && + test_commit main file && git checkout -b side HEAD^ && test_commit side file && - test_must_fail git -c merge.conflictstyle=diff3 rebase --merge master && + test_must_fail git -c merge.conflictstyle=diff3 rebase --merge main && grep "||||||| parent of" file ) ' @@ -203,7 +206,7 @@ test_expect_success 'rebase --apply describes fake ancestor base' ' ( cd rebase && git rebase --abort && - test_must_fail git -c merge.conflictstyle=diff3 rebase --apply master && + test_must_fail git -c merge.conflictstyle=diff3 rebase --apply main && grep "||||||| constructed merge base" file ) ' diff --git a/t/t6428-merge-conflicts-sparse.sh b/t/t6428-merge-conflicts-sparse.sh new file mode 100755 index 0000000000..7e8bf497f8 --- /dev/null +++ b/t/t6428-merge-conflicts-sparse.sh @@ -0,0 +1,158 @@ +#!/bin/sh + +test_description="merge cases" + +# The setup for all of them, pictorially, is: +# +# A +# o +# / \ +# O o ? +# \ / +# o +# B +# +# To help make it easier to follow the flow of tests, they have been +# divided into sections and each test will start with a quick explanation +# of what commits O, A, and B contain. +# +# Notation: +# z/{b,c} means files z/b and z/c both exist +# x/d_1 means file x/d exists with content d1. (Purpose of the +# underscore notation is to differentiate different +# files that might be renamed into each other's paths.) + +. ./test-lib.sh +. "$TEST_DIRECTORY"/lib-merge.sh + + +# Testcase basic, conflicting changes in 'numerals' + +test_setup_numerals () { + test_create_repo numerals_$1 && + ( + cd numerals_$1 && + + >README && + test_write_lines I II III >numerals && + git add README numerals && + test_tick && + git commit -m "O" && + + git branch O && + git branch A && + git branch B && + + git checkout A && + test_write_lines I II III IIII >numerals && + git add numerals && + test_tick && + git commit -m "A" && + + git checkout B && + test_write_lines I II III IV >numerals && + git add numerals && + test_tick && + git commit -m "B" && + + cat <<-EOF >expected-index && + H README + M numerals + M numerals + M numerals + EOF + + cat <<-EOF >expected-merge + I + II + III + <<<<<<< HEAD + IIII + ======= + IV + >>>>>>> B^0 + EOF + + ) +} + +test_expect_success 'conflicting entries written to worktree even if sparse' ' + test_setup_numerals plain && + ( + cd numerals_plain && + + git checkout A^0 && + + test_path_is_file README && + test_path_is_file numerals && + + git sparse-checkout init && + git sparse-checkout set README && + + test_path_is_file README && + test_path_is_missing numerals && + + test_must_fail git merge -s recursive B^0 && + + git ls-files -t >index_files && + test_cmp expected-index index_files && + + test_path_is_file README && + test_path_is_file numerals && + + test_cmp expected-merge numerals && + + # 4 other files: + # * expected-merge + # * expected-index + # * index_files + # * others + git ls-files -o >others && + test_line_count = 4 others + ) +' + +test_expect_merge_algorithm failure success 'present-despite-SKIP_WORKTREE handled reasonably' ' + test_setup_numerals in_the_way && + ( + cd numerals_in_the_way && + + git checkout A^0 && + + test_path_is_file README && + test_path_is_file numerals && + + git sparse-checkout init && + git sparse-checkout set README && + + test_path_is_file README && + test_path_is_missing numerals && + + echo foobar >numerals && + + test_must_fail git merge -s recursive B^0 && + + git ls-files -t >index_files && + test_cmp expected-index index_files && + + test_path_is_file README && + test_path_is_file numerals && + + test_cmp expected-merge numerals && + + # There should still be a file with "foobar" in it + grep foobar * && + + # 5 other files: + # * expected-merge + # * expected-index + # * index_files + # * others + # * whatever name was given to the numerals file that had + # "foobar" in it + git ls-files -o >others && + test_line_count = 5 others + ) +' + +test_done diff --git a/t/t6430-merge-recursive.sh b/t/t6430-merge-recursive.sh index 9c08e63af2..ffcc01fe65 100755 --- a/t/t6430-merge-recursive.sh +++ b/t/t6430-merge-recursive.sh @@ -2,6 +2,9 @@ test_description='merge-recursive backend test' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-merge.sh @@ -35,7 +38,7 @@ test_expect_success 'setup 1' ' git add a d/e && test_tick && - git commit -m "master modifies a and d/e" && + git commit -m "main modifies a and d/e" && c1=$(git rev-parse --verify HEAD) && ( git ls-tree -r HEAD && git ls-files -s ) >actual && ( @@ -466,7 +469,7 @@ test_expect_success SYMLINKS 'dir in working tree with symlink ancestor does not git checkout -b branch1 && git commit --allow-empty -m "empty commit" && - git checkout master && + git checkout main && git rm foo && mkdir foo && >foo/bar && @@ -475,7 +478,7 @@ test_expect_success SYMLINKS 'dir in working tree with symlink ancestor does not git checkout branch1 && - git cherry-pick master && + git cherry-pick main && test_path_is_dir foo && test_path_is_file foo/bar ) @@ -490,8 +493,8 @@ test_expect_success 'reset and 3-way merge' ' test_expect_success 'reset and bind merge' ' - git reset --hard master && - git read-tree --prefix=M/ master && + git reset --hard main && + git read-tree --prefix=M/ main && git ls-files -s >actual && ( echo "100644 $o1 0 M/a" && @@ -505,7 +508,7 @@ test_expect_success 'reset and bind merge' ' ) >expected && test_cmp expected actual && - git read-tree --prefix=a1/ master && + git read-tree --prefix=a1/ main && git ls-files -s >actual && ( echo "100644 $o1 0 M/a" && @@ -523,7 +526,7 @@ test_expect_success 'reset and bind merge' ' ) >expected && test_cmp expected actual && - git read-tree --prefix=z/ master && + git read-tree --prefix=z/ main && git ls-files -s >actual && ( echo "100644 $o1 0 M/a" && @@ -599,11 +602,11 @@ test_expect_success 'merge-recursive w/ empty work tree - theirs has rename' ' test_expect_success 'merge removes empty directories' ' - git reset --hard master && + git reset --hard main && git checkout -b rm && git rm d/e && git commit -mremoved-d/e && - git checkout master && + git checkout main && git merge -s recursive rm && test_path_is_missing d ' diff --git a/t/t6432-merge-recursive-space-options.sh b/t/t6432-merge-recursive-space-options.sh index b56180ee4a..db4b77e63d 100755 --- a/t/t6432-merge-recursive-space-options.sh +++ b/t/t6432-merge-recursive-space-options.sh @@ -2,15 +2,18 @@ test_description='merge-recursive space options -* [master] Clarify +* [main] Clarify ! [remote] Remove cruft -- + [remote] Remove cruft -* [master] Clarify +* [main] Clarify *+ [remote^] Initial revision * ok 1: setup ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_have_prereq SED_STRIPS_CR && SED_OPTIONS=-b @@ -87,7 +90,7 @@ test_expect_success 'setup' ' mv text.txt+ text.txt && git commit -a -m "Remove cruft" && - git checkout master && + git checkout main && sed -e " s/\(not in his right mind\),\(.*\)/\1;\2Q/ s/Quite correct\(.*\)/It is too correct\1Q/ diff --git a/t/t6433-merge-toplevel.sh b/t/t6433-merge-toplevel.sh index e29c284b9b..b16031465f 100755 --- a/t/t6433-merge-toplevel.sh +++ b/t/t6433-merge-toplevel.sh @@ -2,10 +2,13 @@ test_description='"git merge" top-level frontend' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh t3033_reset () { - git checkout -B master two && + git checkout -B main two && git branch -f left three && git branch -f right four } @@ -21,7 +24,7 @@ test_expect_success setup ' test_commit four && git checkout --orphan newroot && test_commit five && - git checkout master + git checkout main ' # Local branches @@ -61,7 +64,7 @@ test_expect_success 'merge octopus, non-fast-forward (ff)' ' test_expect_success 'merge octopus, fast-forward (does not ff)' ' t3033_reset && git merge left right && - # two (master) is not an ancestor of three (left) and four (right) + # two (main) is not an ancestor of three (left) and four (right) test_must_fail git rev-parse --verify HEAD^4 && git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual && git rev-parse two three four | sort >expect && @@ -118,7 +121,7 @@ test_expect_success 'merge FETCH_HEAD octopus fast-forward (does not ff)' ' t3033_reset && git fetch . left right && git merge FETCH_HEAD && - # two (master) is not an ancestor of three (left) and four (right) + # two (main) is not an ancestor of three (left) and four (right) test_must_fail git rev-parse --verify HEAD^4 && git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual && git rev-parse two three four | sort >expect && diff --git a/t/t6434-merge-recursive-rename-options.sh b/t/t6434-merge-recursive-rename-options.sh index 3d9fae68c4..a11707835b 100755 --- a/t/t6434-merge-recursive-rename-options.sh +++ b/t/t6434-merge-recursive-rename-options.sh @@ -5,11 +5,11 @@ test_description='merge-recursive rename options Test rename detection by examining rename/delete conflicts. * (HEAD -> rename) rename -| * (master) delete +| * (main) delete |/ * base -git diff --name-status base master +git diff --name-status base main D 0-old D 1-old D 2-old @@ -26,6 +26,9 @@ they are rounded down (see, e.g., Documentation/diff-generate-patch.txt, which mentions this in a different context). ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh get_expected_stages () { @@ -118,7 +121,7 @@ test_expect_success 'setup repo' ' get_expected_stages 2 && get_expected_stages 3 && check_50="false" && - tail="HEAD^ -- HEAD master" + tail="HEAD^ -- HEAD main" ' test_expect_success 'setup thresholds' ' diff --git a/t/t6436-merge-overwrite.sh b/t/t6436-merge-overwrite.sh index dd9376842f..84b4aacf49 100755 --- a/t/t6436-merge-overwrite.sh +++ b/t/t6436-merge-overwrite.sh @@ -4,6 +4,9 @@ test_description='git-merge Do not overwrite changes.' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -136,7 +139,7 @@ test_expect_success 'will not overwrite untracked file in leading path' ' cp important sub && cp important sub2 && test_must_fail git merge sub 2>out && - test_i18ncmp out expect && + test_cmp out expect && test_path_is_missing .git/MERGE_HEAD && test_cmp important sub && test_cmp important sub2 && @@ -171,7 +174,7 @@ test_expect_success 'will not overwrite untracked file on unborn branch' ' git checkout --orphan new && cp important c0.c && test_must_fail git merge c0 2>out && - test_i18ncmp out expect + test_cmp out expect ' test_expect_success 'will not overwrite untracked file on unborn branch .git/MERGE_HEAD sanity etc.' ' @@ -193,7 +196,7 @@ test_expect_success 'set up unborn branch and content' ' ' test_expect_success 'will not clobber WT/index when merging into unborn' ' - git merge master && + git merge main && grep foo tracked-file && git show :tracked-file >expect && grep foo expect && diff --git a/t/t6437-submodule-merge.sh b/t/t6437-submodule-merge.sh index 3ead2b726f..e5e89c2045 100755 --- a/t/t6437-submodule-merge.sh +++ b/t/t6437-submodule-merge.sh @@ -2,7 +2,11 @@ test_description='merging with submodules' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-merge.sh # # history @@ -27,7 +31,7 @@ test_expect_success setup ' test_tick && git commit -m root && - git checkout -b a master && + git checkout -b a main && (cd sub && echo A > file && git add file && @@ -37,7 +41,7 @@ test_expect_success setup ' test_tick && git commit -m a && - git checkout -b b master && + git checkout -b b main && (cd sub && echo B > file && git add file && @@ -254,22 +258,22 @@ test_expect_success 'setup for recursive merge with submodule' ' (cd sub && git init && test_commit a && - git checkout -b sub-b master && + git checkout -b sub-b main && test_commit b && - git checkout -b sub-c master && + git checkout -b sub-c main && test_commit c && git checkout -b sub-bc sub-b && git merge sub-c && git checkout -b sub-cb sub-c && git merge sub-b && - git checkout master) && + git checkout main) && git add sub && git commit -m a && - git checkout -b top-b master && + git checkout -b top-b main && (cd sub && git checkout sub-b) && git add sub && git commit -m b && - git checkout -b top-c master && + git checkout -b top-c main && (cd sub && git checkout sub-c) && git add sub && git commit -m c && @@ -325,7 +329,7 @@ test_expect_success 'setup file/submodule conflict' ' ) ' -test_expect_failure 'file/submodule conflict' ' +test_expect_merge_algorithm failure success 'file/submodule conflict' ' test_when_finished "git -C file-submodule reset --hard" && ( cd file-submodule && @@ -434,7 +438,7 @@ test_expect_failure 'directory/submodule conflict; keep submodule clean' ' ) ' -test_expect_failure !FAIL_PREREQS 'directory/submodule conflict; should not treat submodule files as untracked or in the way' ' +test_expect_merge_algorithm failure success !FAIL_PREREQS 'directory/submodule conflict; should not treat submodule files as untracked or in the way' ' test_when_finished "git -C directory-submodule/path reset --hard" && test_when_finished "git -C directory-submodule reset --hard" && ( diff --git a/t/t6438-submodule-directory-file-conflicts.sh b/t/t6438-submodule-directory-file-conflicts.sh index 04bf4be7d7..8df67a0ef9 100755 --- a/t/t6438-submodule-directory-file-conflicts.sh +++ b/t/t6438-submodule-directory-file-conflicts.sh @@ -12,8 +12,11 @@ test_submodule_switch "merge --ff" test_submodule_switch "merge --ff-only" -KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 -KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1 +if test "$GIT_TEST_MERGE_ALGORITHM" != ort +then + KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 + KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1 +fi test_submodule_switch "merge --no-ff" test_done diff --git a/t/t6439-merge-co-error-msgs.sh b/t/t6439-merge-co-error-msgs.sh index 5c8894d94f..5bfb027099 100755 --- a/t/t6439-merge-co-error-msgs.sh +++ b/t/t6439-merge-co-error-msgs.sh @@ -2,6 +2,9 @@ test_description='unpack-trees error messages' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh @@ -18,7 +21,7 @@ test_expect_success 'setup' ' git add two three four five && git commit -m Second && - git checkout master && + git checkout main && echo other >two && echo other >three && echo other >four && @@ -37,14 +40,14 @@ EOF test_expect_success 'untracked files overwritten by merge (fast and non-fast forward)' ' test_must_fail git merge branch 2>out && - test_i18ncmp out expect && + test_cmp out expect && git commit --allow-empty -m empty && ( GIT_MERGE_VERBOSITY=0 && export GIT_MERGE_VERBOSITY && test_must_fail git merge branch 2>out2 ) && - test_i18ncmp out2 expect && + test_cmp out2 expect && git reset --hard HEAD^ ' @@ -65,7 +68,7 @@ test_expect_success 'untracked files or local changes ovewritten by merge' ' git add three && git add four && test_must_fail git merge branch 2>out && - test_i18ncmp out expect + test_cmp out expect ' cat >expect <<\EOF @@ -83,11 +86,11 @@ test_expect_success 'cannot switch branches because of local changes' ' echo two >rep/two && git add rep/one rep/two && git commit -m Fourth && - git checkout master && + git checkout main && echo uno >rep/one && echo dos >rep/two && test_must_fail git checkout branch 2>out && - test_i18ncmp out expect + test_cmp out expect ' cat >expect <<\EOF @@ -101,7 +104,7 @@ EOF test_expect_success 'not uptodate file porcelain checkout error' ' git add rep/one rep/two && test_must_fail git checkout branch 2>out && - test_i18ncmp out expect + test_cmp out expect ' cat >expect <<\EOF @@ -128,11 +131,11 @@ test_expect_success 'not_uptodate_dir porcelain checkout error' ' >rep2 && git add rep rep2 && git commit -m "added test as a file" && - git checkout master && + git checkout main && >rep/untracked-file && >rep2/untracked-file && test_must_fail git checkout branch 2>out && - test_i18ncmp out ../expect + test_cmp out ../expect ' test_done diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh index 4a3b8f48ac..60d961b526 100755 --- a/t/t6500-gc.sh +++ b/t/t6500-gc.sh @@ -78,7 +78,7 @@ test_expect_success 'gc --keep-largest-pack' ' git gc && ( cd .git/objects/pack && ls *.pack ) >pack-list && test_line_count = 1 pack-list && - BASE_PACK=.git/objects/pack/pack-*.pack && + cp pack-list base-pack-list && test_commit four && git repack -d && test_commit five && @@ -90,7 +90,7 @@ test_expect_success 'gc --keep-largest-pack' ' test_line_count = 2 pack-list && awk "/^P /{print \$2}" <.git/objects/info/packs >pack-info && test_line_count = 2 pack-info && - test_path_is_file $BASE_PACK && + test_path_is_file .git/objects/pack/$(cat base-pack-list) && git fsck ) ' @@ -106,17 +106,17 @@ test_expect_success 'auto gc with too many loose objects does not attempt to cre test_commit "$(test_oid obj2)" && # Our first gc will create a pack; our second will create a second pack git gc --auto && - ls .git/objects/pack | sort >existing_packs && + ls .git/objects/pack/pack-*.pack | sort >existing_packs && test_commit "$(test_oid obj3)" && test_commit "$(test_oid obj4)" && git gc --auto 2>err && test_i18ngrep ! "^warning:" err && - ls .git/objects/pack/ | sort >post_packs && + ls .git/objects/pack/pack-*.pack | sort >post_packs && comm -1 -3 existing_packs post_packs >new && comm -2 -3 existing_packs post_packs >del && test_line_count = 0 del && # No packs are deleted - test_line_count = 2 new # There is one new pack and its .idx + test_line_count = 1 new # There is one new pack ' test_expect_success 'gc --no-quiet' ' diff --git a/t/t6501-freshen-objects.sh b/t/t6501-freshen-objects.sh index 8a3bb4105b..10662456ae 100755 --- a/t/t6501-freshen-objects.sh +++ b/t/t6501-freshen-objects.sh @@ -25,6 +25,9 @@ # to refer to an existing tree). test_description='check pruning of dependent objects' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # We care about reachability, so we do not want to use @@ -40,15 +43,25 @@ commit () { } maybe_repack () { - if test -n "$repack"; then + case "$title" in + loose) + : skip repack + ;; + repack) git repack -ad - fi + ;; + bitmap) + git repack -adb + ;; + *) + echo >&2 "unknown test type in maybe_repack" + return 1 + ;; + esac } -for repack in '' true; do - title=${repack:+repack} - title=${title:-loose} - +for title in loose repack bitmap +do test_expect_success "make repo completely empty ($title)" ' rm -rf .git && git init @@ -67,7 +80,7 @@ for repack in '' true; do git checkout -b experiment && commit abandon && maybe_repack && - git checkout master && + git checkout main && git branch -D experiment ' diff --git a/t/t6600-test-reach.sh b/t/t6600-test-reach.sh index f807276337..3d7a62ddab 100755 --- a/t/t6600-test-reach.sh +++ b/t/t6600-test-reach.sh @@ -55,10 +55,13 @@ test_expect_success 'setup' ' git show-ref -s commit-5-5 | git commit-graph write --stdin-commits && mv .git/objects/info/commit-graph commit-graph-half && chmod u+w commit-graph-half && + git -c commitGraph.generationVersion=1 commit-graph write --reachable && + mv .git/objects/info/commit-graph commit-graph-no-gdat && + chmod u+w commit-graph-no-gdat && git config core.commitGraph true ' -run_three_modes () { +run_all_modes () { test_when_finished rm -rf .git/objects/info/commit-graph && "$@" <input >actual && test_cmp expect actual && @@ -67,11 +70,14 @@ run_three_modes () { test_cmp expect actual && cp commit-graph-half .git/objects/info/commit-graph && "$@" <input >actual && + test_cmp expect actual && + cp commit-graph-no-gdat .git/objects/info/commit-graph && + "$@" <input >actual && test_cmp expect actual } -test_three_modes () { - run_three_modes test-tool reach "$@" +test_all_modes () { + run_all_modes test-tool reach "$@" } test_expect_success 'ref_newer:miss' ' @@ -80,7 +86,7 @@ test_expect_success 'ref_newer:miss' ' B:commit-4-9 EOF echo "ref_newer(A,B):0" >expect && - test_three_modes ref_newer + test_all_modes ref_newer ' test_expect_success 'ref_newer:hit' ' @@ -89,7 +95,7 @@ test_expect_success 'ref_newer:hit' ' B:commit-2-3 EOF echo "ref_newer(A,B):1" >expect && - test_three_modes ref_newer + test_all_modes ref_newer ' test_expect_success 'in_merge_bases:hit' ' @@ -98,7 +104,7 @@ test_expect_success 'in_merge_bases:hit' ' B:commit-8-8 EOF echo "in_merge_bases(A,B):1" >expect && - test_three_modes in_merge_bases + test_all_modes in_merge_bases ' test_expect_success 'in_merge_bases:miss' ' @@ -107,7 +113,7 @@ test_expect_success 'in_merge_bases:miss' ' B:commit-5-9 EOF echo "in_merge_bases(A,B):0" >expect && - test_three_modes in_merge_bases + test_all_modes in_merge_bases ' test_expect_success 'in_merge_bases_many:hit' ' @@ -117,7 +123,7 @@ test_expect_success 'in_merge_bases_many:hit' ' X:commit-5-7 EOF echo "in_merge_bases_many(A,X):1" >expect && - test_three_modes in_merge_bases_many + test_all_modes in_merge_bases_many ' test_expect_success 'in_merge_bases_many:miss' ' @@ -127,7 +133,7 @@ test_expect_success 'in_merge_bases_many:miss' ' X:commit-8-6 EOF echo "in_merge_bases_many(A,X):0" >expect && - test_three_modes in_merge_bases_many + test_all_modes in_merge_bases_many ' test_expect_success 'in_merge_bases_many:miss-heuristic' ' @@ -137,7 +143,7 @@ test_expect_success 'in_merge_bases_many:miss-heuristic' ' X:commit-6-6 EOF echo "in_merge_bases_many(A,X):0" >expect && - test_three_modes in_merge_bases_many + test_all_modes in_merge_bases_many ' test_expect_success 'is_descendant_of:hit' ' @@ -148,7 +154,7 @@ test_expect_success 'is_descendant_of:hit' ' X:commit-1-1 EOF echo "is_descendant_of(A,X):1" >expect && - test_three_modes is_descendant_of + test_all_modes is_descendant_of ' test_expect_success 'is_descendant_of:miss' ' @@ -159,7 +165,7 @@ test_expect_success 'is_descendant_of:miss' ' X:commit-7-6 EOF echo "is_descendant_of(A,X):0" >expect && - test_three_modes is_descendant_of + test_all_modes is_descendant_of ' test_expect_success 'get_merge_bases_many' ' @@ -174,7 +180,7 @@ test_expect_success 'get_merge_bases_many' ' git rev-parse commit-5-6 \ commit-4-7 | sort } >expect && - test_three_modes get_merge_bases_many + test_all_modes get_merge_bases_many ' test_expect_success 'reduce_heads' ' @@ -196,7 +202,7 @@ test_expect_success 'reduce_heads' ' commit-2-8 \ commit-1-10 | sort } >expect && - test_three_modes reduce_heads + test_all_modes reduce_heads ' test_expect_success 'can_all_from_reach:hit' ' @@ -219,7 +225,7 @@ test_expect_success 'can_all_from_reach:hit' ' Y:commit-8-1 EOF echo "can_all_from_reach(X,Y):1" >expect && - test_three_modes can_all_from_reach + test_all_modes can_all_from_reach ' test_expect_success 'can_all_from_reach:miss' ' @@ -241,7 +247,7 @@ test_expect_success 'can_all_from_reach:miss' ' Y:commit-8-5 EOF echo "can_all_from_reach(X,Y):0" >expect && - test_three_modes can_all_from_reach + test_all_modes can_all_from_reach ' test_expect_success 'can_all_from_reach_with_flag: tags case' ' @@ -264,7 +270,7 @@ test_expect_success 'can_all_from_reach_with_flag: tags case' ' Y:commit-8-1 EOF echo "can_all_from_reach_with_flag(X,_,_,0,0):1" >expect && - test_three_modes can_all_from_reach_with_flag + test_all_modes can_all_from_reach_with_flag ' test_expect_success 'commit_contains:hit' ' @@ -280,8 +286,8 @@ test_expect_success 'commit_contains:hit' ' X:commit-9-3 EOF echo "commit_contains(_,A,X,_):1" >expect && - test_three_modes commit_contains && - test_three_modes commit_contains --tag + test_all_modes commit_contains && + test_all_modes commit_contains --tag ' test_expect_success 'commit_contains:miss' ' @@ -297,8 +303,8 @@ test_expect_success 'commit_contains:miss' ' X:commit-9-3 EOF echo "commit_contains(_,A,X,_):0" >expect && - test_three_modes commit_contains && - test_three_modes commit_contains --tag + test_all_modes commit_contains && + test_all_modes commit_contains --tag ' test_expect_success 'rev-list: basic topo-order' ' @@ -310,7 +316,7 @@ test_expect_success 'rev-list: basic topo-order' ' commit-6-2 commit-5-2 commit-4-2 commit-3-2 commit-2-2 commit-1-2 \ commit-6-1 commit-5-1 commit-4-1 commit-3-1 commit-2-1 commit-1-1 \ >expect && - run_three_modes git rev-list --topo-order commit-6-6 + run_all_modes git rev-list --topo-order commit-6-6 ' test_expect_success 'rev-list: first-parent topo-order' ' @@ -322,7 +328,7 @@ test_expect_success 'rev-list: first-parent topo-order' ' commit-6-2 \ commit-6-1 commit-5-1 commit-4-1 commit-3-1 commit-2-1 commit-1-1 \ >expect && - run_three_modes git rev-list --first-parent --topo-order commit-6-6 + run_all_modes git rev-list --first-parent --topo-order commit-6-6 ' test_expect_success 'rev-list: range topo-order' ' @@ -334,7 +340,7 @@ test_expect_success 'rev-list: range topo-order' ' commit-6-2 commit-5-2 commit-4-2 \ commit-6-1 commit-5-1 commit-4-1 \ >expect && - run_three_modes git rev-list --topo-order commit-3-3..commit-6-6 + run_all_modes git rev-list --topo-order commit-3-3..commit-6-6 ' test_expect_success 'rev-list: range topo-order' ' @@ -346,7 +352,7 @@ test_expect_success 'rev-list: range topo-order' ' commit-6-2 commit-5-2 commit-4-2 \ commit-6-1 commit-5-1 commit-4-1 \ >expect && - run_three_modes git rev-list --topo-order commit-3-8..commit-6-6 + run_all_modes git rev-list --topo-order commit-3-8..commit-6-6 ' test_expect_success 'rev-list: first-parent range topo-order' ' @@ -358,7 +364,7 @@ test_expect_success 'rev-list: first-parent range topo-order' ' commit-6-2 \ commit-6-1 commit-5-1 commit-4-1 \ >expect && - run_three_modes git rev-list --first-parent --topo-order commit-3-8..commit-6-6 + run_all_modes git rev-list --first-parent --topo-order commit-3-8..commit-6-6 ' test_expect_success 'rev-list: ancestry-path topo-order' ' @@ -368,7 +374,7 @@ test_expect_success 'rev-list: ancestry-path topo-order' ' commit-6-4 commit-5-4 commit-4-4 commit-3-4 \ commit-6-3 commit-5-3 commit-4-3 \ >expect && - run_three_modes git rev-list --topo-order --ancestry-path commit-3-3..commit-6-6 + run_all_modes git rev-list --topo-order --ancestry-path commit-3-3..commit-6-6 ' test_expect_success 'rev-list: symmetric difference topo-order' ' @@ -382,7 +388,7 @@ test_expect_success 'rev-list: symmetric difference topo-order' ' commit-3-8 commit-2-8 commit-1-8 \ commit-3-7 commit-2-7 commit-1-7 \ >expect && - run_three_modes git rev-list --topo-order commit-3-8...commit-6-6 + run_all_modes git rev-list --topo-order commit-3-8...commit-6-6 ' test_expect_success 'get_reachable_subset:all' ' @@ -402,7 +408,7 @@ test_expect_success 'get_reachable_subset:all' ' commit-1-7 \ commit-5-6 | sort ) >expect && - test_three_modes get_reachable_subset + test_all_modes get_reachable_subset ' test_expect_success 'get_reachable_subset:some' ' @@ -420,7 +426,7 @@ test_expect_success 'get_reachable_subset:some' ' git rev-parse commit-3-3 \ commit-1-7 | sort ) >expect && - test_three_modes get_reachable_subset + test_all_modes get_reachable_subset ' test_expect_success 'get_reachable_subset:none' ' @@ -434,7 +440,7 @@ test_expect_success 'get_reachable_subset:none' ' Y:commit-2-8 EOF echo "get_reachable_subset(X,Y)" >expect && - test_three_modes get_reachable_subset + test_all_modes get_reachable_subset ' test_done diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh index 63d5f41a12..25bb9bbb89 100755 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@ -3,74 +3,74 @@ test_description='git mv in subdirs' . ./test-lib.sh -test_expect_success \ - 'prepare reference tree' \ - 'mkdir path0 path1 && - cp "$TEST_DIRECTORY"/../COPYING path0/COPYING && - git add path0/COPYING && - git commit -m add -a' +test_expect_success 'prepare reference tree' ' + mkdir path0 path1 && + cp "$TEST_DIRECTORY"/../COPYING path0/COPYING && + git add path0/COPYING && + git commit -m add -a +' -test_expect_success \ - 'moving the file out of subdirectory' \ - 'cd path0 && git mv COPYING ../path1/COPYING' +test_expect_success 'moving the file out of subdirectory' ' + git -C path0 mv COPYING ../path1/COPYING +' # in path0 currently -test_expect_success \ - 'commiting the change' \ - 'cd .. && git commit -m move-out -a' +test_expect_success 'commiting the change' ' + git commit -m move-out -a +' -test_expect_success \ - 'checking the commit' \ - 'git diff-tree -r -M --name-status HEAD^ HEAD >actual && - grep "^R100..*path0/COPYING..*path1/COPYING" actual' +test_expect_success 'checking the commit' ' + git diff-tree -r -M --name-status HEAD^ HEAD >actual && + grep "^R100..*path0/COPYING..*path1/COPYING" actual +' -test_expect_success \ - 'moving the file back into subdirectory' \ - 'cd path0 && git mv ../path1/COPYING COPYING' +test_expect_success 'moving the file back into subdirectory' ' + git -C path0 mv ../path1/COPYING COPYING +' # in path0 currently -test_expect_success \ - 'commiting the change' \ - 'cd .. && git commit -m move-in -a' - -test_expect_success \ - 'checking the commit' \ - 'git diff-tree -r -M --name-status HEAD^ HEAD >actual && - grep "^R100..*path1/COPYING..*path0/COPYING" actual' - -test_expect_success \ - 'mv --dry-run does not move file' \ - 'git mv -n path0/COPYING MOVED && - test -f path0/COPYING && - test ! -f MOVED' - -test_expect_success \ - 'checking -k on non-existing file' \ - 'git mv -k idontexist path0' - -test_expect_success \ - 'checking -k on untracked file' \ - 'touch untracked1 && - git mv -k untracked1 path0 && - test -f untracked1 && - test ! -f path0/untracked1' - -test_expect_success \ - 'checking -k on multiple untracked files' \ - 'touch untracked2 && - git mv -k untracked1 untracked2 path0 && - test -f untracked1 && - test -f untracked2 && - test ! -f path0/untracked1 && - test ! -f path0/untracked2' - -test_expect_success \ - 'checking -f on untracked file with existing target' \ - 'touch path0/untracked1 && - test_must_fail git mv -f untracked1 path0 && - test ! -f .git/index.lock && - test -f untracked1 && - test -f path0/untracked1' +test_expect_success 'commiting the change' ' + git commit -m move-in -a +' + +test_expect_success 'checking the commit' ' + git diff-tree -r -M --name-status HEAD^ HEAD >actual && + grep "^R100..*path1/COPYING..*path0/COPYING" actual +' + +test_expect_success 'mv --dry-run does not move file' ' + git mv -n path0/COPYING MOVED && + test -f path0/COPYING && + test ! -f MOVED +' + +test_expect_success 'checking -k on non-existing file' ' + git mv -k idontexist path0 +' + +test_expect_success 'checking -k on untracked file' ' + >untracked1 && + git mv -k untracked1 path0 && + test -f untracked1 && + test ! -f path0/untracked1 +' + +test_expect_success 'checking -k on multiple untracked files' ' + >untracked2 && + git mv -k untracked1 untracked2 path0 && + test -f untracked1 && + test -f untracked2 && + test ! -f path0/untracked1 && + test ! -f path0/untracked2 +' + +test_expect_success 'checking -f on untracked file with existing target' ' + >path0/untracked1 && + test_must_fail git mv -f untracked1 path0 && + test ! -f .git/index.lock && + test -f untracked1 && + test -f path0/untracked1 +' # clean up the mess in case bad things happen rm -f idontexist untracked1 untracked2 \ @@ -78,87 +78,89 @@ rm -f idontexist untracked1 untracked2 \ .git/index.lock rmdir path1 -test_expect_success \ - 'moving to absent target with trailing slash' \ - 'test_must_fail git mv path0/COPYING no-such-dir/ && - test_must_fail git mv path0/COPYING no-such-dir// && - git mv path0/ no-such-dir/ && - test_path_is_dir no-such-dir' - -test_expect_success \ - 'clean up' \ - 'git reset --hard' - -test_expect_success \ - 'moving to existing untracked target with trailing slash' \ - 'mkdir path1 && - git mv path0/ path1/ && - test_path_is_dir path1/path0/' - -test_expect_success \ - 'moving to existing tracked target with trailing slash' \ - 'mkdir path2 && - >path2/file && git add path2/file && - git mv path1/path0/ path2/ && - test_path_is_dir path2/path0/' - -test_expect_success \ - 'clean up' \ - 'git reset --hard' - -test_expect_success \ - 'adding another file' \ - 'cp "$TEST_DIRECTORY"/../README.md path0/README && - git add path0/README && - git commit -m add2 -a' - -test_expect_success \ - 'moving whole subdirectory' \ - 'git mv path0 path2' - -test_expect_success \ - 'commiting the change' \ - 'git commit -m dir-move -a' - -test_expect_success \ - 'checking the commit' \ - 'git diff-tree -r -M --name-status HEAD^ HEAD >actual && - grep "^R100..*path0/COPYING..*path2/COPYING" actual && - grep "^R100..*path0/README..*path2/README" actual' - -test_expect_success \ - 'succeed when source is a prefix of destination' \ - 'git mv path2/COPYING path2/COPYING-renamed' - -test_expect_success \ - 'moving whole subdirectory into subdirectory' \ - 'git mv path2 path1' - -test_expect_success \ - 'commiting the change' \ - 'git commit -m dir-move -a' - -test_expect_success \ - 'checking the commit' \ - 'git diff-tree -r -M --name-status HEAD^ HEAD >actual && - grep "^R100..*path2/COPYING..*path1/path2/COPYING" actual && - grep "^R100..*path2/README..*path1/path2/README" actual' - -test_expect_success \ - 'do not move directory over existing directory' \ - 'mkdir path0 && mkdir path0/path2 && test_must_fail git mv path2 path0' - -test_expect_success \ - 'move into "."' \ - 'git mv path1/path2/ .' +test_expect_success 'moving to absent target with trailing slash' ' + test_must_fail git mv path0/COPYING no-such-dir/ && + test_must_fail git mv path0/COPYING no-such-dir// && + git mv path0/ no-such-dir/ && + test_path_is_dir no-such-dir +' + +test_expect_success 'clean up' ' + git reset --hard +' + +test_expect_success 'moving to existing untracked target with trailing slash' ' + mkdir path1 && + git mv path0/ path1/ && + test_path_is_dir path1/path0/ +' + +test_expect_success 'moving to existing tracked target with trailing slash' ' + mkdir path2 && + >path2/file && git add path2/file && + git mv path1/path0/ path2/ && + test_path_is_dir path2/path0/ +' + +test_expect_success 'clean up' ' + git reset --hard +' + +test_expect_success 'adding another file' ' + cp "$TEST_DIRECTORY"/../README.md path0/README && + git add path0/README && + git commit -m add2 -a +' + +test_expect_success 'moving whole subdirectory' ' + git mv path0 path2 +' + +test_expect_success 'commiting the change' ' + git commit -m dir-move -a +' + +test_expect_success 'checking the commit' ' + git diff-tree -r -M --name-status HEAD^ HEAD >actual && + grep "^R100..*path0/COPYING..*path2/COPYING" actual && + grep "^R100..*path0/README..*path2/README" actual +' + +test_expect_success 'succeed when source is a prefix of destination' ' + git mv path2/COPYING path2/COPYING-renamed +' + +test_expect_success 'moving whole subdirectory into subdirectory' ' + git mv path2 path1 +' + +test_expect_success 'commiting the change' ' + git commit -m dir-move -a +' + +test_expect_success 'checking the commit' ' + git diff-tree -r -M --name-status HEAD^ HEAD >actual && + grep "^R100..*path2/COPYING..*path1/path2/COPYING" actual && + grep "^R100..*path2/README..*path1/path2/README" actual +' + +test_expect_success 'do not move directory over existing directory' ' + mkdir path0 && + mkdir path0/path2 && + test_must_fail git mv path2 path0 +' + +test_expect_success 'move into "."' ' + git mv path1/path2/ . +' test_expect_success "Michael Cassar's test case" ' rm -fr .git papers partA && git init && mkdir -p papers/unsorted papers/all-papers partA && - echo a > papers/unsorted/Thesis.pdf && - echo b > partA/outline.txt && - echo c > papers/unsorted/_another && + echo a >papers/unsorted/Thesis.pdf && + echo b >partA/outline.txt && + echo c >papers/unsorted/_another && git add papers partA && T1=$(git write-tree) && @@ -181,43 +183,42 @@ test_expect_success "Sergey Vlasov's test case" ' git mv ab a ' -test_expect_success 'absolute pathname' '( - - rm -fr mine && - mkdir mine && - cd mine && - test_create_repo one && - cd one && - mkdir sub && - >sub/file && - git add sub/file && - - git mv sub "$(pwd)/in" && - ! test -d sub && - test -d in && - git ls-files --error-unmatch in/file - - -)' - -test_expect_success 'absolute pathname outside should fail' '( - - rm -fr mine && - mkdir mine && - cd mine && - out=$(pwd) && - test_create_repo one && - cd one && - mkdir sub && - >sub/file && - git add sub/file && - - test_must_fail git mv sub "$out/out" && - test -d sub && - ! test -d ../in && - git ls-files --error-unmatch sub/file +test_expect_success 'absolute pathname' ' + ( + rm -fr mine && + mkdir mine && + cd mine && + test_create_repo one && + cd one && + mkdir sub && + >sub/file && + git add sub/file && + + git mv sub "$(pwd)/in" && + ! test -d sub && + test -d in && + git ls-files --error-unmatch in/file + ) +' -)' +test_expect_success 'absolute pathname outside should fail' ' + ( + rm -fr mine && + mkdir mine && + cd mine && + out=$(pwd) && + test_create_repo one && + cd one && + mkdir sub && + >sub/file && + git add sub/file && + + test_must_fail git mv sub "$out/out" && + test -d sub && + ! test -d ../in && + git ls-files --error-unmatch sub/file + ) +' test_expect_success 'git mv to move multiple sources into a directory' ' rm -fr .git && git init && @@ -227,23 +228,24 @@ test_expect_success 'git mv to move multiple sources into a directory' ' git add dir/?.txt && git mv dir/a.txt dir/b.txt other && git ls-files >actual && - { echo other/a.txt; echo other/b.txt; } >expect && + cat >expect <<-\EOF && + other/a.txt + other/b.txt + EOF test_cmp expect actual ' test_expect_success 'git mv should not change sha1 of moved cache entry' ' - rm -fr .git && git init && echo 1 >dirty && git add dirty && entry="$(git ls-files --stage dirty | cut -f 1)" && git mv dirty dirty2 && - [ "$entry" = "$(git ls-files --stage dirty2 | cut -f 1)" ] && + test "$entry" = "$(git ls-files --stage dirty2 | cut -f 1)" && echo 2 >dirty2 && git mv dirty2 dirty && - [ "$entry" = "$(git ls-files --stage dirty | cut -f 1)" ] - + test "$entry" = "$(git ls-files --stage dirty | cut -f 1)" ' rm -f dirty dirty2 @@ -266,7 +268,6 @@ test_expect_success 'git mv error on conflicted file' ' ' test_expect_success 'git mv should overwrite symlink to a file' ' - rm -fr .git && git init && echo 1 >moved && @@ -279,13 +280,11 @@ test_expect_success 'git mv should overwrite symlink to a file' ' test "$(cat symlink)" = 1 && git update-index --refresh && git diff-files --quiet - ' rm -f moved symlink test_expect_success 'git mv should overwrite file with a symlink' ' - rm -fr .git && git init && echo 1 >moved && @@ -296,11 +295,9 @@ test_expect_success 'git mv should overwrite file with a symlink' ' ! test -e symlink && git update-index --refresh && git diff-files --quiet - ' test_expect_success SYMLINKS 'check moved symlink' ' - test -h moved ' @@ -335,11 +332,8 @@ test_expect_success 'git mv moves a submodule with a .git directory and no .gitm mkdir mod && git mv sub mod/sub && ! test -e sub && - [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] && - ( - cd mod/sub && - git status - ) && + test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" && + git -C mod/sub status && git update-index --refresh && git diff-files --quiet ' @@ -358,11 +352,8 @@ test_expect_success 'git mv moves a submodule with a .git directory and .gitmodu mkdir mod && git mv sub mod/sub && ! test -e sub && - [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] && - ( - cd mod/sub && - git status - ) && + test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" && + git -C mod/sub status && echo mod/sub >expected && git config -f .gitmodules submodule.sub.path >actual && test_cmp expected actual && @@ -376,16 +367,10 @@ test_expect_success 'git mv moves a submodule with gitfile' ' git submodule update && entry="$(git ls-files --stage sub | cut -f 1)" && mkdir mod && - ( - cd mod && - git mv ../sub/ . - ) && + git -C mod mv ../sub/ . && ! test -e sub && - [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] && - ( - cd mod/sub && - git status - ) && + test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" && + git -C mod/sub status && echo mod/sub >expected && git config -f .gitmodules submodule.sub.path >actual && test_cmp expected actual && @@ -403,11 +388,8 @@ test_expect_success 'mv does not complain when no .gitmodules file is found' ' git mv sub mod/sub 2>actual.err && test_must_be_empty actual.err && ! test -e sub && - [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] && - ( - cd mod/sub && - git status - ) && + test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" && + git -C mod/sub status && git update-index --refresh && git diff-files --quiet ' @@ -427,11 +409,8 @@ test_expect_success 'mv will error out on a modified .gitmodules file unless sta git mv sub mod/sub 2>actual.err && test_must_be_empty actual.err && ! test -e sub && - [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] && - ( - cd mod/sub && - git status - ) && + test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" && + git -C mod/sub status && git update-index --refresh && git diff-files --quiet ' @@ -446,13 +425,10 @@ test_expect_success 'mv issues a warning when section is not found in .gitmodule echo "warning: Could not find section in .gitmodules where path=sub" >expect.err && mkdir mod && git mv sub mod/sub 2>actual.err && - test_i18ncmp expect.err actual.err && + test_cmp expect.err actual.err && ! test -e sub && - [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] && - ( - cd mod/sub && - git status - ) && + test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" && + git -C mod/sub status && git update-index --refresh && git diff-files --quiet ' @@ -515,15 +491,17 @@ test_expect_success 'moving a submodule in nested directories' ' test_expect_success 'moving nested submodules' ' git commit -am "cleanup commit" && mkdir sub_nested_nested && - (cd sub_nested_nested && - touch nested_level2 && + ( + cd sub_nested_nested && + >nested_level2 && git init && git add . && git commit -m "nested level 2" ) && mkdir sub_nested && - (cd sub_nested && - touch nested_level1 && + ( + cd sub_nested && + >nested_level1 && git init && git add . && git commit -m "nested level 1" && diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh index 36477cb1f4..1349e5b232 100755 --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='git filter-branch' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY/lib-gpg.sh" @@ -13,7 +16,7 @@ test_expect_success 'setup' ' mkdir dir && test_commit dir/D && test_commit E && - git checkout master && + git checkout main && test_commit C && git checkout branch && git merge C && @@ -25,7 +28,7 @@ test_expect_success 'setup' ' # * G # * Merge commit 'C' into branch # |\ -# | * (master) C +# | * (main) C # * | E # * | dir/D # * | D @@ -162,15 +165,15 @@ test_expect_success 'subdirectory filter result looks okay' ' ' test_expect_success 'more setup' ' - git checkout master && + git checkout main && mkdir subdir && echo A > subdir/new && git add subdir/new && test_tick && - git commit -m "subdir on master" subdir/new && + git commit -m "subdir on main" subdir/new && git rm A.t && test_tick && - git commit -m "again subdir on master" && + git commit -m "again subdir on main" && git merge branch ' @@ -199,7 +202,7 @@ test_expect_success 'author information is preserved' ' git branch preserved-author && (sane_unset GIT_AUTHOR_NAME && git filter-branch -f --msg-filter "cat; \ - test \$GIT_COMMIT != $(git rev-parse master) || \ + test \$GIT_COMMIT != $(git rev-parse main) || \ echo Hallo" \ preserved-author) && git rev-list --author="B V Uips" preserved-author >actual && @@ -218,7 +221,7 @@ test_expect_success "remove a certain author's commits" ' else\ git commit-tree \"\$@\";\ fi" removed-author && - cnt1=$(git rev-list master | wc -l) && + cnt1=$(git rev-list main | wc -l) && cnt2=$(git rev-list removed-author | wc -l) && test $cnt1 -eq $(($cnt2 + 1)) && git rev-list --author="B V Uips" removed-author >actual && @@ -226,7 +229,7 @@ test_expect_success "remove a certain author's commits" ' ' test_expect_success 'barf on invalid name' ' - test_must_fail git filter-branch -f master xy-problem && + test_must_fail git filter-branch -f main xy-problem && test_must_fail git filter-branch -f HEAD^ ' @@ -236,8 +239,8 @@ test_expect_success '"map" works in commit filter' ' mapped=\$(map \$parent) && actual=\$(echo \"\$@\" | sed \"s/^.*-p //\") && test \$mapped = \$actual && - git commit-tree \"\$@\";" master~2..master && - git rev-parse --verify master + git commit-tree \"\$@\";" main~2..main && + git rev-parse --verify main ' test_expect_success 'Name needing quotes' ' @@ -256,7 +259,7 @@ test_expect_success 'Name needing quotes' ' test_expect_success 'Subdirectory filter with disappearing trees' ' git reset --hard && - git checkout master && + git checkout main && mkdir foo && touch foo/bar && @@ -275,7 +278,7 @@ test_expect_success 'Subdirectory filter with disappearing trees' ' git commit -m "Re-adding foo" && git filter-branch -f --subdirectory-filter foo && - git rev-list master >actual && + git rev-list main >actual && test_line_count = 3 actual ' @@ -332,7 +335,7 @@ test_expect_success 'Tag name filtering allows slashes in tag names' ' test_cmp expect actual ' test_expect_success 'setup --prune-empty comparisons' ' - git checkout --orphan master-no-a && + git checkout --orphan main-no-a && git rm -rf . && unset test_tick && test_tick && @@ -343,7 +346,7 @@ test_expect_success 'setup --prune-empty comparisons' ' mkdir dir && test_commit dir/D dir/D.t dir/D dir/Dx && test_commit E E.t E Ex && - git checkout master-no-a && + git checkout main-no-a && test_commit C C.t C Cx && git checkout branch-no-a && git merge Cx -m "Merge tag '\''C'\'' into branch" && @@ -397,7 +400,7 @@ test_expect_success '--prune-empty is able to prune entire branch' ' ' test_expect_success '--remap-to-ancestor with filename filters' ' - git checkout master && + git checkout main && git reset --hard A && test_commit add-foo foo 1 && git branch moved-foo && @@ -407,15 +410,15 @@ test_expect_success '--remap-to-ancestor with filename filters' ' git branch moved-bar && test_commit change-foo foo 2 && git filter-branch -f --remap-to-ancestor \ - moved-foo moved-bar A..master \ + moved-foo moved-bar A..main \ -- -- foo && test $(git rev-parse moved-foo) = $(git rev-parse moved-bar) && - test $(git rev-parse moved-foo) = $(git rev-parse master^) && + test $(git rev-parse moved-foo) = $(git rev-parse main^) && test $orig_invariant = $(git rev-parse invariant) ' test_expect_success 'automatic remapping to ancestor with filename filters' ' - git checkout master && + git checkout main && git reset --hard A && test_commit add-foo2 foo 1 && git branch moved-foo2 && @@ -425,10 +428,10 @@ test_expect_success 'automatic remapping to ancestor with filename filters' ' git branch moved-bar2 && test_commit change-foo2 foo 2 && git filter-branch -f \ - moved-foo2 moved-bar2 A..master \ + moved-foo2 moved-bar2 A..main \ -- -- foo && test $(git rev-parse moved-foo2) = $(git rev-parse moved-bar2) && - test $(git rev-parse moved-foo2) = $(git rev-parse master^) && + test $(git rev-parse moved-foo2) = $(git rev-parse main^) && test $orig_invariant = $(git rev-parse invariant2) ' @@ -503,4 +506,35 @@ test_expect_success 'rewrite repository including refs that point at non-commit ! fgrep fatal filter-output ' +test_expect_success 'filter-branch handles ref deletion' ' + git switch --orphan empty-commit && + git commit --allow-empty -m "empty commit" && + git tag empty && + git branch to-delete && + git filter-branch -f --prune-empty to-delete >out 2>&1 && + grep "to-delete.*was deleted" out && + test_must_fail git rev-parse --verify to-delete +' + +test_expect_success 'filter-branch handles ref rewrite' ' + git checkout empty && + test_commit to-drop && + git branch rewrite && + git filter-branch -f \ + --index-filter "git rm --ignore-unmatch --cached to-drop.t" \ + rewrite >out 2>&1 && + grep "rewrite.*was rewritten" out && + ! grep -i warning out && + git diff-tree empty rewrite +' + +test_expect_success 'filter-branch handles ancestor rewrite' ' + test_commit to-exclude && + git branch ancestor && + git filter-branch -f ancestor -- :^to-exclude.t >out 2>&1 && + grep "ancestor.*was rewritten" out && + ! grep -i warning out && + git diff-tree HEAD^ ancestor +' + test_done diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index 05f411c821..2f72c5c688 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -7,6 +7,9 @@ test_description='git tag Tests for operations with tags.' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-gpg.sh . "$TEST_DIRECTORY"/lib-terminal.sh @@ -17,6 +20,13 @@ tag_exists () { git show-ref --quiet --verify refs/tags/"$1" } +test_expect_success 'setup' ' + test_oid_cache <<-EOM + othersigheader sha1:gpgsig-sha256 + othersigheader sha256:gpgsig + EOM +' + test_expect_success 'listing all tags in an empty tree should succeed' ' git tag -l && git tag @@ -88,7 +98,7 @@ test_expect_success 'creating a tag with --create-reflog should create reflog' ' git tag --create-reflog tag_with_reflog && git reflog exists refs/tags/tag_with_reflog && sed -e "s/^.* //" .git/logs/refs/tags/tag_with_reflog >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'annotated tag with --create-reflog has correct message' ' @@ -99,7 +109,7 @@ test_expect_success 'annotated tag with --create-reflog has correct message' ' git tag -m "annotated tag" --create-reflog tag_with_reflog && git reflog exists refs/tags/tag_with_reflog && sed -e "s/^.* //" .git/logs/refs/tags/tag_with_reflog >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success '--create-reflog does not create reflog on failure' ' @@ -1371,6 +1381,24 @@ test_expect_success GPG \ 'test_config gpg.program echo && test_must_fail git tag -s -m tail tag-gpg-failure' +# try to produce invalid signature +test_expect_success GPG 'git verifies tag is valid with double signature' ' + git tag -s -m tail tag-gpg-double-sig && + git cat-file tag tag-gpg-double-sig >tag && + othersigheader=$(test_oid othersigheader) && + sed -ne "/^\$/q;p" tag >new-tag && + cat <<-EOM >>new-tag && + $othersigheader -----BEGIN PGP SIGNATURE----- + someinvaliddata + -----END PGP SIGNATURE----- + EOM + sed -e "1,/^tagger/d" tag >>new-tag && + new_tag=$(git hash-object -t tag -w new-tag) && + git update-ref refs/tags/tag-gpg-double-sig $new_tag && + git verify-tag tag-gpg-double-sig && + git fsck +' + # try to sign with bad user.signingkey test_expect_success GPGSM \ 'git tag -s fails if gpgsm is misconfigured (bad key)' \ @@ -1406,7 +1434,7 @@ test_expect_success 'message in editor has initial comment: first line' ' # check the first line --- should be empty echo >first.expect && sed -e 1q <actual >first.actual && - test_i18ncmp first.expect first.actual + test_cmp first.expect first.actual ' test_expect_success \ @@ -1583,7 +1611,7 @@ test_expect_success 'checking that branch head with --no-contains lists all but " test_expect_success 'merging original branch into this branch' ' - git merge --strategy=ours master && + git merge --strategy=ours main && git tag v4.0 ' @@ -1729,7 +1757,7 @@ test_expect_success 'recursive tagging should give advice' ' hint: Disable this message with "git config advice.nestedTag false" EOF git tag -m nested nested annotated-v4.0 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'multiple --points-at are OR-ed together' ' @@ -1944,15 +1972,15 @@ test_expect_success ULIMIT_STACK_SIZE '--contains and --no-contains work in a de i=1 && while test $i -lt 8000 do - echo "commit refs/heads/master + echo "commit refs/heads/main committer A U Thor <author@example.com> $((1000000000 + $i * 100)) +0200 data <<EOF commit #$i EOF" - test $i = 1 && echo "from refs/heads/master^0" + test $i = 1 && echo "from refs/heads/main^0" i=$(($i + 1)) done | git fast-import && - git checkout master && + git checkout main && git tag far-far-away HEAD^ && run_with_limited_stack git tag --contains HEAD >actual && test_must_be_empty actual && diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh index fdb450e446..0e7cf75435 100755 --- a/t/t7006-pager.sh +++ b/t/t7006-pager.sh @@ -656,4 +656,134 @@ test_expect_success TTY 'git tag with auto-columns ' ' test_cmp expect actual ' +test_expect_success 'setup trace2' ' + GIT_TRACE2_BRIEF=1 && + export GIT_TRACE2_BRIEF +' + +test_expect_success TTY 'git returns SIGPIPE on early pager exit' ' + test_when_finished "rm pager-used trace.normal" && + test_config core.pager ">pager-used; head -n 1; exit 0" && + GIT_TRACE2="$(pwd)/trace.normal" && + export GIT_TRACE2 && + test_when_finished "unset GIT_TRACE2" && + + if test_have_prereq !MINGW + then + OUT=$( ((test_terminal git log; echo $? 1>&3) | :) 3>&1 ) && + test_match_signal 13 "$OUT" + else + test_terminal git log + fi && + + grep child_exit trace.normal >child-exits && + test_line_count = 1 child-exits && + grep " code:0 " child-exits && + test_path_is_file pager-used +' + +test_expect_success TTY 'git returns SIGPIPE on early pager non-zero exit' ' + test_when_finished "rm pager-used trace.normal" && + test_config core.pager ">pager-used; head -n 1; exit 1" && + GIT_TRACE2="$(pwd)/trace.normal" && + export GIT_TRACE2 && + test_when_finished "unset GIT_TRACE2" && + + if test_have_prereq !MINGW + then + OUT=$( ((test_terminal git log; echo $? 1>&3) | :) 3>&1 ) && + test_match_signal 13 "$OUT" + else + test_terminal git log + fi && + + grep child_exit trace.normal >child-exits && + test_line_count = 1 child-exits && + grep " code:1 " child-exits && + test_path_is_file pager-used +' + +test_expect_success TTY 'git discards pager non-zero exit without SIGPIPE' ' + test_when_finished "rm pager-used trace.normal" && + test_config core.pager "wc >pager-used; exit 1" && + GIT_TRACE2="$(pwd)/trace.normal" && + export GIT_TRACE2 && + test_when_finished "unset GIT_TRACE2" && + + if test_have_prereq !MINGW + then + OUT=$( ((test_terminal git log; echo $? 1>&3) | :) 3>&1 ) && + test "$OUT" -eq 0 + else + test_terminal git log + fi && + + grep child_exit trace.normal >child-exits && + test_line_count = 1 child-exits && + grep " code:1 " child-exits && + test_path_is_file pager-used +' + +test_expect_success TTY 'git discards nonexisting pager without SIGPIPE' ' + test_when_finished "rm pager-used trace.normal" && + test_config core.pager "wc >pager-used; does-not-exist" && + GIT_TRACE2="$(pwd)/trace.normal" && + export GIT_TRACE2 && + test_when_finished "unset GIT_TRACE2" && + + if test_have_prereq !MINGW + then + OUT=$( ((test_terminal git log; echo $? 1>&3) | :) 3>&1 ) && + test "$OUT" -eq 0 + else + test_terminal git log + fi && + + grep child_exit trace.normal >child-exits && + test_line_count = 1 child-exits && + grep " code:127 " child-exits && + test_path_is_file pager-used +' + +test_expect_success TTY 'git attempts to page to nonexisting pager command, gets SIGPIPE' ' + test_when_finished "rm trace.normal" && + test_config core.pager "does-not-exist" && + GIT_TRACE2="$(pwd)/trace.normal" && + export GIT_TRACE2 && + test_when_finished "unset GIT_TRACE2" && + + if test_have_prereq !MINGW + then + OUT=$( ((test_terminal git log; echo $? 1>&3) | :) 3>&1 ) && + test_match_signal 13 "$OUT" + else + test_terminal git log + fi && + + grep child_exit trace.normal >child-exits && + test_line_count = 1 child-exits && + grep " code:-1 " child-exits +' + +test_expect_success TTY 'git returns SIGPIPE on propagated signals from pager' ' + test_when_finished "rm pager-used trace.normal" && + test_config core.pager ">pager-used; test-tool sigchain" && + GIT_TRACE2="$(pwd)/trace.normal" && + export GIT_TRACE2 && + test_when_finished "unset GIT_TRACE2" && + + if test_have_prereq !MINGW + then + OUT=$( ((test_terminal git log; echo $? 1>&3) | :) 3>&1 ) && + test_match_signal 13 "$OUT" + else + test_terminal git log + fi && + + grep child_exit trace.normal >child-exits && + test_line_count = 1 child-exits && + grep " code:143 " child-exits && + test_path_is_file pager-used +' + test_done diff --git a/t/t7007-show.sh b/t/t7007-show.sh index 42d3db6246..d6cc69e0f2 100755 --- a/t/t7007-show.sh +++ b/t/t7007-show.sh @@ -38,6 +38,45 @@ test_expect_success 'showing two commits' ' test_cmp expect actual.filtered ' +test_expect_success 'showing a tree' ' + cat >expected <<-EOF && + tree main1: + + main1.t + EOF + git show main1: >actual && + test_cmp expected actual +' + +test_expect_success 'showing two trees' ' + cat >expected <<-EOF && + tree main1^{tree} + + main1.t + + tree main2^{tree} + + main1.t + main2.t + EOF + git show main1^{tree} main2^{tree} >actual && + test_cmp expected actual +' + +test_expect_success 'showing a trees is not recursive' ' + git worktree add not-recursive main1 && + mkdir not-recursive/a && + test_commit -C not-recursive a/file && + cat >expected <<-EOF && + tree HEAD^{tree} + + a/ + main1.t + EOF + git -C not-recursive show HEAD^{tree} >actual && + test_cmp expected actual +' + test_expect_success 'showing a range walks (linear)' ' cat >expect <<-EOF && commit $(git rev-parse main3) diff --git a/t/t7011-skip-worktree-reading.sh b/t/t7011-skip-worktree-reading.sh index 37525cae3a..1761a2b1b9 100755 --- a/t/t7011-skip-worktree-reading.sh +++ b/t/t7011-skip-worktree-reading.sh @@ -109,15 +109,6 @@ test_expect_success 'ls-files --modified' ' test -z "$(git ls-files -m)" ' -test_expect_success 'grep with skip-worktree file' ' - git update-index --no-skip-worktree 1 && - echo test > 1 && - git update-index 1 && - git update-index --skip-worktree 1 && - rm 1 && - test "$(git grep --no-ext-grep test)" = "1:test" -' - echo ":000000 100644 $ZERO_OID $EMPTY_BLOB A 1" > expected test_expect_success 'diff-index does not examine skip-worktree absent entries' ' setup_absent && @@ -141,11 +132,6 @@ test_expect_success 'diff-files does not examine skip-worktree dirty entries' ' test -z "$(git diff-files -- one)" ' -test_expect_success 'git-rm succeeds on skip-worktree absent entries' ' - setup_absent && - git rm 1 -' - test_expect_success 'commit on skip-worktree absent entries' ' git reset && setup_absent && diff --git a/t/t7012-skip-worktree-writing.sh b/t/t7012-skip-worktree-writing.sh index e5c6a038fb..a1080b94e3 100755 --- a/t/t7012-skip-worktree-writing.sh +++ b/t/t7012-skip-worktree-writing.sh @@ -60,13 +60,6 @@ setup_absent() { git update-index --skip-worktree 1 } -test_absent() { - echo "100644 $EMPTY_BLOB 0 1" > expected && - git ls-files --stage 1 > result && - test_cmp expected result && - test ! -f 1 -} - setup_dirty() { git update-index --force-remove 1 && echo dirty > 1 && @@ -100,18 +93,6 @@ test_expect_success 'index setup' ' test_cmp expected result ' -test_expect_success 'git-add ignores worktree content' ' - setup_absent && - git add 1 && - test_absent -' - -test_expect_success 'git-add ignores worktree content' ' - setup_dirty && - git add 1 && - test_dirty -' - test_expect_success 'git-rm fails if worktree is dirty' ' setup_dirty && test_must_fail git rm 1 && @@ -125,13 +106,13 @@ EOF test_expect_success 'git-clean, absent case' ' setup_absent && git clean -n > result && - test_i18ncmp expected result + test_cmp expected result ' test_expect_success 'git-clean, dirty case' ' setup_dirty && git clean -n > result && - test_i18ncmp expected result + test_cmp expected result ' test_expect_success '--ignore-skip-worktree-entries leaves worktree alone' ' diff --git a/t/t7030-verify-tag.sh b/t/t7030-verify-tag.sh index 5c5bc32ccb..3cefde9602 100755 --- a/t/t7030-verify-tag.sh +++ b/t/t7030-verify-tag.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='signed tag tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY/lib-gpg.sh" @@ -17,7 +20,7 @@ test_expect_success GPG 'create signed tags' ' echo 3 >elif && git add elif && test_tick && git commit -m "third on side" && - git checkout master && + git checkout main && test_tick && git merge -S side && git tag -s -m merge merge && diff --git a/t/t7060-wtstatus.sh b/t/t7060-wtstatus.sh index d5218743e9..0f4344c55e 100755 --- a/t/t7060-wtstatus.sh +++ b/t/t7060-wtstatus.sh @@ -2,6 +2,9 @@ test_description='basic work tree status reporting' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -51,11 +54,11 @@ EOF git checkout -b side HEAD^ && git rm foo && git commit -m delete && - test_must_fail git merge master && + test_must_fail git merge main && test_must_fail git commit --dry-run >../actual && - test_i18ncmp ../expect ../actual && + test_cmp ../expect ../actual && git status >../actual && - test_i18ncmp ../expect ../actual + test_cmp ../expect ../actual ) ' @@ -124,18 +127,18 @@ test_expect_success 'git diff-index --cached -C shows 2 copies + 1 unmerged' ' test_expect_success 'status when conflicts with add and rm advice (deleted by them)' ' git reset --hard && - git checkout master && + git checkout main && test_commit init main.txt init && git checkout -b second_branch && git rm main.txt && git commit -m "main.txt deleted on second_branch" && test_commit second conflict.txt second && - git checkout master && + git checkout main && test_commit on_second main.txt on_second && - test_commit master conflict.txt master && + test_commit main conflict.txt main && test_must_fail git merge second_branch && cat >expected <<\EOF && -On branch master +On branch main You have unmerged paths. (fix conflicts and run "git commit") (use "git merge --abort" to abort the merge) @@ -148,7 +151,7 @@ Unmerged paths: no changes added to commit (use "git add" and/or "git commit -a") EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' @@ -157,8 +160,8 @@ test_expect_success 'prepare for conflicts' ' git checkout -b conflict && test_commit one main.txt one && git branch conflict_second && - git mv main.txt sub_master.txt && - git commit -m "main.txt renamed in sub_master.txt" && + git mv main.txt sub_main.txt && + git commit -m "main.txt renamed in sub_main.txt" && git checkout conflict_second && git mv main.txt sub_second.txt && git commit -m "main.txt renamed in sub_second.txt" @@ -176,20 +179,20 @@ You have unmerged paths. Unmerged paths: (use "git add/rm <file>..." as appropriate to mark resolution) both deleted: main.txt - added by them: sub_master.txt + added by them: sub_main.txt added by us: sub_second.txt no changes added to commit (use "git add" and/or "git commit -a") EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status when conflicts with only rm advice (both deleted)' ' git reset --hard conflict_second && test_must_fail git merge conflict && - git add sub_master.txt && + git add sub_main.txt && git add sub_second.txt && cat >expected <<\EOF && On branch conflict_second @@ -198,7 +201,7 @@ You have unmerged paths. (use "git merge --abort" to abort the merge) Changes to be committed: - new file: sub_master.txt + new file: sub_main.txt Unmerged paths: (use "git rm <file>..." to mark resolution) @@ -207,14 +210,14 @@ Unmerged paths: Untracked files not listed (use -u option to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual && + test_cmp expected actual && git reset --hard && - git checkout master + git checkout main ' test_expect_success 'status --branch with detached HEAD' ' git reset --hard && - git checkout master^0 && + git checkout main^0 && git status --branch --porcelain >actual && cat >expected <<-EOF && ## HEAD (no branch) @@ -224,13 +227,13 @@ test_expect_success 'status --branch with detached HEAD' ' ?? expected ?? mdconflict/ EOF - test_i18ncmp expected actual + test_cmp expected actual ' ## Duplicate the above test and verify --porcelain=v1 arg parsing. test_expect_success 'status --porcelain=v1 --branch with detached HEAD' ' git reset --hard && - git checkout master^0 && + git checkout main^0 && git status --branch --porcelain=v1 >actual && cat >expected <<-EOF && ## HEAD (no branch) @@ -240,7 +243,7 @@ test_expect_success 'status --porcelain=v1 --branch with detached HEAD' ' ?? expected ?? mdconflict/ EOF - test_i18ncmp expected actual + test_cmp expected actual ' ## Verify parser error on invalid --porcelain argument. diff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh index a682a3d826..a0c123b0a7 100755 --- a/t/t7063-status-untracked-cache.sh +++ b/t/t7063-status-untracked-cache.sh @@ -2,6 +2,9 @@ test_description='test untracked cache' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # On some filesystems (e.g. FreeBSD's ext2 and ufs) directory mtime @@ -54,6 +57,20 @@ iuc () { return $ret } +get_relevant_traces () { + # From the GIT_TRACE2_PERF data of the form + # $TIME $FILE:$LINE | d0 | main | data | r1 | ? | ? | read_directo | $RELEVANT_STAT + # extract the $RELEVANT_STAT fields. We don't care about region_enter + # or region_leave, or stats for things outside read_directory. + INPUT_FILE=$1 + OUTPUT_FILE=$2 + grep data.*read_directo $INPUT_FILE | + cut -d "|" -f 9 | + grep -v visited \ + >"$OUTPUT_FILE" +} + + test_lazy_prereq UNTRACKED_CACHE ' { git update-index --test-untracked-cache; ret=$?; } && test $ret -ne 1 @@ -126,19 +143,21 @@ EOF test_expect_success 'status first time (empty cache)' ' avoid_racy && - : >../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && test_cmp ../status.expect ../status.iuc && test_cmp ../status.expect ../actual && + get_relevant_traces ../trace.output ../trace.relevant && cat >../trace.expect <<EOF && -node creation: 3 -gitignore invalidation: 1 -directory invalidation: 0 -opendir: 4 + ....path: + ....node-creation:3 + ....gitignore-invalidation:1 + ....directory-invalidation:0 + ....opendir:4 EOF - test_cmp ../trace.expect ../trace + test_cmp ../trace.expect ../trace.relevant ' test_expect_success 'untracked cache after first status' ' @@ -148,19 +167,21 @@ test_expect_success 'untracked cache after first status' ' test_expect_success 'status second time (fully populated cache)' ' avoid_racy && - : >../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && test_cmp ../status.expect ../status.iuc && test_cmp ../status.expect ../actual && + get_relevant_traces ../trace.output ../trace.relevant && cat >../trace.expect <<EOF && -node creation: 0 -gitignore invalidation: 0 -directory invalidation: 0 -opendir: 0 + ....path: + ....node-creation:0 + ....gitignore-invalidation:0 + ....directory-invalidation:0 + ....opendir:0 EOF - test_cmp ../trace.expect ../trace + test_cmp ../trace.expect ../trace.relevant ' test_expect_success 'untracked cache after second status' ' @@ -171,8 +192,8 @@ test_expect_success 'untracked cache after second status' ' test_expect_success 'modify in root directory, one dir invalidation' ' avoid_racy && : >four && - : >../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && cat >../status.expect <<EOF && @@ -186,13 +207,15 @@ A two EOF test_cmp ../status.expect ../status.iuc && test_cmp ../status.expect ../actual && + get_relevant_traces ../trace.output ../trace.relevant && cat >../trace.expect <<EOF && -node creation: 0 -gitignore invalidation: 0 -directory invalidation: 1 -opendir: 1 + ....path: + ....node-creation:0 + ....gitignore-invalidation:0 + ....directory-invalidation:1 + ....opendir:1 EOF - test_cmp ../trace.expect ../trace + test_cmp ../trace.expect ../trace.relevant ' @@ -220,8 +243,8 @@ EOF test_expect_success 'new .gitignore invalidates recursively' ' avoid_racy && echo four >.gitignore && - : >../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && cat >../status.expect <<EOF && @@ -235,13 +258,15 @@ A two EOF test_cmp ../status.expect ../status.iuc && test_cmp ../status.expect ../actual && + get_relevant_traces ../trace.output ../trace.relevant && cat >../trace.expect <<EOF && -node creation: 0 -gitignore invalidation: 1 -directory invalidation: 1 -opendir: 4 + ....path: + ....node-creation:0 + ....gitignore-invalidation:1 + ....directory-invalidation:1 + ....opendir:4 EOF - test_cmp ../trace.expect ../trace + test_cmp ../trace.expect ../trace.relevant ' @@ -269,8 +294,8 @@ EOF test_expect_success 'new info/exclude invalidates everything' ' avoid_racy && echo three >>.git/info/exclude && - : >../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && cat >../status.expect <<EOF && @@ -282,13 +307,15 @@ A two EOF test_cmp ../status.expect ../status.iuc && test_cmp ../status.expect ../actual && + get_relevant_traces ../trace.output ../trace.relevant && cat >../trace.expect <<EOF && -node creation: 0 -gitignore invalidation: 1 -directory invalidation: 0 -opendir: 4 + ....path: + ....node-creation:0 + ....gitignore-invalidation:1 + ....directory-invalidation:0 + ....opendir:4 EOF - test_cmp ../trace.expect ../trace + test_cmp ../trace.expect ../trace.relevant ' test_expect_success 'verify untracked cache dump' ' @@ -327,8 +354,8 @@ EOF ' test_expect_success 'status after the move' ' - : >../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && cat >../status.expect <<EOF && @@ -340,13 +367,15 @@ A one EOF test_cmp ../status.expect ../status.iuc && test_cmp ../status.expect ../actual && + get_relevant_traces ../trace.output ../trace.relevant && cat >../trace.expect <<EOF && -node creation: 0 -gitignore invalidation: 0 -directory invalidation: 0 -opendir: 1 + ....path: + ....node-creation:0 + ....gitignore-invalidation:0 + ....directory-invalidation:0 + ....opendir:1 EOF - test_cmp ../trace.expect ../trace + test_cmp ../trace.expect ../trace.relevant ' test_expect_success 'verify untracked cache dump' ' @@ -386,8 +415,8 @@ EOF ' test_expect_success 'status after the move' ' - : >../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && cat >../status.expect <<EOF && @@ -399,13 +428,15 @@ A two EOF test_cmp ../status.expect ../status.iuc && test_cmp ../status.expect ../actual && + get_relevant_traces ../trace.output ../trace.relevant && cat >../trace.expect <<EOF && -node creation: 0 -gitignore invalidation: 0 -directory invalidation: 0 -opendir: 1 + ....path: + ....node-creation:0 + ....gitignore-invalidation:0 + ....directory-invalidation:0 + ....opendir:1 EOF - test_cmp ../trace.expect ../trace + test_cmp ../trace.expect ../trace.relevant ' test_expect_success 'verify untracked cache dump' ' @@ -435,8 +466,8 @@ test_expect_success 'set up for sparse checkout testing' ' ' test_expect_success 'status after commit' ' - : >../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && cat >../status.expect <<EOF && @@ -445,13 +476,15 @@ test_expect_success 'status after commit' ' EOF test_cmp ../status.expect ../status.iuc && test_cmp ../status.expect ../actual && + get_relevant_traces ../trace.output ../trace.relevant && cat >../trace.expect <<EOF && -node creation: 0 -gitignore invalidation: 0 -directory invalidation: 0 -opendir: 2 + ....path: + ....node-creation:0 + ....gitignore-invalidation:0 + ....directory-invalidation:0 + ....opendir:2 EOF - test_cmp ../trace.expect ../trace + test_cmp ../trace.expect ../trace.relevant ' test_expect_success 'untracked cache correct after commit' ' @@ -475,7 +508,7 @@ EOF test_expect_success 'set up sparse checkout' ' echo "done/[a-z]*" >.git/info/sparse-checkout && test_config core.sparsecheckout true && - git checkout master && + git checkout main && git update-index --force-untracked-cache && git status --porcelain >/dev/null && # prime the cache test_path_is_missing done/.gitignore && @@ -493,9 +526,9 @@ test_expect_success 'create/modify files, some of which are gitignored' ' ' test_expect_success 'test sparse status with untracked cache' ' - : >../trace && + : >../trace.output && avoid_racy && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../status.actual && iuc status --porcelain >../status.iuc && cat >../status.expect <<EOF && @@ -506,13 +539,15 @@ test_expect_success 'test sparse status with untracked cache' ' EOF test_cmp ../status.expect ../status.iuc && test_cmp ../status.expect ../status.actual && + get_relevant_traces ../trace.output ../trace.relevant && cat >../trace.expect <<EOF && -node creation: 0 -gitignore invalidation: 1 -directory invalidation: 2 -opendir: 2 + ....path: + ....node-creation:0 + ....gitignore-invalidation:1 + ....directory-invalidation:2 + ....opendir:2 EOF - test_cmp ../trace.expect ../trace + test_cmp ../trace.expect ../trace.relevant ' test_expect_success 'untracked cache correct after status' ' @@ -536,8 +571,8 @@ EOF test_expect_success 'test sparse status again with untracked cache' ' avoid_racy && - : >../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../status.actual && iuc status --porcelain >../status.iuc && cat >../status.expect <<EOF && @@ -548,13 +583,15 @@ test_expect_success 'test sparse status again with untracked cache' ' EOF test_cmp ../status.expect ../status.iuc && test_cmp ../status.expect ../status.actual && + get_relevant_traces ../trace.output ../trace.relevant && cat >../trace.expect <<EOF && -node creation: 0 -gitignore invalidation: 0 -directory invalidation: 0 -opendir: 0 + ....path: + ....node-creation:0 + ....gitignore-invalidation:0 + ....directory-invalidation:0 + ....opendir:0 EOF - test_cmp ../trace.expect ../trace + test_cmp ../trace.expect ../trace.relevant ' test_expect_success 'set up for test of subdir and sparse checkouts' ' @@ -565,8 +602,8 @@ test_expect_success 'set up for test of subdir and sparse checkouts' ' test_expect_success 'test sparse status with untracked cache and subdir' ' avoid_racy && - : >../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../status.actual && iuc status --porcelain >../status.iuc && cat >../status.expect <<EOF && @@ -578,13 +615,15 @@ test_expect_success 'test sparse status with untracked cache and subdir' ' EOF test_cmp ../status.expect ../status.iuc && test_cmp ../status.expect ../status.actual && + get_relevant_traces ../trace.output ../trace.relevant && cat >../trace.expect <<EOF && -node creation: 2 -gitignore invalidation: 0 -directory invalidation: 1 -opendir: 3 + ....path: + ....node-creation:2 + ....gitignore-invalidation:0 + ....directory-invalidation:1 + ....opendir:3 EOF - test_cmp ../trace.expect ../trace + test_cmp ../trace.expect ../trace.relevant ' test_expect_success 'verify untracked cache dump (sparse/subdirs)' ' @@ -613,19 +652,21 @@ EOF test_expect_success 'test sparse status again with untracked cache and subdir' ' avoid_racy && - : >../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../status.actual && iuc status --porcelain >../status.iuc && test_cmp ../status.expect ../status.iuc && test_cmp ../status.expect ../status.actual && + get_relevant_traces ../trace.output ../trace.relevant && cat >../trace.expect <<EOF && -node creation: 0 -gitignore invalidation: 0 -directory invalidation: 0 -opendir: 0 + ....path: + ....node-creation:0 + ....gitignore-invalidation:0 + ....directory-invalidation:0 + ....opendir:0 EOF - test_cmp ../trace.expect ../trace + test_cmp ../trace.expect ../trace.relevant ' test_expect_success 'move entry in subdir from untracked to cached' ' @@ -728,19 +769,19 @@ test_expect_success 'test ident field is working' ' cp -R done dthree dtwo four three ../other_worktree && GIT_WORK_TREE=../other_worktree git status 2>../err && echo "warning: untracked cache is disabled on this system or location" >../expect && - test_i18ncmp ../expect ../err + test_cmp ../expect ../err ' test_expect_success 'untracked cache survives a checkout' ' git commit --allow-empty -m empty && test-tool dump-untracked-cache >../before && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && git checkout -b other_branch && test-tool dump-untracked-cache >../after && test_cmp ../before ../after && test_commit test && test-tool dump-untracked-cache >../before && - git checkout master && + git checkout main && test-tool dump-untracked-cache >../after && test_cmp ../before ../after ' @@ -775,7 +816,7 @@ test_expect_success SYMLINKS '"status" after symlink replacement should be clean git checkout HEAD~ && status_is_clean && status_is_clean && - git checkout master && + git checkout main && avoid_racy && status_is_clean && status_is_clean @@ -786,7 +827,7 @@ test_expect_success SYMLINKS '"status" after symlink replacement should be clean git checkout HEAD~ && status_is_clean && status_is_clean && - git checkout master && + git checkout main && avoid_racy && status_is_clean && status_is_clean @@ -810,7 +851,7 @@ test_expect_success '"status" after file replacement should be clean with UC=tru git checkout HEAD~ && status_is_clean && status_is_clean && - git checkout master && + git checkout main && avoid_racy && status_is_clean && test-tool dump-untracked-cache >../actual && @@ -828,7 +869,7 @@ test_expect_success '"status" after file replacement should be clean with UC=fal git checkout HEAD~ && status_is_clean && status_is_clean && - git checkout master && + git checkout main && avoid_racy && status_is_clean && status_is_clean diff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh index 601b47830b..4613882caf 100755 --- a/t/t7064-wtstatus-pv2.sh +++ b/t/t7064-wtstatus-pv2.sh @@ -5,6 +5,9 @@ test_description='git status --porcelain=v2 This test exercises porcelain V2 output for git status.' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh index b1affb001f..601b2bf97f 100755 --- a/t/t7102-reset.sh +++ b/t/t7102-reset.sh @@ -7,6 +7,9 @@ test_description='git reset Documented tests for git reset' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh commit_msg () { @@ -72,14 +75,14 @@ test_expect_success 'reset --hard message' ' hex=$(git log -1 --format="%h") && git reset --hard >.actual && echo HEAD is now at $hex $(commit_msg) >.expected && - test_i18ncmp .expected .actual + test_cmp .expected .actual ' test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' ' hex=$(git log -1 --format="%h") && git -c "i18n.logOutputEncoding=$test_encoding" reset --hard >.actual && echo HEAD is now at $hex $(commit_msg $test_encoding) >.expected && - test_i18ncmp .expected .actual + test_cmp .expected .actual ' test_expect_success 'giving a non existing revision should fail' ' @@ -145,7 +148,7 @@ test_expect_success 'trying to do reset --soft with pending merge should fail' ' printf "1st line 2nd file\n2nd line 2nd file\n3rd line" >secondfile && git commit -a -m "the change in branch2" && - git checkout master && + git checkout main && git branch -D branch1 branch2 && check_changes $head5 ' @@ -167,7 +170,7 @@ test_expect_success 'trying to do reset --soft with pending checkout merge shoul printf "1st line 2nd file\n2nd line 2nd file\n3rd line" >secondfile && git commit -a -m "the line in branch3" && - git checkout master && + git checkout main && git branch -D branch3 branch4 && check_changes $head5 ' @@ -380,7 +383,7 @@ test_expect_success '--hard reset to ORIG_HEAD should clear a fast-forward merge git reset --hard ORIG_HEAD && check_changes $head5 && - git checkout master && + git checkout main && git branch -D branch1 branch2 && check_changes $head5 ' @@ -466,7 +469,7 @@ test_expect_success '--mixed refreshes the index' ' EOF echo 123 >>file2 && git reset --mixed HEAD >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'resetting specific path that is unmerged' ' diff --git a/t/t7104-reset-hard.sh b/t/t7104-reset-hard.sh index 16faa07813..7948ec392b 100755 --- a/t/t7104-reset-hard.sh +++ b/t/t7104-reset-hard.sh @@ -33,7 +33,7 @@ test_expect_success 'reset --hard should restore unmerged ones' ' ' -test_expect_success 'reset --hard did not corrupt index or cached-tree' ' +test_expect_success 'reset --hard did not corrupt index or cache-tree' ' T=$(git write-tree) && rm -f .git/index && diff --git a/t/t7113-post-index-change-hook.sh b/t/t7113-post-index-change-hook.sh index f011ad7eec..688fa995c9 100755 --- a/t/t7113-post-index-change-hook.sh +++ b/t/t7113-post-index-change-hook.sh @@ -2,6 +2,9 @@ test_description='post index change hook' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -85,7 +88,7 @@ test_expect_success 'test checkout and reset trigger the hook' ' EOF : force index to be dirty && test-tool chmtime +60 dir1/file1.txt && - git checkout master && + git checkout main && test_path_is_file testsuccess && rm -f testsuccess && test_path_is_missing testfailure && test-tool chmtime +60 dir1/file1.txt && diff --git a/t/t7201-co.sh b/t/t7201-co.sh index b36a93056f..7f6e23a4bb 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -5,10 +5,10 @@ test_description='git checkout tests. -Creates master, forks renamer and side branches from it. +Creates main, forks renamer and side branches from it. Test switching across them. - ! [master] Initial A one, A two + ! [main] Initial A one, A two * [renamer] Renamer R one->uno, M two ! [side] Side M one, D two, A three ! [simple] Simple D one, M two @@ -16,10 +16,13 @@ Test switching across them. + [simple] Simple D one, M two + [side] Side M one, D two, A three * [renamer] Renamer R one->uno, M two - +*++ [master] Initial A one, A two + +*++ [main] Initial A one, A two ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_tick @@ -46,27 +49,27 @@ test_expect_success setup ' fill a b c d e f >two && git commit -a -m "Renamer R one->uno, M two" && - git checkout -b side master && + git checkout -b side main && fill 1 2 3 4 5 6 7 >one && fill A B C D E >three && rm -f two && git update-index --add --remove one two three && git commit -m "Side M one, D two, A three" && - git checkout -b simple master && + git checkout -b simple main && rm -f one && fill a c e >two && git commit -a -m "Simple D one, M two" && - git checkout master + git checkout main ' test_expect_success 'checkout from non-existing branch' ' - git checkout -b delete-me master && + git checkout -b delete-me main && git update-ref -d --no-deref refs/heads/delete-me && test refs/heads/delete-me = "$(git symbolic-ref HEAD)" && - git checkout master && - test refs/heads/master = "$(git symbolic-ref HEAD)" + git checkout main && + test refs/heads/main = "$(git symbolic-ref HEAD)" ' test_expect_success 'checkout with dirty tree without -m' ' @@ -81,7 +84,7 @@ test_expect_success 'checkout with dirty tree without -m' ' ' test_expect_success 'checkout with unrelated dirty tree without -m' ' - git checkout -f master && + git checkout -f main && fill 0 1 2 3 4 5 6 7 8 >same && cp same kept && git checkout side >messages && @@ -91,7 +94,7 @@ test_expect_success 'checkout with unrelated dirty tree without -m' ' ' test_expect_success 'checkout -m with dirty tree' ' - git checkout -f master && + git checkout -f main && git clean -f && fill 0 1 2 3 4 5 6 7 8 >one && @@ -102,9 +105,9 @@ test_expect_success 'checkout -m with dirty tree' ' printf "M\t%s\n" one >expect.messages && test_cmp expect.messages messages && - fill "M one" "A three" "D two" >expect.master && - git diff --name-status master >current.master && - test_cmp expect.master current.master && + fill "M one" "A three" "D two" >expect.main && + git diff --name-status main >current.main && + test_cmp expect.main current.main && fill "M one" >expect.side && git diff --name-status side >current.side && @@ -115,7 +118,7 @@ test_expect_success 'checkout -m with dirty tree' ' ' test_expect_success 'checkout -m with dirty tree, renamed' ' - git checkout -f master && git clean -f && + git checkout -f main && git clean -f && fill 1 2 3 4 5 7 8 >one && if git checkout renamer @@ -135,7 +138,7 @@ test_expect_success 'checkout -m with dirty tree, renamed' ' ' test_expect_success 'checkout -m with merge conflict' ' - git checkout -f master && git clean -f && + git checkout -f main && git clean -f && fill 1 T 3 4 5 6 S 8 >one && if git checkout renamer @@ -148,7 +151,7 @@ test_expect_success 'checkout -m with merge conflict' ' git checkout -m renamer && - git diff master:one :3:uno | + git diff main:one :3:uno | sed -e "1,/^@@/d" -e "/^ /d" -e "s/^-/d/" -e "s/^+/a/" >current && fill d2 aT d7 aS >expect && test_cmp expect current && @@ -157,7 +160,7 @@ test_expect_success 'checkout -m with merge conflict' ' ' test_expect_success 'format of merge conflict from checkout -m' ' - git checkout -f master && + git checkout -f main && git clean -f && fill b d >two && @@ -181,7 +184,7 @@ test_expect_success 'format of merge conflict from checkout -m' ' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' - git checkout -f master && + git checkout -f main && git reset --hard && git clean -f && @@ -193,7 +196,7 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' a c e - ||||||| master + ||||||| main a b c @@ -208,7 +211,7 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' ' test_expect_success 'switch to another branch while carrying a deletion' ' - git checkout -f master && + git checkout -f main && git reset --hard && git clean -f && git rm two && @@ -229,7 +232,7 @@ test_expect_success 'checkout to detach HEAD (with advice declined)' ' test_i18ngrep "HEAD is now at $rev" messages && test_line_count = 1 messages && H=$(git rev-parse --verify HEAD) && - M=$(git show-ref -s --verify refs/heads/master) && + M=$(git show-ref -s --verify refs/heads/main) && test "z$H" = "z$M" && if git symbolic-ref HEAD >/dev/null 2>&1 then @@ -245,11 +248,11 @@ test_expect_success 'checkout to detach HEAD' ' rev=$(git rev-parse --short renamer^) && git checkout -f renamer && git clean -f && - GIT_TEST_GETTEXT_POISON=false git checkout renamer^ 2>messages && + git checkout renamer^ 2>messages && grep "HEAD is now at $rev" messages && test_line_count -gt 1 messages && H=$(git rev-parse --verify HEAD) && - M=$(git show-ref -s --verify refs/heads/master) && + M=$(git show-ref -s --verify refs/heads/main) && test "z$H" = "z$M" && if git symbolic-ref HEAD >/dev/null 2>&1 then @@ -261,11 +264,11 @@ test_expect_success 'checkout to detach HEAD' ' ' test_expect_success 'checkout to detach HEAD with branchname^' ' - git checkout -f master && + git checkout -f main && git clean -f && git checkout renamer^ && H=$(git rev-parse --verify HEAD) && - M=$(git show-ref -s --verify refs/heads/master) && + M=$(git show-ref -s --verify refs/heads/main) && test "z$H" = "z$M" && if git symbolic-ref HEAD >/dev/null 2>&1 then @@ -277,11 +280,11 @@ test_expect_success 'checkout to detach HEAD with branchname^' ' ' test_expect_success 'checkout to detach HEAD with :/message' ' - git checkout -f master && + git checkout -f main && git clean -f && git checkout ":/Initial" && H=$(git rev-parse --verify HEAD) && - M=$(git show-ref -s --verify refs/heads/master) && + M=$(git show-ref -s --verify refs/heads/main) && test "z$H" = "z$M" && if git symbolic-ref HEAD >/dev/null 2>&1 then @@ -293,11 +296,11 @@ test_expect_success 'checkout to detach HEAD with :/message' ' ' test_expect_success 'checkout to detach HEAD with HEAD^0' ' - git checkout -f master && + git checkout -f main && git clean -f && git checkout HEAD^0 && H=$(git rev-parse --verify HEAD) && - M=$(git show-ref -s --verify refs/heads/master) && + M=$(git show-ref -s --verify refs/heads/main) && test "z$H" = "z$M" && if git symbolic-ref HEAD >/dev/null 2>&1 then @@ -310,13 +313,13 @@ test_expect_success 'checkout to detach HEAD with HEAD^0' ' test_expect_success 'checkout with ambiguous tag/branch names' ' git tag both side && - git branch both master && + git branch both main && git reset --hard && - git checkout master && + git checkout main && git checkout both && H=$(git rev-parse --verify HEAD) && - M=$(git show-ref -s --verify refs/heads/master) && + M=$(git show-ref -s --verify refs/heads/main) && test "z$H" = "z$M" && name=$(git symbolic-ref HEAD 2>/dev/null) && test "z$name" = zrefs/heads/both @@ -324,12 +327,12 @@ test_expect_success 'checkout with ambiguous tag/branch names' ' test_expect_success 'checkout with ambiguous tag/branch names' ' git reset --hard && - git checkout master && + git checkout main && git tag frotz side && - git branch frotz master && + git branch frotz main && git reset --hard && - git checkout master && + git checkout main && git checkout tags/frotz && H=$(git rev-parse --verify HEAD) && @@ -346,7 +349,7 @@ test_expect_success 'checkout with ambiguous tag/branch names' ' test_expect_success 'switch branches while in subdirectory' ' git reset --hard && - git checkout master && + git checkout main && mkdir subs && git -C subs checkout side && @@ -362,7 +365,7 @@ test_expect_success 'checkout specific path while in subdirectory' ' git add subs/bero && git commit -m "add subs/bero" && - git checkout master && + git checkout main && mkdir -p subs && git -C subs checkout side -- bero && test -f subs/bero @@ -370,7 +373,7 @@ test_expect_success 'checkout specific path while in subdirectory' ' test_expect_success 'checkout w/--track sets up tracking' ' git config branch.autosetupmerge false && - git checkout master && + git checkout main && git checkout --track -b track1 && test "$(git config branch.track1.remote)" && test "$(git config branch.track1.merge)" @@ -379,40 +382,40 @@ test_expect_success 'checkout w/--track sets up tracking' ' test_expect_success 'checkout w/autosetupmerge=always sets up tracking' ' test_when_finished git config branch.autosetupmerge false && git config branch.autosetupmerge always && - git checkout master && + git checkout main && git checkout -b track2 && test "$(git config branch.track2.remote)" && test "$(git config branch.track2.merge)" ' test_expect_success 'checkout w/--track from non-branch HEAD fails' ' - git checkout master^0 && + git checkout main^0 && test_must_fail git symbolic-ref HEAD && test_must_fail git checkout --track -b track && test_must_fail git rev-parse --verify track && test_must_fail git symbolic-ref HEAD && - test "z$(git rev-parse master^0)" = "z$(git rev-parse HEAD)" + test "z$(git rev-parse main^0)" = "z$(git rev-parse HEAD)" ' test_expect_success 'checkout w/--track from tag fails' ' - git checkout master^0 && + git checkout main^0 && test_must_fail git symbolic-ref HEAD && test_must_fail git checkout --track -b track frotz && test_must_fail git rev-parse --verify track && test_must_fail git symbolic-ref HEAD && - test "z$(git rev-parse master^0)" = "z$(git rev-parse HEAD)" + test "z$(git rev-parse main^0)" = "z$(git rev-parse HEAD)" ' test_expect_success 'detach a symbolic link HEAD' ' - git checkout master && + git checkout main && git config --bool core.prefersymlinkrefs yes && git checkout side && - git checkout master && + git checkout main && it=$(git symbolic-ref HEAD) && - test "z$it" = zrefs/heads/master && - here=$(git rev-parse --verify refs/heads/master) && + test "z$it" = zrefs/heads/main && + here=$(git rev-parse --verify refs/heads/main) && git checkout side^ && - test "z$(git rev-parse --verify refs/heads/master)" = "z$here" + test "z$(git rev-parse --verify refs/heads/main)" = "z$here" ' test_expect_success 'checkout with --track fakes a sensible -b <name>' ' @@ -423,13 +426,13 @@ test_expect_success 'checkout with --track fakes a sensible -b <name>' ' test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" && test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" && - git checkout master && git branch -D koala/bear && + git checkout main && git branch -D koala/bear && git checkout --track refs/remotes/origin/koala/bear && test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" && test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" && - git checkout master && git branch -D koala/bear && + git checkout main && git branch -D koala/bear && git checkout --track remotes/origin/koala/bear && test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" && @@ -582,17 +585,17 @@ test_expect_success 'checkout --conflict=diff3' ' ' test_expect_success 'failing checkout -b should not break working tree' ' - git reset --hard master && - git symbolic-ref HEAD refs/heads/master && + git reset --hard main && + git symbolic-ref HEAD refs/heads/main && test_must_fail git checkout -b renamer side^ && - test $(git symbolic-ref HEAD) = refs/heads/master && + test $(git symbolic-ref HEAD) = refs/heads/main && git diff --exit-code && git diff --cached --exit-code ' test_expect_success 'switch out of non-branch' ' - git reset --hard master && - git checkout master^0 && + git reset --hard main && + git checkout main^0 && echo modified >one && test_must_fail git checkout renamer 2>error.log && ! grep "^Previous HEAD" error.log diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index cb5e34d94c..0399701e62 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -110,7 +110,7 @@ test_expect_success 'git clean with prefix' ' ' -test_expect_success C_LOCALE_OUTPUT 'git clean with relative prefix' ' +test_expect_success 'git clean with relative prefix' ' mkdir -p build docs && touch a.out src/part3.c docs/manual.txt obj.o build/lib.so && @@ -123,7 +123,7 @@ test_expect_success C_LOCALE_OUTPUT 'git clean with relative prefix' ' verbose test "$would_clean" = ../src/part3.c ' -test_expect_success C_LOCALE_OUTPUT 'git clean with absolute path' ' +test_expect_success 'git clean with absolute path' ' mkdir -p build docs && touch a.out src/part3.c docs/manual.txt obj.o build/lib.so && @@ -407,7 +407,7 @@ test_expect_success 'clean.requireForce and -f' ' ' -test_expect_success C_LOCALE_OUTPUT 'core.excludesfile' ' +test_expect_success 'core.excludesfile' ' echo excludes >excludes && echo included >included && @@ -746,4 +746,46 @@ test_expect_success 'clean untracked paths by pathspec' ' test_must_be_empty actual ' +test_expect_success 'avoid traversing into ignored directories' ' + test_when_finished rm -f output error trace.* && + test_create_repo avoid-traversing-deep-hierarchy && + ( + cd avoid-traversing-deep-hierarchy && + + mkdir -p untracked/subdir/with/a && + >untracked/subdir/with/a/random-file.txt && + + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ + git clean -ffdxn -e untracked + ) && + + # Make sure we only visited into the top-level directory, and did + # not traverse into the "untracked" subdirectory since it was excluded + grep data.*read_directo.*directories-visited trace.output | + cut -d "|" -f 9 >trace.relevant && + cat >trace.expect <<-EOF && + ..directories-visited:1 + EOF + test_cmp trace.expect trace.relevant +' + +test_expect_success 'traverse into directories that may have ignored entries' ' + test_when_finished rm -f output && + test_create_repo need-to-traverse-into-hierarchy && + ( + cd need-to-traverse-into-hierarchy && + mkdir -p modules/foobar/src/generated && + > modules/foobar/src/generated/code.c && + > modules/foobar/Makefile && + echo "/modules/**/src/generated/" >.gitignore && + + git clean -fX modules/foobar >../output && + + grep Removing ../output && + + test_path_is_missing modules/foobar/src/generated/code.c && + test_path_is_file modules/foobar/Makefile + ) +' + test_done diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index fec7e0299d..a924fdb7a6 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -9,6 +9,9 @@ This test tries to verify basic sanity of the init, update and status subcommands of git submodule. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'submodule deinit works on empty repository' ' @@ -52,7 +55,7 @@ test_expect_success 'add aborts on repository with no commits' ' EOF git init repo-no-commits && test_must_fail git submodule add ../a ./repo-no-commits 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'status should ignore inner git repo when not added' ' @@ -124,7 +127,7 @@ inspect() { } test_expect_success 'submodule add' ' - echo "refs/heads/master" >expect && + echo "refs/heads/main" >expect && ( cd addtest && @@ -182,7 +185,7 @@ test_expect_success 'submodule add to .gitignored path fails' ' git add --force .gitignore && git commit -m"Ignore everything" && ! git submodule add "$submodurl" submod >actual 2>&1 && - test_i18ncmp expect actual + test_cmp expect actual ) ' @@ -223,7 +226,7 @@ test_expect_success 'submodule add --branch' ' echo "refs/heads/initial" >expect-head && cat <<-\EOF >expect-heads && refs/heads/initial - refs/heads/master + refs/heads/main EOF ( @@ -241,7 +244,7 @@ test_expect_success 'submodule add --branch' ' ' test_expect_success 'submodule add with ./ in path' ' - echo "refs/heads/master" >expect && + echo "refs/heads/main" >expect && ( cd addtest && @@ -257,7 +260,7 @@ test_expect_success 'submodule add with ./ in path' ' ' test_expect_success 'submodule add with /././ in path' ' - echo "refs/heads/master" >expect && + echo "refs/heads/main" >expect && ( cd addtest && @@ -273,7 +276,7 @@ test_expect_success 'submodule add with /././ in path' ' ' test_expect_success 'submodule add with // in path' ' - echo "refs/heads/master" >expect && + echo "refs/heads/main" >expect && ( cd addtest && @@ -289,7 +292,7 @@ test_expect_success 'submodule add with // in path' ' ' test_expect_success 'submodule add with /.. in path' ' - echo "refs/heads/master" >expect && + echo "refs/heads/main" >expect && ( cd addtest && @@ -305,7 +308,7 @@ test_expect_success 'submodule add with /.. in path' ' ' test_expect_success 'submodule add with ./, /.. and // in path' ' - echo "refs/heads/master" >expect && + echo "refs/heads/main" >expect && ( cd addtest && @@ -335,7 +338,7 @@ test_expect_success !CYGWIN 'submodule add with \\ in path' ' ' test_expect_success 'submodule add in subdirectory' ' - echo "refs/heads/master" >expect && + echo "refs/heads/main" >expect && mkdir addtest/sub && ( @@ -557,7 +560,7 @@ test_expect_success 'status should be "up-to-date" after update' ' test_expect_success 'checkout superproject with subproject already present' ' git checkout initial && - git checkout master + git checkout main ' test_expect_success 'apply submodule diff' ' @@ -574,7 +577,7 @@ test_expect_success 'apply submodule diff' ' git checkout second && git apply --index P.diff && - git diff --cached master >staged && + git diff --cached main >staged && test_must_be_empty staged ' diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh index 7608814708..9c3cc4cf40 100755 --- a/t/t7401-submodule-summary.sh +++ b/t/t7401-submodule-summary.sh @@ -190,7 +190,7 @@ test_expect_success 'typechanged submodule(submodule->blob), --cached' " < Add foo5 EOF - test_i18ncmp expected actual + test_cmp expected actual " test_expect_success 'typechanged submodule(submodule->blob), --files' " @@ -200,7 +200,7 @@ test_expect_success 'typechanged submodule(submodule->blob), --files' " > Add foo5 EOF - test_i18ncmp expected actual + test_cmp expected actual " rm -rf sm1 && @@ -211,7 +211,7 @@ test_expect_success 'typechanged submodule(submodule->blob)' " * sm1 $head4(submodule)->$head5(blob): EOF - test_i18ncmp expected actual + test_cmp expected actual " rm -f sm1 && @@ -224,7 +224,7 @@ test_expect_success 'nonexistent commit' " Warn: sm1 doesn't contain commit $head4_full EOF - test_i18ncmp expected actual + test_cmp expected actual " commit_file @@ -235,7 +235,7 @@ test_expect_success 'typechanged submodule(blob->submodule)' " > Add foo7 EOF - test_i18ncmp expected actual + test_cmp expected actual " commit_file sm1 && @@ -292,7 +292,7 @@ test_expect_success 'given commit' " test_expect_success '--for-status' " git submodule summary --for-status HEAD^ >actual && - test_i18ncmp - actual <<-EOF + test_cmp - actual <<-EOF * sm1 $head6...0000000: * sm2 0000000...$head7 (2): diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh index 0726799e74..7d2ac3322b 100755 --- a/t/t7403-submodule-sync.sh +++ b/t/t7403-submodule-sync.sh @@ -8,6 +8,9 @@ test_description='git submodule sync These tests exercise the "git submodule sync" subcommand. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -78,7 +81,7 @@ test_expect_success 'change submodule url' ' ( cd super && cd submodule && - git checkout master && + git checkout main && git pull ) && mv submodule moved-submodule && @@ -112,7 +115,7 @@ test_expect_success '"git submodule sync" should update submodule URLs' ' )" && ( cd super-clone/submodule && - git checkout master && + git checkout main && git pull ) && ( @@ -140,7 +143,7 @@ test_expect_success '"git submodule sync --recursive" should update all submodul )" && ( cd super-clone/submodule/sub-submodule && - git checkout master && + git checkout main && git pull ) ' @@ -168,7 +171,7 @@ test_expect_success '"git submodule sync" should update submodule URLs - subdire )" && ( cd super-clone/submodule && - git checkout master && + git checkout main && git pull ) && ( @@ -199,7 +202,7 @@ test_expect_success '"git submodule sync --recursive" should update all submodul )" && ( cd super-clone/submodule/sub-submodule && - git checkout master && + git checkout main && git pull ) ' diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index acb8766ac2..f4f61fe554 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -9,15 +9,18 @@ This test verifies that "git submodule update" detaches the HEAD of the submodule and "git submodule update --rebase/--merge" does not detach the HEAD. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh compare_head() { - sha_master=$(git rev-list --max-count=1 master) + sha_main=$(git rev-list --max-count=1 main) sha_head=$(git rev-list --max-count=1 HEAD) - test "$sha_master" = "$sha_head" + test "$sha_main" = "$sha_head" } @@ -152,9 +155,9 @@ test_expect_success 'submodule update --init --recursive from subdirectory' ' cd tmp && git submodule update --init --recursive ../super >../../actual 2>../../actual2 ) && - test_i18ncmp expect actual && + test_cmp expect actual && sort actual2 >actual2.sorted && - test_i18ncmp expect2 actual2.sorted + test_cmp expect2 actual2.sorted ' cat <<EOF >expect2 @@ -171,7 +174,7 @@ test_expect_success 'submodule update --init from and of subdirectory' ' git submodule update --init sub 2>../../actual2 ) ) && - test_i18ncmp expect2 actual2 + test_cmp expect2 actual2 ' test_expect_success 'submodule update does not fetch already present commits' ' @@ -189,7 +192,7 @@ test_expect_success 'submodule update does not fetch already present commits' ' (cd super && git submodule update > ../actual 2> ../actual.err ) && - test_i18ncmp expected actual && + test_cmp expected actual && test_must_be_empty actual.err ' @@ -262,14 +265,14 @@ test_expect_success 'submodule update --remote should fetch upstream changes wit cd super && git submodule update --remote --force submodule && git -C submodule log -1 --oneline >actual && - git -C ../submodule log -1 --oneline master >expect && + git -C ../submodule log -1 --oneline main >expect && test_cmp expect actual && git checkout -b test-branch && git submodule update --remote --force submodule && git -C submodule log -1 --oneline >actual && git -C ../submodule log -1 --oneline test-branch >expect && test_cmp expect actual && - git checkout master && + git checkout main && git branch -d test-branch && git reset --hard HEAD^ ) @@ -282,7 +285,7 @@ test_expect_success 'local config should override .gitmodules branch' ' git add file && test_tick && git commit -m "upstream line5" && - git checkout master + git checkout main ) && (cd super && git config submodule.submodule.branch test-branch && @@ -292,9 +295,9 @@ test_expect_success 'local config should override .gitmodules branch' ' ) ' -test_expect_success 'submodule update --rebase staying on master' ' +test_expect_success 'submodule update --rebase staying on main' ' (cd super/submodule && - git checkout master + git checkout main ) && (cd super && (cd submodule && @@ -306,7 +309,7 @@ test_expect_success 'submodule update --rebase staying on master' ' ) ' -test_expect_success 'submodule update --merge staying on master' ' +test_expect_success 'submodule update --merge staying on main' ' (cd super/submodule && git reset --hard HEAD~1 ) && @@ -458,7 +461,7 @@ test_expect_success 'submodule update - command in .git/config catches failure' (cd super && test_must_fail git submodule update submodule 2>../actual ) && - test_i18ncmp actual expect + test_cmp actual expect ' cat << EOF >expect @@ -476,7 +479,7 @@ test_expect_success 'submodule update - command in .git/config catches failure - mkdir tmp && cd tmp && test_must_fail git submodule update ../submodule 2>../../actual ) && - test_i18ncmp actual expect + test_cmp actual expect ' test_expect_success 'submodule update - command run for initial population of submodule' ' @@ -485,7 +488,7 @@ test_expect_success 'submodule update - command run for initial population of su EOF rm -rf super/submodule && test_must_fail git -C super submodule update 2>actual && - test_i18ncmp expect actual && + test_cmp expect actual && git -C super submodule update --checkout ' @@ -506,7 +509,7 @@ test_expect_success 'recursive submodule update - command in .git/config catches mkdir -p tmp && cd tmp && test_must_fail git submodule update --recursive ../super 2>../../actual ) && - test_i18ncmp actual expect + test_cmp actual expect ' test_expect_success 'submodule init does not copy command into .git/config' ' @@ -609,7 +612,7 @@ test_expect_success 'submodule update - update=none in .git/config' ' (cd super && git config submodule.submodule.update none && (cd submodule && - git checkout master && + git checkout main && compare_head ) && git diff --name-only >out && @@ -629,7 +632,7 @@ test_expect_success 'submodule update - update=none in .git/config but --checkou (cd super && git config submodule.submodule.update none && (cd submodule && - git checkout master && + git checkout main && compare_head ) && git diff --name-only >out && @@ -689,7 +692,7 @@ test_expect_success 'submodule update continues after checkout error' ' test_expect_success 'submodule update continues after recursive checkout error' ' (cd super && git reset --hard HEAD && - git checkout master && + git checkout main && git submodule update && (cd submodule && git submodule add ../submodule subsubmodule && @@ -733,7 +736,7 @@ test_expect_success 'submodule update continues after recursive checkout error' test_expect_success 'submodule update exit immediately in case of merge conflict' ' (cd super && - git checkout master && + git checkout main && git reset --hard HEAD && (cd submodule && (cd subsubmodule && @@ -751,7 +754,7 @@ test_expect_success 'submodule update exit immediately in case of merge conflict git add submodule2 && git commit -m "two_new_submodule_commits" && (cd submodule && - git checkout master && + git checkout main && test_commit "conflict" file && echo "conflict" > file ) && @@ -770,7 +773,7 @@ test_expect_success 'submodule update exit immediately in case of merge conflict test_expect_success 'submodule update exit immediately after recursive rebase error' ' (cd super && - git checkout master && + git checkout main && git reset --hard HEAD && (cd submodule && git reset --hard HEAD && @@ -786,7 +789,7 @@ test_expect_success 'submodule update exit immediately after recursive rebase er git add submodule2 && git commit -m "two_new_submodule_commits" && (cd submodule && - git checkout master && + git checkout main && test_commit "conflict2" file && echo "conflict" > file ) && @@ -878,21 +881,21 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir re git clone subsubsuper_update_r subsubsuper_update_r2 && (cd subsubsuper_update_r2 && test_commit "update_subsubsuper" file && - git push origin master + git push origin main ) && git clone subsuper_update_r subsuper_update_r2 && (cd subsuper_update_r2 && test_commit "update_subsuper" file && git submodule add ../subsubsuper_update_r subsubmodule && git commit -am "subsubmodule" && - git push origin master + git push origin main ) && git clone super_update_r super_update_r2 && (cd super_update_r2 && test_commit "update_super" file && git submodule add ../subsuper_update_r submodule && git commit -am "submodule" && - git push origin master + git push origin main ) && rm -rf super_update_r2 && git clone super_update_r super_update_r2 && @@ -911,7 +914,7 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir re test_expect_success 'submodule add properly re-creates deeper level submodules' ' (cd super && - git reset --hard master && + git reset --hard main && rm -rf deeper/ && git submodule add --force ../submodule deeper/submodule ) @@ -1034,4 +1037,28 @@ test_expect_success 'submodule update --quiet passes quietness to merge/rebase' ) ' +test_expect_success 'submodule update --quiet passes quietness to fetch with a shallow clone' ' + test_when_finished "rm -rf super4 super5 super6" && + git clone . super4 && + (cd super4 && + git submodule add --quiet file://"$TRASH_DIRECTORY"/submodule submodule3 && + git commit -am "setup submodule3" + ) && + (cd submodule && + test_commit line6 file + ) && + git clone super4 super5 && + (cd super5 && + git submodule update --quiet --init --depth=1 submodule3 >out 2>err && + test_must_be_empty out && + test_must_be_empty err + ) && + git clone super4 super6 && + (cd super6 && + git submodule update --init --depth=1 submodule3 >out 2>err && + test_file_not_empty out && + test_file_not_empty err + ) +' + test_done diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh index 6b2aa917e1..e2f110b786 100755 --- a/t/t7407-submodule-foreach.sh +++ b/t/t7407-submodule-foreach.sh @@ -9,6 +9,9 @@ This test verifies that "git submodule foreach" correctly visits all submodules that are currently checked out. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh @@ -77,7 +80,7 @@ test_expect_success 'test basic "submodule foreach" usage' ' git config foo.bar zar && git submodule foreach "git config --file \"\$toplevel/.git/config\" foo.bar" ) && - test_i18ncmp expect actual + test_cmp expect actual ' cat >expect <<EOF @@ -93,7 +96,7 @@ test_expect_success 'test "submodule foreach" from subdirectory' ' cd clone/sub && git submodule foreach "echo \$toplevel-\$name-\$sm_path-\$displaypath-\$sha1" >../../actual ) && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'setup nested submodules' ' @@ -174,7 +177,7 @@ test_expect_success 'test messages from "foreach --recursive"' ' cd clone2 && git submodule foreach --recursive "true" > ../actual ) && - test_i18ncmp expect actual + test_cmp expect actual ' cat > expect <<EOF @@ -194,7 +197,7 @@ test_expect_success 'test messages from "foreach --recursive" from subdirectory' cd untracked && git submodule foreach --recursive >../../actual ) && - test_i18ncmp expect actual + test_cmp expect actual ' sub1sha1=$(cd clone2/sub1 && git rev-parse HEAD) sub2sha1=$(cd clone2/sub2 && git rev-parse HEAD) @@ -226,7 +229,7 @@ test_expect_success 'test "submodule foreach --recursive" from subdirectory' ' cd clone2/untracked && git submodule foreach --recursive "echo toplevel: \$toplevel name: \$name path: \$sm_path displaypath: \$displaypath hash: \$sha1" >../../actual ) && - test_i18ncmp expect actual + test_cmp expect actual ' cat > expect <<EOF @@ -277,13 +280,13 @@ sub1sha1_short=$(cd clone3/sub1 && git rev-parse --short HEAD) sub2sha1_short=$(cd clone3/sub2 && git rev-parse --short HEAD) cat > expect <<EOF - $nested1sha1 nested1 (heads/master) - $nested2sha1 nested1/nested2 (heads/master) - $nested3sha1 nested1/nested2/nested3 (heads/master) - $submodulesha1 nested1/nested2/nested3/submodule (heads/master) + $nested1sha1 nested1 (heads/main) + $nested2sha1 nested1/nested2 (heads/main) + $nested3sha1 nested1/nested2/nested3 (heads/main) + $submodulesha1 nested1/nested2/nested3/submodule (heads/main) $sub1sha1 sub1 ($sub1sha1_short) $sub2sha1 sub2 ($sub2sha1_short) - $sub3sha1 sub3 (heads/master) + $sub3sha1 sub3 (heads/main) EOF test_expect_success 'test "status --recursive"' ' @@ -295,10 +298,10 @@ test_expect_success 'test "status --recursive"' ' ' cat > expect <<EOF - $nested1sha1 nested1 (heads/master) + $nested1sha1 nested1 (heads/main) +$nested2sha1 nested1/nested2 (file2~1) - $nested3sha1 nested1/nested2/nested3 (heads/master) - $submodulesha1 nested1/nested2/nested3/submodule (heads/master) + $nested3sha1 nested1/nested2/nested3 (heads/main) + $submodulesha1 nested1/nested2/nested3/submodule (heads/main) EOF test_expect_success 'ensure "status --cached --recursive" preserves the --cached flag' ' @@ -316,13 +319,13 @@ test_expect_success 'ensure "status --cached --recursive" preserves the --cached nested2sha1=$(git -C clone3/nested1/nested2 rev-parse HEAD) cat > expect <<EOF - $nested1sha1 ../nested1 (heads/master) + $nested1sha1 ../nested1 (heads/main) +$nested2sha1 ../nested1/nested2 (file2) - $nested3sha1 ../nested1/nested2/nested3 (heads/master) - $submodulesha1 ../nested1/nested2/nested3/submodule (heads/master) + $nested3sha1 ../nested1/nested2/nested3 (heads/main) + $submodulesha1 ../nested1/nested2/nested3/submodule (heads/main) $sub1sha1 ../sub1 ($sub1sha1_short) $sub2sha1 ../sub2 ($sub2sha1_short) - $sub3sha1 ../sub3 (heads/master) + $sub3sha1 ../sub3 (heads/main) EOF test_expect_success 'test "status --recursive" from sub directory' ' diff --git a/t/t7409-submodule-detached-work-tree.sh b/t/t7409-submodule-detached-work-tree.sh index fc018e3638..e17ac81a89 100755 --- a/t/t7409-submodule-detached-work-tree.sh +++ b/t/t7409-submodule-detached-work-tree.sh @@ -10,6 +10,9 @@ on detached working trees ' TEST_NO_CREATE_REPO=1 +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'submodule on detached working tree' ' @@ -35,7 +38,7 @@ test_expect_success 'submodule on detached working tree' ' git rev-parse --verify HEAD >actual && test_cmp ../../../../expect actual ) && - git push origin master + git push origin main ) && mkdir home2 && ( @@ -44,7 +47,7 @@ test_expect_success 'submodule on detached working tree' ' GIT_WORK_TREE="$(pwd)" && GIT_DIR="$(pwd)/.dotfiles" && export GIT_WORK_TREE GIT_DIR && - git checkout master && + git checkout main && git submodule update --init && ( unset GIT_WORK_TREE GIT_DIR && @@ -64,10 +67,10 @@ test_expect_success 'submodule on detached working pointed by core.worktree' ' git clone --bare ../remote "$GIT_DIR" && git config core.bare false && git config core.worktree .. && - git checkout master && + git checkout main && git submodule add ../bundle1 .vim/bundle/dupe && test_commit "dupe" && - git push origin master + git push origin main ) && ( cd home && diff --git a/t/t7417-submodule-path-url.sh b/t/t7417-submodule-path-url.sh index f7e7e94d7b..f0f6b9fa9e 100755 --- a/t/t7417-submodule-path-url.sh +++ b/t/t7417-submodule-path-url.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='check handling of .gitmodule path with dash' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'create submodule with dash in path' ' @@ -36,7 +39,7 @@ test_expect_success MINGW 'submodule paths disallows trailing spaces' ' sed "s/sub/sub /" <tree >tree.new && tree=$(git -C super mktree <tree.new) && commit=$(echo with space | git -C super commit-tree $tree) && - git -C super update-ref refs/heads/master $commit && + git -C super update-ref refs/heads/main $commit && test_must_fail git clone --recurse-submodules super dst 2>err && test_i18ngrep "sub " err diff --git a/t/t7415-submodule-names.sh b/t/t7450-bad-git-dotfiles.sh index f70368bc2e..41706c1c9f 100755 --- a/t/t7415-submodule-names.sh +++ b/t/t7450-bad-git-dotfiles.sh @@ -1,9 +1,16 @@ #!/bin/sh -test_description='check handling of .. in submodule names +test_description='check broken or malicious patterns in .git* files -Exercise the name-checking function on a variety of names, and then give a -real-world setup that confirms we catch this in practice. +Such as: + + - presence of .. in submodule names; + Exercise the name-checking function on a variety of names, and then give a + real-world setup that confirms we catch this in practice. + + - nested submodule names + + - symlinked .gitmodules, etc ' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-pack.sh @@ -132,31 +139,84 @@ test_expect_success 'index-pack --strict works for non-repo pack' ' grep gitmodulesName output ' -test_expect_success 'fsck detects symlinked .gitmodules file' ' - git init symlink && - ( - cd symlink && - - # Make the tree directly to avoid index restrictions. - # - # Because symlinks store the target as a blob, choose - # a pathname that could be parsed as a .gitmodules file - # to trick naive non-symlink-aware checking. - tricky="[foo]bar=true" && - content=$(git hash-object -w ../.gitmodules) && - target=$(printf "$tricky" | git hash-object -w --stdin) && - { - printf "100644 blob $content\t$tricky\n" && - printf "120000 blob $target\t.gitmodules\n" - } | git mktree && - - # Check not only that we fail, but that it is due to the - # symlink detector; this grep string comes from the config - # variable name and will not be translated. - test_must_fail git fsck 2>output && - test_i18ngrep gitmodulesSymlink output - ) -' +check_dotx_symlink () { + fsck_must_fail=test_must_fail + fsck_prefix=error + refuse_index=t + case "$1" in + --warning) + fsck_must_fail= + fsck_prefix=warning + refuse_index= + shift + ;; + esac + + name=$1 + type=$2 + path=$3 + dir=symlink-$name-$type + + test_expect_success "set up repo with symlinked $name ($type)" ' + git init $dir && + ( + cd $dir && + + # Make the tree directly to avoid index restrictions. + # + # Because symlinks store the target as a blob, choose + # a pathname that could be parsed as a .gitmodules file + # to trick naive non-symlink-aware checking. + tricky="[foo]bar=true" && + content=$(git hash-object -w ../.gitmodules) && + target=$(printf "$tricky" | git hash-object -w --stdin) && + { + printf "100644 blob $content\t$tricky\n" && + printf "120000 blob $target\t$path\n" + } >bad-tree + ) && + tree=$(git -C $dir mktree <$dir/bad-tree) + ' + + test_expect_success "fsck detects symlinked $name ($type)" ' + ( + cd $dir && + + # Check not only that we fail, but that it is due to the + # symlink detector + $fsck_must_fail git fsck 2>output && + grep "$fsck_prefix.*tree $tree: ${name}Symlink" output + ) + ' + + test -n "$refuse_index" && + test_expect_success "refuse to load symlinked $name into index ($type)" ' + test_must_fail \ + git -C $dir \ + -c core.protectntfs \ + -c core.protecthfs \ + read-tree $tree 2>err && + grep "invalid path.*$name" err && + git -C $dir ls-files -s >out && + test_must_be_empty out + ' +} + +check_dotx_symlink gitmodules vanilla .gitmodules +check_dotx_symlink gitmodules ntfs ".gitmodules ." +check_dotx_symlink gitmodules hfs ".${u200c}gitmodules" + +check_dotx_symlink --warning gitattributes vanilla .gitattributes +check_dotx_symlink --warning gitattributes ntfs ".gitattributes ." +check_dotx_symlink --warning gitattributes hfs ".${u200c}gitattributes" + +check_dotx_symlink --warning gitignore vanilla .gitignore +check_dotx_symlink --warning gitignore ntfs ".gitignore ." +check_dotx_symlink --warning gitignore hfs ".${u200c}gitignore" + +check_dotx_symlink --warning mailmap vanilla .mailmap +check_dotx_symlink --warning mailmap ntfs ".mailmap ." +check_dotx_symlink --warning mailmap hfs ".${u200c}mailmap" test_expect_success 'fsck detects non-blob .gitmodules' ' git init non-blob && @@ -191,7 +251,7 @@ test_expect_success 'fsck detects corrupt .gitmodules' ' ) ' -test_expect_success MINGW 'prevent git~1 squatting on Windows' ' +test_expect_success WINDOWS 'prevent git~1 squatting on Windows' ' git init squatting && ( cd squatting && @@ -219,10 +279,13 @@ test_expect_success MINGW 'prevent git~1 squatting on Windows' ' test_tick && git -c core.protectNTFS=false commit -m "module" ) && - test_must_fail git -c core.protectNTFS=false \ - clone --recurse-submodules squatting squatting-clone 2>err && - test_i18ngrep -e "directory not empty" -e "not an empty directory" err && - ! grep gitdir squatting-clone/d/a/git~2 + if test_have_prereq MINGW + then + test_must_fail git -c core.protectNTFS=false \ + clone --recurse-submodules squatting squatting-clone 2>err && + test_i18ngrep -e "directory not empty" -e "not an empty directory" err && + ! grep gitdir squatting-clone/d/a/git~2 + fi ' test_expect_success 'git dirs of sibling submodules must not be nested' ' diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh index 6d19ece05d..7d02f79c0d 100755 --- a/t/t7500-commit-template-squash-signoff.sh +++ b/t/t7500-commit-template-squash-signoff.sh @@ -9,13 +9,15 @@ Tests for template, signoff, squash and -F functions.' . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-rebase.sh + commit_msg_is () { expect=commit_msg_is.expect actual=commit_msg_is.actual printf "%s" "$(git log --pretty=format:%s%b -1)" >"$actual" && printf "%s" "$1" >"$expect" && - test_i18ncmp "$expect" "$actual" + test_cmp "$expect" "$actual" } # A sanity check to see if commit is working at all. @@ -279,6 +281,163 @@ test_expect_success 'commit --fixup -m"something" -m"extra"' ' extra" ' +get_commit_msg () { + rev="$1" && + git log -1 --pretty=format:"%B" "$rev" +} + +test_expect_success 'commit --fixup=amend: creates amend! commit' ' + commit_for_rebase_autosquash_setup && + cat >expected <<-EOF && + amend! $(git log -1 --format=%s HEAD~) + + $(get_commit_msg HEAD~) + + edited + EOF + ( + set_fake_editor && + FAKE_COMMIT_AMEND="edited" \ + git commit --fixup=amend:HEAD~ + ) && + get_commit_msg HEAD >actual && + test_cmp expected actual +' + +test_expect_success '--fixup=amend: --only ignores staged changes' ' + commit_for_rebase_autosquash_setup && + cat >expected <<-EOF && + amend! $(git log -1 --format=%s HEAD~) + + $(get_commit_msg HEAD~) + + edited + EOF + ( + set_fake_editor && + FAKE_COMMIT_AMEND="edited" \ + git commit --fixup=amend:HEAD~ --only + ) && + get_commit_msg HEAD >actual && + test_cmp expected actual && + test_cmp_rev HEAD@{1}^{tree} HEAD^{tree} && + test_cmp_rev HEAD@{1} HEAD^ && + test_expect_code 1 git diff --cached --exit-code && + git cat-file blob :foo >actual && + test_cmp foo actual +' + +test_expect_success '--fixup=reword: ignores staged changes' ' + commit_for_rebase_autosquash_setup && + cat >expected <<-EOF && + amend! $(git log -1 --format=%s HEAD~) + + $(get_commit_msg HEAD~) + + edited + EOF + ( + set_fake_editor && + FAKE_COMMIT_AMEND="edited" \ + git commit --fixup=reword:HEAD~ + ) && + get_commit_msg HEAD >actual && + test_cmp expected actual && + test_cmp_rev HEAD@{1}^{tree} HEAD^{tree} && + test_cmp_rev HEAD@{1} HEAD^ && + test_expect_code 1 git diff --cached --exit-code && + git cat-file blob :foo >actual && + test_cmp foo actual +' + +test_expect_success '--fixup=reword: error out with -m option' ' + commit_for_rebase_autosquash_setup && + echo "fatal: cannot combine -m with --fixup:reword" >expect && + test_must_fail git commit --fixup=reword:HEAD~ -m "reword commit message" 2>actual && + test_cmp expect actual +' + +test_expect_success '--fixup=amend: error out with -m option' ' + commit_for_rebase_autosquash_setup && + echo "fatal: cannot combine -m with --fixup:amend" >expect && + test_must_fail git commit --fixup=amend:HEAD~ -m "amend commit message" 2>actual && + test_cmp expect actual +' + +test_expect_success 'consecutive amend! commits remove amend! line from commit msg body' ' + commit_for_rebase_autosquash_setup && + cat >expected <<-EOF && + amend! amend! $(git log -1 --format=%s HEAD~) + + $(get_commit_msg HEAD~) + + edited 1 + + edited 2 + EOF + echo "reword new commit message" >actual && + ( + set_fake_editor && + FAKE_COMMIT_AMEND="edited 1" \ + git commit --fixup=reword:HEAD~ && + FAKE_COMMIT_AMEND="edited 2" \ + git commit --fixup=reword:HEAD + ) && + get_commit_msg HEAD >actual && + test_cmp expected actual +' + +test_expect_success 'deny to create amend! commit if its commit msg body is empty' ' + commit_for_rebase_autosquash_setup && + echo "Aborting commit due to empty commit message body." >expected && + ( + set_fake_editor && + test_must_fail env FAKE_COMMIT_MESSAGE="amend! target message subject line" \ + git commit --fixup=amend:HEAD~ 2>actual + ) && + test_cmp expected actual +' + +test_expect_success 'amend! commit allows empty commit msg body with --allow-empty-message' ' + commit_for_rebase_autosquash_setup && + cat >expected <<-EOF && + amend! $(git log -1 --format=%s HEAD~) + EOF + ( + set_fake_editor && + FAKE_COMMIT_MESSAGE="amend! target message subject line" \ + git commit --fixup=amend:HEAD~ --allow-empty-message && + get_commit_msg HEAD >actual + ) && + test_cmp expected actual +' + +test_fixup_reword_opt () { + test_expect_success "--fixup=reword: incompatible with $1" " + echo 'fatal: reword option of --fixup is mutually exclusive with'\ + '--patch/--interactive/--all/--include/--only' >expect && + test_must_fail git commit --fixup=reword:HEAD~ $1 2>actual && + test_cmp expect actual + " +} + +for opt in --all --include --only --interactive --patch +do + test_fixup_reword_opt $opt +done + +test_expect_success '--fixup=reword: give error with pathsec' ' + commit_for_rebase_autosquash_setup && + echo "fatal: cannot combine reword option of --fixup with path '\''foo'\''" >expect && + test_must_fail git commit --fixup=reword:HEAD~ -- foo 2>actual && + test_cmp expect actual +' + +test_expect_success '--fixup=reword: -F give error message' ' + echo "fatal: Only one of -c/-C/-F/--fixup can be used." >expect && + test_must_fail git commit --fixup=reword:HEAD~ -F msg 2>actual && + test_cmp expect actual +' test_expect_success 'commit --squash works with -F' ' commit_for_rebase_autosquash_setup && @@ -356,7 +515,7 @@ test_expect_success 'new line found before status message in commit template' ' touch commit-template-check && git add commit-template-check && GIT_EDITOR="cat >editor-input" git commit --untracked-files=no --allow-empty-message && - test_i18ncmp expected-template editor-input + test_cmp expected-template editor-input ' test_expect_success 'setup empty commit with unstaged rename and copy' ' diff --git a/t/t7501-commit-basic-functionality.sh b/t/t7501-commit-basic-functionality.sh index 110b4bf459..512ae2781f 100755 --- a/t/t7501-commit-basic-functionality.sh +++ b/t/t7501-commit-basic-functionality.sh @@ -7,8 +7,11 @@ # signoff test_description='git commit' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh -. "$TEST_DIRECTORY/diff-lib.sh" +. "$TEST_DIRECTORY/lib-diff.sh" author='The Real Author <someguy@his.email.org>' @@ -603,7 +606,7 @@ test_expect_success 'same tree (merge and amend merge)' ' echo zero >zero && git add zero && git commit -m "add zero" && - git checkout master && + git checkout main && git merge -s ours side -m "empty ok" && git diff HEAD^ HEAD >actual && diff --git a/t/t7502-commit-porcelain.sh b/t/t7502-commit-porcelain.sh index 14c92e4c25..38a532d81c 100755 --- a/t/t7502-commit-porcelain.sh +++ b/t/t7502-commit-porcelain.sh @@ -2,6 +2,9 @@ test_description='git commit porcelain-ish' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh commit_msg_is () { @@ -10,7 +13,7 @@ commit_msg_is () { printf "%s" "$(git log --pretty=format:%s%b -1)" >$actual && printf "%s" "$1" >$expect && - test_i18ncmp $expect $actual + test_cmp $expect $actual } # Arguments: [<prefix] [<commit message>] [<commit options>] @@ -32,7 +35,17 @@ check_summary_oneline() { SUMMARY_POSTFIX="$(git log -1 --pretty='format:%h')" echo "[$SUMMARY_PREFIX $SUMMARY_POSTFIX] $2" >exp && - test_i18ncmp exp act + test_cmp exp act +} + +trailer_commit_base () { + echo "fun" >>file && + git add file && + git commit -s --trailer "Signed-off-by=C1 E1 " \ + --trailer "Helped-by:C2 E2 " \ + --trailer "Reported-by=C3 E3" \ + --trailer "Mentored-by:C4 E4" \ + -m "hello" } test_expect_success 'output summary format' ' @@ -76,7 +89,7 @@ test_expect_success 'output summary format for merges' ' output_tests_cleanup() { # this is needed for "do not fire editor in the presence of conflicts" - git checkout master && + git checkout main && # this is needed for the "partial removal" test to pass git rm file1 && @@ -151,6 +164,308 @@ test_expect_success 'sign off' ' ' +test_expect_success 'commit --trailer with "="' ' + trailer_commit_base && + cat >expected <<-\EOF && + hello + + Signed-off-by: C O Mitter <committer@example.com> + Signed-off-by: C1 E1 + Helped-by: C2 E2 + Reported-by: C3 E3 + Mentored-by: C4 E4 + EOF + git cat-file commit HEAD >commit.msg && + sed -e "1,/^\$/d" commit.msg >actual && + test_cmp expected actual +' + +test_expect_success 'commit --trailer with -c and "replace" as ifexists' ' + trailer_commit_base && + cat >expected <<-\EOF && + hello + + Signed-off-by: C O Mitter <committer@example.com> + Signed-off-by: C1 E1 + Reported-by: C3 E3 + Mentored-by: C4 E4 + Helped-by: C3 E3 + EOF + git -c trailer.ifexists="replace" \ + commit --trailer "Mentored-by: C4 E4" \ + --trailer "Helped-by: C3 E3" \ + --amend && + git cat-file commit HEAD >commit.msg && + sed -e "1,/^\$/d" commit.msg >actual && + test_cmp expected actual +' + +test_expect_success 'commit --trailer with -c and "add" as ifexists' ' + trailer_commit_base && + cat >expected <<-\EOF && + hello + + Signed-off-by: C O Mitter <committer@example.com> + Signed-off-by: C1 E1 + Helped-by: C2 E2 + Reported-by: C3 E3 + Mentored-by: C4 E4 + Reported-by: C3 E3 + Mentored-by: C4 E4 + EOF + git -c trailer.ifexists="add" \ + commit --trailer "Reported-by: C3 E3" \ + --trailer "Mentored-by: C4 E4" \ + --amend && + git cat-file commit HEAD >commit.msg && + sed -e "1,/^\$/d" commit.msg >actual && + test_cmp expected actual +' + +test_expect_success 'commit --trailer with -c and "donothing" as ifexists' ' + trailer_commit_base && + cat >expected <<-\EOF && + hello + + Signed-off-by: C O Mitter <committer@example.com> + Signed-off-by: C1 E1 + Helped-by: C2 E2 + Reported-by: C3 E3 + Mentored-by: C4 E4 + Reviewed-by: C6 E6 + EOF + git -c trailer.ifexists="donothing" \ + commit --trailer "Mentored-by: C5 E5" \ + --trailer "Reviewed-by: C6 E6" \ + --amend && + git cat-file commit HEAD >commit.msg && + sed -e "1,/^\$/d" commit.msg >actual && + test_cmp expected actual +' + +test_expect_success 'commit --trailer with -c and "addIfDifferent" as ifexists' ' + trailer_commit_base && + cat >expected <<-\EOF && + hello + + Signed-off-by: C O Mitter <committer@example.com> + Signed-off-by: C1 E1 + Helped-by: C2 E2 + Reported-by: C3 E3 + Mentored-by: C4 E4 + Mentored-by: C5 E5 + EOF + git -c trailer.ifexists="addIfDifferent" \ + commit --trailer "Reported-by: C3 E3" \ + --trailer "Mentored-by: C5 E5" \ + --amend && + git cat-file commit HEAD >commit.msg && + sed -e "1,/^\$/d" commit.msg >actual && + test_cmp expected actual +' + +test_expect_success 'commit --trailer with -c and "addIfDifferentNeighbor" as ifexists' ' + trailer_commit_base && + cat >expected <<-\EOF && + hello + + Signed-off-by: C O Mitter <committer@example.com> + Signed-off-by: C1 E1 + Helped-by: C2 E2 + Reported-by: C3 E3 + Mentored-by: C4 E4 + Reported-by: C3 E3 + EOF + git -c trailer.ifexists="addIfDifferentNeighbor" \ + commit --trailer "Mentored-by: C4 E4" \ + --trailer "Reported-by: C3 E3" \ + --amend && + git cat-file commit HEAD >commit.msg && + sed -e "1,/^\$/d" commit.msg >actual && + test_cmp expected actual +' + +test_expect_success 'commit --trailer with -c and "end" as where' ' + trailer_commit_base && + cat >expected <<-\EOF && + hello + + Signed-off-by: C O Mitter <committer@example.com> + Signed-off-by: C1 E1 + Helped-by: C2 E2 + Reported-by: C3 E3 + Mentored-by: C4 E4 + Reported-by: C3 E3 + Mentored-by: C4 E4 + EOF + git -c trailer.where="end" \ + commit --trailer "Reported-by: C3 E3" \ + --trailer "Mentored-by: C4 E4" \ + --amend && + git cat-file commit HEAD >commit.msg && + sed -e "1,/^\$/d" commit.msg >actual && + test_cmp expected actual +' + +test_expect_success 'commit --trailer with -c and "start" as where' ' + trailer_commit_base && + cat >expected <<-\EOF && + hello + + Signed-off-by: C1 E1 + Signed-off-by: C O Mitter <committer@example.com> + Signed-off-by: C1 E1 + Helped-by: C2 E2 + Reported-by: C3 E3 + Mentored-by: C4 E4 + EOF + git -c trailer.where="start" \ + commit --trailer "Signed-off-by: C O Mitter <committer@example.com>" \ + --trailer "Signed-off-by: C1 E1" \ + --amend && + git cat-file commit HEAD >commit.msg && + sed -e "1,/^\$/d" commit.msg >actual && + test_cmp expected actual +' + +test_expect_success 'commit --trailer with -c and "after" as where' ' + trailer_commit_base && + cat >expected <<-\EOF && + hello + + Signed-off-by: C O Mitter <committer@example.com> + Signed-off-by: C1 E1 + Helped-by: C2 E2 + Reported-by: C3 E3 + Mentored-by: C4 E4 + Mentored-by: C5 E5 + EOF + git -c trailer.where="after" \ + commit --trailer "Mentored-by: C4 E4" \ + --trailer "Mentored-by: C5 E5" \ + --amend && + git cat-file commit HEAD >commit.msg && + sed -e "1,/^\$/d" commit.msg >actual && + test_cmp expected actual +' + +test_expect_success 'commit --trailer with -c and "before" as where' ' + trailer_commit_base && + cat >expected <<-\EOF && + hello + + Signed-off-by: C O Mitter <committer@example.com> + Signed-off-by: C1 E1 + Helped-by: C2 E2 + Reported-by: C3 E3 + Mentored-by: C2 E2 + Mentored-by: C3 E3 + Mentored-by: C4 E4 + EOF + git -c trailer.where="before" \ + commit --trailer "Mentored-by: C3 E3" \ + --trailer "Mentored-by: C2 E2" \ + --amend && + git cat-file commit HEAD >commit.msg && + sed -e "1,/^\$/d" commit.msg >actual && + test_cmp expected actual +' + +test_expect_success 'commit --trailer with -c and "donothing" as ifmissing' ' + trailer_commit_base && + cat >expected <<-\EOF && + hello + + Signed-off-by: C O Mitter <committer@example.com> + Signed-off-by: C1 E1 + Helped-by: C2 E2 + Reported-by: C3 E3 + Mentored-by: C4 E4 + Helped-by: C5 E5 + EOF + git -c trailer.ifmissing="donothing" \ + commit --trailer "Helped-by: C5 E5" \ + --trailer "Based-by: C6 E6" \ + --amend && + git cat-file commit HEAD >commit.msg && + sed -e "1,/^\$/d" commit.msg >actual && + test_cmp expected actual +' + +test_expect_success 'commit --trailer with -c and "add" as ifmissing' ' + trailer_commit_base && + cat >expected <<-\EOF && + hello + + Signed-off-by: C O Mitter <committer@example.com> + Signed-off-by: C1 E1 + Helped-by: C2 E2 + Reported-by: C3 E3 + Mentored-by: C4 E4 + Helped-by: C5 E5 + Based-by: C6 E6 + EOF + git -c trailer.ifmissing="add" \ + commit --trailer "Helped-by: C5 E5" \ + --trailer "Based-by: C6 E6" \ + --amend && + git cat-file commit HEAD >commit.msg && + sed -e "1,/^\$/d" commit.msg >actual && + test_cmp expected actual +' + +test_expect_success 'commit --trailer with -c ack.key ' ' + echo "fun" >>file1 && + git add file1 && + cat >expected <<-\EOF && + hello + + Acked-by: Peff + EOF + git -c trailer.ack.key="Acked-by" \ + commit --trailer "ack = Peff" -m "hello" && + git cat-file commit HEAD >commit.msg && + sed -e "1,/^\$/d" commit.msg >actual && + test_cmp expected actual +' + +test_expect_success 'commit --trailer with -c and ":=#" as separators' ' + echo "fun" >>file1 && + git add file1 && + cat >expected <<-\EOF && + I hate bug + + Bug #42 + EOF + git -c trailer.separators=":=#" \ + -c trailer.bug.key="Bug #" \ + commit --trailer "bug = 42" -m "I hate bug" && + git cat-file commit HEAD >commit.msg && + sed -e "1,/^\$/d" commit.msg >actual && + test_cmp expected actual +' + +test_expect_success 'commit --trailer with -c and command' ' + trailer_commit_base && + cat >expected <<-\EOF && + hello + + Signed-off-by: C O Mitter <committer@example.com> + Signed-off-by: C1 E1 + Helped-by: C2 E2 + Mentored-by: C4 E4 + Reported-by: A U Thor <author@example.com> + EOF + git -c trailer.report.key="Reported-by: " \ + -c trailer.report.ifexists="replace" \ + -c trailer.report.command="NAME=\"\$ARG\"; test -n \"\$NAME\" && \ + git log --author=\"\$NAME\" -1 --format=\"format:%aN <%aE>\" || true" \ + commit --trailer "report = author" --amend && + git cat-file commit HEAD >commit.msg && + sed -e "1,/^\$/d" commit.msg >actual && + test_cmp expected actual +' + test_expect_success 'multiple -m' ' >negative && @@ -297,7 +612,7 @@ echo "sample # with '#' will be ignored, and an empty message aborts the commit." >expect test_expect_success 'cleanup commit messages (strip option,-F,-e): output' ' - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'cleanup commit message (fail on invalid cleanup mode option)' ' @@ -440,7 +755,7 @@ test_expect_success 'do not fire editor in the presence of conflicts' ' git add g && git commit -m "add g" && git branch second && - echo master >g && + echo main >g && echo g >h && git add g h && git commit -m "modify g and add h" && @@ -449,7 +764,7 @@ test_expect_success 'do not fire editor in the presence of conflicts' ' git add g && git commit -m second && # Must fail due to conflict - test_must_fail git cherry-pick -n master && + test_must_fail git cherry-pick -n main && echo "editor not started" >.git/result && ( GIT_EDITOR="\"$(pwd)/.git/FAKE_EDITOR\"" && @@ -478,9 +793,9 @@ git reset -q --hard test_expect_success 'Hand committing of a redundant merge removes dups' ' - git rev-parse second master >expect && - test_must_fail git merge second master && - git checkout master g && + git rev-parse second main >expect && + test_must_fail git merge second main && + git checkout main g && EDITOR=: git commit -a && git cat-file commit HEAD >raw && sed -n -e "s/^parent //p" -e "/^$/q" raw >actual && diff --git a/t/t7503-pre-commit-and-pre-merge-commit-hooks.sh b/t/t7503-pre-commit-and-pre-merge-commit-hooks.sh index b3485450a2..606d8d0f08 100755 --- a/t/t7503-pre-commit-and-pre-merge-commit-hooks.sh +++ b/t/t7503-pre-commit-and-pre-merge-commit-hooks.sh @@ -2,6 +2,9 @@ test_description='pre-commit and pre-merge-commit hooks' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh HOOKDIR="$(git rev-parse --git-dir)/hooks" @@ -44,16 +47,16 @@ test_expect_success 'root commit' ' git add foo && git commit -m "make it non-ff" && git branch side-orig side && - git checkout master + git checkout main ' test_expect_success 'setup conflicting branches' ' - test_when_finished "git checkout master" && - git checkout -b conflicting-a master && + test_when_finished "git checkout main" && + git checkout -b conflicting-a main && echo a >conflicting && git add conflicting && git commit -m conflicting-a && - git checkout -b conflicting-b master && + git checkout -b conflicting-b main && echo b >conflicting && git add conflicting && git commit -m conflicting-b @@ -71,8 +74,8 @@ test_expect_success 'with no hook (merge)' ' test_when_finished "rm -f actual_hooks" && git branch -f side side-orig && git checkout side && - git merge -m "merge master" master && - git checkout master && + git merge -m "merge main" main && + git checkout main && test_path_is_missing actual_hooks ' @@ -88,8 +91,8 @@ test_expect_success '--no-verify with no hook (merge)' ' test_when_finished "rm -f actual_hooks" && git branch -f side side-orig && git checkout side && - git merge --no-verify -m "merge master" master && - git checkout master && + git merge --no-verify -m "merge main" main && + git checkout main && test_path_is_missing actual_hooks ' @@ -108,15 +111,15 @@ test_expect_success 'with succeeding hook (merge)' ' cp "$HOOKDIR/success.sample" "$PREMERGE" && echo "$PREMERGE" >expected_hooks && git checkout side && - git merge -m "merge master" master && - git checkout master && + git merge -m "merge main" main && + git checkout main && test_cmp expected_hooks actual_hooks ' test_expect_success 'automatic merge fails; both hooks are available' ' test_when_finished "rm -f \"$PREMERGE\" \"$PRECOMMIT\"" && test_when_finished "rm -f expected_hooks actual_hooks" && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && cp "$HOOKDIR/success.sample" "$PREMERGE" && cp "$HOOKDIR/success.sample" "$PRECOMMIT" && @@ -145,8 +148,8 @@ test_expect_success '--no-verify with succeeding hook (merge)' ' cp "$HOOKDIR/success.sample" "$PREMERGE" && git branch -f side side-orig && git checkout side && - git merge --no-verify -m "merge master" master && - git checkout master && + git merge --no-verify -m "merge main" main && + git checkout main && test_path_is_missing actual_hooks ' @@ -174,8 +177,8 @@ test_expect_success 'with failing hook (merge)' ' cp "$HOOKDIR/fail.sample" "$PREMERGE" && echo "$PREMERGE" >expected_hooks && git checkout side && - test_must_fail git merge -m "merge master" master && - git checkout master && + test_must_fail git merge -m "merge main" main && + git checkout main && test_cmp expected_hooks actual_hooks ' @@ -184,8 +187,8 @@ test_expect_success '--no-verify with failing hook (merge)' ' cp "$HOOKDIR/fail.sample" "$PREMERGE" && git branch -f side side-orig && git checkout side && - git merge --no-verify -m "merge master" master && - git checkout master && + git merge --no-verify -m "merge main" main && + git checkout main && test_path_is_missing actual_hooks ' @@ -212,8 +215,8 @@ test_expect_success POSIXPERM 'with non-executable hook (merge)' ' cp "$HOOKDIR/non-exec.sample" "$PREMERGE" && git branch -f side side-orig && git checkout side && - git merge -m "merge master" master && - git checkout master && + git merge -m "merge main" main && + git checkout main && test_path_is_missing actual_hooks ' @@ -222,8 +225,8 @@ test_expect_success POSIXPERM '--no-verify with non-executable hook (merge)' ' cp "$HOOKDIR/non-exec.sample" "$PREMERGE" && git branch -f side side-orig && git checkout side && - git merge --no-verify -m "merge master" master && - git checkout master && + git merge --no-verify -m "merge main" main && + git checkout main && test_path_is_missing actual_hooks ' diff --git a/t/t7504-commit-msg-hook.sh b/t/t7504-commit-msg-hook.sh index 31b9c6a2c1..4e7592522a 100755 --- a/t/t7504-commit-msg-hook.sh +++ b/t/t7504-commit-msg-hook.sh @@ -2,6 +2,9 @@ test_description='commit-msg hook' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'with no hook' ' @@ -142,12 +145,12 @@ test_expect_success '--no-verify with failing hook (editor)' ' test_expect_success 'merge fails with failing hook' ' test_when_finished "git branch -D newbranch" && - test_when_finished "git checkout -f master" && + test_when_finished "git checkout -f main" && git checkout --orphan newbranch && : >file2 && git add file2 && git commit --no-verify file2 -m in-side-branch && - test_must_fail git merge --allow-unrelated-histories master && + test_must_fail git merge --allow-unrelated-histories main && commit_msg_is "in-side-branch" # HEAD before merge ' @@ -155,14 +158,14 @@ test_expect_success 'merge fails with failing hook' ' test_expect_success 'merge bypasses failing hook with --no-verify' ' test_when_finished "git branch -D newbranch" && - test_when_finished "git checkout -f master" && + test_when_finished "git checkout -f main" && git checkout --orphan newbranch && git rm -f file && : >file2 && git add file2 && git commit --no-verify file2 -m in-side-branch && - git merge --no-verify --allow-unrelated-histories master && - commit_msg_is "Merge branch '\''master'\'' into newbranch" + git merge --no-verify --allow-unrelated-histories main && + commit_msg_is "Merge branch '\''main'\'' into newbranch" ' @@ -248,28 +251,28 @@ test_expect_success "hook doesn't edit commit message (editor)" ' test_expect_success 'hook called in git-merge picks up commit message' ' test_when_finished "git branch -D newbranch" && - test_when_finished "git checkout -f master" && + test_when_finished "git checkout -f main" && git checkout --orphan newbranch && git rm -f file && : >file2 && git add file2 && git commit --no-verify file2 -m in-side-branch && - git merge --allow-unrelated-histories master && + git merge --allow-unrelated-histories main && commit_msg_is "new message" ' test_expect_failure 'merge --continue remembers --no-verify' ' test_when_finished "git branch -D newbranch" && - test_when_finished "git checkout -f master" && - git checkout master && + test_when_finished "git checkout -f main" && + git checkout main && echo a >file2 && git add file2 && - git commit --no-verify -m "add file2 to master" && - git checkout -b newbranch master^ && + git commit --no-verify -m "add file2 to main" && + git checkout -b newbranch main^ && echo b >file2 && git add file2 && git commit --no-verify file2 -m in-side-branch && - git merge --no-verify -m not-rewritten-by-hook master && + git merge --no-verify -m not-rewritten-by-hook main && # resolve conflict: echo c >file2 && git add file2 && diff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh index 94f85cdf83..7a8194ce72 100755 --- a/t/t7505-prepare-commit-msg-hook.sh +++ b/t/t7505-prepare-commit-msg-hook.sh @@ -2,6 +2,9 @@ test_description='prepare-commit-msg hook' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'set up commits for rebasing' ' @@ -15,7 +18,7 @@ test_expect_success 'set up commits for rebasing' ' do test_commit rebase-$i c $i done && - git checkout master && + git checkout main && cat >rebase-todo <<-EOF pick $(git rev-parse rebase-a) @@ -190,7 +193,7 @@ test_expect_success 'with hook (-c)' ' test_expect_success 'with hook (merge)' ' - test_when_finished "git checkout -f master" && + test_when_finished "git checkout -f main" && git checkout -B other HEAD@{1} && echo "more" >>file && git add file && @@ -202,7 +205,7 @@ test_expect_success 'with hook (merge)' ' test_expect_success 'with hook and editor (merge)' ' - test_when_finished "git checkout -f master" && + test_when_finished "git checkout -f main" && git checkout -B other HEAD@{1} && echo "more" >>file && git add file && @@ -215,10 +218,10 @@ test_expect_success 'with hook and editor (merge)' ' test_rebase () { expect=$1 && mode=$2 && - test_expect_$expect C_LOCALE_OUTPUT "with hook (rebase ${mode:--i})" ' + test_expect_$expect "with hook (rebase ${mode:--i})" ' test_when_finished "\ git rebase --abort - git checkout -f master + git checkout -f main git branch -D tmp" && git checkout -b tmp rebase-me && GIT_SEQUENCE_EDITOR="cp rebase-todo" && @@ -250,14 +253,14 @@ test_rebase success test_have_prereq !REBASE_P || test_rebase success -p test_expect_success 'with hook (cherry-pick)' ' - test_when_finished "git checkout -f master" && + test_when_finished "git checkout -f main" && git checkout -B other b && git cherry-pick rebase-1 && test "$(git log -1 --pretty=format:%s)" = "message (no editor)" ' test_expect_success 'with hook and editor (cherry-pick)' ' - test_when_finished "git checkout -f master" && + test_when_finished "git checkout -f main" && git checkout -B other b && git cherry-pick -e rebase-1 && test "$(git log -1 --pretty=format:%s)" = merge @@ -270,7 +273,7 @@ EOF test_expect_success 'with failing hook' ' - test_when_finished "git checkout -f master" && + test_when_finished "git checkout -f main" && head=$(git rev-parse HEAD) && echo "more" >> file && git add file && @@ -280,7 +283,7 @@ test_expect_success 'with failing hook' ' test_expect_success 'with failing hook (--no-verify)' ' - test_when_finished "git checkout -f master" && + test_when_finished "git checkout -f main" && head=$(git rev-parse HEAD) && echo "more" >> file && git add file && @@ -290,7 +293,7 @@ test_expect_success 'with failing hook (--no-verify)' ' test_expect_success 'with failing hook (merge)' ' - test_when_finished "git checkout -f master" && + test_when_finished "git checkout -f main" && git checkout -B other HEAD@{1} && echo "more" >> file && git add file && @@ -304,8 +307,8 @@ test_expect_success 'with failing hook (merge)' ' ' -test_expect_success C_LOCALE_OUTPUT 'with failing hook (cherry-pick)' ' - test_when_finished "git checkout -f master" && +test_expect_success 'with failing hook (cherry-pick)' ' + test_when_finished "git checkout -f main" && git checkout -B other b && test_must_fail git cherry-pick rebase-1 2>actual && test $(grep -c prepare-commit-msg actual) = 1 diff --git a/t/t7508-status.sh b/t/t7508-status.sh index 963fed6821..2b72451ba3 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -37,11 +37,11 @@ test_expect_success 'create upstream branch' ' git checkout -b upstream && test_commit upstream1 && test_commit upstream2 && - # leave the first commit on master as root because several + # leave the first commit on main as root because several # tests depend on this case; for our upstream we only # care about commit counts anyway, so a totally divergent # history is OK - git checkout --orphan master + git checkout --orphan main ' test_expect_success 'setup' ' @@ -88,7 +88,7 @@ EOF test_expect_success 'status --column' ' cat >expect <<\EOF && -# On branch master +# On branch main # Your branch and '\''upstream'\'' have diverged, # and have 1 and 2 different commits each, respectively. # (use "git pull" to merge the remote branch into yours) @@ -109,17 +109,17 @@ test_expect_success 'status --column' ' # EOF COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status --column status.displayCommentPrefix=false' ' strip_comments expect && COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect <<\EOF -# On branch master +# On branch main # Your branch and 'upstream' have diverged, # and have 1 and 2 different commits each, respectively. # (use "git pull" to merge the remote branch into yours) @@ -144,19 +144,19 @@ EOF test_expect_success 'status with status.displayCommentPrefix=true' ' git -c status.displayCommentPrefix=true status >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status with status.displayCommentPrefix=false' ' strip_comments expect && git -c status.displayCommentPrefix=false status >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status -v' ' (cat expect && git diff --cached) >expect-with-v && git status -v >output && - test_i18ncmp expect-with-v output + test_cmp expect-with-v output ' test_expect_success 'status -v -v' ' @@ -167,7 +167,7 @@ test_expect_success 'status -v -v' ' echo "Changes not staged for commit:" && git -c diff.mnemonicprefix=true diff) >expect-with-v && git status -v -v >output && - test_i18ncmp expect-with-v output + test_cmp expect-with-v output ' test_expect_success 'setup fake editor' ' @@ -193,7 +193,7 @@ test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_ ' cat >expect <<\EOF -On branch master +On branch main Your branch and 'upstream' have diverged, and have 1 and 2 different commits each, respectively. @@ -214,7 +214,7 @@ EOF test_expect_success 'status (advice.statusHints false)' ' test_config advice.statusHints false && git status >output && - test_i18ncmp expect output + test_cmp expect output ' @@ -266,7 +266,7 @@ test_expect_success 'status with gitignore' ' test_cmp expect output && cat >expect <<\EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -296,7 +296,7 @@ Ignored files: EOF git status --ignored >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status with gitignore (nothing untracked)' ' @@ -331,7 +331,7 @@ test_expect_success 'status with gitignore (nothing untracked)' ' test_cmp expect output && cat >expect <<\EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -358,7 +358,7 @@ Ignored files: EOF git status --ignored >output && - test_i18ncmp expect output + test_cmp expect output ' cat >.gitignore <<\EOF @@ -368,7 +368,7 @@ output* EOF cat >expect <<\EOF -## master...upstream [ahead 1, behind 2] +## main...upstream [ahead 1, behind 2] M dir1/modified A dir2/added ?? dir1/untracked @@ -380,7 +380,7 @@ EOF test_expect_success 'status -s -b' ' git status -s -b >output && - test_i18ncmp expect output + test_cmp expect output ' @@ -390,7 +390,7 @@ test_expect_success 'status -s -z -b' ' git status -s -z -b >output && nul_to_q <output >output.q && mv output.q output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'setup dir3' ' @@ -401,7 +401,7 @@ test_expect_success 'setup dir3' ' test_expect_success 'status -uno' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -418,18 +418,18 @@ Changes not staged for commit: Untracked files not listed (use -u option to show untracked files) EOF git status -uno >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status (status.showUntrackedFiles no)' ' test_config status.showuntrackedfiles no && git status >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status -uno (advice.statusHints false)' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. @@ -443,7 +443,7 @@ Untracked files not listed EOF test_config advice.statusHints false && git status -uno >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect << EOF @@ -463,7 +463,7 @@ test_expect_success 'status -s (status.showUntrackedFiles no)' ' test_expect_success 'status -unormal' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -487,13 +487,13 @@ Untracked files: EOF git status -unormal >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status (status.showUntrackedFiles normal)' ' test_config status.showuntrackedfiles normal && git status >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect <<EOF @@ -518,7 +518,7 @@ test_expect_success 'status -s (status.showUntrackedFiles normal)' ' test_expect_success 'status -uall' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -543,13 +543,13 @@ Untracked files: EOF git status -uall >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status (status.showUntrackedFiles all)' ' test_config status.showuntrackedfiles all && git status >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'teardown dir3' ' @@ -578,7 +578,7 @@ test_expect_success 'status -s (status.showUntrackedFiles all)' ' test_expect_success 'status with relative paths' ' cat >expect <<\EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -601,7 +601,7 @@ Untracked files: EOF (cd dir1 && git status) >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect <<\EOF @@ -646,7 +646,7 @@ test_expect_success 'setup unique colors' ' test_expect_success TTY 'status with color.ui' ' cat >expect <<\EOF && -On branch <GREEN>master<RESET> +On branch <GREEN>main<RESET> Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -670,13 +670,13 @@ Untracked files: EOF test_config color.ui auto && test_terminal git status | test_decode_color >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success TTY 'status with color.status' ' test_config color.status auto && test_terminal git status | test_decode_color >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect <<\EOF @@ -706,7 +706,7 @@ test_expect_success TTY 'status -s with color.status' ' ' cat >expect <<\EOF -## <YELLOW>master<RESET>...<CYAN>upstream<RESET> [ahead <YELLOW>1<RESET>, behind <CYAN>2<RESET>] +## <YELLOW>main<RESET>...<CYAN>upstream<RESET> [ahead <YELLOW>1<RESET>, behind <CYAN>2<RESET>] <RED>M<RESET> dir1/modified <GREEN>A<RESET> dir2/added <BLUE>??<RESET> dir1/untracked @@ -718,7 +718,7 @@ EOF test_expect_success TTY 'status -s -b with color.status' ' test_terminal git status -s -b | test_decode_color >output && - test_i18ncmp expect output + test_cmp expect output ' @@ -757,7 +757,7 @@ test_expect_success 'status --porcelain respects -b' ' git status --porcelain -b >output && { - echo "## master...upstream [ahead 1, behind 2]" && + echo "## main...upstream [ahead 1, behind 2]" && cat expect } >tmp && mv tmp expect && @@ -769,7 +769,7 @@ test_expect_success 'status --porcelain respects -b' ' test_expect_success 'status without relative paths' ' cat >expect <<\EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -793,7 +793,7 @@ Untracked files: EOF test_config status.relativePaths false && (cd dir1 && git status) >output && - test_i18ncmp expect output + test_cmp expect output ' @@ -843,7 +843,7 @@ test_expect_success 'status -s without relative paths' ' test_expect_success 'dry-run of partial commit excluding new file in index' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -860,7 +860,7 @@ Untracked files: EOF git commit --dry-run dir1/modified >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect <<EOF @@ -897,7 +897,7 @@ test_expect_success 'setup status submodule summary' ' test_expect_success 'status submodule summary is disabled by default' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -921,13 +921,13 @@ Untracked files: EOF git status >output && - test_i18ncmp expect output + test_cmp expect output ' # we expect the same as the previous test test_expect_success 'status --untracked-files=all does not show submodule' ' git status --untracked-files=all >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect <<EOF @@ -954,7 +954,7 @@ head=$(cd sm && git rev-parse --short=7 --verify HEAD) test_expect_success 'status submodule summary' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -984,13 +984,13 @@ Untracked files: EOF git config status.submodulesummary 10 && git status >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status submodule summary with status.displayCommentPrefix=false' ' strip_comments expect && git -c status.displayCommentPrefix=false status >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' ' @@ -1013,7 +1013,7 @@ test_expect_success 'status -s submodule summary' ' test_expect_success 'status submodule summary (clean submodule): commit' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -1035,9 +1035,9 @@ EOF git commit -m "commit submodule" && git config status.submodulesummary 10 && test_must_fail git commit --dry-run >output && - test_i18ncmp expect output && + test_cmp expect output && git status >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect <<EOF @@ -1061,7 +1061,7 @@ test_expect_success 'status -z implies porcelain' ' test_expect_success 'commit --dry-run submodule summary (--amend)' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -1091,7 +1091,7 @@ Untracked files: EOF git config status.submodulesummary 10 && git commit --dry-run --amend >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' ' @@ -1113,7 +1113,7 @@ touch .gitmodules test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' ' cat > expect << EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -1143,17 +1143,17 @@ Untracked files: EOF echo modified sm/untracked && git status --ignore-submodules=untracked >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' ' test_config diff.ignoreSubmodules dirty && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config --add -f .gitmodules submodule.subname.ignore untracked && git config --add -f .gitmodules submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config -f .gitmodules --remove-section submodule.subname ' @@ -1163,14 +1163,14 @@ test_expect_success '.git/config ignore=untracked suppresses submodules with unt git config --add submodule.subname.ignore untracked && git config --add submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config --remove-section submodule.subname && git config --remove-section -f .gitmodules submodule.subname ' test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' ' git status --ignore-submodules=dirty >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' ' @@ -1180,7 +1180,7 @@ test_expect_success '.gitmodules ignore=dirty suppresses submodules with untrack git config --add -f .gitmodules submodule.subname.ignore dirty && git config --add -f .gitmodules submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config -f .gitmodules --remove-section submodule.subname ' @@ -1190,7 +1190,7 @@ test_expect_success '.git/config ignore=dirty suppresses submodules with untrack git config --add submodule.subname.ignore dirty && git config --add submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config --remove-section submodule.subname && git config -f .gitmodules --remove-section submodule.subname ' @@ -1198,14 +1198,14 @@ test_expect_success '.git/config ignore=dirty suppresses submodules with untrack test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' ' echo modified >sm/foo && git status --ignore-submodules=dirty >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' ' git config --add -f .gitmodules submodule.subname.ignore dirty && git config --add -f .gitmodules submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config -f .gitmodules --remove-section submodule.subname ' @@ -1215,14 +1215,14 @@ test_expect_success '.git/config ignore=dirty suppresses submodules with modifie git config --add submodule.subname.ignore dirty && git config --add submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config --remove-section submodule.subname && git config -f .gitmodules --remove-section submodule.subname ' test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" ' cat > expect << EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -1253,14 +1253,14 @@ Untracked files: EOF git status --ignore-submodules=untracked > output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" ' git config --add -f .gitmodules submodule.subname.ignore untracked && git config --add -f .gitmodules submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config -f .gitmodules --remove-section submodule.subname ' @@ -1270,7 +1270,7 @@ test_expect_success ".git/config ignore=untracked doesn't suppress submodules wi git config --add submodule.subname.ignore untracked && git config --add submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config --remove-section submodule.subname && git config -f .gitmodules --remove-section submodule.subname ' @@ -1279,7 +1279,7 @@ head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 -- test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" ' cat > expect << EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -1314,14 +1314,14 @@ Untracked files: EOF git status --ignore-submodules=untracked > output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" ' git config --add -f .gitmodules submodule.subname.ignore untracked && git config --add -f .gitmodules submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config -f .gitmodules --remove-section submodule.subname ' @@ -1331,20 +1331,20 @@ test_expect_success ".git/config ignore=untracked doesn't suppress submodule sum git config --add submodule.subname.ignore untracked && git config --add submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config --remove-section submodule.subname && git config -f .gitmodules --remove-section submodule.subname ' test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" ' git status --ignore-submodules=dirty > output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" ' git config --add -f .gitmodules submodule.subname.ignore dirty && git config --add -f .gitmodules submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config -f .gitmodules --remove-section submodule.subname ' @@ -1354,13 +1354,13 @@ test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary git config --add submodule.subname.ignore dirty && git config --add submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config --remove-section submodule.subname && git config -f .gitmodules --remove-section submodule.subname ' cat > expect << EOF -; On branch master +; On branch main ; Your branch and 'upstream' have diverged, ; and have 2 and 2 different commits each, respectively. ; (use "git pull" to merge the remote branch into yours) @@ -1398,7 +1398,7 @@ EOF test_expect_success "status (core.commentchar with submodule summary)" ' test_config core.commentchar ";" && git -c status.displayCommentPrefix=true status >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success "status (core.commentchar with two chars with submodule summary)" ' @@ -1408,7 +1408,7 @@ test_expect_success "status (core.commentchar with two chars with submodule summ test_expect_success "--ignore-submodules=all suppresses submodule summary" ' cat > expect << EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -1429,12 +1429,12 @@ Untracked files: no changes added to commit (use "git add" and/or "git commit -a") EOF git status --ignore-submodules=all > output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success '.gitmodules ignore=all suppresses unstaged submodule summary' ' cat > expect << EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -1460,7 +1460,7 @@ EOF git config --add -f .gitmodules submodule.subname.ignore all && git config --add -f .gitmodules submodule.subname.path sm && git status > output && - test_i18ncmp expect output && + test_cmp expect output && git config -f .gitmodules --remove-section submodule.subname ' @@ -1470,7 +1470,7 @@ test_expect_success '.git/config ignore=all suppresses unstaged submodule summar git config --add submodule.subname.ignore all && git config --add submodule.subname.path sm && git status > output && - test_i18ncmp expect output && + test_cmp expect output && git config --remove-section submodule.subname && git config -f .gitmodules --remove-section submodule.subname ' @@ -1554,7 +1554,7 @@ test_expect_success 'git commit --dry-run will show a staged but ignored submodu git reset HEAD^ && git add sm && cat >expect << EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -1571,7 +1571,7 @@ Changes not staged for commit: Untracked files not listed (use -u option to show untracked files) EOF git commit -uno --dry-run >output && - test_i18ncmp expect output && + test_cmp expect output && git status -s --ignore-submodules=dirty >output && test_i18ngrep "^M. sm" output ' diff --git a/t/t7509-commit-authorship.sh b/t/t7509-commit-authorship.sh index 500ab2fe72..ee6c47416e 100755 --- a/t/t7509-commit-authorship.sh +++ b/t/t7509-commit-authorship.sh @@ -18,11 +18,8 @@ message_body () { } test_expect_success '-C option copies authorship and message' ' - echo "Initial" >foo && - git add foo && - test_tick && - git commit -m "Initial Commit" --author Frigate\ \<flying@over.world\> && - git tag Initial && + test_commit --author Frigate\ \<flying@over.world\> \ + "Initial Commit" foo Initial Initial && echo "Test 1" >>foo && test_tick && git commit -a -C Initial && diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh index 6baaa1ad91..8df5a74f1d 100755 --- a/t/t7510-signed-commit.sh +++ b/t/t7510-signed-commit.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='signed commit tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh GNUPGHOME_NOT_USED=$GNUPGHOME . "$TEST_DIRECTORY/lib-gpg.sh" @@ -25,7 +28,7 @@ test_expect_success GPG 'create signed commits' ' echo 3 >elif && git add elif && test_tick && git commit -m "third on side" && - git checkout master && + git checkout main && test_tick && git merge -S side && git tag merge && @@ -172,7 +175,7 @@ test_expect_success GPG 'show signed commit with signature' ' git cat-file commit initial >cat && grep -v -e "gpg: " -e "Warning: " show >show.commit && grep -e "gpg: " -e "Warning: " show >show.gpg && - grep -v "^ " cat | grep -v "^$(test_oid header) " >cat.commit && + grep -v "^ " cat | grep -v "^gpgsig.* " >cat.commit && test_cmp show.commit commit && test_cmp show.gpg verify.2 && test_cmp cat.commit verify.1 @@ -334,4 +337,45 @@ test_expect_success GPG 'show double signature with custom format' ' test_cmp expect actual ' + +test_expect_success GPG 'verify-commit verifies multiply signed commits' ' + git init multiply-signed && + cd multiply-signed && + test_commit first && + echo 1 >second && + git add second && + tree=$(git write-tree) && + parent=$(git rev-parse HEAD^{commit}) && + git commit --gpg-sign -m second && + git cat-file commit HEAD && + # Avoid trailing whitespace. + sed -e "s/^Q//" -e "s/^Z/ /" >commit <<-EOF && + Qtree $tree + Qparent $parent + Qauthor A U Thor <author@example.com> 1112912653 -0700 + Qcommitter C O Mitter <committer@example.com> 1112912653 -0700 + Qgpgsig -----BEGIN PGP SIGNATURE----- + QZ + Q iHQEABECADQWIQRz11h0S+chaY7FTocTtvUezd5DDQUCX/uBDRYcY29tbWl0dGVy + Q QGV4YW1wbGUuY29tAAoJEBO29R7N3kMNd+8AoK1I8mhLHviPH+q2I5fIVgPsEtYC + Q AKCTqBh+VabJceXcGIZuF0Ry+udbBQ== + Q =tQ0N + Q -----END PGP SIGNATURE----- + Qgpgsig-sha256 -----BEGIN PGP SIGNATURE----- + QZ + Q iHQEABECADQWIQRz11h0S+chaY7FTocTtvUezd5DDQUCX/uBIBYcY29tbWl0dGVy + Q QGV4YW1wbGUuY29tAAoJEBO29R7N3kMN/NEAn0XO9RYSBj2dFyozi0JKSbssYMtO + Q AJwKCQ1BQOtuwz//IjU8TiS+6S4iUw== + Q =pIwP + Q -----END PGP SIGNATURE----- + Q + Qsecond + EOF + head=$(git hash-object -t commit -w commit) && + git reset --hard $head && + git verify-commit $head 2>actual && + grep "Good signature from" actual && + ! grep "BAD signature from" actual +' + test_done diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh index 29518e0949..7f2956d77a 100755 --- a/t/t7512-status-help.sh +++ b/t/t7512-status-help.sh @@ -7,6 +7,9 @@ test_description='git status advice' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh @@ -17,14 +20,14 @@ test_expect_success 'prepare for conflicts' ' git config --global advice.statusuoption false && test_commit init main.txt init && git branch conflicts && - test_commit on_master main.txt on_master && + test_commit on_main main.txt on_main && git checkout conflicts && test_commit on_conflicts main.txt on_conflicts ' test_expect_success 'status when conflicts unresolved' ' - test_must_fail git merge master && + test_must_fail git merge main && cat >expected <<\EOF && On branch conflicts You have unmerged paths. @@ -38,13 +41,13 @@ Unmerged paths: no changes added to commit (use "git add" and/or "git commit -a") EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status when conflicts resolved before commit' ' git reset --hard conflicts && - test_must_fail git merge master && + test_must_fail git merge main && echo one >main.txt && git add main.txt && cat >expected <<\EOF && @@ -58,12 +61,12 @@ Changes to be committed: Untracked files not listed (use -u option to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'prepare for rebase conflicts' ' - git reset --hard master && + git reset --hard main && git checkout -b rebase_conflicts && test_commit one_rebase main.txt one && test_commit two_rebase main.txt two && @@ -90,7 +93,7 @@ Unmerged paths: no changes added to commit (use "git add" and/or "git commit -a") EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' @@ -113,16 +116,16 @@ Changes to be committed: Untracked files not listed (use -u option to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'prepare for rebase_i_conflicts' ' - git reset --hard master && + git reset --hard main && git checkout -b rebase_i_conflicts && test_commit one_unmerge main.txt one_unmerge && git branch rebase_i_conflicts_second && - test_commit one_master main.txt one_master && + test_commit one_main main.txt one_main && git checkout rebase_i_conflicts_second && test_commit one_second main.txt one_second ' @@ -151,7 +154,7 @@ Unmerged paths: no changes added to commit (use "git add" and/or "git commit -a") EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' @@ -177,12 +180,12 @@ Changes to be committed: Untracked files not listed (use -u option to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status when rebasing -i in edit mode' ' - git reset --hard master && + git reset --hard main && git checkout -b rebase_i_edit && test_commit one_rebase_i main.txt one && test_commit two_rebase_i main.txt two && @@ -207,12 +210,12 @@ You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' o nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status when splitting a commit' ' - git reset --hard master && + git reset --hard main && git checkout -b split_commit && test_commit one_split main.txt one && test_commit two_split main.txt two && @@ -246,12 +249,12 @@ Changes not staged for commit: no changes added to commit (use "git add" and/or "git commit -a") EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status after editing the last commit with --amend during a rebase -i' ' - git reset --hard master && + git reset --hard main && git checkout -b amend_last && test_commit one_amend main.txt one && test_commit two_amend main.txt two && @@ -279,12 +282,12 @@ You are currently editing a commit while rebasing branch '\''amend_last'\'' on ' nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'prepare for several edits' ' - git reset --hard master && + git reset --hard main && git checkout -b several_edits && test_commit one_edits main.txt one && test_commit two_edits main.txt two && @@ -318,7 +321,7 @@ You are currently editing a commit while rebasing branch '\''several_edits'\'' o nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' @@ -353,7 +356,7 @@ Changes not staged for commit: no changes added to commit (use "git add" and/or "git commit -a") EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' @@ -384,7 +387,7 @@ You are currently editing a commit while rebasing branch '\''several_edits'\'' o nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' @@ -415,7 +418,7 @@ You are currently editing a commit while rebasing branch '\''several_edits'\'' o nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' @@ -451,7 +454,7 @@ Changes not staged for commit: no changes added to commit (use "git add" and/or "git commit -a") EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' @@ -483,7 +486,7 @@ You are currently editing a commit while rebasing branch '\''several_edits'\'' o nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' @@ -516,7 +519,7 @@ You are currently editing a commit while rebasing branch '\''several_edits'\'' o nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' @@ -554,7 +557,7 @@ Changes not staged for commit: no changes added to commit (use "git add" and/or "git commit -a") EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' @@ -588,12 +591,12 @@ You are currently editing a commit while rebasing branch '\''several_edits'\'' o nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'prepare am_session' ' - git reset --hard master && + git reset --hard main && git checkout -b am_session && test_commit one_am one.txt "one" && test_commit two_am two.txt "two" && @@ -616,7 +619,7 @@ You are in the middle of an am session. nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' @@ -638,7 +641,7 @@ You are in the middle of an am session. nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' @@ -661,12 +664,12 @@ The current patch is empty. nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status when bisecting' ' - git reset --hard master && + git reset --hard main && git checkout -b bisect && test_commit one_bisect main.txt one && test_commit two_bisect main.txt two && @@ -684,12 +687,12 @@ You are currently bisecting, started from branch '\''bisect'\''. nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status when rebase --apply conflicts with statushints disabled' ' - git reset --hard master && + git reset --hard main && git checkout -b statushints_disabled && test_when_finished "git config --local advice.statushints true" && git config --local advice.statushints false && @@ -709,12 +712,12 @@ Unmerged paths: no changes added to commit EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'prepare for cherry-pick conflicts' ' - git reset --hard master && + git reset --hard main && git checkout -b cherry_branch && test_commit one_cherry main.txt one && test_commit two_cherries main.txt two && @@ -743,7 +746,7 @@ Unmerged paths: no changes added to commit (use "git add" and/or "git commit -a") EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' @@ -767,7 +770,7 @@ Changes to be committed: Untracked files not listed (use -u option to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status when cherry-picking after committing conflict resolution' ' @@ -786,7 +789,7 @@ Cherry-pick currently in progress. nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status shows cherry-pick with invalid oid' ' @@ -795,7 +798,7 @@ test_expect_success 'status shows cherry-pick with invalid oid' ' git status --untracked-files=no >actual 2>err && git cherry-pick --quit && test_must_be_empty err && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status does not show error if .git/sequencer is a file' ' @@ -813,7 +816,7 @@ HEAD detached at atag nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual && + test_cmp expected actual && git reset --hard HEAD^ && cat >expected <<\EOF && @@ -821,11 +824,11 @@ HEAD detached from atag nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status while reverting commit (conflicts)' ' - git checkout master && + git checkout main && echo before >to-revert.txt && test_commit before to-revert.txt && echo old >to-revert.txt && @@ -835,7 +838,7 @@ test_expect_success 'status while reverting commit (conflicts)' ' TO_REVERT=$(git rev-parse --short HEAD^) && test_must_fail git revert $TO_REVERT && cat >expected <<EOF && -On branch master +On branch main You are currently reverting commit $TO_REVERT. (fix conflicts and run "git revert --continue") (use "git revert --skip" to skip this patch) @@ -849,14 +852,14 @@ Unmerged paths: no changes added to commit (use "git add" and/or "git commit -a") EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status while reverting commit (conflicts resolved)' ' echo reverted >to-revert.txt && git add to-revert.txt && cat >expected <<EOF && -On branch master +On branch main You are currently reverting commit $TO_REVERT. (all conflicts fixed: run "git revert --continue") (use "git revert --skip" to skip this patch) @@ -869,17 +872,17 @@ Changes to be committed: Untracked files not listed (use -u option to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status after reverting commit' ' git revert --continue && cat >expected <<\EOF && -On branch master +On branch main nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status while reverting after committing conflict resolution' ' @@ -889,7 +892,7 @@ test_expect_success 'status while reverting after committing conflict resolution echo reverted >to-revert.txt && git commit -a && cat >expected <<EOF && -On branch master +On branch main Revert currently in progress. (run "git revert --continue" to continue) (use "git revert --skip" to skip this patch) @@ -898,11 +901,11 @@ Revert currently in progress. nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'prepare for different number of commits rebased' ' - git reset --hard master && + git reset --hard main && git checkout -b several_commits && test_commit one_commit main.txt one && test_commit two_commit main.txt two && @@ -928,7 +931,7 @@ You are currently editing a commit while rebasing branch '\''several_commits'\'' nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status: two commands done with some white lines in done file' ' @@ -956,7 +959,7 @@ You are currently editing a commit while rebasing branch '\''several_commits'\'' nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status: two remaining commands with some white lines in todo file' ' @@ -985,7 +988,7 @@ You are currently editing a commit while rebasing branch '\''several_commits'\'' nothing to commit (use -u to show untracked files) EOF git status --untracked-files=no >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_expect_success 'status: handle not-yet-started rebase -i gracefully' ' @@ -1004,7 +1007,7 @@ You are currently editing a commit while rebasing branch '\''several_commits'\'' nothing to commit (use -u to show untracked files) EOF - test_i18ncmp expected actual + test_cmp expected actual ' test_done diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh index 6602790b5f..04885d0a5e 100755 --- a/t/t7513-interpret-trailers.sh +++ b/t/t7513-interpret-trailers.sh @@ -51,6 +51,69 @@ test_expect_success 'setup' ' EOF ' +test_expect_success 'with cmd' ' + test_when_finished "git config --remove-section trailer.bug" && + git config trailer.bug.key "Bug-maker: " && + git config trailer.bug.ifExists "add" && + git config trailer.bug.cmd "echo \"maybe is\"" && + cat >expected2 <<-EOF && + + Bug-maker: maybe is him + Bug-maker: maybe is me + EOF + git interpret-trailers --trailer "bug: him" --trailer "bug:me" \ + >actual2 && + test_cmp expected2 actual2 +' + +test_expect_success 'with cmd and $1' ' + test_when_finished "git config --remove-section trailer.bug" && + git config trailer.bug.key "Bug-maker: " && + git config trailer.bug.ifExists "add" && + git config trailer.bug.cmd "echo \"\$1\" is" && + cat >expected2 <<-EOF && + + Bug-maker: him is him + Bug-maker: me is me + EOF + git interpret-trailers --trailer "bug: him" --trailer "bug:me" \ + >actual2 && + test_cmp expected2 actual2 +' + +test_expect_success 'with cmd and $1 with sh -c' ' + test_when_finished "git config --remove-section trailer.bug" && + git config trailer.bug.key "Bug-maker: " && + git config trailer.bug.ifExists "replace" && + git config trailer.bug.cmd "sh -c \"echo who is \"\$1\"\"" && + cat >expected2 <<-EOF && + + Bug-maker: who is me + EOF + git interpret-trailers --trailer "bug: him" --trailer "bug:me" \ + >actual2 && + test_cmp expected2 actual2 +' + +test_expect_success 'with cmd and $1 with shell script' ' + test_when_finished "git config --remove-section trailer.bug" && + git config trailer.bug.key "Bug-maker: " && + git config trailer.bug.ifExists "replace" && + git config trailer.bug.cmd "./echoscript" && + cat >expected2 <<-EOF && + + Bug-maker: who is me + EOF + cat >echoscript <<-EOF && + #!/bin/sh + echo who is "\$1" + EOF + chmod +x echoscript && + git interpret-trailers --trailer "bug: him" --trailer "bug:me" \ + >actual2 && + test_cmp expected2 actual2 +' + test_expect_success 'without config' ' sed -e "s/ Z\$/ /" >expected <<-\EOF && @@ -1274,6 +1337,27 @@ test_expect_success 'setup a commit' ' git commit -m "Add file a.txt" ' +test_expect_success 'cmd takes precedence over command' ' + test_when_finished "git config --unset trailer.fix.cmd" && + git config trailer.fix.ifExists "replace" && + git config trailer.fix.cmd "test -n \"\$1\" && git log -1 --oneline --format=\"%h (%aN)\" \ + --abbrev-commit --abbrev=14 \"\$1\" || true" && + git config trailer.fix.command "git log -1 --oneline --format=\"%h (%s)\" \ + --abbrev-commit --abbrev=14 \$ARG" && + FIXED=$(git log -1 --oneline --format="%h (%aN)" --abbrev-commit --abbrev=14 HEAD) && + cat complex_message_body >expected2 && + sed -e "s/ Z\$/ /" >>expected2 <<-EOF && + Fixes: $FIXED + Acked-by= Z + Reviewed-by: + Signed-off-by: Z + Signed-off-by: A U Thor <author@example.com> + EOF + git interpret-trailers --trailer "review:" --trailer "fix=HEAD" \ + <complex_message >actual2 && + test_cmp expected2 actual2 +' + test_expect_success 'with command using $ARG' ' git config trailer.fix.ifExists "replace" && git config trailer.fix.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" && diff --git a/t/t7517-per-repo-email.sh b/t/t7517-per-repo-email.sh index b2401cec3e..405420ae4d 100755 --- a/t/t7517-per-repo-email.sh +++ b/t/t7517-per-repo-email.sh @@ -6,6 +6,9 @@ test_description='per-repo forced setting of email address' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup a likely user.useConfigOnly use case' ' @@ -47,24 +50,24 @@ test_expect_success 'set up rebase scenarios' ' test_expect_success 'fast-forward rebase does not care about ident' ' git checkout -B tmp side-without-commit && - git rebase master + git rebase main ' test_expect_success 'non-fast-forward rebase refuses to write commits' ' test_when_finished "git rebase --abort || true" && git checkout -B tmp side-with-commit && - test_must_fail git rebase master + test_must_fail git rebase main ' test_expect_success 'fast-forward rebase does not care about ident (interactive)' ' git checkout -B tmp side-without-commit && - git rebase -i master + git rebase -i main ' test_expect_success 'non-fast-forward rebase refuses to write commits (interactive)' ' test_when_finished "git rebase --abort || true" && git checkout -B tmp side-with-commit && - test_must_fail git rebase -i master + test_must_fail git rebase -i main ' test_expect_success 'noop interactive rebase does not care about ident' ' @@ -75,14 +78,14 @@ test_expect_success 'noop interactive rebase does not care about ident' ' test_expect_success REBASE_P \ 'fast-forward rebase does not care about ident (preserve)' ' git checkout -B tmp side-without-commit && - git rebase -p master + git rebase -p main ' test_expect_success REBASE_P \ 'non-fast-forward rebase refuses to write commits (preserve)' ' test_when_finished "git rebase --abort || true" && git checkout -B tmp side-with-commit && - test_must_fail git rebase -p master + test_must_fail git rebase -p main ' test_expect_success 'author.name overrides user.name' ' diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh index fbfdcca000..637391c6ce 100755 --- a/t/t7519-status-fsmonitor.sh +++ b/t/t7519-status-fsmonitor.sh @@ -236,7 +236,7 @@ test_expect_success 'refresh_index() invalidates fsmonitor cache' ' git reset HEAD~1 && git status >actual && git -c core.fsmonitor= status >expect && - test_i18ncmp expect actual + test_cmp expect actual ' # test fsmonitor with and without preloadIndex @@ -273,7 +273,7 @@ do git add dir2/new && git status >actual && git -c core.fsmonitor= status >expect && - test_i18ncmp expect actual + test_cmp expect actual ' # Make sure it's actually skipping the check for modified and untracked @@ -334,7 +334,7 @@ test_expect_success UNTRACKED_CACHE 'ignore .git changes when invalidating UNTR' git config core.fsmonitor .git/hooks/fsmonitor-test && git update-index --untracked-cache && git update-index --fsmonitor && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace-before" \ + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace-before" \ git status && test-tool dump-untracked-cache >../before ) && @@ -346,12 +346,12 @@ test_expect_success UNTRACKED_CACHE 'ignore .git changes when invalidating UNTR' EOF ( cd dot-git && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace-after" \ + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace-after" \ git status && test-tool dump-untracked-cache >../after ) && - grep "directory invalidation" trace-before >>before && - grep "directory invalidation" trace-after >>after && + grep "directory-invalidation" trace-before | cut -d"|" -f 9 >>before && + grep "directory-invalidation" trace-after | cut -d"|" -f 9 >>after && # UNTR extension unchanged, dir invalidation count unchanged test_cmp before after ' diff --git a/t/t7521-ignored-mode.sh b/t/t7521-ignored-mode.sh index 91790943c3..a88b02b06e 100755 --- a/t/t7521-ignored-mode.sh +++ b/t/t7521-ignored-mode.sh @@ -30,7 +30,7 @@ test_expect_success 'Verify behavior of status on directories with ignored files dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign && git status --porcelain=v2 --ignored=matching --untracked-files=all >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'Verify status behavior on directory with tracked & ignored files' ' @@ -55,7 +55,7 @@ test_expect_success 'Verify status behavior on directory with tracked & ignored git commit -m "commit tracked files" && git status --porcelain=v2 --ignored=matching --untracked-files=all >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'Verify status behavior on directory with untracked and ignored files' ' @@ -80,7 +80,7 @@ test_expect_success 'Verify status behavior on directory with untracked and igno dir/untracked_ignored/ignored_1.ign dir/untracked_ignored/ignored_2.ign && git status --porcelain=v2 --ignored=matching --untracked-files=all >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'Verify status matching ignored files on ignored directory' ' @@ -96,7 +96,7 @@ test_expect_success 'Verify status matching ignored files on ignored directory' ignored_dir/ignored_1.ign ignored_dir/ignored_2.ign && git status --porcelain=v2 --ignored=matching --untracked-files=all >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'Verify status behavior on ignored directory containing tracked file' ' @@ -117,7 +117,7 @@ test_expect_success 'Verify status behavior on ignored directory containing trac git add -f ignored_dir/tracked && git commit -m "Force add file in ignored directory" && git status --porcelain=v2 --ignored=matching --untracked-files=all >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'Verify matching ignored files with --untracked-files=normal' ' @@ -136,7 +136,7 @@ test_expect_success 'Verify matching ignored files with --untracked-files=normal ignored_files/ignored_1.ign ignored_files/ignored_2.ign \ untracked_dir/untracked && git status --porcelain=v2 --ignored=matching --untracked-files=normal >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'Verify matching ignored files with --untracked-files=normal' ' @@ -155,7 +155,7 @@ test_expect_success 'Verify matching ignored files with --untracked-files=normal ignored_files/ignored_1.ign ignored_files/ignored_2.ign \ untracked_dir/untracked && git status --porcelain=v2 --ignored=matching --untracked-files=normal >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'Verify status behavior on ignored directory containing tracked file' ' @@ -176,7 +176,7 @@ test_expect_success 'Verify status behavior on ignored directory containing trac git add -f ignored_dir/tracked && git commit -m "Force add file in ignored directory" && git status --porcelain=v2 --ignored=matching --untracked-files=normal >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'Verify behavior of status with --ignored=no' ' @@ -191,7 +191,7 @@ test_expect_success 'Verify behavior of status with --ignored=no' ' dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign && git status --porcelain=v2 --ignored=no --untracked-files=all >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'Verify behavior of status with --ignored=traditional and --untracked-files=all' ' @@ -210,7 +210,7 @@ test_expect_success 'Verify behavior of status with --ignored=traditional and -- dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign && git status --porcelain=v2 --ignored=traditional --untracked-files=all >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'Verify behavior of status with --ignored=traditional and --untracked-files=normal' ' @@ -227,7 +227,7 @@ test_expect_success 'Verify behavior of status with --ignored=traditional and -- dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign && git status --porcelain=v2 --ignored=traditional --untracked-files=normal >output && - test_i18ncmp expect output + test_cmp expect output ' test_done diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 1c85f75555..1cbc9715a8 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -14,9 +14,9 @@ Testing basic merge operations/option parsing. ! [c4] c4 ! [c5] c5 ! [c6] c6 - * [master] Merge commit 'c1' + * [main] Merge commit 'c1' -------- - - [master] Merge commit 'c1' + - [main] Merge commit 'c1' + * [c1] commit 1 + [c6] c6 + [c5] c5 @@ -26,6 +26,9 @@ Testing basic merge operations/option parsing. +++++++* [c0] commit 0 ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-gpg.sh @@ -203,13 +206,13 @@ test_expect_success 'merge c0 with c1 with --ff-only' ' test_debug 'git log --graph --decorate --oneline --all' test_expect_success 'merge from unborn branch' ' - git checkout -f master && + git checkout -f main && test_might_fail git branch -D kid && echo "OBJID HEAD@{0}: initial pull" >reflog.expected && git checkout --orphan kid && - test_when_finished "git checkout -f master" && + test_when_finished "git checkout -f main" && git rm -fr . && test_tick && git merge --ff-only c1 && @@ -269,7 +272,7 @@ test_expect_success 'merge c3 with c7 with commit.cleanup = scissors' ' EOF git cat-file commit HEAD >raw && sed -e "1,/^$/d" raw >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'merge c3 with c7 with --squash commit.cleanup = scissors' ' @@ -293,7 +296,7 @@ test_expect_success 'merge c3 with c7 with --squash commit.cleanup = scissors' ' EOF git cat-file commit HEAD >raw && sed -e "1,/^$/d" raw >actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_debug 'git log --graph --decorate --oneline --all' @@ -413,7 +416,7 @@ test_debug 'git log --graph --decorate --oneline --all' test_expect_success 'merge c1 with c2 (no-commit in config)' ' git reset --hard c1 && - test_config branch.master.mergeoptions "--no-commit" && + test_config branch.main.mergeoptions "--no-commit" && git merge c2 && verify_merge file result.1-5 && verify_head $c1 && @@ -427,7 +430,7 @@ test_expect_success 'merge c1 with c2 (log in config)' ' git merge --log c2 && git show -s --pretty=tformat:%s%n%b >expect && - test_config branch.master.mergeoptions "--log" && + test_config branch.main.mergeoptions "--log" && git reset --hard c1 && git merge c2 && git show -s --pretty=tformat:%s%n%b >actual && @@ -440,7 +443,7 @@ test_expect_success 'merge c1 with c2 (log in config gets overridden)' ' git merge c2 && git show -s --pretty=tformat:%s%n%b >expect && - test_config branch.master.mergeoptions "--no-log" && + test_config branch.main.mergeoptions "--no-log" && test_config merge.log "true" && git reset --hard c1 && git merge c2 && @@ -451,7 +454,7 @@ test_expect_success 'merge c1 with c2 (log in config gets overridden)' ' test_expect_success 'merge c1 with c2 (squash in config)' ' git reset --hard c1 && - test_config branch.master.mergeoptions "--squash" && + test_config branch.main.mergeoptions "--squash" && git merge c2 && verify_merge file result.1-5 && verify_head $c1 && @@ -463,7 +466,7 @@ test_debug 'git log --graph --decorate --oneline --all' test_expect_success 'override config option -n with --summary' ' git reset --hard c1 && - test_config branch.master.mergeoptions "-n" && + test_config branch.main.mergeoptions "-n" && test_tick && git merge --summary c2 >diffstat.txt && verify_merge file result.1-5 msg.1-5 && @@ -477,7 +480,7 @@ test_expect_success 'override config option -n with --summary' ' test_expect_success 'override config option -n with --stat' ' git reset --hard c1 && - test_config branch.master.mergeoptions "-n" && + test_config branch.main.mergeoptions "-n" && test_tick && git merge --stat c2 >diffstat.txt && verify_merge file result.1-5 msg.1-5 && @@ -493,7 +496,7 @@ test_debug 'git log --graph --decorate --oneline --all' test_expect_success 'override config option --stat' ' git reset --hard c1 && - test_config branch.master.mergeoptions "--stat" && + test_config branch.main.mergeoptions "--stat" && test_tick && git merge -n c2 >diffstat.txt && verify_merge file result.1-5 msg.1-5 && @@ -509,7 +512,7 @@ test_debug 'git log --graph --decorate --oneline --all' test_expect_success 'merge c1 with c2 (override --no-commit)' ' git reset --hard c1 && - test_config branch.master.mergeoptions "--no-commit" && + test_config branch.main.mergeoptions "--no-commit" && test_tick && git merge --commit c2 && verify_merge file result.1-5 msg.1-5 && @@ -520,7 +523,7 @@ test_debug 'git log --graph --decorate --oneline --all' test_expect_success 'merge c1 with c2 (override --squash)' ' git reset --hard c1 && - test_config branch.master.mergeoptions "--squash" && + test_config branch.main.mergeoptions "--squash" && test_tick && git merge --no-squash c2 && verify_merge file result.1-5 msg.1-5 && @@ -549,9 +552,9 @@ test_expect_success 'merge c0 with c1 (merge.ff=false)' ' ' test_debug 'git log --graph --decorate --oneline --all' -test_expect_success 'combine branch.master.mergeoptions with merge.ff' ' +test_expect_success 'combine branch.main.mergeoptions with merge.ff' ' git reset --hard c0 && - test_config branch.master.mergeoptions "--ff" && + test_config branch.main.mergeoptions "--ff" && test_config merge.ff "false" && test_tick && git merge c1 && @@ -593,7 +596,7 @@ test_expect_success 'option --no-ff overrides merge.ff=only config' ' test_expect_success 'merge c0 with c1 (ff overrides no-ff)' ' git reset --hard c0 && - test_config branch.master.mergeoptions "--no-ff" && + test_config branch.main.mergeoptions "--no-ff" && git merge --ff c1 && verify_merge file result.1 && verify_head $c1 @@ -606,7 +609,7 @@ test_expect_success 'merge log message' ' test_must_be_empty msg.act && git reset --hard c0 && - test_config branch.master.mergeoptions "--no-ff" && + test_config branch.main.mergeoptions "--no-ff" && git merge --no-log c2 && git show -s --pretty=format:%b HEAD >msg.act && test_must_be_empty msg.act && @@ -950,10 +953,10 @@ test_expect_success 'set up mod-256 conflict scenario' ' git add file && git commit -m base && - # one side changes the first line of each to "master" - sed s/-1/-master/ file >tmp && + # one side changes the first line of each to "main" + sed s/-1/-main/ file >tmp && mv tmp file && - git commit -am master && + git commit -am main && # and the other to "side"; merging the two will # yield 256 separate conflicts @@ -965,12 +968,12 @@ test_expect_success 'set up mod-256 conflict scenario' ' test_expect_success 'merge detects mod-256 conflicts (recursive)' ' git reset --hard && - test_must_fail git merge -s recursive master + test_must_fail git merge -s recursive main ' test_expect_success 'merge detects mod-256 conflicts (resolve)' ' git reset --hard && - test_must_fail git merge -s resolve master + test_must_fail git merge -s resolve main ' test_expect_success 'merge nothing into void' ' diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 6774e9d86f..52e8ccc933 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -29,11 +29,8 @@ test_expect_success 'setup' ' test_expect_success 'pull.rebase not set' ' git reset --hard c0 && - git -c color.advice=always pull . c1 2>err && - test_decode_color <err >decoded && - test_i18ngrep "<YELLOW>hint: " decoded && - test_i18ngrep "Pulling without specifying how to reconcile" decoded - + git pull . c1 2>err && + test_i18ngrep ! "Pulling without specifying how to reconcile" err ' test_expect_success 'pull.rebase not set and pull.ff=true' ' @@ -87,6 +84,65 @@ test_expect_success 'pull.rebase not set and --ff-only given' ' test_i18ngrep ! "Pulling without specifying how to reconcile" err ' +test_expect_success 'pull.rebase not set (not-fast-forward)' ' + git reset --hard c2 && + git -c color.advice=always pull . c1 2>err && + test_decode_color <err >decoded && + test_i18ngrep "<YELLOW>hint: " decoded && + test_i18ngrep "Pulling without specifying how to reconcile" decoded +' + +test_expect_success 'pull.rebase not set and pull.ff=true (not-fast-forward)' ' + git reset --hard c2 && + test_config pull.ff true && + git pull . c1 2>err && + test_i18ngrep ! "Pulling without specifying how to reconcile" err +' + +test_expect_success 'pull.rebase not set and pull.ff=false (not-fast-forward)' ' + git reset --hard c2 && + test_config pull.ff false && + git pull . c1 2>err && + test_i18ngrep ! "Pulling without specifying how to reconcile" err +' + +test_expect_success 'pull.rebase not set and pull.ff=only (not-fast-forward)' ' + git reset --hard c2 && + test_config pull.ff only && + test_must_fail git pull . c1 2>err && + test_i18ngrep ! "Pulling without specifying how to reconcile" err +' + +test_expect_success 'pull.rebase not set and --rebase given (not-fast-forward)' ' + git reset --hard c2 && + git pull --rebase . c1 2>err && + test_i18ngrep ! "Pulling without specifying how to reconcile" err +' + +test_expect_success 'pull.rebase not set and --no-rebase given (not-fast-forward)' ' + git reset --hard c2 && + git pull --no-rebase . c1 2>err && + test_i18ngrep ! "Pulling without specifying how to reconcile" err +' + +test_expect_success 'pull.rebase not set and --ff given (not-fast-forward)' ' + git reset --hard c2 && + git pull --ff . c1 2>err && + test_i18ngrep ! "Pulling without specifying how to reconcile" err +' + +test_expect_success 'pull.rebase not set and --no-ff given (not-fast-forward)' ' + git reset --hard c2 && + git pull --no-ff . c1 2>err && + test_i18ngrep ! "Pulling without specifying how to reconcile" err +' + +test_expect_success 'pull.rebase not set and --ff-only given (not-fast-forward)' ' + git reset --hard c2 && + test_must_fail git pull --ff-only . c1 2>err && + test_i18ngrep ! "Pulling without specifying how to reconcile" err +' + test_expect_success 'merge c1 with c2' ' git reset --hard c1 && test -f c0.c && diff --git a/t/t7602-merge-octopus-many.sh b/t/t7602-merge-octopus-many.sh index 13859ec859..a9c816b47f 100755 --- a/t/t7602-merge-octopus-many.sh +++ b/t/t7602-merge-octopus-many.sh @@ -66,7 +66,7 @@ EOF test_expect_success 'merge output uses pretty names' ' git reset --hard c1 && git merge c2 c3 c4 >actual && - test_i18ncmp expected actual + test_cmp expected actual ' cat >expected <<\EOF @@ -84,7 +84,7 @@ test_expect_success 'merge reduces irrelevant remote heads' ' rm expected.tmp fi && GIT_MERGE_VERBOSITY=0 git merge c4 c5 >actual && - test_i18ncmp expected actual + test_cmp expected actual ' cat >expected <<\EOF @@ -101,7 +101,7 @@ EOF test_expect_success 'merge fast-forward output uses pretty names' ' git reset --hard c0 && git merge c1 c2 >actual && - test_i18ncmp expected actual + test_cmp expected actual ' test_done diff --git a/t/t7606-merge-custom.sh b/t/t7606-merge-custom.sh index 8e8c4d7246..81fb7c474c 100755 --- a/t/t7606-merge-custom.sh +++ b/t/t7606-merge-custom.sh @@ -4,7 +4,7 @@ test_description="git merge Testing a custom strategy. -* (HEAD, master) Merge commit 'c3' +* (HEAD, main) Merge commit 'c3' |\ | * (tag: c3) c3 * | (tag: c1) c1 diff --git a/t/t7608-merge-messages.sh b/t/t7608-merge-messages.sh index 8e7e0a5865..0b908ab2e7 100755 --- a/t/t7608-merge-messages.sh +++ b/t/t7608-merge-messages.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='test auto-generated merge messages' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh check_oneline() { @@ -10,51 +13,51 @@ check_oneline() { } test_expect_success 'merge local branch' ' - test_commit master-1 && + test_commit main-1 && git checkout -b local-branch && test_commit branch-1 && - git checkout master && - test_commit master-2 && + git checkout main && + test_commit main-2 && git merge local-branch && check_oneline "Merge branch Qlocal-branchQ" ' test_expect_success 'merge octopus branches' ' - git checkout -b octopus-a master && + git checkout -b octopus-a main && test_commit octopus-1 && - git checkout -b octopus-b master && + git checkout -b octopus-b main && test_commit octopus-2 && - git checkout master && + git checkout main && git merge octopus-a octopus-b && check_oneline "Merge branches Qoctopus-aQ and Qoctopus-bQ" ' test_expect_success 'merge tag' ' - git checkout -b tag-branch master && + git checkout -b tag-branch main && test_commit tag-1 && - git checkout master && - test_commit master-3 && + git checkout main && + test_commit main-3 && git merge tag-1 && check_oneline "Merge tag Qtag-1Q" ' test_expect_success 'ambiguous tag' ' - git checkout -b ambiguous master && + git checkout -b ambiguous main && test_commit ambiguous && - git checkout master && - test_commit master-4 && + git checkout main && + test_commit main-4 && git merge ambiguous && check_oneline "Merge tag QambiguousQ" ' test_expect_success 'remote-tracking branch' ' - git checkout -b remote master && + git checkout -b remote main && test_commit remote-1 && - git update-ref refs/remotes/origin/master remote && - git checkout master && - test_commit master-5 && - git merge origin/master && - check_oneline "Merge remote-tracking branch Qorigin/masterQ" + git update-ref refs/remotes/origin/main remote && + git checkout main && + test_commit main-5 && + git merge origin/main && + check_oneline "Merge remote-tracking branch Qorigin/mainQ" ' test_done diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh index 6ac75b5d4c..8cc64729ad 100755 --- a/t/t7610-mergetool.sh +++ b/t/t7610-mergetool.sh @@ -7,22 +7,25 @@ test_description='git mergetool Testing basic merge tool invocation' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # All the mergetool test work by checking out a temporary branch based -# off 'branch1' and then merging in master and checking the results of +# off 'branch1' and then merging in main and checking the results of # running mergetool test_expect_success 'setup' ' test_config rerere.enabled true && - echo master >file1 && - echo master spaced >"spaced name" && - echo master file11 >file11 && - echo master file12 >file12 && - echo master file13 >file13 && - echo master file14 >file14 && + echo main >file1 && + echo main spaced >"spaced name" && + echo main file11 >file11 && + echo main file12 >file12 && + echo main file13 >file13 && + echo main file14 >file14 && mkdir subdir && - echo master sub >subdir/file3 && + echo main sub >subdir/file3 && test_create_repo submod && ( cd submod && @@ -34,7 +37,7 @@ test_expect_success 'setup' ' git add file1 "spaced name" file1[1-4] subdir/file3 .gitmodules submod && git commit -m "add initial versions" && - git checkout -b branch1 master && + git checkout -b branch1 main && git submodule update -N && echo branch1 change >file1 && echo branch1 newfile >file2 && @@ -71,39 +74,39 @@ test_expect_success 'setup' ' test_write_lines one two 3 >c/c/file.txt && git commit -a -m"move to c" && - git checkout -b stash1 master && + git checkout -b stash1 main && echo stash1 change file11 >file11 && git add file11 && git commit -m "stash1 changes" && - git checkout -b stash2 master && + git checkout -b stash2 main && echo stash2 change file11 >file11 && git add file11 && git commit -m "stash2 changes" && - git checkout master && + git checkout main && git submodule update -N && - echo master updated >file1 && - echo master new >file2 && - echo master updated spaced >"spaced name" && - echo master both added >both && - echo master updated file12 >file12 && - echo master updated file14 >file14 && - echo master new sub >subdir/file3 && + echo main updated >file1 && + echo main new >file2 && + echo main updated spaced >"spaced name" && + echo main both added >both && + echo main updated file12 >file12 && + echo main updated file14 >file14 && + echo main new sub >subdir/file3 && ( cd submod && - echo master submodule >bar && + echo main submodule >bar && git add bar && - git commit -m "Add bar on master" && - git checkout -b submod-master + git commit -m "Add bar on main" && + git checkout -b submod-main ) && git add file1 "spaced name" file12 file14 file2 subdir/file3 submod && git add both && git rm file11 && - git commit -m "master updates" && + git commit -m "main updates" && git clean -fdx && - git checkout -b order-file-start master && + git checkout -b order-file-start main && echo start >a && echo start >b && git add a b && @@ -130,7 +133,7 @@ test_expect_success 'custom mergetool' ' test_when_finished "git reset --hard" && git checkout -b test$test_count branch1 && git submodule update -N && - test_must_fail git merge master && + test_must_fail git merge main && yes "" | git mergetool both && yes "" | git mergetool file1 file1 && yes "" | git mergetool file2 "spaced name" && @@ -138,11 +141,11 @@ test_expect_success 'custom mergetool' ' yes "d" | git mergetool file11 && yes "d" | git mergetool file12 && yes "l" | git mergetool submod && - echo "master updated" >expect && + echo "main updated" >expect && test_cmp expect file1 && - echo "master new" >expect && + echo "main new" >expect && test_cmp expect file2 && - echo "master new sub" >expect && + echo "main new sub" >expect && test_cmp expect subdir/file3 && echo "branch1 submodule" >expect && test_cmp expect submod/bar && @@ -156,7 +159,7 @@ test_expect_success 'gui mergetool' ' test_when_finished "git reset --hard" && git checkout -b test$test_count branch1 && git submodule update -N && - test_must_fail git merge master && + test_must_fail git merge main && yes "" | git mergetool --gui both && yes "" | git mergetool -g file1 file1 && yes "" | git mergetool --gui file2 "spaced name" && @@ -164,11 +167,11 @@ test_expect_success 'gui mergetool' ' yes "d" | git mergetool --gui file11 && yes "d" | git mergetool --gui file12 && yes "l" | git mergetool --gui submod && - echo "gui master updated" >expect && + echo "gui main updated" >expect && test_cmp expect file1 && - echo "gui master new" >expect && + echo "gui main new" >expect && test_cmp expect file2 && - echo "gui master new sub" >expect && + echo "gui main new sub" >expect && test_cmp expect subdir/file3 && echo "branch1 submodule" >expect && test_cmp expect submod/bar && @@ -179,7 +182,7 @@ test_expect_success 'gui mergetool without merge.guitool set falls back to merge test_when_finished "git reset --hard" && git checkout -b test$test_count branch1 && git submodule update -N && - test_must_fail git merge master && + test_must_fail git merge main && yes "" | git mergetool --gui both && yes "" | git mergetool -g file1 file1 && yes "" | git mergetool --gui file2 "spaced name" && @@ -187,11 +190,11 @@ test_expect_success 'gui mergetool without merge.guitool set falls back to merge yes "d" | git mergetool --gui file11 && yes "d" | git mergetool --gui file12 && yes "l" | git mergetool --gui submod && - echo "master updated" >expect && + echo "main updated" >expect && test_cmp expect file1 && - echo "master new" >expect && + echo "main new" >expect && test_cmp expect file2 && - echo "master new sub" >expect && + echo "main new sub" >expect && test_cmp expect subdir/file3 && echo "branch1 submodule" >expect && test_cmp expect submod/bar && @@ -206,7 +209,7 @@ test_expect_success 'mergetool crlf' ' # test_when_finished is LIFO.) test_config core.autocrlf true && git checkout -b test$test_count branch1 && - test_must_fail git merge master && + test_must_fail git merge main && yes "" | git mergetool file1 && yes "" | git mergetool file2 && yes "" | git mergetool "spaced name" && @@ -215,11 +218,11 @@ test_expect_success 'mergetool crlf' ' yes "d" | git mergetool file11 && yes "d" | git mergetool file12 && yes "r" | git mergetool submod && - test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" && - test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" && - test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" && + test "$(printf x | cat file1 -)" = "$(printf "main updated\r\nx")" && + test "$(printf x | cat file2 -)" = "$(printf "main new\r\nx")" && + test "$(printf x | cat subdir/file3 -)" = "$(printf "main new sub\r\nx")" && git submodule update -N && - echo "master submodule" >expect && + echo "main submodule" >expect && test_cmp expect submod/bar && git commit -m "branch1 resolved with mergetool - autocrlf" ' @@ -230,9 +233,9 @@ test_expect_success 'mergetool in subdir' ' git submodule update -N && ( cd subdir && - test_must_fail git merge master && + test_must_fail git merge main && yes "" | git mergetool file3 && - echo "master new sub" >expect && + echo "main new sub" >expect && test_cmp expect file3 ) ' @@ -243,7 +246,7 @@ test_expect_success 'mergetool on file in parent dir' ' git submodule update -N && ( cd subdir && - test_must_fail git merge master && + test_must_fail git merge main && yes "" | git mergetool file3 && yes "" | git mergetool ../file1 && yes "" | git mergetool ../file2 ../spaced\ name && @@ -251,9 +254,9 @@ test_expect_success 'mergetool on file in parent dir' ' yes "d" | git mergetool ../file11 && yes "d" | git mergetool ../file12 && yes "l" | git mergetool ../submod && - echo "master updated" >expect && + echo "main updated" >expect && test_cmp expect ../file1 && - echo "master new" >expect && + echo "main new" >expect && test_cmp expect ../file2 && echo "branch1 submodule" >expect && test_cmp expect ../submod/bar && @@ -265,7 +268,7 @@ test_expect_success 'mergetool skips autoresolved' ' test_when_finished "git reset --hard" && git checkout -b test$test_count branch1 && git submodule update -N && - test_must_fail git merge master && + test_must_fail git merge main && test -n "$(git ls-files -u)" && yes "d" | git mergetool file11 && yes "d" | git mergetool file12 && @@ -280,17 +283,17 @@ test_expect_success 'mergetool merges all from subdir (rerere disabled)' ' test_config rerere.enabled false && ( cd subdir && - test_must_fail git merge master && + test_must_fail git merge main && yes "r" | git mergetool ../submod && yes "d" "d" | git mergetool --no-prompt && - echo "master updated" >expect && + echo "main updated" >expect && test_cmp expect ../file1 && - echo "master new" >expect && + echo "main new" >expect && test_cmp expect ../file2 && - echo "master new sub" >expect && + echo "main new sub" >expect && test_cmp expect file3 && ( cd .. && git submodule update -N ) && - echo "master submodule" >expect && + echo "main submodule" >expect && test_cmp expect ../submod/bar && git commit -m "branch2 resolved by mergetool from subdir" ) @@ -303,17 +306,17 @@ test_expect_success 'mergetool merges all from subdir (rerere enabled)' ' rm -rf .git/rr-cache && ( cd subdir && - test_must_fail git merge master && + test_must_fail git merge main && yes "r" | git mergetool ../submod && yes "d" "d" | git mergetool --no-prompt && - echo "master updated" >expect && + echo "main updated" >expect && test_cmp expect ../file1 && - echo "master new" >expect && + echo "main new" >expect && test_cmp expect ../file2 && - echo "master new sub" >expect && + echo "main new sub" >expect && test_cmp expect file3 && ( cd .. && git submodule update -N ) && - echo "master submodule" >expect && + echo "main submodule" >expect && test_cmp expect ../submod/bar && git commit -m "branch2 resolved by mergetool from subdir" ) @@ -325,7 +328,7 @@ test_expect_success 'mergetool skips resolved paths when rerere is active' ' rm -rf .git/rr-cache && git checkout -b test$test_count branch1 && git submodule update -N && - test_must_fail git merge master && + test_must_fail git merge main && yes "l" | git mergetool --no-prompt submod && yes "d" "d" | git mergetool --no-prompt && git submodule update -N && @@ -366,11 +369,11 @@ test_expect_success 'mergetool takes partial path' ' test_config rerere.enabled false && git checkout -b test$test_count branch1 && git submodule update -N && - test_must_fail git merge master && + test_must_fail git merge main && yes "" | git mergetool subdir && - echo "master new sub" >expect && + echo "main new sub" >expect && test_cmp expect subdir/file3 ' @@ -434,7 +437,7 @@ test_expect_success 'deleted vs modified submodule' ' git rm --cached submod && git commit -m "Submodule deleted from branch" && git checkout -b test$test_count.a test$test_count && - test_must_fail git merge master && + test_must_fail git merge main && test -n "$(git ls-files -u)" && yes "" | git mergetool file1 file2 spaced\ name subdir/file3 && yes "" | git mergetool both && @@ -444,7 +447,7 @@ test_expect_success 'deleted vs modified submodule' ' echo "branch1 submodule" >expect && test_cmp expect submod/bar && git submodule update -N && - echo "master submodule" >expect && + echo "main submodule" >expect && test_cmp expect submod/bar && output="$(git mergetool --no-prompt)" && test "$output" = "No files need merging" && @@ -453,7 +456,7 @@ test_expect_success 'deleted vs modified submodule' ' mv submod submod-movedaside && git checkout -b test$test_count.b test$test_count && git submodule update -N && - test_must_fail git merge master && + test_must_fail git merge main && test -n "$(git ls-files -u)" && yes "" | git mergetool file1 file2 spaced\ name subdir/file3 && yes "" | git mergetool both && @@ -465,7 +468,7 @@ test_expect_success 'deleted vs modified submodule' ' git commit -m "Merge resolved by deleting module" && mv submod-movedaside submod && - git checkout -b test$test_count.c master && + git checkout -b test$test_count.c main && git submodule update -N && test_must_fail git merge test$test_count && test -n "$(git ls-files -u)" && @@ -481,7 +484,7 @@ test_expect_success 'deleted vs modified submodule' ' git commit -m "Merge resolved by deleting module" && mv submod.orig submod && - git checkout -b test$test_count.d master && + git checkout -b test$test_count.d main && git submodule update -N && test_must_fail git merge test$test_count && test -n "$(git ls-files -u)" && @@ -489,10 +492,10 @@ test_expect_success 'deleted vs modified submodule' ' yes "" | git mergetool both && yes "d" | git mergetool file11 file12 && yes "l" | git mergetool submod && - echo "master submodule" >expect && + echo "main submodule" >expect && test_cmp expect submod/bar && git submodule update -N && - echo "master submodule" >expect && + echo "main submodule" >expect && test_cmp expect submod/bar && output="$(git mergetool --no-prompt)" && test "$output" = "No files need merging" && @@ -509,7 +512,7 @@ test_expect_success 'file vs modified submodule' ' git add submod && git commit -m "Submodule path becomes file" && git checkout -b test$test_count.a branch1 && - test_must_fail git merge master && + test_must_fail git merge main && test -n "$(git ls-files -u)" && yes "" | git mergetool file1 file2 spaced\ name subdir/file3 && yes "" | git mergetool both && @@ -519,7 +522,7 @@ test_expect_success 'file vs modified submodule' ' echo "branch1 submodule" >expect && test_cmp expect submod/bar && git submodule update -N && - echo "master submodule" >expect && + echo "main submodule" >expect && test_cmp expect submod/bar && output="$(git mergetool --no-prompt)" && test "$output" = "No files need merging" && @@ -527,7 +530,7 @@ test_expect_success 'file vs modified submodule' ' mv submod submod-movedaside && git checkout -b test$test_count.b test$test_count && - test_must_fail git merge master && + test_must_fail git merge main && test -n "$(git ls-files -u)" && yes "" | git mergetool file1 file2 spaced\ name subdir/file3 && yes "" | git mergetool both && @@ -547,7 +550,7 @@ test_expect_success 'file vs modified submodule' ' test "$output" = "No files need merging" && git commit -m "Merge resolved by keeping file" && - git checkout -b test$test_count.c master && + git checkout -b test$test_count.c main && rmdir submod && mv submod-movedaside submod && test ! -e submod.orig && git submodule update -N && @@ -573,7 +576,7 @@ test_expect_success 'file vs modified submodule' ' test "$output" = "No files need merging" && git commit -m "Merge resolved by keeping file" && - git checkout -b test$test_count.d master && + git checkout -b test$test_count.d main && rmdir submod && mv submod.orig submod && git submodule update -N && test_must_fail git merge test$test_count && @@ -586,10 +589,10 @@ test_expect_success 'file vs modified submodule' ' then yes "d" | git mergetool submod~test19 fi && - echo "master submodule" >expect && + echo "main submodule" >expect && test_cmp expect submod/bar && git submodule update -N && - echo "master submodule" >expect && + echo "main submodule" >expect && test_cmp expect submod/bar && output="$(git mergetool --no-prompt)" && test "$output" = "No files need merging" && @@ -672,7 +675,7 @@ test_expect_success 'directory vs modified submodule' ' git add submod/file16 && git commit -m "Submodule path becomes directory" && - test_must_fail git merge master && + test_must_fail git merge main && test -n "$(git ls-files -u)" && yes "l" | git mergetool submod && echo "not a submodule" >expect && @@ -680,14 +683,14 @@ test_expect_success 'directory vs modified submodule' ' rm -rf submod.orig && git reset --hard && - test_must_fail git merge master && + test_must_fail git merge main && test -n "$(git ls-files -u)" && test ! -e submod.orig && if test "$GIT_TEST_MERGE_ALGORITHM" = ort then - yes "r" | git mergetool submod~master && + yes "r" | git mergetool submod~main && git mv submod submod.orig && - git mv submod~master submod + git mv submod~main submod else yes "r" | git mergetool submod fi && @@ -698,18 +701,18 @@ test_expect_success 'directory vs modified submodule' ' mv submod-movedaside/.git submod && ( cd submod && git clean -f && git reset --hard ) && git submodule update -N && - echo "master submodule" >expect && + echo "main submodule" >expect && test_cmp expect submod/bar && git reset --hard && rm -rf submod-movedaside && - git checkout -b test$test_count.c master && + git checkout -b test$test_count.c main && git submodule update -N && test_must_fail git merge test$test_count && test -n "$(git ls-files -u)" && yes "l" | git mergetool submod && git submodule update -N && - echo "master submodule" >expect && + echo "main submodule" >expect && test_cmp expect submod/bar && git reset --hard && @@ -721,7 +724,7 @@ test_expect_success 'directory vs modified submodule' ' echo "not a submodule" >expect && test_cmp expect submod/file16 && - git reset --hard master && + git reset --hard main && ( cd submod && git clean -f && git reset --hard ) && git submodule update -N ' @@ -729,7 +732,7 @@ test_expect_success 'directory vs modified submodule' ' test_expect_success 'file with no base' ' test_when_finished "git reset --hard" && git checkout -b test$test_count branch1 && - test_must_fail git merge master && + test_must_fail git merge main && git mergetool --no-prompt --tool mybase -- both && test_must_be_empty both ' @@ -739,9 +742,9 @@ test_expect_success 'custom commands override built-ins' ' git checkout -b test$test_count branch1 && test_config mergetool.defaults.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" && test_config mergetool.defaults.trustExitCode true && - test_must_fail git merge master && + test_must_fail git merge main && git mergetool --no-prompt --tool defaults -- both && - echo master both added >expected && + echo main both added >expected && test_cmp expected both ' @@ -751,7 +754,7 @@ test_expect_success 'filenames seen by tools start with ./' ' test_config mergetool.writeToTemp false && test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" && test_config mergetool.myecho.trustExitCode true && - test_must_fail git merge master && + test_must_fail git merge main && git mergetool --no-prompt --tool myecho -- both >actual && grep ^\./both_LOCAL_ actual ' @@ -768,7 +771,7 @@ test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToT test_config mergetool.writeToTemp true && test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" && test_config mergetool.myecho.trustExitCode true && - test_must_fail git merge master && + test_must_fail git merge main && git mergetool --no-prompt --tool myecho -- both >actual && ! grep ^\./both_LOCAL_ actual && grep /both_LOCAL_ actual @@ -839,4 +842,22 @@ test_expect_success 'mergetool --tool-help shows recognized tools' ' grep meld mergetools ' +test_expect_success 'mergetool hideResolved' ' + test_config mergetool.hideResolved true && + test_when_finished "git reset --hard" && + git checkout -b test${test_count}_b main && + test_write_lines >file1 base "" a && + git commit -a -m "base" && + test_write_lines >file1 base "" c && + git commit -a -m "remote update" && + git checkout -b test${test_count}_a HEAD~ && + test_write_lines >file1 local "" b && + git commit -a -m "local update" && + test_must_fail git merge test${test_count}_b && + yes "" | git mergetool file1 && + test_write_lines >expect local "" c && + test_cmp expect file1 && + git commit -m "test resolved with mergetool" +' + test_done diff --git a/t/t7611-merge-abort.sh b/t/t7611-merge-abort.sh index 7c84a518aa..c0e9425115 100755 --- a/t/t7611-merge-abort.sh +++ b/t/t7611-merge-abort.sh @@ -7,7 +7,7 @@ Set up repo with conflicting and non-conflicting branches: There are three files foo/bar/baz, and the following graph illustrates the content of these files in each commit: -# foo/bar/baz --- foo/bar/bazz <-- master +# foo/bar/baz --- foo/bar/bazz <-- main # \ # --- foo/barf/bazf <-- conflict_branch # \ @@ -22,6 +22,9 @@ Next, test git merge --abort with the following variables: - changed/unchanged worktree after merge - changed/unchanged index after merge ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -40,7 +43,7 @@ test_expect_success 'setup' ' git checkout -b clean_branch HEAD^ && echo bart > bar && git commit -a -m "clean" && - git checkout master + git checkout main ' pre_merge_head="$(git rev-parse HEAD)" diff --git a/t/t7612-merge-verify-signatures.sh b/t/t7612-merge-verify-signatures.sh index a426f3a89a..61330f71b1 100755 --- a/t/t7612-merge-verify-signatures.sh +++ b/t/t7612-merge-verify-signatures.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='merge signature verification tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY/lib-gpg.sh" @@ -31,7 +34,7 @@ test_expect_success GPG 'create signed commits' ' echo 3 >baz && git add baz && test_tick && git commit -SB7227189 -m "untrusted on side" && - git checkout master + git checkout main ' test_expect_success GPG 'merge unsigned commit with verification' ' diff --git a/t/t7614-merge-signoff.sh b/t/t7614-merge-signoff.sh index c1b8446f49..fee258d4f0 100755 --- a/t/t7614-merge-signoff.sh +++ b/t/t7614-merge-signoff.sh @@ -5,23 +5,26 @@ test_description='git merge --signoff This test runs git merge --signoff and makes sure that it works. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # Setup test files test_setup() { # Expected commit message after merge --signoff cat >expected-signed <<EOF && -Merge branch 'master' into other-branch +Merge branch 'main' into other-branch Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/") EOF # Expected commit message after merge without --signoff (or with --no-signoff) cat >expected-unsigned <<EOF && -Merge branch 'master' into other-branch +Merge branch 'main' into other-branch EOF - # Initial commit and feature branch to merge master into it. + # Initial commit and feature branch to merge main into it. git commit --allow-empty -m "Initial empty commit" && git checkout -b other-branch && test_commit other-branch file1 1 @@ -38,30 +41,30 @@ test_expect_success 'setup' ' # Test with --signoff flag test_expect_success 'git merge --signoff adds a sign-off line' ' - git checkout master && - test_commit master-branch-2 file2 2 && + git checkout main && + test_commit main-branch-2 file2 2 && git checkout other-branch && - git merge master --signoff --no-edit && + git merge main --signoff --no-edit && git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && test_cmp expected-signed actual ' # Test without --signoff flag test_expect_success 'git merge does not add a sign-off line' ' - git checkout master && - test_commit master-branch-3 file3 3 && + git checkout main && + test_commit main-branch-3 file3 3 && git checkout other-branch && - git merge master --no-edit && + git merge main --no-edit && git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && test_cmp expected-unsigned actual ' # Test for --no-signoff flag test_expect_success 'git merge --no-signoff flag cancels --signoff flag' ' - git checkout master && - test_commit master-branch-4 file4 4 && + git checkout main && + test_commit main-branch-4 file4 4 && git checkout other-branch && - git merge master --no-edit --signoff --no-signoff && + git merge main --no-edit --signoff --no-signoff && git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && test_cmp expected-unsigned actual ' diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh index 48261ba080..937f89ee8c 100755 --- a/t/t7701-repack-unpack-unreachable.sh +++ b/t/t7701-repack-unpack-unreachable.sh @@ -2,6 +2,9 @@ test_description='git repack works correctly' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh fsha1= @@ -22,7 +25,7 @@ test_expect_success '-A with -d option leaves unreachable objects unpacked' ' git commit -a -m more_content && csha1=$(git rev-parse HEAD^{commit}) && tsha1=$(git rev-parse HEAD^{tree}) && - git checkout master && + git checkout main && echo even more content >> file1 && test_tick && git commit -a -m even_more_content && diff --git a/t/t7703-repack-geometric.sh b/t/t7703-repack-geometric.sh new file mode 100755 index 0000000000..5ccaa440e0 --- /dev/null +++ b/t/t7703-repack-geometric.sh @@ -0,0 +1,183 @@ +#!/bin/sh + +test_description='git repack --geometric works correctly' + +. ./test-lib.sh + +GIT_TEST_MULTI_PACK_INDEX=0 + +objdir=.git/objects +midx=$objdir/pack/multi-pack-index + +test_expect_success '--geometric with no packs' ' + git init geometric && + test_when_finished "rm -fr geometric" && + ( + cd geometric && + + git repack --geometric 2 >out && + test_i18ngrep "Nothing new to pack" out + ) +' + +test_expect_success '--geometric with one pack' ' + git init geometric && + test_when_finished "rm -fr geometric" && + ( + cd geometric && + + test_commit "base" && + git repack -d && + + git repack --geometric 2 >out && + + test_i18ngrep "Nothing new to pack" out + ) +' + +test_expect_success '--geometric with an intact progression' ' + git init geometric && + test_when_finished "rm -fr geometric" && + ( + cd geometric && + + # These packs already form a geometric progression. + test_commit_bulk --start=1 1 && # 3 objects + test_commit_bulk --start=2 2 && # 6 objects + test_commit_bulk --start=4 4 && # 12 objects + + find $objdir/pack -name "*.pack" | sort >expect && + git repack --geometric 2 -d && + find $objdir/pack -name "*.pack" | sort >actual && + + test_cmp expect actual + ) +' + +test_expect_success '--geometric with loose objects' ' + git init geometric && + test_when_finished "rm -fr geometric" && + ( + cd geometric && + + # These packs already form a geometric progression. + test_commit_bulk --start=1 1 && # 3 objects + test_commit_bulk --start=2 2 && # 6 objects + # The loose objects are packed together, breaking the + # progression. + test_commit loose && # 3 objects + + find $objdir/pack -name "*.pack" | sort >before && + git repack --geometric 2 -d && + find $objdir/pack -name "*.pack" | sort >after && + + comm -13 before after >new && + comm -23 before after >removed && + + test_line_count = 1 new && + test_must_be_empty removed && + + git repack --geometric 2 -d && + find $objdir/pack -name "*.pack" | sort >after && + + # The progression (3, 3, 6) is combined into one new pack. + test_line_count = 1 after + ) +' + +test_expect_success '--geometric with small-pack rollup' ' + git init geometric && + test_when_finished "rm -fr geometric" && + ( + cd geometric && + + test_commit_bulk --start=1 1 && # 3 objects + test_commit_bulk --start=2 1 && # 3 objects + find $objdir/pack -name "*.pack" | sort >small && + test_commit_bulk --start=3 4 && # 12 objects + test_commit_bulk --start=7 8 && # 24 objects + find $objdir/pack -name "*.pack" | sort >before && + + git repack --geometric 2 -d && + + # Three packs in total; two of the existing large ones, and one + # new one. + find $objdir/pack -name "*.pack" | sort >after && + test_line_count = 3 after && + comm -3 small before | tr -d "\t" >large && + grep -qFf large after + ) +' + +test_expect_success '--geometric with small- and large-pack rollup' ' + git init geometric && + test_when_finished "rm -fr geometric" && + ( + cd geometric && + + # size(small1) + size(small2) > size(medium) / 2 + test_commit_bulk --start=1 1 && # 3 objects + test_commit_bulk --start=2 1 && # 3 objects + test_commit_bulk --start=2 3 && # 7 objects + test_commit_bulk --start=6 9 && # 27 objects && + + find $objdir/pack -name "*.pack" | sort >before && + + git repack --geometric 2 -d && + + find $objdir/pack -name "*.pack" | sort >after && + comm -12 before after >untouched && + + # Two packs in total; the largest pack from before running "git + # repack", and one new one. + test_line_count = 1 untouched && + test_line_count = 2 after + ) +' + +test_expect_success '--geometric ignores kept packs' ' + git init geometric && + test_when_finished "rm -fr geometric" && + ( + cd geometric && + + test_commit kept && # 3 objects + test_commit pack && # 3 objects + + KEPT=$(git pack-objects --revs $objdir/pack/pack <<-EOF + refs/tags/kept + EOF + ) && + PACK=$(git pack-objects --revs $objdir/pack/pack <<-EOF + refs/tags/pack + ^refs/tags/kept + EOF + ) && + + # neither pack contains more than twice the number of objects in + # the other, so they should be combined. but, marking one as + # .kept on disk will "freeze" it, so the pack structure should + # remain unchanged. + touch $objdir/pack/pack-$KEPT.keep && + + find $objdir/pack -name "*.pack" | sort >before && + git repack --geometric 2 -d && + find $objdir/pack -name "*.pack" | sort >after && + + # both packs should still exist + test_path_is_file $objdir/pack/pack-$KEPT.pack && + test_path_is_file $objdir/pack/pack-$PACK.pack && + + # and no new packs should be created + test_cmp before after && + + # Passing --pack-kept-objects causes packs with a .keep file to + # be repacked, too. + git repack --geometric 2 -d --pack-kept-objects && + + find $objdir/pack -name "*.pack" >after && + test_line_count = 1 after + ) +' + +test_done diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index a578b35761..3e041e83ae 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -8,6 +8,9 @@ test_description='git-difftool Testing basic diff tool invocation ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh difftool_test_setup () @@ -35,23 +38,23 @@ test_expect_success 'basic usage requires no repo' ' test_i18ngrep ^usage: output ' -# Create a file on master and change it on branch +# Create a file on main and change it on branch test_expect_success 'setup' ' - echo master >file && + echo main >file && git add file && git commit -m "added file" && - git checkout -b branch master && + git checkout -b branch main && echo branch >file && git commit -a -m "branch changed file" && - git checkout master + git checkout main ' # Configure a custom difftool.<tool>.cmd and use it test_expect_success 'custom commands' ' difftool_test_setup && test_config difftool.test-tool.cmd "cat \"\$REMOTE\"" && - echo master >expect && + echo main >expect && git difftool --no-prompt branch >actual && test_cmp expect actual && @@ -63,7 +66,7 @@ test_expect_success 'custom commands' ' test_expect_success 'custom tool commands override built-ins' ' test_config difftool.vimdiff.cmd "cat \"\$REMOTE\"" && - echo master >expect && + echo main >expect && git difftool --tool vimdiff --no-prompt branch >actual && test_cmp expect actual ' @@ -311,21 +314,21 @@ test_expect_success 'difftool.<tool>.path' ' test_expect_success 'difftool --extcmd=cat' ' echo branch >expect && - echo master >>expect && + echo main >>expect && git difftool --no-prompt --extcmd=cat branch >actual && test_cmp expect actual ' test_expect_success 'difftool --extcmd cat' ' echo branch >expect && - echo master >>expect && + echo main >>expect && git difftool --no-prompt --extcmd=cat branch >actual && test_cmp expect actual ' test_expect_success 'difftool -x cat' ' echo branch >expect && - echo master >>expect && + echo main >>expect && git difftool --no-prompt -x cat branch >actual && test_cmp expect actual ' @@ -338,7 +341,7 @@ test_expect_success 'difftool --extcmd echo arg1' ' ' test_expect_success 'difftool --extcmd cat arg1' ' - echo master >expect && + echo main >expect && git difftool --no-prompt \ --extcmd sh\ -c\ \"cat\ \$1\" branch >actual && test_cmp expect actual @@ -351,7 +354,7 @@ test_expect_success 'difftool --extcmd cat arg2' ' test_cmp expect actual ' -# Create a second file on master and a different version on branch +# Create a second file on main and a different version on branch test_expect_success 'setup with 2 files different' ' echo m2 >file2 && git add file2 && @@ -361,7 +364,7 @@ test_expect_success 'setup with 2 files different' ' echo br2 >file2 && git add file2 && git commit -a -m "branch changed file2" && - git checkout master + git checkout main ' test_expect_success 'say no to the first file' ' @@ -369,14 +372,14 @@ test_expect_success 'say no to the first file' ' git difftool -x cat branch <input >output && grep m2 output && grep br2 output && - ! grep master output && + ! grep main output && ! grep branch output ' test_expect_success 'say no to the second file' ' (echo && echo n) >input && git difftool -x cat branch <input >output && - grep master output && + grep main output && grep branch output && ! grep m2 output && ! grep br2 output @@ -384,7 +387,7 @@ test_expect_success 'say no to the second file' ' test_expect_success 'ending prompt input with EOF' ' git difftool -x cat branch </dev/null >output && - ! grep master output && + ! grep main output && ! grep branch output && ! grep m2 output && ! grep br2 output @@ -396,9 +399,9 @@ test_expect_success 'difftool --tool-help' ' ' test_expect_success 'setup change in subdirectory' ' - git checkout master && + git checkout main && mkdir sub && - echo master >sub/sub && + echo main >sub/sub && git add sub/sub && git commit -m "added sub/sub" && git tag v1 && @@ -440,20 +443,20 @@ run_dir_diff_test () { run_dir_diff_test 'difftool -d' ' git difftool -d $symlinks --extcmd ls branch >output && - grep sub output && - grep file output + grep "^sub$" output && + grep "^file$" output ' run_dir_diff_test 'difftool --dir-diff' ' git difftool --dir-diff $symlinks --extcmd ls branch >output && - grep sub output && - grep file output + grep "^sub$" output && + grep "^file$" output ' run_dir_diff_test 'difftool --dir-diff ignores --prompt' ' git difftool --dir-diff $symlinks --prompt --extcmd ls branch >output && - grep sub output && - grep file output + grep "^sub$" output && + grep "^file$" output ' run_dir_diff_test 'difftool --dir-diff branch from subdirectory' ' @@ -462,11 +465,11 @@ run_dir_diff_test 'difftool --dir-diff branch from subdirectory' ' git difftool --dir-diff $symlinks --extcmd ls branch >output && # "sub" must only exist in "right" # "file" and "file2" must be listed in both "left" and "right" - grep sub output >sub-output && + grep "^sub$" output >sub-output && test_line_count = 1 sub-output && - grep file"$" output >file-output && + grep "^file$" output >file-output && test_line_count = 2 file-output && - grep file2 output >file2-output && + grep "^file2$" output >file2-output && test_line_count = 2 file2-output ) ' @@ -477,11 +480,11 @@ run_dir_diff_test 'difftool --dir-diff v1 from subdirectory' ' git difftool --dir-diff $symlinks --extcmd ls v1 >output && # "sub" and "file" exist in both v1 and HEAD. # "file2" is unchanged. - grep sub output >sub-output && + grep "^sub$" output >sub-output && test_line_count = 2 sub-output && - grep file output >file-output && + grep "^file$" output >file-output && test_line_count = 2 file-output && - ! grep file2 output + ! grep "^file2$" output ) ' @@ -491,9 +494,9 @@ run_dir_diff_test 'difftool --dir-diff branch from subdirectory w/ pathspec' ' git difftool --dir-diff $symlinks --extcmd ls branch -- .>output && # "sub" only exists in "right" # "file" and "file2" must not be listed - grep sub output >sub-output && + grep "^sub$" output >sub-output && test_line_count = 1 sub-output && - ! grep file output + ! grep "^file$" output ) ' @@ -503,9 +506,9 @@ run_dir_diff_test 'difftool --dir-diff v1 from subdirectory w/ pathspec' ' git difftool --dir-diff $symlinks --extcmd ls v1 -- .>output && # "sub" exists in v1 and HEAD # "file" is filtered out by the pathspec - grep sub output >sub-output && + grep "^sub$" output >sub-output && test_line_count = 2 sub-output && - ! grep file output + ! grep "^file$" output ) ' @@ -518,16 +521,16 @@ run_dir_diff_test 'difftool --dir-diff from subdirectory with GIT_DIR set' ' cd sub && git difftool --dir-diff $symlinks --extcmd ls \ branch -- sub >output && - grep sub output && - ! grep file output + grep "^sub$" output && + ! grep "^file$" output ) ' run_dir_diff_test 'difftool --dir-diff when worktree file is missing' ' test_when_finished git reset --hard && rm file2 && - git difftool --dir-diff $symlinks --extcmd ls branch master >output && - grep file2 output + git difftool --dir-diff $symlinks --extcmd ls branch main >output && + grep "^file2$" output ' run_dir_diff_test 'difftool --dir-diff with unmerged files' ' @@ -543,7 +546,7 @@ run_dir_diff_test 'difftool --dir-diff with unmerged files' ' echo b >>file && git add file && git commit -m conflict-b && - git checkout master && + git checkout main && git merge conflict-a && test_must_fail git merge conflict-b && cat >expect <<-EOF && @@ -759,4 +762,36 @@ test_expect_success 'difftool --gui, --tool and --extcmd are mutually exclusive' test_must_fail git difftool --gui --tool=test-tool --extcmd=cat ' +test_expect_success 'difftool --rotate-to' ' + difftool_test_setup && + test_when_finished git reset --hard && + echo 1 >1 && + echo 2 >2 && + echo 4 >4 && + git add 1 2 4 && + git commit -a -m "124" && + git difftool --no-prompt --extcmd=cat --rotate-to="2" HEAD^ >output&& + cat >expect <<-\EOF && + 2 + 4 + 1 + EOF + test_cmp output expect +' + +test_expect_success 'difftool --skip-to' ' + difftool_test_setup && + test_when_finished git reset --hard && + git difftool --no-prompt --extcmd=cat --skip-to="2" HEAD^ >output && + cat >expect <<-\EOF && + 2 + 4 + EOF + test_cmp output expect +' + +test_expect_success 'difftool --rotate/skip-to error condition' ' + test_must_fail git difftool --no-prompt --extcmd=cat --rotate-to="3" HEAD^ && + test_must_fail git difftool --no-prompt --extcmd=cat --skip-to="3" HEAD^ +' test_done diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 991d5bd9c0..5830733f3d 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -6,6 +6,9 @@ test_description='git grep various. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh cat >hello.c <<EOF @@ -687,21 +690,9 @@ test_expect_success 'grep -C1 hunk mark between files' ' ' test_expect_success 'log grep setup' ' - echo a >>file && - test_tick && - GIT_AUTHOR_NAME="With * Asterisk" \ - GIT_AUTHOR_EMAIL="xyzzy@frotz.com" \ - git commit -a -m "second" && - - echo a >>file && - test_tick && - git commit -a -m "third" && - - echo a >>file && - test_tick && - GIT_AUTHOR_NAME="Night Fall" \ - GIT_AUTHOR_EMAIL="nitfol@frobozz.com" \ - git commit -a -m "fourth" + test_commit --append --author "With * Asterisk <xyzzy@frotz.com>" second file a && + test_commit --append third file a && + test_commit --append --author "Night Fall <nitfol@frobozz.com>" fourth file a ' test_expect_success 'log grep (1)' ' @@ -978,7 +969,8 @@ do " done -test_expect_success !PTHREADS,C_LOCALE_OUTPUT 'grep --threads=N or pack.threads=N warns when no pthreads' ' +test_expect_success !PTHREADS,!FAIL_PREREQS \ + 'grep --threads=N or pack.threads=N warns when no pthreads' ' git grep --threads=2 Hello hello_world 2>err && grep ^warning: err >warnings && test_line_count = 1 warnings && @@ -1206,19 +1198,19 @@ test_expect_success 'grep -e -- -- path' ' ' test_expect_success 'dashdash disambiguates rev as rev' ' - test_when_finished "rm -f master" && - echo content >master && - echo master:hello.c >expect && - git grep -l o master -- hello.c >actual && + test_when_finished "rm -f main" && + echo content >main && + echo main:hello.c >expect && + git grep -l o main -- hello.c >actual && test_cmp expect actual ' test_expect_success 'dashdash disambiguates pathspec as pathspec' ' - test_when_finished "git rm -f master" && - echo content >master && - git add master && - echo master:content >expect && - git grep o -- master >actual && + test_when_finished "git rm -f main" && + echo content >main && + git add main && + echo main:content >expect && + git grep o -- main >actual && test_cmp expect actual ' @@ -1254,15 +1246,15 @@ test_expect_success 'grep --no-index pattern -- path' ' ' test_expect_success 'grep --no-index complains of revs' ' - test_must_fail git grep --no-index o master -- 2>err && + test_must_fail git grep --no-index o main -- 2>err && test_i18ngrep "cannot be used with revs" err ' test_expect_success 'grep --no-index prefers paths to revs' ' - test_when_finished "rm -f master" && - echo content >master && - echo master:content >expect && - git grep --no-index o master >actual && + test_when_finished "rm -f main" && + echo content >main && + echo main:content >expect && + git grep --no-index o main >actual && test_cmp expect actual ' diff --git a/t/t7812-grep-icase-non-ascii.sh b/t/t7812-grep-icase-non-ascii.sh index 03dba6685a..e5d1e4ea68 100755 --- a/t/t7812-grep-icase-non-ascii.sh +++ b/t/t7812-grep-icase-non-ascii.sh @@ -57,7 +57,12 @@ test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: setup invalid UTF-8 data' printf "\\200\\n" >invalid-0x80 && echo "ævar" >expected && cat expected >>invalid-0x80 && - git add invalid-0x80 + git add invalid-0x80 && + + # Test for PCRE2_MATCH_INVALID_UTF bug + # https://bugs.exim.org/show_bug.cgi?id=2642 + printf "\\345Aæ\\n" >invalid-0xe5 && + git add invalid-0xe5 ' test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep ASCII from invalid UTF-8 data' ' @@ -67,6 +72,13 @@ test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep ASCII from invalid UT test_cmp expected actual ' +test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep ASCII from invalid UTF-8 data (PCRE2 bug #2642)' ' + git grep -h "Aæ" invalid-0xe5 >actual && + test_cmp invalid-0xe5 actual && + git grep -h "(*NO_JIT)Aæ" invalid-0xe5 >actual && + test_cmp invalid-0xe5 actual +' + test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data' ' git grep -h "æ" invalid-0x80 >actual && test_cmp expected actual && @@ -74,14 +86,41 @@ test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invali test_cmp expected actual ' +test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data (PCRE2 bug #2642)' ' + git grep -h "Aæ" invalid-0xe5 >actual && + test_cmp invalid-0xe5 actual && + git grep -h "(*NO_JIT)Aæ" invalid-0xe5 >actual && + test_cmp invalid-0xe5 actual +' + +test_lazy_prereq PCRE2_MATCH_INVALID_UTF ' + test-tool pcre2-config has-PCRE2_MATCH_INVALID_UTF +' + test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' ' test_might_fail git grep -hi "Æ" invalid-0x80 >actual && - if test -s actual - then - test_cmp expected actual - fi && - test_must_fail git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual && - ! test_cmp expected actual + test_might_fail git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual +' + +test_expect_success GETTEXT_LOCALE,LIBPCRE2,PCRE2_MATCH_INVALID_UTF 'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' ' + git grep -hi "Æ" invalid-0x80 >actual && + test_cmp expected actual && + git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual && + test_cmp expected actual +' + +test_expect_success GETTEXT_LOCALE,LIBPCRE2,PCRE2_MATCH_INVALID_UTF 'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i (PCRE2 bug #2642)' ' + git grep -hi "Æ" invalid-0xe5 >actual && + test_cmp invalid-0xe5 actual && + git grep -hi "(*NO_JIT)Æ" invalid-0xe5 >actual && + test_cmp invalid-0xe5 actual && + + # Only the case of grepping the ASCII part in a way that + # relies on -i fails + git grep -hi "aÆ" invalid-0xe5 >actual && + test_cmp invalid-0xe5 actual && + git grep -hi "(*NO_JIT)aÆ" invalid-0xe5 >actual && + test_cmp invalid-0xe5 actual ' test_done diff --git a/t/t7817-grep-sparse-checkout.sh b/t/t7817-grep-sparse-checkout.sh new file mode 100755 index 0000000000..590b99bbb6 --- /dev/null +++ b/t/t7817-grep-sparse-checkout.sh @@ -0,0 +1,174 @@ +#!/bin/sh + +test_description='grep in sparse checkout + +This test creates a repo with the following structure: + +. +|-- a +|-- b +|-- dir +| `-- c +|-- sub +| |-- A +| | `-- a +| `-- B +| `-- b +`-- sub2 + `-- a + +Where the outer repository has non-cone mode sparsity patterns, sub is a +submodule with cone mode sparsity patterns and sub2 is a submodule that is +excluded by the superproject sparsity patterns. The resulting sparse checkout +should leave the following structure in the working tree: + +. +|-- a +|-- sub +| `-- B +| `-- b +`-- sub2 + `-- a + +But note that sub2 should have the SKIP_WORKTREE bit set. +' + +. ./test-lib.sh + +test_expect_success 'setup' ' + echo "text" >a && + echo "text" >b && + mkdir dir && + echo "text" >dir/c && + + git init sub && + ( + cd sub && + mkdir A B && + echo "text" >A/a && + echo "text" >B/b && + git add A B && + git commit -m sub && + git sparse-checkout init --cone && + git sparse-checkout set B + ) && + + git init sub2 && + ( + cd sub2 && + echo "text" >a && + git add a && + git commit -m sub2 + ) && + + git submodule add ./sub && + git submodule add ./sub2 && + git add a b dir && + git commit -m super && + git sparse-checkout init --no-cone && + git sparse-checkout set "/*" "!b" "!/*/" "sub" && + + git tag -am tag-to-commit tag-to-commit HEAD && + tree=$(git rev-parse HEAD^{tree}) && + git tag -am tag-to-tree tag-to-tree $tree && + + test_path_is_missing b && + test_path_is_missing dir && + test_path_is_missing sub/A && + test_path_is_file a && + test_path_is_file sub/B/b && + test_path_is_file sub2/a && + git branch -m main +' + +# The test below covers a special case: the sparsity patterns exclude '/b' and +# sparse checkout is enabled, but the path exists in the working tree (e.g. +# manually created after `git sparse-checkout init`). git grep should skip it. +test_expect_success 'working tree grep honors sparse checkout' ' + cat >expect <<-EOF && + a:text + EOF + test_when_finished "rm -f b" && + echo "new-text" >b && + git grep "text" >actual && + test_cmp expect actual +' + +test_expect_success 'grep searches unmerged file despite not matching sparsity patterns' ' + cat >expect <<-EOF && + b:modified-b-in-branchX + b:modified-b-in-branchY + EOF + test_when_finished "test_might_fail git merge --abort && \ + git checkout main && git sparse-checkout init" && + + git sparse-checkout disable && + git checkout -b branchY main && + test_commit modified-b-in-branchY b && + git checkout -b branchX main && + test_commit modified-b-in-branchX b && + + git sparse-checkout init && + test_path_is_missing b && + test_must_fail git merge branchY && + git grep "modified-b" >actual && + test_cmp expect actual +' + +test_expect_success 'grep --cached searches entries with the SKIP_WORKTREE bit' ' + cat >expect <<-EOF && + a:text + b:text + dir/c:text + EOF + git grep --cached "text" >actual && + test_cmp expect actual +' + +# Note that sub2/ is present in the worktree but it is excluded by the sparsity +# patterns, so grep should not recurse into it. +test_expect_success 'grep --recurse-submodules honors sparse checkout in submodule' ' + cat >expect <<-EOF && + a:text + sub/B/b:text + EOF + git grep --recurse-submodules "text" >actual && + test_cmp expect actual +' + +test_expect_success 'grep --recurse-submodules --cached searches entries with the SKIP_WORKTREE bit' ' + cat >expect <<-EOF && + a:text + b:text + dir/c:text + sub/A/a:text + sub/B/b:text + sub2/a:text + EOF + git grep --recurse-submodules --cached "text" >actual && + test_cmp expect actual +' + +test_expect_success 'working tree grep does not search the index with CE_VALID and SKIP_WORKTREE' ' + cat >expect <<-EOF && + a:text + EOF + test_when_finished "git update-index --no-assume-unchanged b" && + git update-index --assume-unchanged b && + git grep text >actual && + test_cmp expect actual +' + +test_expect_success 'grep --cached searches index entries with both CE_VALID and SKIP_WORKTREE' ' + cat >expect <<-EOF && + a:text + b:text + dir/c:text + EOF + test_when_finished "git update-index --no-assume-unchanged b" && + git update-index --assume-unchanged b && + git grep --cached text >actual && + test_cmp expect actual +' + +test_done diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index 99bf0c7582..b93ae014ee 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -7,6 +7,19 @@ test_description='git maintenance builtin' GIT_TEST_COMMIT_GRAPH=0 GIT_TEST_MULTI_PACK_INDEX=0 +test_lazy_prereq XMLLINT ' + xmllint --version +' + +test_xmllint () { + if test_have_prereq XMLLINT + then + xmllint --noout "$@" + else + true + fi +} + test_expect_success 'help text' ' test_expect_code 129 git maintenance -h 2>err && test_i18ngrep "usage: git maintenance <subcommand>" err && @@ -128,15 +141,45 @@ test_expect_success 'prefetch multiple remotes' ' test_commit -C clone1 one && test_commit -C clone2 two && GIT_TRACE2_EVENT="$(pwd)/run-prefetch.txt" git maintenance run --task=prefetch 2>/dev/null && - fetchargs="--prune --no-tags --no-write-fetch-head --recurse-submodules=no --refmap= --quiet" && - test_subcommand git fetch remote1 $fetchargs +refs/heads/\\*:refs/prefetch/remote1/\\* <run-prefetch.txt && - test_subcommand git fetch remote2 $fetchargs +refs/heads/\\*:refs/prefetch/remote2/\\* <run-prefetch.txt && + fetchargs="--prefetch --prune --no-tags --no-write-fetch-head --recurse-submodules=no --quiet" && + test_subcommand git fetch remote1 $fetchargs <run-prefetch.txt && + test_subcommand git fetch remote2 $fetchargs <run-prefetch.txt && test_path_is_missing .git/refs/remotes && - git log prefetch/remote1/one && - git log prefetch/remote2/two && + git log prefetch/remotes/remote1/one && + git log prefetch/remotes/remote2/two && git fetch --all && - test_cmp_rev refs/remotes/remote1/one refs/prefetch/remote1/one && - test_cmp_rev refs/remotes/remote2/two refs/prefetch/remote2/two + test_cmp_rev refs/remotes/remote1/one refs/prefetch/remotes/remote1/one && + test_cmp_rev refs/remotes/remote2/two refs/prefetch/remotes/remote2/two && + + test_cmp_config refs/prefetch/ log.excludedecoration && + git log --oneline --decorate --all >log && + ! grep "prefetch" log && + + test_when_finished git config --unset remote.remote1.skipFetchAll && + git config remote.remote1.skipFetchAll true && + GIT_TRACE2_EVENT="$(pwd)/skip-remote1.txt" git maintenance run --task=prefetch 2>/dev/null && + test_subcommand ! git fetch remote1 $fetchargs <skip-remote1.txt && + test_subcommand git fetch remote2 $fetchargs <skip-remote1.txt +' + +test_expect_success 'prefetch and existing log.excludeDecoration values' ' + git config --unset-all log.excludeDecoration && + git config log.excludeDecoration refs/remotes/remote1/ && + git maintenance run --task=prefetch && + + git config --get-all log.excludeDecoration >out && + grep refs/remotes/remote1/ out && + grep refs/prefetch/ out && + + git log --oneline --decorate --all >log && + ! grep "prefetch" log && + ! grep "remote1" log && + grep "remote2" log && + + # a second run does not change the config + git maintenance run --task=prefetch && + git log --oneline --decorate --all >log2 && + test_cmp log log2 ' test_expect_success 'loose-objects task' ' @@ -219,6 +262,13 @@ test_expect_success 'incremental-repack task' ' HEAD ^HEAD~1 EOF + + # Delete refs that have not been repacked in these packs. + git for-each-ref --format="delete %(refname)" \ + refs/prefetch refs/tags >refs && + git update-ref --stdin <refs && + + # Replace the object directory with this pack layout. rm -f $packDir/pack-* && rm -f $packDir/loose-* && ls $packDir/*.pack >packs-before && @@ -299,6 +349,18 @@ test_expect_success 'maintenance.incremental-repack.auto' ' test_subcommand git multi-pack-index write --no-progress <trace-B ' +test_expect_success 'pack-refs task' ' + for n in $(test_seq 1 5) + do + git branch -f to-pack/$n HEAD || return 1 + done && + GIT_TRACE2_EVENT="$(pwd)/pack-refs.txt" \ + git maintenance run --task=pack-refs && + ls .git/refs/heads/ >after && + test_must_be_empty after && + test_subcommand git pack-refs --all --prune <pack-refs.txt +' + test_expect_success '--auto and --schedule incompatible' ' test_must_fail git maintenance run --auto --schedule=daily 2>err && test_i18ngrep "at most one" err @@ -352,18 +414,32 @@ test_expect_success 'maintenance.strategy inheritance' ' git maintenance run --schedule=hourly --quiet && GIT_TRACE2_EVENT="$(pwd)/incremental-daily.txt" \ git maintenance run --schedule=daily --quiet && + GIT_TRACE2_EVENT="$(pwd)/incremental-weekly.txt" \ + git maintenance run --schedule=weekly --quiet && test_subcommand git commit-graph write --split --reachable \ --no-progress <incremental-hourly.txt && test_subcommand ! git prune-packed --quiet <incremental-hourly.txt && test_subcommand ! git multi-pack-index write --no-progress \ <incremental-hourly.txt && + test_subcommand ! git pack-refs --all --prune \ + <incremental-hourly.txt && test_subcommand git commit-graph write --split --reachable \ --no-progress <incremental-daily.txt && test_subcommand git prune-packed --quiet <incremental-daily.txt && test_subcommand git multi-pack-index write --no-progress \ <incremental-daily.txt && + test_subcommand ! git pack-refs --all --prune \ + <incremental-daily.txt && + + test_subcommand git commit-graph write --split --reachable \ + --no-progress <incremental-weekly.txt && + test_subcommand git prune-packed --quiet <incremental-weekly.txt && + test_subcommand git multi-pack-index write --no-progress \ + <incremental-weekly.txt && + test_subcommand git pack-refs --all --prune \ + <incremental-weekly.txt && # Modify defaults git config maintenance.commit-graph.schedule daily && @@ -419,7 +495,7 @@ test_expect_success !MINGW 'register and unregister with regex metacharacters' ' ' test_expect_success 'start from empty cron table' ' - GIT_TEST_CRONTAB="test-tool crontab cron.txt" git maintenance start && + GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt" git maintenance start && # start registers the repo git config --get --global --fixed-value maintenance.repo "$(pwd)" && @@ -430,19 +506,19 @@ test_expect_success 'start from empty cron table' ' ' test_expect_success 'stop from existing schedule' ' - GIT_TEST_CRONTAB="test-tool crontab cron.txt" git maintenance stop && + GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt" git maintenance stop && # stop does not unregister the repo git config --get --global --fixed-value maintenance.repo "$(pwd)" && # Operation is idempotent - GIT_TEST_CRONTAB="test-tool crontab cron.txt" git maintenance stop && + GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt" git maintenance stop && test_must_be_empty cron.txt ' test_expect_success 'start preserves existing schedule' ' echo "Important information!" >cron.txt && - GIT_TEST_CRONTAB="test-tool crontab cron.txt" git maintenance start && + GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt" git maintenance start && grep "Important information!" cron.txt ' @@ -457,11 +533,94 @@ test_expect_success 'magic markers are correct' ' test_expect_success 'stop preserves surrounding schedule' ' echo "Crucial information!" >>cron.txt && - GIT_TEST_CRONTAB="test-tool crontab cron.txt" git maintenance stop && + GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt" git maintenance stop && grep "Important information!" cron.txt && grep "Crucial information!" cron.txt ' +test_expect_success 'start and stop macOS maintenance' ' + # ensure $HOME can be compared against hook arguments on all platforms + pfx=$(cd "$HOME" && pwd) && + + write_script print-args <<-\EOF && + echo $* | sed "s:gui/[0-9][0-9]*:gui/[UID]:" >>args + EOF + + rm -f args && + GIT_TEST_MAINT_SCHEDULER=launchctl:./print-args git maintenance start && + + # start registers the repo + git config --get --global --fixed-value maintenance.repo "$(pwd)" && + + ls "$HOME/Library/LaunchAgents" >actual && + cat >expect <<-\EOF && + org.git-scm.git.daily.plist + org.git-scm.git.hourly.plist + org.git-scm.git.weekly.plist + EOF + test_cmp expect actual && + + rm -f expect && + for frequency in hourly daily weekly + do + PLIST="$pfx/Library/LaunchAgents/org.git-scm.git.$frequency.plist" && + test_xmllint "$PLIST" && + grep schedule=$frequency "$PLIST" && + echo "bootout gui/[UID] $PLIST" >>expect && + echo "bootstrap gui/[UID] $PLIST" >>expect || return 1 + done && + test_cmp expect args && + + rm -f args && + GIT_TEST_MAINT_SCHEDULER=launchctl:./print-args git maintenance stop && + + # stop does not unregister the repo + git config --get --global --fixed-value maintenance.repo "$(pwd)" && + + printf "bootout gui/[UID] $pfx/Library/LaunchAgents/org.git-scm.git.%s.plist\n" \ + hourly daily weekly >expect && + test_cmp expect args && + ls "$HOME/Library/LaunchAgents" >actual && + test_line_count = 0 actual +' + +test_expect_success 'start and stop Windows maintenance' ' + write_script print-args <<-\EOF && + echo $* >>args + while test $# -gt 0 + do + case "$1" in + /xml) shift; xmlfile=$1; break ;; + *) shift ;; + esac + done + test -z "$xmlfile" || cp "$xmlfile" "$xmlfile.xml" + EOF + + rm -f args && + GIT_TEST_MAINT_SCHEDULER="schtasks:./print-args" git maintenance start && + + # start registers the repo + git config --get --global --fixed-value maintenance.repo "$(pwd)" && + + for frequency in hourly daily weekly + do + grep "/create /tn Git Maintenance ($frequency) /f /xml" args && + file=$(ls .git/schedule_${frequency}*.xml) && + test_xmllint "$file" || return 1 + done && + + rm -f args && + GIT_TEST_MAINT_SCHEDULER="schtasks:./print-args" git maintenance stop && + + # stop does not unregister the repo + git config --get --global --fixed-value maintenance.repo "$(pwd)" && + + printf "/delete /tn Git Maintenance (%s) /f\n" \ + hourly daily weekly >expect && + test_cmp expect args +' + test_expect_success 'register preserves existing strategy' ' git config maintenance.strategy none && git maintenance register && @@ -479,4 +638,17 @@ test_expect_success 'fails when running outside of a repository' ' nongit test_must_fail git maintenance unregister ' +test_expect_success 'register and unregister bare repo' ' + test_when_finished "git config --global --unset-all maintenance.repo || :" && + test_might_fail git config --global --unset-all maintenance.repo && + git init --bare barerepo && + ( + cd barerepo && + git maintenance register && + git config --get --global --fixed-value maintenance.repo "$(pwd)" && + git maintenance unregister && + test_must_fail git config --global --get-all maintenance.repo + ) +' + test_done diff --git a/t/t8001-annotate.sh b/t/t8001-annotate.sh index 72176e42c1..a536a621b2 100755 --- a/t/t8001-annotate.sh +++ b/t/t8001-annotate.sh @@ -1,13 +1,16 @@ #!/bin/sh test_description='git annotate' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh PROG='git annotate' . "$TEST_DIRECTORY"/annotate-tests.sh test_expect_success 'annotate old revision' ' - git annotate file master >actual && + git annotate file main >actual && awk "{ print \$3; }" <actual >authors && test 2 = $(grep A <authors | wc -l) && test 2 = $(grep B <authors | wc -l) diff --git a/t/t8002-blame.sh b/t/t8002-blame.sh index 015973e8fe..5bb302b1ba 100755 --- a/t/t8002-blame.sh +++ b/t/t8002-blame.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='git blame' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh PROG='git blame -c' diff --git a/t/t8003-blame-corner-cases.sh b/t/t8003-blame-corner-cases.sh index ba8013b002..da80f815ce 100755 --- a/t/t8003-blame-corner-cases.sh +++ b/t/t8003-blame-corner-cases.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='git blame corner cases' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh pick_fc='s/^[0-9a-f^]* *\([^ ]*\) *(\([^ ]*\) .*/\1-\2/' @@ -161,13 +164,13 @@ test_expect_success 'blame wholesale copy and more in the index' ' test_expect_success 'blame during cherry-pick with file rename conflict' ' - test_when_finished "git reset --hard && git checkout master" && + test_when_finished "git reset --hard && git checkout main" && git checkout HEAD~3 && echo MOUSE >> mouse && git mv mouse rodent && git add rodent && GIT_AUTHOR_NAME=Rodent git commit -m "rodent" && - git checkout --detach master && + git checkout --detach main && (git cherry-pick HEAD@{1} || test $? -eq 1) && git show HEAD@{1}:rodent > rodent && git add rodent && diff --git a/t/t8004-blame-with-conflicts.sh b/t/t8004-blame-with-conflicts.sh index 9c353ab222..35414a5336 100755 --- a/t/t8004-blame-with-conflicts.sh +++ b/t/t8004-blame-with-conflicts.sh @@ -3,6 +3,9 @@ # Based on a test case submitted by Björn Steinbrink. test_description='git blame on conflicted files' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup first case' ' @@ -21,16 +24,16 @@ test_expect_success 'setup first case' ' git add file2 && git commit --author "U Gly <ug@localhost>" -m ugly && - # Back to master and change something - git checkout master && + # Back to main and change something + git checkout main && echo " bla" >> file1 && git commit --author "Old Line <ol@localhost>" -a -m file1.b && - # Back to foo and merge master + # Back to foo and merge main git checkout foo && - if git merge master; then + if git merge main; then echo needed conflict here exit 1 else @@ -44,8 +47,8 @@ Even more" > file2 && git rm file1 && git commit --author "M Result <mr@localhost>" -a -m merged && - # Back to master and change file1 again - git checkout master && + # Back to main and change file1 again + git checkout main && sed s/bla/foo/ <file1 >X && rm file1 && mv X file1 && @@ -53,7 +56,7 @@ Even more" > file2 && # Try to merge into foo again git checkout foo && - if git merge master; then + if git merge main; then echo needed conflict here exit 1 else diff --git a/t/t8012-blame-colors.sh b/t/t8012-blame-colors.sh index ed38f74de9..90c75dbb28 100755 --- a/t/t8012-blame-colors.sh +++ b/t/t8012-blame-colors.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='colored git blame' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh PROG='git blame -c' diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index a08f72596a..30eff725a9 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='git send-email' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # May be altered later in the test @@ -412,15 +415,23 @@ test_expect_success $PREREQ 'reject long lines' ' z512=$z64$z64$z64$z64$z64$z64$z64$z64 && clean_fake_sendmail && cp $patches longline.patch && - echo $z512$z512 >>longline.patch && + cat >>longline.patch <<-EOF && + $z512$z512 + not a long line + $z512$z512 + EOF test_must_fail git send-email \ --from="Example <nobody@example.com>" \ --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ --transfer-encoding=8bit \ $patches longline.patch \ - 2>errors && - grep longline.patch errors + 2>actual && + cat >expect <<-\EOF && + fatal: longline.patch:35 is longer than 998 characters + warning: no patches were sent + EOF + test_cmp expect actual ' test_expect_success $PREREQ 'no patch was sent' ' @@ -510,6 +521,49 @@ do done +test_expect_success $PREREQ "--validate respects relative core.hooksPath path" ' + clean_fake_sendmail && + mkdir my-hooks && + test_when_finished "rm my-hooks.ran" && + write_script my-hooks/sendemail-validate <<-\EOF && + >my-hooks.ran + exit 1 + EOF + test_config core.hooksPath "my-hooks" && + test_must_fail git send-email \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + --validate \ + longline.patch 2>actual && + test_path_is_file my-hooks.ran && + cat >expect <<-EOF && + fatal: longline.patch: rejected by sendemail-validate hook + fatal: command '"'"'my-hooks/sendemail-validate'"'"' died with exit code 1 + warning: no patches were sent + EOF + test_cmp expect actual +' + +test_expect_success $PREREQ "--validate respects absolute core.hooksPath path" ' + hooks_path="$(pwd)/my-hooks" && + test_config core.hooksPath "$hooks_path" && + test_when_finished "rm my-hooks.ran" && + test_must_fail git send-email \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + --validate \ + longline.patch 2>actual && + test_path_is_file my-hooks.ran && + cat >expect <<-EOF && + fatal: longline.patch: rejected by sendemail-validate hook + fatal: command '"'"'$hooks_path/sendemail-validate'"'"' died with exit code 1 + warning: no patches were sent + EOF + test_cmp expect actual +' + for enc in 7bit 8bit quoted-printable base64 do test_expect_success $PREREQ "--transfer-encoding=$enc produces correct header" ' @@ -590,14 +644,33 @@ test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' ' test_cmp expect actual ' +test_set_editor "$(pwd)/fake-editor" + +test_expect_success $PREREQ 'setup erroring fake editor' ' + write_script fake-editor <<-\EOF + echo >&2 "I am about to error" + exit 1 + EOF +' + +test_expect_success $PREREQ 'fake editor dies with error' ' + clean_fake_sendmail && + test_must_fail git send-email \ + --compose --subject foo \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches 2>err && + grep "I am about to error" err && + grep "the editor exited uncleanly, aborting everything" err +' + test_expect_success $PREREQ 'setup fake editor' ' write_script fake-editor <<-\EOF echo fake edit >>"$1" EOF ' -test_set_editor "$(pwd)/fake-editor" - test_expect_success $PREREQ '--compose works' ' clean_fake_sendmail && git send-email \ @@ -1168,10 +1241,10 @@ test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' ' ' test_expect_success $PREREQ 'detects ambiguous reference/file conflict' ' - echo master >master && - git add master && - git commit -m"add master" && - test_must_fail git send-email --dry-run master 2>errors && + echo main >main && + git add main && + git commit -m"add main" && + test_must_fail git send-email --dry-run main 2>errors && grep disambiguate errors ' @@ -1185,7 +1258,7 @@ test_expect_success $PREREQ 'feed two files' ' outdir/000?-*.patch 2>errors >out && grep "^Subject: " out >subjects && test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." && - test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master" + test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add main" ' test_expect_success $PREREQ 'in-reply-to but no threading' ' @@ -2037,7 +2110,7 @@ test_expect_success $PREREQ 'setup expected-list' ' --cc="Cc2 <cc2@example.com>" \ --bcc="bcc1@example.com" \ --bcc="bcc2@example.com" \ - 0001-add-master.patch | replace_variable_fields \ + 0001-add-main.patch | replace_variable_fields \ >expected-list ' @@ -2049,7 +2122,7 @@ test_expect_success $PREREQ 'use email list in --cc --to and --bcc' ' --to="to3@example.com" \ --cc="Cc 1 <cc1@example.com>, Cc2 <cc2@example.com>" \ --bcc="bcc1@example.com, bcc2@example.com" \ - 0001-add-master.patch | replace_variable_fields \ + 0001-add-main.patch | replace_variable_fields \ >actual-list && test_cmp expected-list actual-list ' @@ -2065,7 +2138,7 @@ test_expect_success $PREREQ 'aliases work with email list' ' --to="To 1 <to1@example.com>, to2, to3@example.com" \ --cc="cc1, Cc2 <cc2@example.com>" \ --bcc="bcc1@example.com, bcc2@example.com" \ - 0001-add-master.patch | replace_variable_fields \ + 0001-add-main.patch | replace_variable_fields \ >actual-list && test_cmp expected-list actual-list ' @@ -2089,11 +2162,42 @@ test_expect_success $PREREQ 'leading and trailing whitespaces are removed' ' --cc="Cc2 <cc2@example.com>" \ --bcc="$BCC1" \ --bcc="bcc2@example.com" \ - 0001-add-master.patch | replace_variable_fields \ + 0001-add-main.patch | replace_variable_fields \ >actual-list && test_cmp expected-list actual-list ' +test_expect_success $PREREQ 'test using command name with --sendmail-cmd' ' + clean_fake_sendmail && + PATH="$(pwd):$PATH" \ + git send-email \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --sendmail-cmd="fake.sendmail" \ + HEAD^ && + test_path_is_file commandline1 +' + +test_expect_success $PREREQ 'test using arguments with --sendmail-cmd' ' + clean_fake_sendmail && + git send-email \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --sendmail-cmd='\''"$(pwd)/fake.sendmail" -f nobody@example.com'\'' \ + HEAD^ && + test_path_is_file commandline1 +' + +test_expect_success $PREREQ 'test shell expression with --sendmail-cmd' ' + clean_fake_sendmail && + git send-email \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --sendmail-cmd='\''f() { "$(pwd)/fake.sendmail" "$@"; };f'\'' \ + HEAD^ && + test_path_is_file commandline1 +' + test_expect_success $PREREQ 'invoke hook' ' mkdir -p .git/hooks && @@ -2108,8 +2212,8 @@ test_expect_success $PREREQ 'invoke hook' ' false ;; esac && - test -f 0001-add-master.patch && - grep "add master" "$1" + test -f 0001-add-main.patch && + grep "add main" "$1" EOF mkdir subdir && @@ -2121,10 +2225,10 @@ test_expect_success $PREREQ 'invoke hook' ' --from="Example <nobody@example.com>" \ --to=nobody@example.com \ --smtp-server="$(pwd)/../fake.sendmail" \ - ../0001-add-master.patch && + ../0001-add-main.patch && # Verify error message when a patch is rejected by the hook - sed -e "s/add master/x/" ../0001-add-master.patch >../another.patch && + sed -e "s/add main/x/" ../0001-add-main.patch >../another.patch && test_must_fail git send-email \ --from="Example <nobody@example.com>" \ --to=nobody@example.com \ @@ -2139,7 +2243,7 @@ test_expect_success $PREREQ 'test that send-email works outside a repo' ' --from="Example <nobody@example.com>" \ --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ - "$(pwd)/0001-add-master.patch" + "$(pwd)/0001-add-main.patch" ' test_expect_success $PREREQ 'test that sendmail config is rejected' ' diff --git a/t/t9003-help-autocorrect.sh b/t/t9003-help-autocorrect.sh index 03cd5c5423..f00deaf381 100755 --- a/t/t9003-help-autocorrect.sh +++ b/t/t9003-help-autocorrect.sh @@ -56,11 +56,8 @@ test_expect_success 'autocorrect can be declined altogether' ' git config help.autocorrect never && test_must_fail git lfg 2>actual && - if test_have_prereq C_LOCALE_OUTPUT - then - grep "is not a git command" actual && - test_line_count = 1 actual - fi + grep "is not a git command" actual && + test_line_count = 1 actual ' test_done diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh index e4bb22034e..1d3fdcc997 100755 --- a/t/t9100-git-svn-basic.sh +++ b/t/t9100-git-svn-basic.sh @@ -6,6 +6,9 @@ test_description='git svn basic tests' GIT_SVN_LC_ALL=${LC_ALL:-$LANG} +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-git-svn.sh case "$GIT_SVN_LC_ALL" in @@ -275,7 +278,7 @@ test_expect_success 'dcommit $rev does not clobber current branch' ' test refs/heads/my-bar = $(git symbolic-ref HEAD) && git log refs/remotes/bar | grep "change 1" && ! git log refs/remotes/bar | grep "change 2" && - git checkout master && + git checkout main && git branch -D my-bar ' diff --git a/t/t9117-git-svn-init-clone.sh b/t/t9117-git-svn-init-clone.sh index 044f65e916..62de819a44 100755 --- a/t/t9117-git-svn-init-clone.sh +++ b/t/t9117-git-svn-init-clone.sh @@ -7,12 +7,6 @@ test_description='git svn init/clone tests' . ./lib-git-svn.sh -# setup, run inside tmp so we don't have any conflicts with $svnrepo -set -e -rm -r .git -mkdir tmp -cd tmp - test_expect_success 'setup svnrepo' ' mkdir project project/trunk project/branches project/tags && echo foo > project/trunk/foo && diff --git a/t/t9145-git-svn-master-branch.sh b/t/t9145-git-svn-master-branch.sh index 3bbf341f6a..f863e437f7 100755 --- a/t/t9145-git-svn-master-branch.sh +++ b/t/t9145-git-svn-master-branch.sh @@ -2,7 +2,10 @@ # # Copyright (c) 2009 Eric Wong # -test_description='git svn initial master branch is "trunk" if possible' +test_description='git svn initial main branch is "trunk" if possible' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-git-svn.sh test_expect_success 'setup test repository' ' @@ -13,12 +16,12 @@ test_expect_success 'setup test repository' ' svn_cmd import -m b/b i "$svnrepo/branches/b" ' -test_expect_success 'git svn clone --stdlayout sets up trunk as master' ' +test_expect_success 'git svn clone --stdlayout sets up trunk as main' ' git svn clone -s "$svnrepo" g && ( cd g && test x$(git rev-parse --verify refs/remotes/origin/trunk^0) = \ - x$(git rev-parse --verify refs/heads/master^0) + x$(git rev-parse --verify refs/heads/main^0) ) ' diff --git a/t/t9148-git-svn-propset.sh b/t/t9148-git-svn-propset.sh index 102639090c..aebb28995e 100755 --- a/t/t9148-git-svn-propset.sh +++ b/t/t9148-git-svn-propset.sh @@ -7,19 +7,22 @@ test_description='git svn propset tests' . ./lib-git-svn.sh -foo_subdir2="subdir/subdir2/foo_subdir2" +test_expect_success 'setup propset via import' ' + test_when_finished "rm -rf import" && -set -e -mkdir import && -(set -e ; cd import - mkdir subdir - mkdir subdir/subdir2 - touch foo # for 'add props top level' - touch subdir/foo_subdir # for 'add props relative' - touch "$foo_subdir2" # for 'add props subdir' - svn_cmd import -m 'import for git svn' . "$svnrepo" >/dev/null -) -rm -rf import + foo_subdir2="subdir/subdir2/foo_subdir2" && + mkdir -p import/subdir/subdir2 && + ( + cd import && + # for "add props top level" + >foo && + # for "add props relative" + >subdir/foo_subdir && + # for "add props subdir" + >"$foo_subdir2" && + svn_cmd import -m "import for git svn" . "$svnrepo" + ) +' test_expect_success 'initialize git svn' ' git svn init "$svnrepo" diff --git a/t/t9151-svn-mergeinfo.sh b/t/t9151-svn-mergeinfo.sh index 4f6c06ecb2..1fbe84feb1 100755 --- a/t/t9151-svn-mergeinfo.sh +++ b/t/t9151-svn-mergeinfo.sh @@ -5,53 +5,53 @@ test_description='git-svn svn mergeinfo properties' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-git-svn.sh test_expect_success 'load svn dump' " svnadmin load -q '$rawsvnrepo' \ - < '$TEST_DIRECTORY/t9151/svn-mergeinfo.dump' && + <'$TEST_DIRECTORY/t9151/svn-mergeinfo.dump' && git svn init --minimize-url -R svnmerge \ --rewrite-root=http://svn.example.org \ -T trunk -b branches '$svnrepo' && git svn fetch --all - " +" test_expect_success 'all svn merges became git merge commits' ' - unmarked=$(git rev-list --parents --all --grep=Merge | - grep -v " .* " | cut -f1 -d" ") && - [ -z "$unmarked" ] - ' + git rev-list --all --no-merges --grep=Merge >unmarked && + test_must_be_empty unmarked +' test_expect_success 'cherry picks did not become git merge commits' ' - bad_cherries=$(git rev-list --parents --all --grep=Cherry | - grep " .* " | cut -f1 -d" ") && - [ -z "$bad_cherries" ] - ' + git rev-list --all --merges --grep=Cherry >bad-cherries && + test_must_be_empty bad-cherries +' test_expect_success 'svn non-merge merge commits did not become git merge commits' ' - bad_non_merges=$(git rev-list --parents --all --grep=non-merge | - grep " .* " | cut -f1 -d" ") && - [ -z "$bad_non_merges" ] - ' + git rev-list --all --merges --grep=non-merge >bad-non-merges && + test_must_be_empty bad-non-merges +' test_expect_success 'commit made to merged branch is reachable from the merge' ' before_commit=$(git rev-list --all --grep="trunk commit before merging trunk to b2") && merge_commit=$(git rev-list --all --grep="Merge trunk to b2") && - not_reachable=$(git rev-list -1 $before_commit --not $merge_commit) && - [ -z "$not_reachable" ] - ' + git rev-list -1 $before_commit --not $merge_commit >not-reachable && + test_must_be_empty not-reachable +' test_expect_success 'merging two branches in one commit is detected correctly' ' f1_commit=$(git rev-list --all --grep="make f1 branch from trunk") && f2_commit=$(git rev-list --all --grep="make f2 branch from trunk") && merge_commit=$(git rev-list --all --grep="Merge f1 and f2 to trunk") && - not_reachable=$(git rev-list -1 $f1_commit $f2_commit --not $merge_commit) && - [ -z "$not_reachable" ] - ' + git rev-list -1 $f1_commit $f2_commit --not $merge_commit >not-reachable && + test_must_be_empty not-reachable +' test_expect_failure 'everything got merged in the end' ' - unmerged=$(git rev-list --all --not master) && - [ -z "$unmerged" ] - ' + git rev-list --all --not main >unmerged && + test_must_be_empty unmerged +' test_done diff --git a/t/t9155-git-svn-fetch-deleted-tag.sh b/t/t9155-git-svn-fetch-deleted-tag.sh index 184336f346..3258374c13 100755 --- a/t/t9155-git-svn-fetch-deleted-tag.sh +++ b/t/t9155-git-svn-fetch-deleted-tag.sh @@ -2,6 +2,9 @@ test_description='git svn fetch deleted tag' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-git-svn.sh test_expect_success 'setup svn repo' ' @@ -36,7 +39,7 @@ test_expect_success 'fetch deleted tags from same revision with checksum error' git svn fetch && git diff --exit-code origin/mybranch:trunk/subdir/file origin/tags/mytag:file && - git diff --exit-code master:subdir/file origin/tags/mytag^:file + git diff --exit-code main:subdir/file origin/tags/mytag^:file ' test_done diff --git a/t/t9156-git-svn-fetch-deleted-tag-2.sh b/t/t9156-git-svn-fetch-deleted-tag-2.sh index 7a6e33ba3c..2b75c403e3 100755 --- a/t/t9156-git-svn-fetch-deleted-tag-2.sh +++ b/t/t9156-git-svn-fetch-deleted-tag-2.sh @@ -2,6 +2,9 @@ test_description='git svn fetch deleted tag 2' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-git-svn.sh test_expect_success 'setup svn repo' ' @@ -36,9 +39,9 @@ test_expect_success 'fetch deleted tags from same revision with no checksum erro cd git_project && git svn fetch && - git diff --exit-code master:subdir3/file origin/tags/mytag:file && - git diff --exit-code master:subdir2/file origin/tags/mytag^:file && - git diff --exit-code master:subdir1/file origin/tags/mytag^^:file + git diff --exit-code main:subdir3/file origin/tags/mytag:file && + git diff --exit-code main:subdir2/file origin/tags/mytag^:file && + git diff --exit-code main:subdir1/file origin/tags/mytag^^:file ' test_done diff --git a/t/t9163-git-svn-reset-clears-caches.sh b/t/t9163-git-svn-reset-clears-caches.sh index d6245cee08..978eb62ff4 100755 --- a/t/t9163-git-svn-reset-clears-caches.sh +++ b/t/t9163-git-svn-reset-clears-caches.sh @@ -4,6 +4,9 @@ # test_description='git svn reset clears memoized caches' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-git-svn.sh svn_ver="$(svn --version --quiet)" @@ -59,7 +62,7 @@ test_expect_success 'fetch to merge-base (a)' ' test_expect_success 'rebase looses SVN merge (m)' ' git svn rebase && git svn fetch && - test 1 = $(git cat-file -p master|grep parent|wc -l) + test 1 = $(git cat-file -p main|grep parent|wc -l) ' # git svn fetch creates correct history with merge commit diff --git a/t/t9169-git-svn-dcommit-crlf.sh b/t/t9169-git-svn-dcommit-crlf.sh index 54b1f61a2a..7080b5d24f 100755 --- a/t/t9169-git-svn-dcommit-crlf.sh +++ b/t/t9169-git-svn-dcommit-crlf.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='git svn dcommit CRLF' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-git-svn.sh test_expect_success 'setup commit repository' ' @@ -14,7 +17,7 @@ test_expect_success 'setup commit repository' ' p=$(git rev-parse HEAD) && t=$(git write-tree) && cmt=$(git commit-tree -p $p $t <cmt) && - git update-ref refs/heads/master $cmt && + git update-ref refs/heads/main $cmt && git cat-file commit HEAD | tail -n4 >out && test_cmp cmt out && git svn dcommit && diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 308c1ef42c..5c47ac4465 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -4,8 +4,11 @@ # test_description='test git fast-import utility' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash +. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash verify_packs () { for p in .git/objects/pack/*.pack @@ -62,7 +65,7 @@ test_expect_success 'A: create pack from stdin' ' mark :4 data $file4_len $file4_data - commit refs/heads/master + commit refs/heads/main mark :5 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <<COMMIT @@ -117,7 +120,7 @@ test_expect_success 'A: create pack from stdin' ' INPUT_END git fast-import --export-marks=marks.out <input && - git whatchanged master + git whatchanged main ' test_expect_success 'A: verify pack' ' @@ -131,7 +134,7 @@ test_expect_success 'A: verify commit' ' initial EOF - git cat-file commit master | sed 1d >actual && + git cat-file commit main | sed 1d >actual && test_cmp expect actual ' @@ -141,31 +144,31 @@ test_expect_success 'A: verify tree' ' 100644 blob file3 100755 blob file4 EOF - git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual && + git cat-file -p main^{tree} | sed "s/ [0-9a-f]* / /" >actual && test_cmp expect actual ' test_expect_success 'A: verify file2' ' echo "$file2_data" >expect && - git cat-file blob master:file2 >actual && + git cat-file blob main:file2 >actual && test_cmp expect actual ' test_expect_success 'A: verify file3' ' echo "$file3_data" >expect && - git cat-file blob master:file3 >actual && + git cat-file blob main:file3 >actual && test_cmp expect actual ' test_expect_success 'A: verify file4' ' printf "$file4_data" >expect && - git cat-file blob master:file4 >actual && + git cat-file blob main:file4 >actual && test_cmp expect actual ' test_expect_success 'A: verify tag/series-A' ' cat >expect <<-EOF && - object $(git rev-parse refs/heads/master) + object $(git rev-parse refs/heads/main) type commit tag series-A @@ -177,7 +180,7 @@ test_expect_success 'A: verify tag/series-A' ' test_expect_success 'A: verify tag/series-A-blob' ' cat >expect <<-EOF && - object $(git rev-parse refs/heads/master:file3) + object $(git rev-parse refs/heads/main:file3) type blob tag series-A-blob @@ -193,13 +196,13 @@ test_expect_success 'A: verify tag deletion is successful' ' test_expect_success 'A: verify marks output' ' cat >expect <<-EOF && - :2 $(git rev-parse --verify master:file2) - :3 $(git rev-parse --verify master:file3) - :4 $(git rev-parse --verify master:file4) - :5 $(git rev-parse --verify master^0) + :2 $(git rev-parse --verify main:file2) + :3 $(git rev-parse --verify main:file3) + :4 $(git rev-parse --verify main:file4) + :5 $(git rev-parse --verify main^0) :6 $(git cat-file tag nested | grep object | cut -d" " -f 2) :7 $(git rev-parse --verify nested) - :8 $(git rev-parse --verify master^0) + :8 $(git rev-parse --verify main^0) EOF test_cmp expect marks.out ' @@ -217,7 +220,7 @@ test_expect_success 'A: tag blob by sha1' ' new_blob=$(echo testing | git hash-object --stdin) && cat >input <<-INPUT_END && tag series-A-blob-2 - from $(git rev-parse refs/heads/master:file3) + from $(git rev-parse refs/heads/main:file3) data <<EOF Tag blob by sha1. EOF @@ -243,7 +246,7 @@ test_expect_success 'A: tag blob by sha1' ' INPUT_END cat >expect <<-EOF && - object $(git rev-parse refs/heads/master:file3) + object $(git rev-parse refs/heads/main:file3) type blob tag series-A-blob-2 @@ -284,13 +287,13 @@ test_expect_success 'A: verify pack' ' ' test_expect_success 'A: verify diff' ' - copy=$(git rev-parse --verify master:file2) && + copy=$(git rev-parse --verify main:file2) && cat >expect <<-EOF && :000000 100755 $ZERO_OID $copy A copy-of-file2 EOF - git diff-tree -M -r master verify--import-marks >actual && + git diff-tree -M -r main verify--import-marks >actual && compare_diff_raw expect actual && - test $(git rev-parse --verify master:file2) \ + test $(git rev-parse --verify main:file2) \ = $(git rev-parse --verify verify--import-marks:copy-of-file2) ' @@ -364,7 +367,7 @@ test_expect_success 'B: fail on invalid blob sha1' ' corrupt COMMIT - from refs/heads/master + from refs/heads/main M 755 $(echo $ZERO_OID | sed -e "s/0$/1/") zero1 INPUT_END @@ -381,7 +384,7 @@ test_expect_success 'B: accept branch name "TEMP_TAG"' ' tag base COMMIT - from refs/heads/master + from refs/heads/main INPUT_END @@ -390,7 +393,7 @@ test_expect_success 'B: accept branch name "TEMP_TAG"' ' git prune" && git fast-import <input && test -f .git/TEMP_TAG && - test $(git rev-parse master) = $(git rev-parse TEMP_TAG^) + test $(git rev-parse main) = $(git rev-parse TEMP_TAG^) ' test_expect_success 'B: accept empty committer' ' @@ -528,8 +531,8 @@ test_expect_success 'B: fail on invalid committer (5)' ' test_expect_success 'C: incremental import create pack from stdin' ' newf=$(echo hi newf | git hash-object -w --stdin) && - oldf=$(git rev-parse --verify master:file2) && - thrf=$(git rev-parse --verify master:file3) && + oldf=$(git rev-parse --verify main:file2) && + thrf=$(git rev-parse --verify main:file3) && test_tick && cat >input <<-INPUT_END && commit refs/heads/branch @@ -538,7 +541,7 @@ test_expect_success 'C: incremental import create pack from stdin' ' second COMMIT - from refs/heads/master + from refs/heads/main M 644 $oldf file2/oldf M 755 $newf file2/newf D file3 @@ -560,7 +563,7 @@ test_expect_success 'C: validate reuse existing blob' ' test_expect_success 'C: verify commit' ' cat >expect <<-EOF && - parent $(git rev-parse --verify master^0) + parent $(git rev-parse --verify main^0) author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE @@ -578,7 +581,7 @@ test_expect_success 'C: validate rename result' ' :100644 100644 $oldf $oldf R100 file2 file2/oldf :100644 000000 $thrf $zero D file3 EOF - git diff-tree -M -r master branch >actual && + git diff-tree -M -r main branch >actual && compare_diff_raw expect actual ' @@ -1629,7 +1632,10 @@ test_expect_success 'O: blank lines not necessary after other commands' ' INPUT_END git fast-import <input && - test 8 = $(find .git/objects/pack -type f | grep -v multi-pack-index | wc -l) && + ls -la .git/objects/pack/pack-*.pack >packlist && + ls -la .git/objects/pack/pack-*.pack >idxlist && + test_line_count = 4 idxlist && + test_line_count = 4 packlist && test $(git rev-parse refs/tags/O3-2nd) = $(git rev-parse O3^) && git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual && test_cmp expect actual @@ -1698,7 +1704,7 @@ test_expect_success 'P: superproject & submodule mix' ' committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data 8 initial - from refs/heads/master + from refs/heads/main M 100644 :3 .gitmodules M 160000 :2 sub @@ -1733,8 +1739,8 @@ test_expect_success 'P: superproject & submodule mix' ' ( cd sub && git init && - git fetch --update-head-ok .. refs/heads/sub:refs/heads/master && - git checkout master + git fetch --update-head-ok .. refs/heads/sub:refs/heads/main && + git checkout main ) && git submodule init && git submodule update @@ -1758,7 +1764,7 @@ test_expect_success 'P: verbatim SHA gitlinks' ' committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data 8 initial - from refs/heads/master + from refs/heads/main M 100644 :1 .gitmodules M 160000 $SUBPREV sub @@ -3429,8 +3435,8 @@ mark :1 data 4 foo -reset refs/heads/master -commit refs/heads/master +reset refs/heads/main +commit refs/heads/main mark :2 author Full Name <user@company.tld> 1000000000 +0100 committer Full Name <user@company.tld> 1000000000 +0100 @@ -3444,7 +3450,7 @@ data 8 foo bar -commit refs/heads/master +commit refs/heads/main mark :4 author Full Name <user@company.tld> 1000000001 +0100 committer Full Name <user@company.tld> 1000000001 +0100 @@ -3461,8 +3467,8 @@ mark :1 data 4 foo -reset refs/heads/master -commit refs/heads/master +reset refs/heads/main +commit refs/heads/main mark :2 author Full Name <user@company.tld> 2000000000 +0100 committer Full Name <user@company.tld> 2000000000 +0100 @@ -3477,7 +3483,7 @@ data 73 path = sub1 url = https://void.example.com/main.git -commit refs/heads/master +commit refs/heads/main mark :4 author Full Name <user@company.tld> 2000000001 +0100 committer Full Name <user@company.tld> 2000000001 +0100 @@ -3493,7 +3499,7 @@ data 8 foo bar -commit refs/heads/master +commit refs/heads/main mark :6 author Full Name <user@company.tld> 2000000002 +0100 committer Full Name <user@company.tld> 2000000002 +0100 @@ -3511,8 +3517,8 @@ Y_INPUT_END test_expect_success 'Y: setup' ' test_oid_cache <<-EOF - Ymaster sha1:9afed2f9161ddf416c0a1863b8b0725b00070504 - Ymaster sha256:c0a1010da1df187b2e287654793df01b464bd6f8e3f17fc1481a7dadf84caee3 + Ymain sha1:9afed2f9161ddf416c0a1863b8b0725b00070504 + Ymain sha256:c0a1010da1df187b2e287654793df01b464bd6f8e3f17fc1481a7dadf84caee3 EOF ' @@ -3524,7 +3530,7 @@ test_expect_success 'Y: rewrite submodules' ' git -C sub2 fast-import --export-marks=../sub2-marks <../Y-sub-input && git fast-import --rewrite-submodules-from=sub:../Y-marks \ --rewrite-submodules-to=sub:sub2-marks <../Y-main-input && - test "$(git rev-parse master)" = "$(test_oid Ymaster)" + test "$(git rev-parse main)" = "$(test_oid Ymain)" ) ' diff --git a/t/t9301-fast-import-notes.sh b/t/t9301-fast-import-notes.sh index 14c1baa739..1ae4d7c0d3 100755 --- a/t/t9301-fast-import-notes.sh +++ b/t/t9301-fast-import-notes.sh @@ -4,12 +4,15 @@ # test_description='test git fast-import of notes objects' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_tick cat >input <<INPUT_END -commit refs/heads/master +commit refs/heads/main committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <<COMMIT first commit @@ -30,7 +33,7 @@ data <<EOF file baz/xyzzy in first commit EOF -commit refs/heads/master +commit refs/heads/main committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <<COMMIT second commit @@ -46,7 +49,7 @@ data <<EOF file baz/xyzzy in second commit EOF -commit refs/heads/master +commit refs/heads/main committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <<COMMIT third commit @@ -57,7 +60,7 @@ data <<EOF file foo in third commit EOF -commit refs/heads/master +commit refs/heads/main committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <<COMMIT fourth commit @@ -70,13 +73,13 @@ EOF INPUT_END -test_expect_success 'set up master branch' ' +test_expect_success 'set up main branch' ' git fast-import <input && - git whatchanged master + git whatchanged main ' -commit4=$(git rev-parse refs/heads/master) +commit4=$(git rev-parse refs/heads/main) commit3=$(git rev-parse "$commit4^") commit2=$(git rev-parse "$commit4~2") commit1=$(git rev-parse "$commit4~3") diff --git a/t/t9302-fast-import-unpack-limit.sh b/t/t9302-fast-import-unpack-limit.sh index bb1c39cfcc..f519e4f1bf 100755 --- a/t/t9302-fast-import-unpack-limit.sh +++ b/t/t9302-fast-import-unpack-limit.sh @@ -5,7 +5,7 @@ test_description='test git fast-import unpack limit' test_expect_success 'create loose objects on import' ' test_tick && cat >input <<-INPUT_END && - commit refs/heads/master + commit refs/heads/main committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <<COMMIT initial @@ -23,12 +23,12 @@ test_expect_success 'create loose objects on import' ' test_expect_success 'bigger packs are preserved' ' test_tick && cat >input <<-INPUT_END && - commit refs/heads/master + commit refs/heads/main committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <<COMMIT incremental should create a pack COMMIT - from refs/heads/master^0 + from refs/heads/main^0 commit refs/heads/branch committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE @@ -48,7 +48,7 @@ test_expect_success 'bigger packs are preserved' ' test_expect_success 'lookups after checkpoint works' ' hello_id=$(echo hello | git hash-object --stdin -t blob) && id="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE" && - before=$(git rev-parse refs/heads/master^0) && + before=$(git rev-parse refs/heads/main^0) && ( cat <<-INPUT_END && blob @@ -56,13 +56,13 @@ test_expect_success 'lookups after checkpoint works' ' data 6 hello - commit refs/heads/master + commit refs/heads/main mark :2 committer $id data <<COMMIT checkpoint after this COMMIT - from refs/heads/master^0 + from refs/heads/main^0 M 100644 :1 hello # pre-checkpoint @@ -86,10 +86,10 @@ test_expect_success 'lookups after checkpoint works' ' n=$(($n + 1)) fi && sleep 1 && - from=$(git rev-parse refs/heads/master^0) + from=$(git rev-parse refs/heads/main^0) done && cat <<-INPUT_END && - commit refs/heads/master + commit refs/heads/main committer $id data <<COMMIT make sure from "unpacked sha1 reference" works, too diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh index 1372842559..409b48e244 100755 --- a/t/t9350-fast-export.sh +++ b/t/t9350-fast-export.sh @@ -4,6 +4,9 @@ # test_description='git fast-export' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup' ' @@ -31,13 +34,13 @@ test_expect_success 'setup' ' git commit -m sitzt file2 && test_tick && git tag -a -m valentin muss && - git merge -s ours master + git merge -s ours main ' test_expect_success 'fast-export | fast-import' ' - MASTER=$(git rev-parse --verify master) && + MAIN=$(git rev-parse --verify main) && REIN=$(git rev-parse --verify rein) && WER=$(git rev-parse --verify wer) && MUSS=$(git rev-parse --verify muss) && @@ -46,7 +49,7 @@ test_expect_success 'fast-export | fast-import' ' git fast-export --all >actual && (cd new && git fast-import && - test $MASTER = $(git rev-parse --verify refs/heads/master) && + test $MAIN = $(git rev-parse --verify refs/heads/main) && test $REIN = $(git rev-parse --verify refs/tags/rein) && test $WER = $(git rev-parse --verify refs/heads/wer) && test $MUSS = $(git rev-parse --verify refs/tags/muss)) <actual @@ -80,35 +83,35 @@ test_expect_success 'fast-export --mark-tags ^muss^{commit} muss' ' test_cmp expected actual ' -test_expect_success 'fast-export master~2..master' ' +test_expect_success 'fast-export main~2..main' ' - git fast-export master~2..master >actual && - sed "s/master/partial/" actual | + git fast-export main~2..main >actual && + sed "s/main/partial/" actual | (cd new && git fast-import && - test $MASTER != $(git rev-parse --verify refs/heads/partial) && - git diff --exit-code master partial && - git diff --exit-code master^ partial^ && + test $MAIN != $(git rev-parse --verify refs/heads/partial) && + git diff --exit-code main partial && + git diff --exit-code main^ partial^ && test_must_fail git rev-parse partial~2) ' -test_expect_success 'fast-export --reference-excluded-parents master~2..master' ' +test_expect_success 'fast-export --reference-excluded-parents main~2..main' ' - git fast-export --reference-excluded-parents master~2..master >actual && - grep commit.refs/heads/master actual >commit-count && + git fast-export --reference-excluded-parents main~2..main >actual && + grep commit.refs/heads/main actual >commit-count && test_line_count = 2 commit-count && - sed "s/master/rewrite/" actual | + sed "s/main/rewrite/" actual | (cd new && git fast-import && - test $MASTER = $(git rev-parse --verify refs/heads/rewrite)) + test $MAIN = $(git rev-parse --verify refs/heads/rewrite)) ' test_expect_success 'fast-export --show-original-ids' ' - git fast-export --show-original-ids master >output && + git fast-export --show-original-ids main >output && grep ^original-oid output| sed -e s/^original-oid.// | sort >actual && - git rev-list --objects master muss >objects-and-names && + git rev-list --objects main muss >objects-and-names && awk "{print \$1}" objects-and-names | sort >commits-trees-blobs && comm -23 actual commits-trees-blobs >unfound && test_must_be_empty unfound @@ -116,8 +119,8 @@ test_expect_success 'fast-export --show-original-ids' ' test_expect_success 'fast-export --show-original-ids | git fast-import' ' - git fast-export --show-original-ids master muss | git fast-import --quiet && - test $MASTER = $(git rev-parse --verify refs/heads/master) && + git fast-export --show-original-ids main muss | git fast-import --quiet && + test $MAIN = $(git rev-parse --verify refs/heads/main) && test $MUSS = $(git rev-parse --verify refs/tags/muss) ' @@ -200,7 +203,7 @@ test_expect_success 'encoding preserved if reencoding fails' ' test_expect_success 'import/export-marks' ' - git checkout -b marks master && + git checkout -b marks main && git fast-export --export-marks=tmp-marks HEAD && test -s tmp-marks && test_line_count = 3 tmp-marks && @@ -265,7 +268,7 @@ test_expect_success 'signed-tags=warn-strip' ' test_expect_success 'setup submodule' ' - git checkout -f master && + git checkout -f main && mkdir sub && ( cd sub && @@ -290,17 +293,17 @@ test_expect_success 'setup submodule' ' test_expect_success 'submodule fast-export | fast-import' ' - SUBENT1=$(git ls-tree master^ sub) && - SUBENT2=$(git ls-tree master sub) && + SUBENT1=$(git ls-tree main^ sub) && + SUBENT2=$(git ls-tree main sub) && rm -rf new && mkdir new && git --git-dir=new/.git init && git fast-export --signed-tags=strip --all >actual && (cd new && git fast-import && - test "$SUBENT1" = "$(git ls-tree refs/heads/master^ sub)" && - test "$SUBENT2" = "$(git ls-tree refs/heads/master sub)" && - git checkout master && + test "$SUBENT1" = "$(git ls-tree refs/heads/main^ sub)" && + test "$SUBENT2" = "$(git ls-tree refs/heads/main sub)" && + git checkout main && git submodule init && git submodule update && cmp sub/file ../sub/file) <actual @@ -352,7 +355,7 @@ test_expect_success 'fast-export -C -C | fast-import' ' ' -test_expect_success 'fast-export | fast-import when master is tagged' ' +test_expect_success 'fast-export | fast-import when main is tagged' ' git tag -m msg last && git fast-export -C -C --signed-tags=strip --all > output && @@ -467,8 +470,8 @@ mark :2 data 3 hi -reset refs/heads/master -commit refs/heads/master +reset refs/heads/main +commit refs/heads/main mark :3 author A U Thor <author@example.com> 1112912713 -0700 committer C O Mitter <committer@example.com> 1112912713 -0700 @@ -482,7 +485,7 @@ EOF test_expect_failure 'no exact-ref revisions included' ' ( cd limit-by-paths && - git fast-export master~2..master~1 > output && + git fast-export main~2..main~1 > output && test_cmp expected output ) ' @@ -524,7 +527,7 @@ test_expect_success 'full-tree re-shows unmodified files' ' ' test_expect_success 'set-up a few more tags for tag export tests' ' - git checkout -f master && + git checkout -f main && HEAD_TREE=$(git show -s --pretty=raw HEAD | grep tree | sed "s/tree //") && git tag tree_tag -m "tagging a tree" $HEAD_TREE && git tag -a tree_tag-obj -m "tagging a tree" $HEAD_TREE && @@ -549,7 +552,7 @@ test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag' test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj' test_expect_success 'handling tags of blobs' ' - git tag -a -m "Tag of a blob" blobtag $(git rev-parse master:file) && + git tag -a -m "Tag of a blob" blobtag $(git rev-parse main:file) && git fast-export blobtag >actual && cat >expect <<-EOF && blob @@ -592,10 +595,10 @@ test_expect_success 'directory becomes symlink' ' ) && ( cd dirtosymlink && - git fast-export master -- foo | + git fast-export main -- foo | (cd ../result && git fast-import --quiet) ) && - (cd result && git show master:foo) + (cd result && git show main:foo) ' test_expect_success 'fast-export quotes pathnames' ' @@ -643,7 +646,7 @@ mark :13 data 5 bump -commit refs/heads/master +commit refs/heads/main mark :14 author A U Thor <author@example.com> 1112912773 -0700 committer C O Mitter <committer@example.com> 1112912773 -0700 @@ -657,18 +660,18 @@ EOF test_expect_success 'avoid uninteresting refs' ' > tmp-marks && git fast-export --import-marks=tmp-marks \ - --export-marks=tmp-marks master > /dev/null && + --export-marks=tmp-marks main > /dev/null && git tag v1.0 && git branch uninteresting && echo bump > file && git commit -a -m bump && git fast-export --import-marks=tmp-marks \ - --export-marks=tmp-marks ^uninteresting ^v1.0 master > actual && + --export-marks=tmp-marks ^uninteresting ^v1.0 main > actual && test_cmp expected actual ' cat > expected << EOF -reset refs/heads/master +reset refs/heads/main from :14 EOF @@ -676,14 +679,14 @@ EOF test_expect_success 'refs are updated even if no commits need to be exported' ' > tmp-marks && git fast-export --import-marks=tmp-marks \ - --export-marks=tmp-marks master > /dev/null && + --export-marks=tmp-marks main > /dev/null && git fast-export --import-marks=tmp-marks \ - --export-marks=tmp-marks master > actual && + --export-marks=tmp-marks main > actual && test_cmp expected actual ' test_expect_success 'use refspec' ' - git fast-export --refspec refs/heads/master:refs/heads/foobar master >actual2 && + git fast-export --refspec refs/heads/main:refs/heads/foobar main >actual2 && grep "^commit " actual2 | sort | uniq >actual && echo "commit refs/heads/foobar" > expected && test_cmp expected actual @@ -736,13 +739,13 @@ test_expect_success 'merge commit gets exported with --import-marks' ' test_commit initial && git checkout -b topic && test_commit on-topic && - git checkout master && - test_commit on-master && + git checkout main && + test_commit on-main && test_tick && git merge --no-ff -m Yeah topic && echo ":1 $(git rev-parse HEAD^^)" >marks && - git fast-export --import-marks=marks master >out && + git fast-export --import-marks=marks main >out && grep Yeah out ) ' diff --git a/t/t9351-fast-export-anonymize.sh b/t/t9351-fast-export-anonymize.sh index 5ac2c3b5ee..1c6e6fcdaf 100755 --- a/t/t9351-fast-export-anonymize.sh +++ b/t/t9351-fast-export-anonymize.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='basic tests for fast-export --anonymize' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success 'setup simple repo' ' @@ -51,7 +54,7 @@ test_expect_success 'stream retains other as refname' ' ' test_expect_success 'stream omits other refnames' ' - ! grep master stream && + ! grep main stream && ! grep mytag stream ' @@ -85,7 +88,7 @@ test_expect_success 'repo has original shape and timestamps' ' shape () { git log --format="%m %ct" --left-right --boundary "$@" } && - (cd .. && shape master...other) >expect && + (cd .. && shape main...other) >expect && shape $main_branch...$other_branch >actual && test_cmp expect actual ' diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh index 4a46f31c41..2d29d486ee 100755 --- a/t/t9400-git-cvsserver-server.sh +++ b/t/t9400-git-cvsserver-server.sh @@ -8,6 +8,9 @@ test_description='git-cvsserver access tests read access to a git repository with the cvs CLI client via git-cvsserver server' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh if ! test_have_prereq PERL; then @@ -45,7 +48,7 @@ test_expect_success 'setup' ' touch secondrootfile && git add secondrootfile && git commit -m "second root") && - git fetch secondroot master && + git fetch secondroot main && git merge --allow-unrelated-histories FETCH_HEAD && git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 && GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && @@ -57,7 +60,7 @@ test_expect_success 'setup' ' # note that cvs doesn't accept absolute pathnames # as argument to co -d test_expect_success 'basic checkout' \ - 'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master && + 'GIT_CONFIG="$git_config" cvs -Q co -d cvswork main && test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | head -n 1))" = "empty/1.1/" && test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | sed -ne \$p))" = "secondrootfile/1.1/"' @@ -226,7 +229,7 @@ GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1 test_expect_success 'gitcvs.enabled = false' \ 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false && - if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 + if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 then echo unexpected cvs success false @@ -240,14 +243,14 @@ rm -fr cvswork2 test_expect_success 'gitcvs.ext.enabled = true' \ 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false && - GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 && test_cmp cvswork cvswork2' rm -fr cvswork2 test_expect_success 'gitcvs.ext.enabled = false' \ 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false && GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && - if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 + if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 then echo unexpected cvs success false @@ -261,21 +264,21 @@ rm -fr cvswork2 test_expect_success 'gitcvs.dbname' \ 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite && - GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 && test_cmp cvswork cvswork2 && - test -f "$SERVERDIR/gitcvs.ext.master.sqlite" && - cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs.ext.master.sqlite"' + test -f "$SERVERDIR/gitcvs.ext.main.sqlite" && + cmp "$SERVERDIR/gitcvs.main.sqlite" "$SERVERDIR/gitcvs.ext.main.sqlite"' rm -fr cvswork2 test_expect_success 'gitcvs.ext.dbname' \ 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite && GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite && - GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 && test_cmp cvswork cvswork2 && - test -f "$SERVERDIR/gitcvs1.ext.master.sqlite" && - test ! -f "$SERVERDIR/gitcvs2.ext.master.sqlite" && - cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs1.ext.master.sqlite"' + test -f "$SERVERDIR/gitcvs1.ext.main.sqlite" && + test ! -f "$SERVERDIR/gitcvs2.ext.main.sqlite" && + cmp "$SERVERDIR/gitcvs.main.sqlite" "$SERVERDIR/gitcvs1.ext.main.sqlite"' #------------ @@ -457,7 +460,7 @@ cd "$WORKDIR" test_expect_success 'cvs update (module list supports packed refs)' ' GIT_DIR="$SERVERDIR" git pack-refs --all && GIT_CONFIG="$git_config" cvs -n up -d 2> out && - grep "cvs update: New directory \`master'\''" < out + grep "cvs update: New directory \`main'\''" < out ' #------------ @@ -499,8 +502,8 @@ test_expect_success 'cvs status (no subdirs in header)' ' cd "$WORKDIR" test_expect_success 'cvs co -c (shows module database)' ' GIT_CONFIG="$git_config" cvs co -c > out && - grep "^master[ ][ ]*master$" <out && - ! grep -v "^master[ ][ ]*master$" <out + grep "^main[ ][ ]*main$" <out && + ! grep -v "^main[ ][ ]*main$" <out ' #------------ @@ -526,7 +529,7 @@ test_expect_success 'cvs co -c (shows module database)' ' sed -e 's/^x//' -e 's/SP$/ /' > "$WORKDIR/expect" <<EOF x -xRCS file: $WORKDIR/gitcvs.git/master/merge,v +xRCS file: $WORKDIR/gitcvs.git/main/merge,v xWorking file: merge xhead: 1.4 xbranch: diff --git a/t/t9401-git-cvsserver-crlf.sh b/t/t9401-git-cvsserver-crlf.sh index c7a0dd84a4..a34805acdc 100755 --- a/t/t9401-git-cvsserver-crlf.sh +++ b/t/t9401-git-cvsserver-crlf.sh @@ -9,6 +9,9 @@ test_description='git-cvsserver -kb modes tests -kb mode for binary files when accessing a git repository using cvs CLI client via git-cvsserver server' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh marked_as () { @@ -105,14 +108,14 @@ test_expect_success 'setup' ' ' test_expect_success 'cvs co (default crlf)' ' - GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork main >cvs.log 2>&1 && test x"$(grep '/-k' cvswork/CVS/Entries cvswork/subdir/CVS/Entries)" = x"" ' rm -rf cvswork test_expect_success 'cvs co (allbinary)' ' GIT_DIR="$SERVERDIR" git config --bool gitcvs.allbinary true && - GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork main >cvs.log 2>&1 && marked_as cvswork textfile.c -kb && marked_as cvswork binfile.bin -kb && marked_as cvswork .gitattributes -kb && @@ -125,7 +128,7 @@ test_expect_success 'cvs co (allbinary)' ' rm -rf cvswork cvs.log test_expect_success 'cvs co (use attributes/allbinary)' ' GIT_DIR="$SERVERDIR" git config --bool gitcvs.usecrlfattr true && - GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork main >cvs.log 2>&1 && marked_as cvswork textfile.c "" && marked_as cvswork binfile.bin -kb && marked_as cvswork .gitattributes -kb && @@ -138,7 +141,7 @@ test_expect_success 'cvs co (use attributes/allbinary)' ' rm -rf cvswork test_expect_success 'cvs co (use attributes)' ' GIT_DIR="$SERVERDIR" git config --bool gitcvs.allbinary false && - GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork main >cvs.log 2>&1 && marked_as cvswork textfile.c "" && marked_as cvswork binfile.bin -kb && marked_as cvswork .gitattributes "" && @@ -194,7 +197,7 @@ test_expect_success 'updating' ' rm -rf cvswork test_expect_success 'cvs co (use attributes/guess)' ' GIT_DIR="$SERVERDIR" git config gitcvs.allbinary guess && - GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork main >cvs.log 2>&1 && marked_as cvswork textfile.c "" && marked_as cvswork binfile.bin -kb && marked_as cvswork .gitattributes "" && @@ -224,7 +227,7 @@ test_expect_success 'setup multi-line files' ' rm -rf cvswork test_expect_success 'cvs co (guess)' ' GIT_DIR="$SERVERDIR" git config --bool gitcvs.usecrlfattr false && - GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork main >cvs.log 2>&1 && marked_as cvswork textfile.c "" && marked_as cvswork binfile.bin -kb && marked_as cvswork .gitattributes "" && @@ -239,7 +242,7 @@ test_expect_success 'cvs co (guess)' ' ' test_expect_success 'cvs co another copy (guess)' ' - GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 && marked_as cvswork2 textfile.c "" && marked_as cvswork2 binfile.bin -kb && marked_as cvswork2 .gitattributes "" && @@ -335,7 +338,7 @@ test_expect_success 'update subdir of other copy (guess)' ' echo "starting update/merge" >> "${WORKDIR}/marked.log" test_expect_success 'update/merge full other copy (guess)' ' - git pull gitcvs.git master && + git pull gitcvs.git main && sed "s/3/replaced_3/" < multilineTxt.c > ml.temp && mv ml.temp multilineTxt.c && git add multilineTxt.c && diff --git a/t/t9402-git-cvsserver-refs.sh b/t/t9402-git-cvsserver-refs.sh index 6436c91a3c..2ee41f9443 100755 --- a/t/t9402-git-cvsserver-refs.sh +++ b/t/t9402-git-cvsserver-refs.sh @@ -5,6 +5,9 @@ test_description='git-cvsserver and git refspecs tests ability for git-cvsserver to switch between and compare tags, branches and other git refspecs' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh ######### @@ -115,7 +118,7 @@ test_expect_success 'setup v1, b1' ' rm -rf cvswork test_expect_success 'cvs co v1' ' - cvs -f -Q co -r v1 -d cvswork master >cvs.log 2>&1 && + cvs -f -Q co -r v1 -d cvswork main >cvs.log 2>&1 && check_start_tree cvswork && check_file cvswork textfile.c v1 && check_file cvswork t2 v1 && @@ -128,7 +131,7 @@ test_expect_success 'cvs co v1' ' rm -rf cvswork test_expect_success 'cvs co b1' ' - cvs -f co -r b1 -d cvswork master >cvs.log 2>&1 && + cvs -f co -r b1 -d cvswork main >cvs.log 2>&1 && check_start_tree cvswork && check_file cvswork textfile.c v1 && check_file cvswork t2 v1 && @@ -140,7 +143,7 @@ test_expect_success 'cvs co b1' ' ' test_expect_success 'cvs co b1 [cvswork3]' ' - cvs -f co -r b1 -d cvswork3 master >cvs.log 2>&1 && + cvs -f co -r b1 -d cvswork3 main >cvs.log 2>&1 && check_start_tree cvswork3 && check_file cvswork3 textfile.c v1 && check_file cvswork3 t2 v1 && @@ -265,7 +268,7 @@ test_expect_success 'setup simple b2' ' ' test_expect_success 'cvs co b2 [into cvswork2]' ' - cvs -f co -r b2 -d cvswork2 master >cvs.log 2>&1 && + cvs -f co -r b2 -d cvswork2 main >cvs.log 2>&1 && check_start_tree cvswork && check_file cvswork textfile.c v1 && check_file cvswork t2 v1 && diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh index b484e3e250..0333065d4d 100755 --- a/t/t9500-gitweb-standalone-no-errors.sh +++ b/t/t9500-gitweb-standalone-no-errors.sh @@ -10,7 +10,10 @@ commandline, and checks that it would not write any errors or warnings to log.' -. ./gitweb-lib.sh +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + +. ./lib-gitweb.sh # ---------------------------------------------------------------------- # no commits (empty, just initialized repository) @@ -327,7 +330,7 @@ test_expect_success \ echo "Branch" >>b && git add b && git commit -a -m "On branch" && - git checkout master && + git checkout main && git merge b && git tag merge_commit' @@ -364,7 +367,7 @@ test_expect_success \ echo "Changed and have mode changed" >07-change-mode-change && test_chmod +x 07-change-mode-change && git commit -a -m "Large commit" && - git checkout master' + git checkout main' test_expect_success \ 'commit(1): large commit' \ @@ -402,7 +405,7 @@ test_expect_success 'side-by-side: merge commit' ' test_expect_success \ 'tags: list of different types of tags' \ - 'git checkout master && + 'git checkout main && git tag -a -m "Tag commit object" tag-commit HEAD && git tag -a -m "" tag-commit-nomessage HEAD && git tag -a -m "Tag tag object" tag-tag tag-commit && @@ -443,7 +446,7 @@ test_expect_success \ test_expect_success \ 'logs: history (implicit HEAD, deleted file)' \ - 'git checkout master && + 'git checkout main && echo "to be deleted" >deleted_file && git add deleted_file && git commit -m "Add file to be deleted" && @@ -463,11 +466,11 @@ test_expect_success \ test_expect_success \ 'path_info: project/branch:file' \ - 'gitweb_run "" "/.git/master:file"' + 'gitweb_run "" "/.git/main:file"' test_expect_success \ 'path_info: project/branch:dir/' \ - 'gitweb_run "" "/.git/master:foo/"' + 'gitweb_run "" "/.git/main:foo/"' test_expect_success \ 'path_info: project/branch (non-existent)' \ @@ -479,16 +482,16 @@ test_expect_success \ test_expect_success \ 'path_info: project/branch:file (non-existent)' \ - 'gitweb_run "" "/.git/master:non-existent"' + 'gitweb_run "" "/.git/main:non-existent"' test_expect_success \ 'path_info: project/branch:dir/ (non-existent)' \ - 'gitweb_run "" "/.git/master:non-existent/"' + 'gitweb_run "" "/.git/main:non-existent/"' test_expect_success \ 'path_info: project/branch:/file' \ - 'gitweb_run "" "/.git/master:/file"' + 'gitweb_run "" "/.git/main:/file"' test_expect_success \ 'path_info: project/:/file (implicit HEAD)' \ @@ -801,7 +804,7 @@ test_expect_success \ git checkout orphan_branch || git checkout --orphan orphan_branch } && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && gitweb_run "p=.git;a=summary"' test_done diff --git a/t/t9501-gitweb-standalone-http-status.sh b/t/t9501-gitweb-standalone-http-status.sh index 2a0ffed870..32814e75df 100755 --- a/t/t9501-gitweb-standalone-http-status.sh +++ b/t/t9501-gitweb-standalone-http-status.sh @@ -10,7 +10,10 @@ commandline, and checks that it returns the expected HTTP status code and message.' -. ./gitweb-lib.sh +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + +. ./lib-gitweb.sh # # Gitweb only provides the functionality tested by the 'modification times' @@ -85,7 +88,7 @@ test_debug 'cat gitweb.headers' # snapshot hash ids test_expect_success 'snapshots: good tree-ish id' ' - gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && + gitweb_run "p=.git;a=snapshot;h=main;sf=tgz" && grep "Status: 200 OK" gitweb.output ' test_debug 'cat gitweb.headers' @@ -123,7 +126,7 @@ test_debug 'cat gitweb.output' # modification times (Last-Modified and If-Modified-Since) test_expect_success DATE_PARSER 'modification: feed last-modified' ' - gitweb_run "p=.git;a=atom;h=master" && + gitweb_run "p=.git;a=atom;h=main" && grep "Status: 200 OK" gitweb.headers && grep "Last-modified: Thu, 7 Apr 2005 22:14:13 +0000" gitweb.headers ' @@ -133,7 +136,7 @@ test_expect_success DATE_PARSER 'modification: feed if-modified-since (modified) HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" && export HTTP_IF_MODIFIED_SINCE && test_when_finished "unset HTTP_IF_MODIFIED_SINCE" && - gitweb_run "p=.git;a=atom;h=master" && + gitweb_run "p=.git;a=atom;h=main" && grep "Status: 200 OK" gitweb.headers ' test_debug 'cat gitweb.headers' @@ -142,13 +145,13 @@ test_expect_success DATE_PARSER 'modification: feed if-modified-since (unmodifie HTTP_IF_MODIFIED_SINCE="Thu, 7 Apr 2005 22:14:13 +0000" && export HTTP_IF_MODIFIED_SINCE && test_when_finished "unset HTTP_IF_MODIFIED_SINCE" && - gitweb_run "p=.git;a=atom;h=master" && + gitweb_run "p=.git;a=atom;h=main" && grep "Status: 304 Not Modified" gitweb.headers ' test_debug 'cat gitweb.headers' test_expect_success DATE_PARSER 'modification: snapshot last-modified' ' - gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && + gitweb_run "p=.git;a=snapshot;h=main;sf=tgz" && grep "Status: 200 OK" gitweb.headers && grep "Last-modified: Thu, 7 Apr 2005 22:14:13 +0000" gitweb.headers ' @@ -158,7 +161,7 @@ test_expect_success DATE_PARSER 'modification: snapshot if-modified-since (modif HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" && export HTTP_IF_MODIFIED_SINCE && test_when_finished "unset HTTP_IF_MODIFIED_SINCE" && - gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && + gitweb_run "p=.git;a=snapshot;h=main;sf=tgz" && grep "Status: 200 OK" gitweb.headers ' test_debug 'cat gitweb.headers' @@ -167,7 +170,7 @@ test_expect_success DATE_PARSER 'modification: snapshot if-modified-since (unmod HTTP_IF_MODIFIED_SINCE="Thu, 7 Apr 2005 22:14:13 +0000" && export HTTP_IF_MODIFIED_SINCE && test_when_finished "unset HTTP_IF_MODIFIED_SINCE" && - gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && + gitweb_run "p=.git;a=snapshot;h=main;sf=tgz" && grep "Status: 304 Not Modified" gitweb.headers ' test_debug 'cat gitweb.headers' diff --git a/t/t9502-gitweb-standalone-parse-output.sh b/t/t9502-gitweb-standalone-parse-output.sh index e38cbc97d3..3167473b30 100755 --- a/t/t9502-gitweb-standalone-parse-output.sh +++ b/t/t9502-gitweb-standalone-parse-output.sh @@ -10,7 +10,10 @@ commandline, and checks that it produces the correct output, either in the HTTP header or the actual script output.' -. ./gitweb-lib.sh +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + +. ./lib-gitweb.sh # ---------------------------------------------------------------------- # snapshot file name and prefix @@ -79,10 +82,10 @@ test_expect_success 'snapshot: HEAD' ' ' test_debug 'cat gitweb.headers && cat file_list' -test_expect_success 'snapshot: short branch name (master)' ' - gitweb_run "p=.git;a=snapshot;h=master;sf=tar" && - ID=$(git rev-parse --verify --short=7 master) && - check_snapshot ".git-master-$ID" +test_expect_success 'snapshot: short branch name (main)' ' + gitweb_run "p=.git;a=snapshot;h=main;sf=tar" && + ID=$(git rev-parse --verify --short=7 main) && + check_snapshot ".git-main-$ID" ' test_debug 'cat gitweb.headers && cat file_list' @@ -93,10 +96,10 @@ test_expect_success 'snapshot: short tag name (first)' ' ' test_debug 'cat gitweb.headers && cat file_list' -test_expect_success 'snapshot: full branch name (refs/heads/master)' ' - gitweb_run "p=.git;a=snapshot;h=refs/heads/master;sf=tar" && - ID=$(git rev-parse --verify --short=7 master) && - check_snapshot ".git-master-$ID" +test_expect_success 'snapshot: full branch name (refs/heads/main)' ' + gitweb_run "p=.git;a=snapshot;h=refs/heads/main;sf=tar" && + ID=$(git rev-parse --verify --short=7 main) && + check_snapshot ".git-main-$ID" ' test_debug 'cat gitweb.headers && cat file_list' diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh index 251fdd66c4..5680849218 100755 --- a/t/t9600-cvsimport.sh +++ b/t/t9600-cvsimport.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='git cvsimport basic tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-cvs.sh if ! test_have_prereq NOT_ROOT; then @@ -159,6 +162,6 @@ test_expect_success PERL 'no .git/cvs-revisions created by default' ' ' -test_expect_success PERL 'test entire HEAD' 'test_cmp_branch_tree master' +test_expect_success PERL 'test entire HEAD' 'test_cmp_branch_tree main' test_done diff --git a/t/t9601-cvsimport-vendor-branch.sh b/t/t9601-cvsimport-vendor-branch.sh index 827d39f5bf..116cddba3a 100755 --- a/t/t9601-cvsimport-vendor-branch.sh +++ b/t/t9601-cvsimport-vendor-branch.sh @@ -32,6 +32,9 @@ # tag has been removed. test_description='git cvsimport handling of vendor branches' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-cvs.sh setup_cvs_test_repository t9601 @@ -42,43 +45,43 @@ test_expect_success PERL 'import a module with a vendor branch' ' ' -test_expect_success PERL 'check HEAD out of cvs repository' 'test_cvs_co master' +test_expect_success PERL 'check HEAD out of cvs repository' 'test_cvs_co main' -test_expect_success PERL 'check master out of git repository' 'test_git_co master' +test_expect_success PERL 'check main out of git repository' 'test_git_co main' test_expect_success PERL 'check a file that was imported once' ' - test_cmp_branch_file master imported-once.txt + test_cmp_branch_file main imported-once.txt ' test_expect_failure PERL 'check a file that was imported twice' ' - test_cmp_branch_file master imported-twice.txt + test_cmp_branch_file main imported-twice.txt ' test_expect_success PERL 'check a file that was imported then modified on HEAD' ' - test_cmp_branch_file master imported-modified.txt + test_cmp_branch_file main imported-modified.txt ' test_expect_success PERL 'check a file that was imported, modified, then imported again' ' - test_cmp_branch_file master imported-modified-imported.txt + test_cmp_branch_file main imported-modified-imported.txt ' test_expect_success PERL 'check a file that was added to HEAD then imported' ' - test_cmp_branch_file master added-imported.txt + test_cmp_branch_file main added-imported.txt ' test_expect_success PERL 'a vendor branch whose tag has been removed' ' - test_cmp_branch_file master imported-anonymously.txt + test_cmp_branch_file main imported-anonymously.txt ' diff --git a/t/t9602-cvsimport-branches-tags.sh b/t/t9602-cvsimport-branches-tags.sh index e1db323f54..e5266c9a87 100755 --- a/t/t9602-cvsimport-branches-tags.sh +++ b/t/t9602-cvsimport-branches-tags.sh @@ -4,6 +4,9 @@ # t9602/README. test_description='git cvsimport handling of branches and tags' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-cvs.sh setup_cvs_test_repository t9602 @@ -14,9 +17,9 @@ test_expect_success PERL 'import module' ' ' -test_expect_success PERL 'test branch master' ' +test_expect_success PERL 'test branch main' ' - test_cmp_branch_tree master + test_cmp_branch_tree main ' diff --git a/t/t9603-cvsimport-patchsets.sh b/t/t9603-cvsimport-patchsets.sh index e7a91611dc..0e9daa5768 100755 --- a/t/t9603-cvsimport-patchsets.sh +++ b/t/t9603-cvsimport-patchsets.sh @@ -12,6 +12,9 @@ # bug. test_description='git cvsimport testing for correct patchset estimation' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-cvs.sh setup_cvs_test_repository t9603 @@ -20,16 +23,16 @@ test_expect_failure PERL 'import with criss cross times on revisions' ' git cvsimport -p"-x" -C module-git module && ( cd module-git && - git log --pretty=format:%s > ../actual-master && + git log --pretty=format:%s > ../actual-main && git log A~2..A --pretty="format:%s %ad" -- > ../actual-A && - echo "" >> ../actual-master && + echo "" >> ../actual-main && echo "" >> ../actual-A ) && echo "Rev 4 Rev 3 Rev 2 -Rev 1" > expect-master && - test_cmp expect-master actual-master && +Rev 1" > expect-main && + test_cmp expect-main actual-main && echo "Rev 5 Branch A Wed Mar 11 19:09:10 2009 +0000 Rev 4 Branch A Wed Mar 11 19:03:52 2009 +0000" > expect-A && diff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh index c98c1dfc23..81bc8e8da1 100755 --- a/t/t9800-git-p4-basic.sh +++ b/t/t9800-git-p4-basic.sh @@ -2,6 +2,9 @@ test_description='git p4 tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-git-p4.sh test_expect_success 'start p4d' ' @@ -226,7 +229,7 @@ test_expect_success 'clone --bare should make a bare repository' ' git config --get --bool core.bare true && git rev-parse --verify refs/remotes/p4/master && git rev-parse --verify refs/remotes/p4/HEAD && - git rev-parse --verify refs/heads/master && + git rev-parse --verify refs/heads/main && git rev-parse --verify HEAD ) ' diff --git a/t/t9801-git-p4-branch.sh b/t/t9801-git-p4-branch.sh index a3abd778f9..50a6f8bad5 100755 --- a/t/t9801-git-p4-branch.sh +++ b/t/t9801-git-p4-branch.sh @@ -2,6 +2,9 @@ test_description='git p4 tests for p4 branches' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-git-p4.sh test_expect_success 'start p4d' ' @@ -67,7 +70,7 @@ test_expect_success 'import main, no branch detection' ' ( cd "$git" && git log --oneline --graph --decorate --all && - git rev-list master -- >wc && + git rev-list main -- >wc && test_line_count = 4 wc ) ' @@ -78,7 +81,7 @@ test_expect_success 'import branch1, no branch detection' ' ( cd "$git" && git log --oneline --graph --decorate --all && - git rev-list master -- >wc && + git rev-list main -- >wc && test_line_count = 2 wc ) ' @@ -89,7 +92,7 @@ test_expect_success 'import branch2, no branch detection' ' ( cd "$git" && git log --oneline --graph --decorate --all && - git rev-list master -- >wc && + git rev-list main -- >wc && test_line_count = 2 wc ) ' @@ -100,7 +103,7 @@ test_expect_success 'import depot, no branch detection' ' ( cd "$git" && git log --oneline --graph --decorate --all && - git rev-list master -- >wc && + git rev-list main -- >wc && test_line_count = 8 wc ) ' @@ -114,7 +117,7 @@ test_expect_success 'import depot, branch detection' ' git log --oneline --graph --decorate --all && # 4 main commits - git rev-list master -- >wc && + git rev-list main -- >wc && test_line_count = 4 wc && # 3 main, 1 integrate, 1 on branch2 @@ -137,7 +140,7 @@ test_expect_success 'import depot, branch detection, branchList branch definitio git log --oneline --graph --decorate --all && # 4 main commits - git rev-list master -- >wc && + git rev-list main -- >wc && test_line_count = 4 wc && # 3 main, 1 integrate, 1 on branch2 @@ -200,19 +203,19 @@ test_expect_success 'git p4 clone simple branches' ' git p4 clone --dest=. --detect-branches //depot@all && git log --all --graph --decorate --stat && git reset --hard p4/depot/branch1 && - test -f file1 && - test -f file2 && - test -f file3 && + test_path_is_file file1 && + test_path_is_file file2 && + test_path_is_file file3 && grep update file2 && git reset --hard p4/depot/branch2 && - test -f file1 && - test -f file2 && + test_path_is_file file1 && + test_path_is_file file2 && test ! -f file3 && ! grep update file2 && git reset --hard p4/depot/branch3 && - test -f file1 && - test -f file2 && - test -f file3 && + test_path_is_file file1 && + test_path_is_file file2 && + test_path_is_file file3 && grep update file2 && cd "$cli" && cd branch1 && @@ -291,11 +294,13 @@ test_expect_success 'git p4 clone complex branches' ' test_path_is_file file3 && grep update file2 && git reset --hard p4/depot/branch4 && + git diff-tree --quiet HEAD && test_path_is_file file1 && test_path_is_file file2 && test_path_is_missing file3 && ! grep update file2 && git reset --hard p4/depot/branch5 && + git diff-tree --quiet HEAD && test_path_is_file file1 && test_path_is_file file2 && test_path_is_file file3 && @@ -484,7 +489,7 @@ test_expect_success 'use-client-spec detect-branches files in top-level' ' ( cd "$git" && git p4 sync --detect-branches --use-client-spec //depot/usecs@all && - git checkout -b master p4/usecs/b1 && + git checkout -b main p4/usecs/b1 && test_path_is_file b1-file1 && test_path_is_missing b2-file2 && test_path_is_missing b1 && @@ -537,7 +542,7 @@ test_expect_success 'use-client-spec detect-branches skips files in branches' ' ( cd "$git" && git p4 sync --detect-branches --use-client-spec //depot/usecs@all && - git checkout -b master p4/usecs/b3 && + git checkout -b main p4/usecs/b3 && test_path_is_file b1-file1 && test_path_is_file b3-file3_2 && test_path_is_missing b3-file3_1 @@ -603,22 +608,22 @@ test_expect_success 'git p4 clone simple branches with base folder on server sid git p4 clone --dest=. --use-client-spec --detect-branches //depot@all && git log --all --graph --decorate --stat && git reset --hard p4/depot/branch1 && - test -f file1 && - test -f file2 && - test -f file3 && - test -f sub_file1 && + test_path_is_file file1 && + test_path_is_file file2 && + test_path_is_file file3 && + test_path_is_file sub_file1 && grep update file2 && git reset --hard p4/depot/branch2 && - test -f file1 && - test -f file2 && + test_path_is_file file1 && + test_path_is_file file2 && test ! -f file3 && - test -f sub_file1 && + test_path_is_file sub_file1 && ! grep update file2 && git reset --hard p4/depot/branch3 && - test -f file1 && - test -f file2 && - test -f file3 && - test -f sub_file1 && + test_path_is_file file1 && + test_path_is_file file2 && + test_path_is_file file3 && + test_path_is_file sub_file1 && grep update file2 && cd "$cli" && cd branch1 && diff --git a/t/t9806-git-p4-options.sh b/t/t9806-git-p4-options.sh index 4e794a01bf..c26d297433 100755 --- a/t/t9806-git-p4-options.sh +++ b/t/t9806-git-p4-options.sh @@ -2,6 +2,9 @@ test_description='git p4 options' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-git-p4.sh test_expect_success 'start p4d' ' @@ -27,14 +30,14 @@ test_expect_success 'clone no --git-dir' ' test_must_fail git p4 clone --git-dir=xx //depot ' -test_expect_success 'clone --branch should checkout master' ' +test_expect_success 'clone --branch should checkout main' ' git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot && test_when_finished cleanup_git && ( cd "$git" && git rev-parse refs/remotes/p4/sb >sb && - git rev-parse refs/heads/master >master && - test_cmp sb master && + git rev-parse refs/heads/main >main && + test_cmp sb main && git rev-parse HEAD >head && test_cmp sb head ) @@ -147,22 +150,22 @@ test_expect_success 'clone --changesfile, @all' ' test_must_fail git p4 clone --changesfile="$TRASH_DIRECTORY/cf" --dest="$git" //depot@all ' -# imports both master and p4/master in refs/heads +# imports both main and p4/master in refs/heads # requires --import-local on sync to find p4 refs/heads -# does not update master on sync, just p4/master +# does not update main on sync, just p4/master test_expect_success 'clone/sync --import-local' ' git p4 clone --import-local --dest="$git" //depot@1,2 && test_when_finished cleanup_git && ( cd "$git" && - git log --oneline refs/heads/master >lines && + git log --oneline refs/heads/main >lines && test_line_count = 2 lines && git log --oneline refs/heads/p4/master >lines && test_line_count = 2 lines && test_must_fail git p4 sync && git p4 sync --import-local && - git log --oneline refs/heads/master >lines && + git log --oneline refs/heads/main >lines && test_line_count = 2 lines && git log --oneline refs/heads/p4/master >lines && test_line_count = 3 lines @@ -174,7 +177,7 @@ test_expect_success 'clone --max-changes' ' test_when_finished cleanup_git && ( cd "$git" && - git log --oneline refs/heads/master >lines && + git log --oneline refs/heads/main >lines && test_line_count = 2 lines ) ' @@ -237,7 +240,7 @@ test_expect_success 'clone --use-client-spec' ' git init && git config git-p4.useClientSpec true && git p4 sync //depot/... && - git checkout -b master p4/master && + git checkout -b main p4/master && test_path_is_file bus/dir/f4 && test_path_is_missing file1 ) diff --git a/t/t9807-git-p4-submit.sh b/t/t9807-git-p4-submit.sh index eaaae414a1..7d4109f29d 100755 --- a/t/t9807-git-p4-submit.sh +++ b/t/t9807-git-p4-submit.sh @@ -2,6 +2,9 @@ test_description='git p4 submit' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-git-p4.sh test_expect_success 'start p4d' ' @@ -114,7 +117,7 @@ test_expect_success 'submit with allowSubmit' ' git config git-p4.skipSubmitEdit true && git config git-p4.allowSubmit "nobranch" && test_must_fail git p4 submit && - git config git-p4.allowSubmit "nobranch,master" && + git config git-p4.allowSubmit "nobranch,main" && git p4 submit ) ' diff --git a/t/t9811-git-p4-label-import.sh b/t/t9811-git-p4-label-import.sh index c1446f26ab..5ac5383fb7 100755 --- a/t/t9811-git-p4-label-import.sh +++ b/t/t9811-git-p4-label-import.sh @@ -2,6 +2,9 @@ test_description='git p4 label tests' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-git-p4.sh test_expect_success 'start p4d' ' @@ -185,7 +188,7 @@ test_expect_success 'tag that cannot be exported' ' git add main/f12 && git commit -m "adding f12" && git tag -m "tag on a_branch" GIT_TAG_ON_A_BRANCH && - git checkout master && + git checkout main && git p4 submit --export-labels ) && ( diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index a1c4f1f6d4..cb057ef161 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -5,6 +5,9 @@ test_description='test bash completion' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-bash.sh complete () @@ -1876,6 +1879,7 @@ test_expect_success '__git_find_on_cmdline - single match' ' ( words=(git command --opt list) && cword=${#words[@]} && + __git_cmd_idx=1 && __git_find_on_cmdline "add list remove" >actual ) && test_cmp expect actual @@ -1886,6 +1890,7 @@ test_expect_success '__git_find_on_cmdline - multiple matches' ' ( words=(git command -o --opt remove list add) && cword=${#words[@]} && + __git_cmd_idx=1 && __git_find_on_cmdline "add list remove" >actual ) && test_cmp expect actual @@ -1895,6 +1900,7 @@ test_expect_success '__git_find_on_cmdline - no match' ' ( words=(git command --opt branch) && cword=${#words[@]} && + __git_cmd_idx=1 && __git_find_on_cmdline "add list remove" >actual ) && test_must_be_empty actual @@ -1905,6 +1911,7 @@ test_expect_success '__git_find_on_cmdline - single match with index' ' ( words=(git command --opt list) && cword=${#words[@]} && + __git_cmd_idx=1 && __git_find_on_cmdline --show-idx "add list remove" >actual ) && test_cmp expect actual @@ -1915,6 +1922,7 @@ test_expect_success '__git_find_on_cmdline - multiple matches with index' ' ( words=(git command -o --opt remove list add) && cword=${#words[@]} && + __git_cmd_idx=1 && __git_find_on_cmdline --show-idx "add list remove" >actual ) && test_cmp expect actual @@ -1924,11 +1932,23 @@ test_expect_success '__git_find_on_cmdline - no match with index' ' ( words=(git command --opt branch) && cword=${#words[@]} && + __git_cmd_idx=1 && __git_find_on_cmdline --show-idx "add list remove" >actual ) && test_must_be_empty actual ' +test_expect_success '__git_find_on_cmdline - ignores matches before command with index' ' + echo "6 remove" >expect && + ( + words=(git -C remove command -o --opt remove list add) && + cword=${#words[@]} && + __git_cmd_idx=3 && + __git_find_on_cmdline --show-idx "add list remove" >actual + ) && + test_cmp expect actual +' + test_expect_success '__git_get_config_variables' ' cat >expect <<-EOF && name-1 @@ -2272,6 +2292,7 @@ do ( words=(git push '$flag' other ma) && cword=${#words[@]} cur=${words[cword-1]} && + __git_cmd_idx=1 && __git_complete_remote_or_refspec && print_comp ) && @@ -2285,6 +2306,7 @@ do ( words=(git push other '$flag' ma) && cword=${#words[@]} cur=${words[cword-1]} && + __git_cmd_idx=1 && __git_complete_remote_or_refspec && print_comp ) && @@ -2303,6 +2325,7 @@ test_expect_success 'git config - variable name' ' test_completion "git config log.d" <<-\EOF log.date Z log.decorate Z + log.diffMerges Z EOF ' @@ -2324,6 +2347,7 @@ test_expect_success 'git -c - variable name' ' test_completion "git -c log.d" <<-\EOF log.date=Z log.decorate=Z + log.diffMerges=Z EOF ' @@ -2345,6 +2369,7 @@ test_expect_success 'git clone --config= - variable name' ' test_completion "git clone --config=log.d" <<-\EOF log.date=Z log.decorate=Z + log.diffMerges=Z EOF ' @@ -2363,7 +2388,6 @@ test_expect_success 'sourcing the completion script clears cached commands' ' ' test_expect_success 'sourcing the completion script clears cached merge strategies' ' - GIT_TEST_GETTEXT_POISON=false && __git_compute_merge_strategies && verbose test -n "$__git_merge_strategies" && . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" && @@ -2380,4 +2404,24 @@ test_expect_success 'sourcing the completion script clears cached --options' ' verbose test -z "$__gitcomp_builtin_notes_edit" ' +test_expect_success '__git_complete' ' + unset -f __git_wrap__git_main && + + __git_complete foo __git_main && + __git_have_func __git_wrap__git_main && + unset -f __git_wrap__git_main && + + __git_complete gf _git_fetch && + __git_have_func __git_wrap_git_fetch && + + __git_complete foo git && + __git_have_func __git_wrap__git_main && + unset -f __git_wrap__git_main && + + __git_complete gd git_diff && + __git_have_func __git_wrap_git_diff && + + test_must_fail __git_complete ga missing +' + test_done diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh index ab5da2cabc..bbd513bab0 100755 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@ -5,6 +5,9 @@ test_description='test git-specific bash prompt functions' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./lib-bash.sh . "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh" @@ -28,7 +31,7 @@ test_expect_success 'setup for prompt tests' ' echo 3 >file && git commit -m "third b1" file && git tag -a -m msg2 t2 && - git checkout -b b2 master && + git checkout -b b2 main && echo 0 >file && git commit -m "second b2" file && echo 00 >file && @@ -37,20 +40,20 @@ test_expect_success 'setup for prompt tests' ' git commit -m "yet another b2" file && mkdir ignored_dir && echo "ignored_dir/" >>.gitignore && - git checkout master + git checkout main ' test_expect_success 'prompt - branch name' ' - printf " (master)" >expected && + printf " (main)" >expected && __git_ps1 >"$actual" && test_cmp expected "$actual" ' test_expect_success SYMLINKS 'prompt - branch name - symlink symref' ' - printf " (master)" >expected && - test_when_finished "git checkout master" && + printf " (main)" >expected && + test_when_finished "git checkout main" && test_config core.preferSymlinkRefs true && - git checkout master && + git checkout main && __git_ps1 >"$actual" && test_cmp expected "$actual" ' @@ -58,7 +61,7 @@ test_expect_success SYMLINKS 'prompt - branch name - symlink symref' ' test_expect_success 'prompt - unborn branch' ' printf " (unborn)" >expected && git checkout --orphan unborn && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && __git_ps1 >"$actual" && test_cmp expected "$actual" ' @@ -72,7 +75,7 @@ test_expect_success FUNNYNAMES 'prompt - with newline in path' ' with newline" && mkdir "$repo_with_newline" && - printf " (master)" >expected && + printf " (main)" >expected && git init "$repo_with_newline" && test_when_finished "rm -rf \"$repo_with_newline\"" && mkdir "$repo_with_newline"/subdir && @@ -87,7 +90,7 @@ test_expect_success 'prompt - detached head' ' printf " ((%s...))" $(git log -1 --format="%h" --abbrev=13 b1^) >expected && test_config core.abbrev 13 && git checkout b1^ && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && __git_ps1 >"$actual" && test_cmp expected "$actual" ' @@ -95,7 +98,7 @@ test_expect_success 'prompt - detached head' ' test_expect_success 'prompt - describe detached head - contains' ' printf " ((t2~1))" >expected && git checkout b1^ && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && ( GIT_PS1_DESCRIBE_STYLE=contains && __git_ps1 >"$actual" @@ -106,7 +109,7 @@ test_expect_success 'prompt - describe detached head - contains' ' test_expect_success 'prompt - describe detached head - branch' ' printf " ((tags/t2~1))" >expected && git checkout b1^ && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && ( GIT_PS1_DESCRIBE_STYLE=branch && __git_ps1 >"$actual" @@ -117,7 +120,7 @@ test_expect_success 'prompt - describe detached head - branch' ' test_expect_success 'prompt - describe detached head - describe' ' printf " ((t1-1-g%s))" $(git log -1 --format="%h" b1^) >expected && git checkout b1^ && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && ( GIT_PS1_DESCRIBE_STYLE=describe && __git_ps1 >"$actual" @@ -128,7 +131,7 @@ test_expect_success 'prompt - describe detached head - describe' ' test_expect_success 'prompt - describe detached head - default' ' printf " ((t2))" >expected && git checkout --detach b1 && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && __git_ps1 >"$actual" && test_cmp expected "$actual" ' @@ -152,7 +155,7 @@ test_expect_success 'prompt - deep inside .git directory' ' ' test_expect_success 'prompt - inside bare repository' ' - printf " (BARE:master)" >expected && + printf " (BARE:main)" >expected && git init --bare bare.git && test_when_finished "rm -rf bare.git" && ( @@ -172,7 +175,7 @@ test_expect_success 'prompt - interactive rebase' ' test_when_finished "rm -f fake_editor.sh" && test_set_editor "$TRASH_DIRECTORY/fake_editor.sh" && git checkout b1 && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && git rebase -i HEAD^ && test_when_finished "git rebase --abort" && __git_ps1 >"$actual" && @@ -182,7 +185,7 @@ test_expect_success 'prompt - interactive rebase' ' test_expect_success 'prompt - rebase merge' ' printf " (b2|REBASE 1/3)" >expected && git checkout b2 && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && test_must_fail git rebase --merge b1 b2 && test_when_finished "git rebase --abort" && __git_ps1 >"$actual" && @@ -192,7 +195,7 @@ test_expect_success 'prompt - rebase merge' ' test_expect_success 'prompt - rebase am' ' printf " (b2|REBASE 1/3)" >expected && git checkout b2 && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && test_must_fail git rebase --apply b1 b2 && test_when_finished "git rebase --abort" && __git_ps1 >"$actual" && @@ -202,7 +205,7 @@ test_expect_success 'prompt - rebase am' ' test_expect_success 'prompt - merge' ' printf " (b1|MERGING)" >expected && git checkout b1 && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && test_must_fail git merge b2 && test_when_finished "git reset --hard" && __git_ps1 >"$actual" && @@ -210,7 +213,7 @@ test_expect_success 'prompt - merge' ' ' test_expect_success 'prompt - cherry-pick' ' - printf " (master|CHERRY-PICKING)" >expected && + printf " (main|CHERRY-PICKING)" >expected && test_must_fail git cherry-pick b1 b1^ && test_when_finished "git cherry-pick --abort" && __git_ps1 >"$actual" && @@ -222,7 +225,7 @@ test_expect_success 'prompt - cherry-pick' ' ' test_expect_success 'prompt - revert' ' - printf " (master|REVERTING)" >expected && + printf " (main|REVERTING)" >expected && test_must_fail git revert b1^ b1 && test_when_finished "git revert --abort" && __git_ps1 >"$actual" && @@ -234,7 +237,7 @@ test_expect_success 'prompt - revert' ' ' test_expect_success 'prompt - bisect' ' - printf " (master|BISECTING)" >expected && + printf " (main|BISECTING)" >expected && git bisect start && test_when_finished "git bisect reset" && __git_ps1 >"$actual" && @@ -242,7 +245,7 @@ test_expect_success 'prompt - bisect' ' ' test_expect_success 'prompt - dirty status indicator - clean' ' - printf " (master)" >expected && + printf " (main)" >expected && ( GIT_PS1_SHOWDIRTYSTATE=y && __git_ps1 >"$actual" @@ -251,7 +254,7 @@ test_expect_success 'prompt - dirty status indicator - clean' ' ' test_expect_success 'prompt - dirty status indicator - dirty worktree' ' - printf " (master *)" >expected && + printf " (main *)" >expected && echo "dirty" >file && test_when_finished "git reset --hard" && ( @@ -262,7 +265,7 @@ test_expect_success 'prompt - dirty status indicator - dirty worktree' ' ' test_expect_success 'prompt - dirty status indicator - dirty index' ' - printf " (master +)" >expected && + printf " (main +)" >expected && echo "dirty" >file && test_when_finished "git reset --hard" && git add -u && @@ -274,7 +277,7 @@ test_expect_success 'prompt - dirty status indicator - dirty index' ' ' test_expect_success 'prompt - dirty status indicator - dirty index and worktree' ' - printf " (master *+)" >expected && + printf " (main *+)" >expected && echo "dirty index" >file && test_when_finished "git reset --hard" && git add -u && @@ -288,7 +291,7 @@ test_expect_success 'prompt - dirty status indicator - dirty index and worktree' test_expect_success 'prompt - dirty status indicator - orphan branch - clean' ' printf " (orphan #)" >expected && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && git checkout --orphan orphan && git reset --hard && ( @@ -300,7 +303,7 @@ test_expect_success 'prompt - dirty status indicator - orphan branch - clean' ' test_expect_success 'prompt - dirty status indicator - orphan branch - dirty index' ' printf " (orphan +)" >expected && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && git checkout --orphan orphan && ( GIT_PS1_SHOWDIRTYSTATE=y && @@ -311,7 +314,7 @@ test_expect_success 'prompt - dirty status indicator - orphan branch - dirty ind test_expect_success 'prompt - dirty status indicator - orphan branch - dirty index and worktree' ' printf " (orphan *+)" >expected && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && git checkout --orphan orphan && >file && ( @@ -322,7 +325,7 @@ test_expect_success 'prompt - dirty status indicator - orphan branch - dirty ind ' test_expect_success 'prompt - dirty status indicator - shell variable unset with config disabled' ' - printf " (master)" >expected && + printf " (main)" >expected && echo "dirty" >file && test_when_finished "git reset --hard" && test_config bash.showDirtyState false && @@ -334,7 +337,7 @@ test_expect_success 'prompt - dirty status indicator - shell variable unset with ' test_expect_success 'prompt - dirty status indicator - shell variable unset with config enabled' ' - printf " (master)" >expected && + printf " (main)" >expected && echo "dirty" >file && test_when_finished "git reset --hard" && test_config bash.showDirtyState true && @@ -346,7 +349,7 @@ test_expect_success 'prompt - dirty status indicator - shell variable unset with ' test_expect_success 'prompt - dirty status indicator - shell variable set with config disabled' ' - printf " (master)" >expected && + printf " (main)" >expected && echo "dirty" >file && test_when_finished "git reset --hard" && test_config bash.showDirtyState false && @@ -358,7 +361,7 @@ test_expect_success 'prompt - dirty status indicator - shell variable set with c ' test_expect_success 'prompt - dirty status indicator - shell variable set with config enabled' ' - printf " (master *)" >expected && + printf " (main *)" >expected && echo "dirty" >file && test_when_finished "git reset --hard" && test_config bash.showDirtyState true && @@ -382,7 +385,7 @@ test_expect_success 'prompt - dirty status indicator - not shown inside .git dir ' test_expect_success 'prompt - stash status indicator - no stash' ' - printf " (master)" >expected && + printf " (main)" >expected && ( GIT_PS1_SHOWSTASHSTATE=y && __git_ps1 >"$actual" @@ -391,7 +394,7 @@ test_expect_success 'prompt - stash status indicator - no stash' ' ' test_expect_success 'prompt - stash status indicator - stash' ' - printf " (master $)" >expected && + printf " (main $)" >expected && echo 2 >file && git stash && test_when_finished "git stash drop" && @@ -417,7 +420,7 @@ test_expect_success 'prompt - stash status indicator - not shown inside .git dir ' test_expect_success 'prompt - untracked files status indicator - no untracked files' ' - printf " (master)" >expected && + printf " (main)" >expected && ( GIT_PS1_SHOWUNTRACKEDFILES=y && cd otherrepo && @@ -427,7 +430,7 @@ test_expect_success 'prompt - untracked files status indicator - no untracked fi ' test_expect_success 'prompt - untracked files status indicator - untracked files' ' - printf " (master %%)" >expected && + printf " (main %%)" >expected && ( GIT_PS1_SHOWUNTRACKEDFILES=y && __git_ps1 >"$actual" @@ -436,7 +439,7 @@ test_expect_success 'prompt - untracked files status indicator - untracked files ' test_expect_success 'prompt - untracked files status indicator - empty untracked dir' ' - printf " (master)" >expected && + printf " (main)" >expected && mkdir otherrepo/untracked-dir && test_when_finished "rm -rf otherrepo/untracked-dir" && ( @@ -448,7 +451,7 @@ test_expect_success 'prompt - untracked files status indicator - empty untracked ' test_expect_success 'prompt - untracked files status indicator - non-empty untracked dir' ' - printf " (master %%)" >expected && + printf " (main %%)" >expected && mkdir otherrepo/untracked-dir && test_when_finished "rm -rf otherrepo/untracked-dir" && >otherrepo/untracked-dir/untracked-file && @@ -461,7 +464,7 @@ test_expect_success 'prompt - untracked files status indicator - non-empty untra ' test_expect_success 'prompt - untracked files status indicator - untracked files outside cwd' ' - printf " (master %%)" >expected && + printf " (main %%)" >expected && ( mkdir -p ignored_dir && cd ignored_dir && @@ -472,7 +475,7 @@ test_expect_success 'prompt - untracked files status indicator - untracked files ' test_expect_success 'prompt - untracked files status indicator - shell variable unset with config disabled' ' - printf " (master)" >expected && + printf " (main)" >expected && test_config bash.showUntrackedFiles false && ( sane_unset GIT_PS1_SHOWUNTRACKEDFILES && @@ -482,7 +485,7 @@ test_expect_success 'prompt - untracked files status indicator - shell variable ' test_expect_success 'prompt - untracked files status indicator - shell variable unset with config enabled' ' - printf " (master)" >expected && + printf " (main)" >expected && test_config bash.showUntrackedFiles true && ( sane_unset GIT_PS1_SHOWUNTRACKEDFILES && @@ -492,7 +495,7 @@ test_expect_success 'prompt - untracked files status indicator - shell variable ' test_expect_success 'prompt - untracked files status indicator - shell variable set with config disabled' ' - printf " (master)" >expected && + printf " (main)" >expected && test_config bash.showUntrackedFiles false && ( GIT_PS1_SHOWUNTRACKEDFILES=y && @@ -502,7 +505,7 @@ test_expect_success 'prompt - untracked files status indicator - shell variable ' test_expect_success 'prompt - untracked files status indicator - shell variable set with config enabled' ' - printf " (master %%)" >expected && + printf " (main %%)" >expected && test_config bash.showUntrackedFiles true && ( GIT_PS1_SHOWUNTRACKEDFILES=y && @@ -522,13 +525,13 @@ test_expect_success 'prompt - untracked files status indicator - not shown insid ' test_expect_success 'prompt - format string starting with dash' ' - printf -- "-master" >expected && + printf -- "-main" >expected && __git_ps1 "-%s" >"$actual" && test_cmp expected "$actual" ' test_expect_success 'prompt - pc mode' ' - printf "BEFORE: (\${__git_ps1_branch_name}):AFTER\\nmaster" >expected && + printf "BEFORE: (\${__git_ps1_branch_name}):AFTER\\nmain" >expected && ( __git_ps1 "BEFORE:" ":AFTER" >"$actual" && test_must_be_empty "$actual" && @@ -538,7 +541,7 @@ test_expect_success 'prompt - pc mode' ' ' test_expect_success 'prompt - bash color pc mode - branch name' ' - printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nmaster" >expected && + printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nmain" >expected && ( GIT_PS1_SHOWCOLORHINTS=y && __git_ps1 "BEFORE:" ":AFTER" >"$actual" && @@ -550,7 +553,7 @@ test_expect_success 'prompt - bash color pc mode - branch name' ' test_expect_success 'prompt - bash color pc mode - detached head' ' printf "BEFORE: (${c_red}\${__git_ps1_branch_name}${c_clear}):AFTER\\n(%s...)" $(git log -1 --format="%h" b1^) >expected && git checkout b1^ && - test_when_finished "git checkout master" && + test_when_finished "git checkout main" && ( GIT_PS1_SHOWCOLORHINTS=y && __git_ps1 "BEFORE:" ":AFTER" && @@ -560,7 +563,7 @@ test_expect_success 'prompt - bash color pc mode - detached head' ' ' test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty worktree' ' - printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_clear}):AFTER\\nmaster" >expected && + printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_clear}):AFTER\\nmain" >expected && echo "dirty" >file && test_when_finished "git reset --hard" && ( @@ -573,7 +576,7 @@ test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirt ' test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index' ' - printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}+${c_clear}):AFTER\\nmaster" >expected && + printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}+${c_clear}):AFTER\\nmain" >expected && echo "dirty" >file && test_when_finished "git reset --hard" && git add -u && @@ -587,7 +590,7 @@ test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirt ' test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index and worktree' ' - printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_green}+${c_clear}):AFTER\\nmaster" >expected && + printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_green}+${c_clear}):AFTER\\nmain" >expected && echo "dirty index" >file && test_when_finished "git reset --hard" && git add -u && @@ -602,7 +605,7 @@ test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirt ' test_expect_success 'prompt - bash color pc mode - dirty status indicator - before root commit' ' - printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}#${c_clear}):AFTER\\nmaster" >expected && + printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}#${c_clear}):AFTER\\nmain" >expected && ( GIT_PS1_SHOWDIRTYSTATE=y && GIT_PS1_SHOWCOLORHINTS=y && @@ -628,7 +631,7 @@ test_expect_success 'prompt - bash color pc mode - inside .git directory' ' ' test_expect_success 'prompt - bash color pc mode - stash status indicator' ' - printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_lblue}\$${c_clear}):AFTER\\nmaster" >expected && + printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_lblue}\$${c_clear}):AFTER\\nmain" >expected && echo 2 >file && git stash && test_when_finished "git stash drop" && @@ -642,7 +645,7 @@ test_expect_success 'prompt - bash color pc mode - stash status indicator' ' ' test_expect_success 'prompt - bash color pc mode - untracked files status indicator' ' - printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}%%${c_clear}):AFTER\\nmaster" >expected && + printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}%%${c_clear}):AFTER\\nmain" >expected && ( GIT_PS1_SHOWUNTRACKEDFILES=y && GIT_PS1_SHOWCOLORHINTS=y && @@ -653,7 +656,7 @@ test_expect_success 'prompt - bash color pc mode - untracked files status indica ' test_expect_success 'prompt - zsh color pc mode' ' - printf "BEFORE: (%%F{green}master%%f):AFTER" >expected && + printf "BEFORE: (%%F{green}main%%f):AFTER" >expected && ( ZSH_VERSION=5.0.0 && GIT_PS1_SHOWCOLORHINTS=y && @@ -664,7 +667,7 @@ test_expect_success 'prompt - zsh color pc mode' ' ' test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled' ' - printf " (master)" >expected && + printf " (main)" >expected && test_config bash.hideIfPwdIgnored false && ( cd ignored_dir && @@ -685,7 +688,7 @@ test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabl ' test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset' ' - printf " (master)" >expected && + printf " (main)" >expected && ( cd ignored_dir && __git_ps1 >"$actual" @@ -704,7 +707,7 @@ test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset, ' test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled' ' - printf " (master)" >expected && + printf " (main)" >expected && test_config bash.hideIfPwdIgnored false && ( cd ignored_dir && diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 2f08ce7cba..b823c14027 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -32,11 +32,6 @@ test_set_editor () { export EDITOR } -test_set_index_version () { - GIT_INDEX_VERSION="$1" - export GIT_INDEX_VERSION -} - test_decode_color () { awk ' function name(n) { @@ -116,13 +111,6 @@ remove_cr () { tr '\015' Q | sed -e 's/Q$//' } -# Generate an output of $1 bytes of all zeroes (NULs, not ASCII zeroes). -# If $1 is 'infinity', output forever or until the receiving pipe stops reading, -# whichever comes first. -generate_zero_bytes () { - test-tool genzeros "$@" -} - # In some bourne shell implementations, the "unset" builtin returns # nonzero status when a variable to be unset was not set in the first # place. @@ -178,34 +166,60 @@ debug () { GIT_DEBUGGER="${GIT_DEBUGGER}" "$@" <&6 >&5 2>&7 } -# Call test_commit with the arguments -# [-C <directory>] <message> [<file> [<contents> [<tag>]]]" +# Usage: test_commit [options] <message> [<file> [<contents> [<tag>]]] +# -C <dir>: +# Run all git commands in directory <dir> +# --notick +# Do not call test_tick before making a commit +# --append +# Use "echo >>" instead of "echo >" when writing "<contents>" to +# "<file>" +# --signoff +# Invoke "git commit" with --signoff +# --author <author> +# Invoke "git commit" with --author <author> # # This will commit a file with the given contents and the given commit # message, and tag the resulting commit with the given tag name. # # <file>, <contents>, and <tag> all default to <message>. -# -# If the first argument is "-C", the second argument is used as a path for -# the git invocations. test_commit () { notick= && + append= && + author= && signoff= && indir= && + no_tag= && while test $# != 0 do case "$1" in --notick) notick=yes ;; + --append) + append=yes + ;; + --author) + author="$2" + shift + ;; --signoff) signoff="$1" ;; + --date) + notick=yes + GIT_COMMITTER_DATE="$2" + GIT_AUTHOR_DATE="$2" + shift + ;; -C) indir="$2" shift ;; + --no-tag) + no_tag=yes + ;; *) break ;; @@ -214,14 +228,24 @@ test_commit () { done && indir=${indir:+"$indir"/} && file=${2:-"$1.t"} && - echo "${3-$1}" > "$indir$file" && + if test -n "$append" + then + echo "${3-$1}" >>"$indir$file" + else + echo "${3-$1}" >"$indir$file" + fi && git ${indir:+ -C "$indir"} add "$file" && if test -z "$notick" then test_tick fi && - git ${indir:+ -C "$indir"} commit $signoff -m "$1" && - git ${indir:+ -C "$indir"} tag "${4:-$1}" + git ${indir:+ -C "$indir"} commit \ + ${author:+ --author "$author"} \ + $signoff -m "$1" && + if test -z "$no_tag" + then + git ${indir:+ -C "$indir"} tag "${4:-$1}" + fi } # Call test_merge with the arguments "<message> <commit>", where <commit> @@ -706,34 +730,37 @@ test_external_without_stderr () { } # debugging-friendly alternatives to "test [-f|-d|-e]" -# The commands test the existence or non-existence of $1. $2 can be -# given to provide a more precise diagnosis. +# The commands test the existence or non-existence of $1 test_path_is_file () { + test "$#" -ne 1 && BUG "1 param" if ! test -f "$1" then - echo "File $1 doesn't exist. $2" + echo "File $1 doesn't exist" false fi } test_path_is_dir () { + test "$#" -ne 1 && BUG "1 param" if ! test -d "$1" then - echo "Directory $1 doesn't exist. $2" + echo "Directory $1 doesn't exist" false fi } test_path_exists () { + test "$#" -ne 1 && BUG "1 param" if ! test -e "$1" then - echo "Path $1 doesn't exist. $2" + echo "Path $1 doesn't exist" false fi } # Check if the directory exists and is empty as expected, barf otherwise. test_dir_is_empty () { + test "$#" -ne 1 && BUG "1 param" test_path_is_dir "$1" && if test -n "$(ls -a1 "$1" | egrep -v '^\.\.?$')" then @@ -745,6 +772,7 @@ test_dir_is_empty () { # Check if the file exists and has a size greater than zero test_file_not_empty () { + test "$#" = 2 && BUG "2 param" if ! test -s "$1" then echo "'$1' is not a non-empty file." @@ -753,6 +781,7 @@ test_file_not_empty () { } test_path_is_missing () { + test "$#" -ne 1 && BUG "1 param" if test -e "$1" then echo "Path exists:" @@ -789,6 +818,7 @@ test_line_count () { } test_file_size () { + test "$#" -ne 1 && BUG "1 param" test-tool path-utils file-size "$1" } @@ -961,6 +991,7 @@ test_expect_code () { # - not all diff versions understand "-u" test_cmp () { + test "$#" -ne 2 && BUG "2 param" eval "$GIT_TEST_CMP" '"$@"' } @@ -990,22 +1021,13 @@ test_cmp_config () { # test_cmp_bin - helper to compare binary files test_cmp_bin () { + test "$#" -ne 2 && BUG "2 param" cmp "$@" } -# Use this instead of test_cmp to compare files that contain expected and -# actual output from git commands that can be translated. When running -# under GIT_TEST_GETTEXT_POISON this pretends that the command produced expected -# results. -test_i18ncmp () { - ! test_have_prereq C_LOCALE_OUTPUT || test_cmp "$@" -} - -# Use this instead of "grep expected-string actual" to see if the -# output from a git command that can be translated either contains an -# expected string, or does not contain an unwanted one. When running -# under GIT_TEST_GETTEXT_POISON this pretends that the command produced expected -# results. +# Wrapper for grep which used to be used for +# GIT_TEST_GETTEXT_POISON=false. Only here as a shim for other +# in-flight changes. Should not be used and will be removed soon. test_i18ngrep () { eval "last_arg=\${$#}" @@ -1018,12 +1040,6 @@ test_i18ngrep () { BUG "too few parameters to test_i18ngrep" fi - if test_have_prereq !C_LOCALE_OUTPUT - then - # pretend success - return 0 - fi - if test "x!" = "x$1" then shift @@ -1059,6 +1075,7 @@ verbose () { # otherwise. test_must_be_empty () { + test "$#" -ne 1 && BUG "1 param" test_path_is_file "$1" && if test -s "$1" then @@ -1082,7 +1099,7 @@ test_cmp_rev () { fi if test $# != 2 then - error "bug in the test script: test_cmp_rev requires two revisions, but got $#" + BUG "test_cmp_rev requires two revisions, but got $#" else local r1 r2 r1=$(git rev-parse --verify "$1") && @@ -1193,7 +1210,7 @@ test_atexit () { # doing so on Bash is better than nothing (the test will # silently pass on other shells). test "${BASH_SUBSHELL-0}" = 0 || - error "bug in test script: test_atexit does nothing in a subshell" + BUG "test_atexit does nothing in a subshell" test_atexit_cleanup="{ $* } && (exit \"\$eval_ret\"); eval_ret=\$?; $test_atexit_cleanup" } @@ -1591,33 +1608,6 @@ test_set_port () { eval $var=$port } -# Compare a file containing rev-list bitmap traversal output to its non-bitmap -# counterpart. You can't just use test_cmp for this, because the two produce -# subtly different output: -# -# - regular output is in traversal order, whereas bitmap is split by type, -# with non-packed objects at the end -# -# - regular output has a space and the pathname appended to non-commit -# objects; bitmap output omits this -# -# This function normalizes and compares the two. The second file should -# always be the bitmap output. -test_bitmap_traversal () { - if test "$1" = "--no-confirm-bitmaps" - then - shift - elif cmp "$1" "$2" - then - echo >&2 "identical raw outputs; are you sure bitmaps were used?" - return 1 - fi && - cut -d' ' -f1 "$1" | sort >"$1.normalized" && - sort "$2" >"$2.normalized" && - test_cmp "$1.normalized" "$2.normalized" && - rm -f "$1.normalized" "$2.normalized" -} - # Tests for the hidden file attribute on Windows test_path_is_hidden () { test_have_prereq MINGW || @@ -1660,3 +1650,45 @@ test_subcommand () { grep "\[$expr\]" fi } + +# Check that the given command was invoked as part of the +# trace2-format trace on stdin. +# +# test_region [!] <category> <label> git <command> <args>... +# +# For example, to look for trace2_region_enter("index", "do_read_index", repo) +# in an invocation of "git checkout HEAD~1", run +# +# GIT_TRACE2_EVENT="$(pwd)/trace.txt" GIT_TRACE2_EVENT_NESTING=10 \ +# git checkout HEAD~1 && +# test_region index do_read_index <trace.txt +# +# If the first parameter passed is !, this instead checks that +# the given region was not entered. +# +test_region () { + local expect_exit=0 + if test "$1" = "!" + then + expect_exit=1 + shift + fi + + grep -e '"region_enter".*"category":"'"$1"'","label":"'"$2"\" "$3" + exitcode=$? + + if test $exitcode != $expect_exit + then + return 1 + fi + + grep -e '"region_leave".*"category":"'"$1"'","label":"'"$2"\" "$3" + exitcode=$? + + if test $exitcode != $expect_exit + then + return 1 + fi + + return 0 +} diff --git a/t/test-lib.sh b/t/test-lib.sh index 9fa7c1d0f6..adaf03543e 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -163,8 +163,8 @@ parse_option () { ;; --stress-jobs=*) stress=t; - stress=${opt#--*=} - case "$stress" in + stress_jobs=${opt#--*=} + case "$stress_jobs" in *[!0-9]*|0*|"") echo "error: --stress-jobs=<N> requires the number of jobs to run" >&2 exit 1 @@ -262,9 +262,9 @@ then : # Don't stress test again. elif test -n "$stress" then - if test "$stress" != t + if test -n "$stress_jobs" then - job_count=$stress + job_count=$stress_jobs elif test -n "$GIT_TEST_STRESS_LOAD" then job_count="$GIT_TEST_STRESS_LOAD" @@ -404,15 +404,6 @@ TZ=UTC export LANG LC_ALL PAGER TZ EDITOR=: -# GIT_TEST_GETTEXT_POISON should not influence git commands executed -# during initialization of test-lib and the test repo. Back it up, -# unset and then restore after initialization is finished. -if test -n "$GIT_TEST_GETTEXT_POISON" -then - GIT_TEST_GETTEXT_POISON_ORIG=$GIT_TEST_GETTEXT_POISON - unset GIT_TEST_GETTEXT_POISON -fi - # A call to "unset" with no arguments causes at least Solaris 10 # /usr/xpg4/bin/sh and /bin/ksh to bail out. So keep the unsets # deriving from the command substitution clustered with the other @@ -457,41 +448,13 @@ export EDITOR GIT_DEFAULT_HASH="${GIT_TEST_DEFAULT_HASH:-sha1}" export GIT_DEFAULT_HASH +GIT_TEST_MERGE_ALGORITHM="${GIT_TEST_MERGE_ALGORITHM:-ort}" +export GIT_TEST_MERGE_ALGORITHM # Tests using GIT_TRACE typically don't want <timestamp> <file>:<line> output GIT_TRACE_BARE=1 export GIT_TRACE_BARE -check_var_migration () { - # the warnings and hints given from this helper depends - # on end-user settings, which will disrupt the self-test - # done on the test framework itself. - case "$GIT_TEST_FRAMEWORK_SELFTEST" in - t) return ;; - esac - - old_name=$1 new_name=$2 - eval "old_isset=\${${old_name}:+isset}" - eval "new_isset=\${${new_name}:+isset}" - - case "$old_isset,$new_isset" in - isset,) - echo >&2 "warning: $old_name is now $new_name" - echo >&2 "hint: set $new_name too during the transition period" - eval "$new_name=\$$old_name" - ;; - isset,isset) - # do this later - # echo >&2 "warning: $old_name is now $new_name" - # echo >&2 "hint: remove $old_name" - ;; - esac -} - -check_var_migration GIT_FSMONITOR_TEST GIT_TEST_FSMONITOR -check_var_migration TEST_GIT_INDEX_VERSION GIT_TEST_INDEX_VERSION -check_var_migration GIT_FORCE_PRELOAD_TEST GIT_TEST_PRELOAD_INDEX - # Use specific version of the index file format if test -n "${GIT_TEST_INDEX_VERSION:+isset}" then @@ -984,8 +947,11 @@ test_run_ () { trace= # 117 is magic because it is unlikely to match the exit # code of other programs - if $(printf '%s\n' "$1" | sed -f "$GIT_BUILD_DIR/t/chainlint.sed" | grep -q '?![A-Z][A-Z]*?!') || - test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)" + if test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)" || + { + test "${GIT_TEST_CHAIN_LINT_HARDER:-${GIT_TEST_CHAIN_LINT_HARDER_DEFAULT:-1}}" != 0 && + $(printf '%s\n' "$1" | sed -f "$GIT_BUILD_DIR/t/chainlint.sed" | grep -q '?![A-Z][A-Z]*?!') + } then BUG "broken &&-chain or run-away HERE-DOC: $1" fi @@ -1496,6 +1462,7 @@ case $uname_s in test_set_prereq NATIVE_CRLF test_set_prereq SED_STRIPS_CR test_set_prereq GREP_STRIPS_CR + test_set_prereq WINDOWS GIT_TEST_CMP=mingw_test_cmp ;; *CYGWIN*) @@ -1504,6 +1471,7 @@ case $uname_s in test_set_prereq CYGWIN test_set_prereq SED_STRIPS_CR test_set_prereq GREP_STRIPS_CR + test_set_prereq WINDOWS ;; *) test_set_prereq POSIXPERM @@ -1524,22 +1492,10 @@ esac test -z "$NO_PERL" && test_set_prereq PERL test -z "$NO_PTHREADS" && test_set_prereq PTHREADS test -z "$NO_PYTHON" && test_set_prereq PYTHON -test -n "$USE_LIBPCRE1$USE_LIBPCRE2" && test_set_prereq PCRE -test -n "$USE_LIBPCRE1" && test_set_prereq LIBPCRE1 +test -n "$USE_LIBPCRE2" && test_set_prereq PCRE test -n "$USE_LIBPCRE2" && test_set_prereq LIBPCRE2 test -z "$NO_GETTEXT" && test_set_prereq GETTEXT -if test -n "$GIT_TEST_GETTEXT_POISON_ORIG" -then - GIT_TEST_GETTEXT_POISON=$GIT_TEST_GETTEXT_POISON_ORIG - export GIT_TEST_GETTEXT_POISON - unset GIT_TEST_GETTEXT_POISON_ORIG -fi - -test_lazy_prereq C_LOCALE_OUTPUT ' - ! test_bool_env GIT_TEST_GETTEXT_POISON false -' - if test -z "$GIT_TEST_CHECK_CACHE_TREE" then GIT_TEST_CHECK_CACHE_TREE=true @@ -1713,7 +1669,8 @@ test_lazy_prereq REBASE_P ' ' # Ensure that no test accidentally triggers a Git command -# that runs 'crontab', affecting a user's cron schedule. -# Tests that verify the cron integration must set this locally +# that runs the actual maintenance scheduler, affecting a user's +# system permanently. +# Tests that verify the scheduler integration must set this locally # to avoid errors. -GIT_TEST_CRONTAB="exit 1" +GIT_TEST_MAINT_SCHEDULER="none:exit 1" |