Git fork

Merge branch 'bf/set-head-symref'

When "git fetch $remote" notices that refs/remotes/$remote/HEAD is
missing and discovers what branch the other side points with its
HEAD, refs/remotes/$remote/HEAD is updated to point to it.

* bf/set-head-symref:
fetch set_head: handle mirrored bare repositories
fetch: set remote/HEAD if it does not exist
refs: add create_only option to refs_update_symref_extended
refs: add TRANSACTION_CREATE_EXISTS error
remote set-head: better output for --auto
remote set-head: refactor for readability
refs: atomically record overwritten ref in update_symref
refs: standardize output of refs_read_symbolic_ref
t/t5505-remote: test failure of set-head
t/t5505-remote: set default branch to main

+439 -57
+74
builtin/fetch.c
··· 1574 1574 return retcode; 1575 1575 } 1576 1576 1577 + static const char *strip_refshead(const char *name){ 1578 + skip_prefix(name, "refs/heads/", &name); 1579 + return name; 1580 + } 1581 + 1582 + static int set_head(const struct ref *remote_refs) 1583 + { 1584 + int result = 0, is_bare; 1585 + struct strbuf b_head = STRBUF_INIT, b_remote_head = STRBUF_INIT; 1586 + const char *remote = gtransport->remote->name; 1587 + char *head_name = NULL; 1588 + struct ref *ref, *matches; 1589 + struct ref *fetch_map = NULL, **fetch_map_tail = &fetch_map; 1590 + struct refspec_item refspec = { 1591 + .force = 0, 1592 + .pattern = 1, 1593 + .src = (char *) "refs/heads/*", 1594 + .dst = (char *) "refs/heads/*", 1595 + }; 1596 + struct string_list heads = STRING_LIST_INIT_DUP; 1597 + struct ref_store *refs = get_main_ref_store(the_repository); 1598 + 1599 + get_fetch_map(remote_refs, &refspec, &fetch_map_tail, 0); 1600 + matches = guess_remote_head(find_ref_by_name(remote_refs, "HEAD"), 1601 + fetch_map, 1); 1602 + for (ref = matches; ref; ref = ref->next) { 1603 + string_list_append(&heads, strip_refshead(ref->name)); 1604 + } 1605 + 1606 + 1607 + if (!heads.nr) 1608 + result = 1; 1609 + else if (heads.nr > 1) 1610 + result = 1; 1611 + else 1612 + head_name = xstrdup(heads.items[0].string); 1613 + 1614 + if (!head_name) 1615 + goto cleanup; 1616 + is_bare = is_bare_repository(); 1617 + if (is_bare) { 1618 + strbuf_addstr(&b_head, "HEAD"); 1619 + strbuf_addf(&b_remote_head, "refs/heads/%s", head_name); 1620 + } else { 1621 + strbuf_addf(&b_head, "refs/remotes/%s/HEAD", remote); 1622 + strbuf_addf(&b_remote_head, "refs/remotes/%s/%s", remote, head_name); 1623 + } 1624 + /* make sure it's valid */ 1625 + if (!is_bare && !refs_ref_exists(refs, b_remote_head.buf)) { 1626 + result = 1; 1627 + goto cleanup; 1628 + } 1629 + if (refs_update_symref_extended(refs, b_head.buf, b_remote_head.buf, 1630 + "fetch", NULL, !is_bare)) 1631 + result = 1; 1632 + 1633 + cleanup: 1634 + free(head_name); 1635 + free_refs(fetch_map); 1636 + free_refs(matches); 1637 + string_list_clear(&heads, 0); 1638 + strbuf_release(&b_head); 1639 + strbuf_release(&b_remote_head); 1640 + return result; 1641 + } 1642 + 1577 1643 static int do_fetch(struct transport *transport, 1578 1644 struct refspec *rs, 1579 1645 const struct fetch_config *config) ··· 1642 1708 strvec_push(&transport_ls_refs_options.ref_prefixes, 1643 1709 "refs/tags/"); 1644 1710 } 1711 + 1712 + strvec_push(&transport_ls_refs_options.ref_prefixes, "HEAD"); 1645 1713 1646 1714 if (must_list_refs) { 1647 1715 trace2_region_enter("fetch", "remote_refs", the_repository); ··· 1787 1855 "you need to specify exactly one branch with the --set-upstream option")); 1788 1856 } 1789 1857 } 1858 + if (set_head(remote_refs)) 1859 + ; 1860 + /* 1861 + * Way too many cases where this can go wrong 1862 + * so let's just fail silently for now. 1863 + */ 1790 1864 1791 1865 cleanup: 1792 1866 if (retcode) {
+53 -17
builtin/remote.c
··· 1403 1403 return result; 1404 1404 } 1405 1405 1406 + static void report_set_head_auto(const char *remote, const char *head_name, 1407 + struct strbuf *b_local_head, int was_detached) { 1408 + struct strbuf buf_prefix = STRBUF_INIT; 1409 + const char *prev_head = NULL; 1410 + 1411 + strbuf_addf(&buf_prefix, "refs/remotes/%s/", remote); 1412 + skip_prefix(b_local_head->buf, buf_prefix.buf, &prev_head); 1413 + 1414 + if (prev_head && !strcmp(prev_head, head_name)) 1415 + printf(_("'%s/HEAD' is unchanged and points to '%s'\n"), 1416 + remote, head_name); 1417 + else if (prev_head) 1418 + printf(_("'%s/HEAD' has changed from '%s' and now points to '%s'\n"), 1419 + remote, prev_head, head_name); 1420 + else if (!b_local_head->len) 1421 + printf(_("'%s/HEAD' is now created and points to '%s'\n"), 1422 + remote, head_name); 1423 + else if (was_detached && b_local_head->len) 1424 + printf(_("'%s/HEAD' was detached at '%s' and now points to '%s'\n"), 1425 + remote, b_local_head->buf, head_name); 1426 + else 1427 + printf(_("'%s/HEAD' used to point to '%s' " 1428 + "(which is not a remote branch), but now points to '%s'\n"), 1429 + remote, b_local_head->buf, head_name); 1430 + strbuf_release(&buf_prefix); 1431 + } 1432 + 1406 1433 static int set_head(int argc, const char **argv, const char *prefix, 1407 1434 struct repository *repo UNUSED) 1408 1435 { 1409 - int i, opt_a = 0, opt_d = 0, result = 0; 1410 - struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT; 1436 + int i, opt_a = 0, opt_d = 0, result = 0, was_detached; 1437 + struct strbuf b_head = STRBUF_INIT, b_remote_head = STRBUF_INIT, 1438 + b_local_head = STRBUF_INIT; 1411 1439 char *head_name = NULL; 1440 + struct ref_store *refs = get_main_ref_store(the_repository); 1412 1441 1413 1442 struct option options[] = { 1414 1443 OPT_BOOL('a', "auto", &opt_a, ··· 1420 1449 argc = parse_options(argc, argv, prefix, options, 1421 1450 builtin_remote_sethead_usage, 0); 1422 1451 if (argc) 1423 - strbuf_addf(&buf, "refs/remotes/%s/HEAD", argv[0]); 1452 + strbuf_addf(&b_head, "refs/remotes/%s/HEAD", argv[0]); 1424 1453 1425 1454 if (!opt_a && !opt_d && argc == 2) { 1426 1455 head_name = xstrdup(argv[1]); ··· 1439 1468 head_name = xstrdup(states.heads.items[0].string); 1440 1469 free_remote_ref_states(&states); 1441 1470 } else if (opt_d && !opt_a && argc == 1) { 1442 - if (refs_delete_ref(get_main_ref_store(the_repository), NULL, buf.buf, NULL, REF_NO_DEREF)) 1443 - result |= error(_("Could not delete %s"), buf.buf); 1471 + if (refs_delete_ref(refs, NULL, b_head.buf, NULL, REF_NO_DEREF)) 1472 + result |= error(_("Could not delete %s"), b_head.buf); 1444 1473 } else 1445 1474 usage_with_options(builtin_remote_sethead_usage, options); 1446 1475 1447 - if (head_name) { 1448 - strbuf_addf(&buf2, "refs/remotes/%s/%s", argv[0], head_name); 1449 - /* make sure it's valid */ 1450 - if (!refs_ref_exists(get_main_ref_store(the_repository), buf2.buf)) 1451 - result |= error(_("Not a valid ref: %s"), buf2.buf); 1452 - else if (refs_update_symref(get_main_ref_store(the_repository), buf.buf, buf2.buf, "remote set-head")) 1453 - result |= error(_("Could not setup %s"), buf.buf); 1454 - else if (opt_a) 1455 - printf("%s/HEAD set to %s\n", argv[0], head_name); 1456 - free(head_name); 1476 + if (!head_name) 1477 + goto cleanup; 1478 + strbuf_addf(&b_remote_head, "refs/remotes/%s/%s", argv[0], head_name); 1479 + if (!refs_ref_exists(refs, b_remote_head.buf)) { 1480 + result |= error(_("Not a valid ref: %s"), b_remote_head.buf); 1481 + goto cleanup; 1482 + } 1483 + was_detached = refs_update_symref_extended(refs, b_head.buf, b_remote_head.buf, 1484 + "remote set-head", &b_local_head, 0); 1485 + if (was_detached == -1) { 1486 + result |= error(_("Could not set up %s"), b_head.buf); 1487 + goto cleanup; 1457 1488 } 1489 + if (opt_a) 1490 + report_set_head_auto(argv[0], head_name, &b_local_head, was_detached); 1458 1491 1459 - strbuf_release(&buf); 1460 - strbuf_release(&buf2); 1492 + cleanup: 1493 + free(head_name); 1494 + strbuf_release(&b_head); 1495 + strbuf_release(&b_remote_head); 1496 + strbuf_release(&b_local_head); 1461 1497 return result; 1462 1498 } 1463 1499
+40 -7
refs.c
··· 2167 2167 int refs_update_symref(struct ref_store *refs, const char *ref, 2168 2168 const char *target, const char *logmsg) 2169 2169 { 2170 + return refs_update_symref_extended(refs, ref, target, logmsg, NULL, 0); 2171 + } 2172 + 2173 + int refs_update_symref_extended(struct ref_store *refs, const char *ref, 2174 + const char *target, const char *logmsg, 2175 + struct strbuf *referent, int create_only) 2176 + { 2170 2177 struct ref_transaction *transaction; 2171 2178 struct strbuf err = STRBUF_INIT; 2172 - int ret = 0; 2179 + int ret = 0, prepret = 0; 2173 2180 2174 2181 transaction = ref_store_transaction_begin(refs, 0, &err); 2175 - if (!transaction || 2176 - ref_transaction_update(transaction, ref, NULL, NULL, 2177 - target, NULL, REF_NO_DEREF, 2178 - logmsg, &err) || 2179 - ref_transaction_commit(transaction, &err)) { 2182 + if (!transaction) { 2183 + error_return: 2180 2184 ret = error("%s", err.buf); 2185 + goto cleanup; 2186 + } 2187 + if (create_only) { 2188 + if (ref_transaction_create(transaction, ref, NULL, target, 2189 + REF_NO_DEREF, logmsg, &err)) 2190 + goto error_return; 2191 + prepret = ref_transaction_prepare(transaction, &err); 2192 + if (prepret && prepret != TRANSACTION_CREATE_EXISTS) 2193 + goto error_return; 2194 + } else { 2195 + if (ref_transaction_update(transaction, ref, NULL, NULL, 2196 + target, NULL, REF_NO_DEREF, 2197 + logmsg, &err) || 2198 + ref_transaction_prepare(transaction, &err)) 2199 + goto error_return; 2181 2200 } 2182 2201 2202 + if (referent && refs_read_symbolic_ref(refs, ref, referent) == NOT_A_SYMREF) { 2203 + struct object_id oid; 2204 + if (!refs_read_ref(refs, ref, &oid)) { 2205 + strbuf_addstr(referent, oid_to_hex(&oid)); 2206 + ret = NOT_A_SYMREF; 2207 + } 2208 + } 2209 + 2210 + if (prepret == TRANSACTION_CREATE_EXISTS) 2211 + goto cleanup; 2212 + 2213 + if (ref_transaction_commit(transaction, &err)) 2214 + goto error_return; 2215 + 2216 + cleanup: 2183 2217 strbuf_release(&err); 2184 2218 if (transaction) 2185 2219 ref_transaction_free(transaction); ··· 2993 3027 return (update->flags & REF_HAVE_OLD) && 2994 3028 (!is_null_oid(&update->old_oid) || update->old_target); 2995 3029 } 2996 -
+18 -1
refs.h
··· 83 83 84 84 int refs_read_ref(struct ref_store *refs, const char *refname, struct object_id *oid); 85 85 86 + #define NOT_A_SYMREF -2 87 + 88 + /* 89 + * Read the symbolic ref named "refname" and write its immediate referent into 90 + * the provided buffer. Referent is left empty if "refname" is not a symbolic 91 + * ref. It does not resolve the symbolic reference recursively in case the 92 + * target is also a symbolic ref. 93 + * 94 + * Returns 0 on success, -2 if the "refname" is not a symbolic ref, 95 + * -1 otherwise. 96 + */ 86 97 int refs_read_symbolic_ref(struct ref_store *ref_store, const char *refname, 87 98 struct strbuf *referent); 88 99 ··· 604 615 int refs_update_symref(struct ref_store *refs, const char *refname, 605 616 const char *target, const char *logmsg); 606 617 618 + int refs_update_symref_extended(struct ref_store *refs, const char *refname, 619 + const char *target, const char *logmsg, 620 + struct strbuf *referent, int create_only); 621 + 607 622 enum action_on_err { 608 623 UPDATE_REFS_MSG_ON_ERR, 609 624 UPDATE_REFS_DIE_ON_ERR, ··· 805 820 806 821 /* Naming conflict (for example, the ref names A and A/B conflict). */ 807 822 #define TRANSACTION_NAME_CONFLICT -1 823 + /* When only creation was requested, but the ref already exists. */ 824 + #define TRANSACTION_CREATE_EXISTS -2 808 825 /* All other errors. */ 809 - #define TRANSACTION_GENERIC_ERROR -2 826 + #define TRANSACTION_GENERIC_ERROR -3 810 827 811 828 /* 812 829 * Perform the preparatory stages of committing `transaction`. Acquire
+19 -12
refs/files-backend.c
··· 598 598 unsigned int type; 599 599 600 600 ret = read_ref_internal(ref_store, refname, &oid, referent, &type, &failure_errno, 1); 601 - if (ret) 602 - return ret; 603 - 604 - return !(type & REF_ISSYMREF); 601 + if (!ret && !(type & REF_ISSYMREF)) 602 + return NOT_A_SYMREF; 603 + return ret; 605 604 } 606 605 607 606 int parse_loose_ref_contents(const struct git_hash_algo *algop, ··· 2509 2508 static int check_old_oid(struct ref_update *update, struct object_id *oid, 2510 2509 struct strbuf *err) 2511 2510 { 2511 + int ret = TRANSACTION_GENERIC_ERROR; 2512 + 2512 2513 if (!(update->flags & REF_HAVE_OLD) || 2513 2514 oideq(oid, &update->old_oid)) 2514 2515 return 0; 2515 2516 2516 - if (is_null_oid(&update->old_oid)) 2517 + if (is_null_oid(&update->old_oid)) { 2517 2518 strbuf_addf(err, "cannot lock ref '%s': " 2518 2519 "reference already exists", 2519 2520 ref_update_original_update_refname(update)); 2521 + ret = TRANSACTION_CREATE_EXISTS; 2522 + } 2520 2523 else if (is_null_oid(oid)) 2521 2524 strbuf_addf(err, "cannot lock ref '%s': " 2522 2525 "reference is missing but expected %s", ··· 2529 2532 oid_to_hex(oid), 2530 2533 oid_to_hex(&update->old_oid)); 2531 2534 2532 - return -1; 2535 + return ret; 2533 2536 } 2534 2537 2535 2538 /* ··· 2609 2612 ret = TRANSACTION_GENERIC_ERROR; 2610 2613 goto out; 2611 2614 } 2612 - } else if (check_old_oid(update, &lock->old_oid, err)) { 2613 - ret = TRANSACTION_GENERIC_ERROR; 2614 - goto out; 2615 + } else { 2616 + ret = check_old_oid(update, &lock->old_oid, err); 2617 + if (ret) { 2618 + goto out; 2619 + } 2615 2620 } 2616 2621 } else { 2617 2622 /* ··· 2642 2647 update->old_target); 2643 2648 ret = TRANSACTION_GENERIC_ERROR; 2644 2649 goto out; 2645 - } else if (check_old_oid(update, &lock->old_oid, err)) { 2646 - ret = TRANSACTION_GENERIC_ERROR; 2647 - goto out; 2650 + } else { 2651 + ret = check_old_oid(update, &lock->old_oid, err); 2652 + if (ret) { 2653 + goto out; 2654 + } 2648 2655 } 2649 2656 2650 2657 /*
+5
refs/refs-internal.h
··· 674 674 675 675 ref_iterator_begin_fn *iterator_begin; 676 676 read_raw_ref_fn *read_raw_ref; 677 + 678 + /* 679 + * Please refer to `refs_read_symbolic_ref()` for the expected 680 + * behaviour. 681 + */ 677 682 read_symbolic_ref_fn *read_symbolic_ref; 678 683 679 684 reflog_iterator_begin_fn *reflog_iterator_begin;
+9 -3
refs/reftable-backend.c
··· 920 920 return ret; 921 921 922 922 ret = reftable_backend_read_ref(be, refname, &oid, referent, &type); 923 - if (type != REF_ISSYMREF) 923 + if (ret) 924 924 ret = -1; 925 + else if (type == REF_ISSYMREF) 926 + ; /* happy */ 927 + else 928 + ret = NOT_A_SYMREF; 925 929 return ret; 926 930 } 927 931 ··· 1328 1332 goto done; 1329 1333 } 1330 1334 } else if ((u->flags & REF_HAVE_OLD) && !oideq(&current_oid, &u->old_oid)) { 1331 - if (is_null_oid(&u->old_oid)) 1335 + ret = TRANSACTION_NAME_CONFLICT; 1336 + if (is_null_oid(&u->old_oid)) { 1332 1337 strbuf_addf(err, _("cannot lock ref '%s': " 1333 1338 "reference already exists"), 1334 1339 ref_update_original_update_refname(u)); 1340 + ret = TRANSACTION_CREATE_EXISTS; 1341 + } 1335 1342 else if (is_null_oid(&current_oid)) 1336 1343 strbuf_addf(err, _("cannot lock ref '%s': " 1337 1344 "reference is missing but expected %s"), ··· 1343 1350 ref_update_original_update_refname(u), 1344 1351 oid_to_hex(&current_oid), 1345 1352 oid_to_hex(&u->old_oid)); 1346 - ret = -1; 1347 1353 goto done; 1348 1354 } 1349 1355
+2 -1
t/t4207-log-decoration-colors.sh
··· 58 58 ${c_reset}${c_tag}tag: ${c_reset}${c_tag}B${c_reset}${c_commit})${c_reset} B 59 59 ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ 60 60 ${c_tag}tag: ${c_reset}${c_tag}A1${c_reset}${c_commit}, \ 61 - ${c_reset}${c_remoteBranch}other/main${c_reset}${c_commit})${c_reset} A1 61 + ${c_reset}${c_remoteBranch}other/main${c_reset}${c_commit}, \ 62 + ${c_reset}${c_remoteBranch}other/HEAD${c_reset}${c_commit})${c_reset} A1 62 63 ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ 63 64 ${c_stash}refs/stash${c_reset}${c_commit})${c_reset} On main: Changes to A.t 64 65 ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\
+101 -6
t/t5505-remote.sh
··· 2 2 3 3 test_description='git remote porcelain-ish' 4 4 5 + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 6 + export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 7 + 5 8 . ./test-lib.sh 6 9 7 10 setup_repository () { ··· 70 73 cd test && 71 74 git remote add -f second ../two && 72 75 tokens_match "origin second" "$(git remote)" && 73 - check_tracking_branch second main side another && 76 + check_tracking_branch second main side another HEAD && 74 77 git for-each-ref "--format=%(refname)" refs/remotes | 75 78 sed -e "/^refs\/remotes\/origin\//d" \ 76 79 -e "/^refs\/remotes\/second\//d" >actual && ··· 428 431 ) 429 432 ' 430 433 434 + test_expect_success REFFILES 'set-head --auto failure' ' 435 + test_when_finished "rm -f test/.git/refs/remotes/origin/HEAD.lock" && 436 + ( 437 + cd test && 438 + touch .git/refs/remotes/origin/HEAD.lock && 439 + test_must_fail git remote set-head --auto origin 2>err && 440 + tail -n1 err >output && 441 + echo "error: Could not set up refs/remotes/origin/HEAD" >expect && 442 + test_cmp expect output 443 + ) 444 + ' 445 + 446 + test_expect_success 'set-head --auto detects creation' ' 447 + ( 448 + cd test && 449 + git update-ref --no-deref -d refs/remotes/origin/HEAD && 450 + git remote set-head --auto origin >output && 451 + echo "${SQ}origin/HEAD${SQ} is now created and points to ${SQ}main${SQ}" >expect && 452 + test_cmp expect output 453 + ) 454 + ' 455 + 456 + test_expect_success 'set-head --auto to update a non symbolic ref' ' 457 + ( 458 + cd test && 459 + git update-ref --no-deref -d refs/remotes/origin/HEAD && 460 + git update-ref refs/remotes/origin/HEAD HEAD && 461 + HEAD=$(git log --pretty="%H") && 462 + git remote set-head --auto origin >output && 463 + echo "${SQ}origin/HEAD${SQ} was detached at ${SQ}${HEAD}${SQ} and now points to ${SQ}main${SQ}" >expect && 464 + test_cmp expect output 465 + ) 466 + ' 467 + 468 + test_expect_success 'set-head --auto detects no change' ' 469 + ( 470 + cd test && 471 + git remote set-head --auto origin >output && 472 + echo "${SQ}origin/HEAD${SQ} is unchanged and points to ${SQ}main${SQ}" >expect && 473 + test_cmp expect output 474 + ) 475 + ' 476 + 477 + test_expect_success 'set-head --auto detects change' ' 478 + ( 479 + cd test && 480 + git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/ahead && 481 + git remote set-head --auto origin >output && 482 + echo "${SQ}origin/HEAD${SQ} has changed from ${SQ}ahead${SQ} and now points to ${SQ}main${SQ}" >expect && 483 + test_cmp expect output 484 + ) 485 + ' 486 + 487 + test_expect_success 'set-head --auto detects strange ref' ' 488 + ( 489 + cd test && 490 + git symbolic-ref refs/remotes/origin/HEAD refs/heads/main && 491 + git remote set-head --auto origin >output && 492 + echo "${SQ}origin/HEAD${SQ} used to point to ${SQ}refs/heads/main${SQ} (which is not a remote branch), but now points to ${SQ}main${SQ}" >expect && 493 + test_cmp expect output 494 + ) 495 + ' 496 + 431 497 test_expect_success 'set-head --auto has no problem w/multiple HEADs' ' 432 498 ( 433 499 cd test && 434 500 git fetch two "refs/heads/*:refs/remotes/two/*" && 435 501 git remote set-head --auto two >output 2>&1 && 436 - echo "two/HEAD set to main" >expect && 502 + echo "${SQ}two/HEAD${SQ} is unchanged and points to ${SQ}main${SQ}" >expect && 437 503 test_cmp expect output 438 504 ) 439 505 ' ··· 452 518 ) 453 519 ' 454 520 521 + test_expect_success 'set-head --auto reports change' ' 522 + ( 523 + cd test && 524 + git remote set-head origin side2 && 525 + git remote set-head --auto origin >output 2>&1 && 526 + echo "${SQ}origin/HEAD${SQ} has changed from ${SQ}side2${SQ} and now points to ${SQ}main${SQ}" >expect && 527 + test_cmp expect output 528 + ) 529 + ' 530 + 455 531 cat >test/expect <<EOF 456 532 Pruning origin 457 533 URL: $(pwd)/one ··· 489 565 git remote prune origin && 490 566 test_must_fail git rev-parse --verify refs/heads/side2 && 491 567 git rev-parse --verify refs/heads/side 568 + ) 569 + ' 570 + 571 + test_expect_success 'add --mirror setting HEAD' ' 572 + mkdir headmirror && 573 + ( 574 + cd headmirror && 575 + git init --bare -b notmain && 576 + git remote add --mirror -f origin ../one && 577 + test "$(git symbolic-ref HEAD)" = "refs/heads/main" 492 578 ) 493 579 ' 494 580 ··· 711 797 ' 712 798 713 799 cat >one/expect <<\EOF 800 + apis/HEAD -> apis/main 714 801 apis/main 715 802 apis/side 803 + drosophila/HEAD -> drosophila/main 716 804 drosophila/another 717 805 drosophila/main 718 806 drosophila/side ··· 730 818 ' 731 819 732 820 cat >one/expect <<\EOF 821 + drosophila/HEAD -> drosophila/main 733 822 drosophila/another 734 823 drosophila/main 735 824 drosophila/side 825 + manduca/HEAD -> manduca/main 736 826 manduca/main 737 827 manduca/side 828 + megaloprepus/HEAD -> megaloprepus/main 738 829 megaloprepus/main 739 830 megaloprepus/side 740 831 EOF ··· 742 833 test_expect_success 'update with arguments' ' 743 834 ( 744 835 cd one && 745 - for b in $(git branch -r) 836 + for b in $(git branch -r | grep -v HEAD) 746 837 do 747 838 git branch -r -d $b || exit 1 748 839 done && ··· 774 865 ' 775 866 776 867 cat >one/expect <<-\EOF 868 + apis/HEAD -> apis/main 777 869 apis/main 778 870 apis/side 871 + manduca/HEAD -> manduca/main 779 872 manduca/main 780 873 manduca/side 874 + megaloprepus/HEAD -> megaloprepus/main 781 875 megaloprepus/main 782 876 megaloprepus/side 783 877 EOF ··· 785 879 test_expect_success 'update default' ' 786 880 ( 787 881 cd one && 788 - for b in $(git branch -r) 882 + for b in $(git branch -r | grep -v HEAD) 789 883 do 790 884 git branch -r -d $b || exit 1 791 885 done && ··· 797 891 ' 798 892 799 893 cat >one/expect <<\EOF 894 + drosophila/HEAD -> drosophila/main 800 895 drosophila/another 801 896 drosophila/main 802 897 drosophila/side ··· 805 900 test_expect_success 'update default (overridden, with funny whitespace)' ' 806 901 ( 807 902 cd one && 808 - for b in $(git branch -r) 903 + for b in $(git branch -r | grep -v HEAD) 809 904 do 810 905 git branch -r -d $b || exit 1 811 906 done && ··· 819 914 test_expect_success 'update (with remotes.default defined)' ' 820 915 ( 821 916 cd one && 822 - for b in $(git branch -r) 917 + for b in $(git branch -r | grep -v HEAD) 823 918 do 824 919 git branch -r -d $b || exit 1 825 920 done &&
+24
t/t5510-fetch.sh
··· 74 74 cut -f -2 .git/FETCH_HEAD >actual && 75 75 test_cmp expected actual' 76 76 77 + test_expect_success "fetch test remote HEAD" ' 78 + cd "$D" && 79 + cd two && 80 + git fetch && 81 + git rev-parse --verify refs/remotes/origin/HEAD && 82 + git rev-parse --verify refs/remotes/origin/main && 83 + head=$(git rev-parse refs/remotes/origin/HEAD) && 84 + branch=$(git rev-parse refs/remotes/origin/main) && 85 + test "z$head" = "z$branch"' 86 + 87 + test_expect_success "fetch test remote HEAD change" ' 88 + cd "$D" && 89 + cd two && 90 + git switch -c other && 91 + git push -u origin other && 92 + git rev-parse --verify refs/remotes/origin/HEAD && 93 + git rev-parse --verify refs/remotes/origin/main && 94 + git rev-parse --verify refs/remotes/origin/other && 95 + git remote set-head origin other && 96 + git fetch && 97 + head=$(git rev-parse refs/remotes/origin/HEAD) && 98 + branch=$(git rev-parse refs/remotes/origin/other) && 99 + test "z$head" = "z$branch"' 100 + 77 101 test_expect_success 'fetch --prune on its own works as expected' ' 78 102 cd "$D" && 79 103 git clone . prune &&
+2
t/t5512-ls-remote.sh
··· 292 292 cat >expect <<-EOF && 293 293 ref: refs/heads/main HEAD 294 294 $rev HEAD 295 + ref: refs/remotes/origin/main refs/remotes/origin/HEAD 296 + $rev refs/remotes/origin/HEAD 295 297 EOF 296 298 git ls-remote --symref . HEAD >actual && 297 299 test_cmp expect actual
+15 -2
t/t5514-fetch-multiple.sh
··· 44 44 ' 45 45 46 46 cat > test/expect << EOF 47 + one/HEAD -> one/main 47 48 one/main 48 49 one/side 49 50 origin/HEAD -> origin/main 50 51 origin/main 51 52 origin/side 53 + three/HEAD -> three/main 52 54 three/another 53 55 three/main 54 56 three/side 57 + two/HEAD -> two/main 55 58 two/another 56 59 two/main 57 60 two/side ··· 96 99 origin/HEAD -> origin/main 97 100 origin/main 98 101 origin/side 102 + three/HEAD -> three/main 99 103 three/another 100 104 three/main 101 105 three/side ··· 111 115 ' 112 116 113 117 cat > expect << EOF 118 + one/HEAD -> one/main 114 119 one/main 115 120 one/side 121 + two/HEAD -> two/main 116 122 two/another 117 123 two/main 118 124 two/side ··· 140 146 141 147 test_expect_success 'git fetch --all (skipFetchAll)' ' 142 148 (cd test4 && 143 - for b in $(git branch -r) 149 + for b in $(git branch -r | grep -v HEAD) 144 150 do 145 151 git branch -r -d $b || exit 1 146 152 done && ··· 152 158 ' 153 159 154 160 cat > expect << EOF 161 + one/HEAD -> one/main 155 162 one/main 156 163 one/side 164 + three/HEAD -> three/main 157 165 three/another 158 166 three/main 159 167 three/side 168 + two/HEAD -> two/main 160 169 two/another 161 170 two/main 162 171 two/side ··· 164 173 165 174 test_expect_success 'git fetch --multiple (ignoring skipFetchAll)' ' 166 175 (cd test4 && 167 - for b in $(git branch -r) 176 + for b in $(git branch -r | grep -v HEAD) 168 177 do 169 178 git branch -r -d $b || exit 1 170 179 done && ··· 220 229 221 230 create_fetch_all_expect () { 222 231 cat >expect <<-\EOF 232 + one/HEAD -> one/main 223 233 one/main 224 234 one/side 225 235 origin/HEAD -> origin/main 226 236 origin/main 227 237 origin/side 238 + three/HEAD -> three/main 228 239 three/another 229 240 three/main 230 241 three/side 242 + two/HEAD -> two/main 231 243 two/another 232 244 two/main 233 245 two/side ··· 264 276 265 277 create_fetch_one_expect () { 266 278 cat >expect <<-\EOF 279 + one/HEAD -> one/main 267 280 one/main 268 281 one/side 269 282 origin/HEAD -> origin/main
+2 -1
t/t5516-fetch-push.sh
··· 1394 1394 git tag -m "annotated" tag && 1395 1395 git for-each-ref >tmp1 && 1396 1396 sed -n "p; s|refs/heads/main$|refs/remotes/origin/main|p" tmp1 | 1397 - sort -k 3 >../expect 1397 + sed -n "p; s|refs/heads/main$|refs/remotes/origin/HEAD|p" | 1398 + sort -k 4 >../expect 1398 1399 ) && 1399 1400 test_when_finished "rm -rf dst" && 1400 1401 git init dst &&
+2 -1
t/t5527-fetch-odd-refs.sh
··· 51 51 long 52 52 main 53 53 EOF 54 - git for-each-ref --format="%(subject)" refs/remotes/long >actual && 54 + git for-each-ref --format="%(subject)" refs/remotes/long \ 55 + --exclude=refs/remotes/long/HEAD >actual && 55 56 test_cmp expect actual 56 57 ' 57 58
+2 -1
t/t7900-maintenance.sh
··· 328 328 329 329 # Delete refs that have not been repacked in these packs. 330 330 git for-each-ref --format="delete %(refname)" \ 331 - refs/prefetch refs/tags refs/remotes >refs && 331 + refs/prefetch refs/tags refs/remotes \ 332 + --exclude=refs/remotes/*/HEAD >refs && 332 333 git update-ref --stdin <refs && 333 334 334 335 # Replace the object directory with this pack layout.
+3 -2
t/t9210-scalar.sh
··· 150 150 "$(pwd)" && 151 151 152 152 git for-each-ref --format="%(refname)" refs/remotes/origin/ >actual && 153 - echo "refs/remotes/origin/parallel" >expect && 153 + echo "refs/remotes/origin/HEAD" >>expect && 154 + echo "refs/remotes/origin/parallel" >>expect && 154 155 test_cmp expect actual && 155 156 156 157 test_path_is_missing 1/2 && ··· 219 220 done 220 221 ' 221 222 222 - test_expect_success 'scalar reconfigure --all with detached HEADs' ' 223 + test_expect_success 'scalar reconfigure --all with detached HEADs' ' 223 224 repos="two three four" && 224 225 for num in $repos 225 226 do
+3 -3
t/t9211-scalar-clone.sh
··· 31 31 ) 32 32 ' 33 33 34 - cleanup_clone () { 34 + cleanup_clone() { 35 35 rm -rf "$1" 36 36 } 37 37 ··· 127 127 ( 128 128 cd $enlistment/src && 129 129 git for-each-ref refs/remotes/origin >out && 130 - test_line_count = 1 out && 130 + test_line_count = 2 out && 131 131 grep "refs/remotes/origin/base" out 132 132 ) && 133 133 ··· 141 141 ( 142 142 cd $enlistment/src && 143 143 git for-each-ref refs/remotes/origin >out && 144 - test_line_count = 2 out && 144 + test_line_count = 3 out && 145 145 grep "refs/remotes/origin/base" out && 146 146 grep "refs/remotes/origin/parallel" out 147 147 ) &&
+65
t/t9902-completion.sh
··· 657 657 HEAD 658 658 main 659 659 matching-branch 660 + other/HEAD 660 661 other/branch-in-other 661 662 other/main-in-other 662 663 matching-tag ··· 672 673 cat >expected <<-EOF && 673 674 refs/heads/main 674 675 refs/heads/matching-branch 676 + refs/remotes/other/HEAD 675 677 refs/remotes/other/branch-in-other 676 678 refs/remotes/other/main-in-other 677 679 refs/tags/matching-tag ··· 727 729 728 730 test_expect_success '__git_refs - configured remote' ' 729 731 cat >expected <<-EOF && 732 + HEAD 730 733 HEAD 731 734 branch-in-other 732 735 main-in-other ··· 755 758 test_expect_success '__git_refs - configured remote - repo given on the command line' ' 756 759 cat >expected <<-EOF && 757 760 HEAD 761 + HEAD 758 762 branch-in-other 759 763 main-in-other 760 764 EOF ··· 785 789 786 790 test_expect_success '__git_refs - configured remote - remote name matches a directory' ' 787 791 cat >expected <<-EOF && 792 + HEAD 788 793 HEAD 789 794 branch-in-other 790 795 main-in-other ··· 874 879 HEAD 875 880 main 876 881 matching-branch 882 + other/HEAD 877 883 other/ambiguous 878 884 other/branch-in-other 879 885 other/main-in-other 880 886 remote/ambiguous 881 887 remote/branch-in-remote 882 888 matching-tag 889 + HEAD 883 890 branch-in-other 884 891 branch-in-remote 885 892 main-in-other ··· 903 910 HEAD 904 911 main 905 912 matching-branch 913 + other/HEAD 906 914 other/branch-in-other 907 915 other/main-in-other 908 916 matching-tag ··· 918 926 cat >expected <<-EOF && 919 927 refs/heads/main 920 928 refs/heads/matching-branch 929 + refs/remotes/other/HEAD 921 930 refs/remotes/other/branch-in-other 922 931 refs/remotes/other/main-in-other 923 932 refs/tags/matching-tag ··· 934 943 ^HEAD 935 944 ^main 936 945 ^matching-branch 946 + ^other/HEAD 937 947 ^other/branch-in-other 938 948 ^other/main-in-other 939 949 ^matching-tag ··· 949 959 cat >expected <<-EOF && 950 960 ^refs/heads/main 951 961 ^refs/heads/matching-branch 962 + ^refs/remotes/other/HEAD 952 963 ^refs/remotes/other/branch-in-other 953 964 ^refs/remotes/other/main-in-other 954 965 ^refs/tags/matching-tag ··· 974 985 main 975 986 matching-branch 976 987 matching/branch 988 + other/HEAD 977 989 other/branch-in-other 978 990 other/main-in-other 979 991 other/matching/branch-in-other ··· 1094 1106 HEAD Z 1095 1107 main Z 1096 1108 matching-branch Z 1109 + other/HEAD Z 1097 1110 other/branch-in-other Z 1098 1111 other/main-in-other Z 1099 1112 matching-tag Z ··· 1122 1135 test_expect_success '__git_complete_refs - remote' ' 1123 1136 sed -e "s/Z$//" >expected <<-EOF && 1124 1137 HEAD Z 1138 + HEAD Z 1125 1139 branch-in-other Z 1126 1140 main-in-other Z 1127 1141 EOF ··· 1138 1152 HEAD Z 1139 1153 main Z 1140 1154 matching-branch Z 1155 + other/HEAD Z 1141 1156 other/branch-in-other Z 1142 1157 other/main-in-other Z 1143 1158 matching-tag Z 1159 + HEAD Z 1144 1160 branch-in-other Z 1145 1161 main-in-other Z 1146 1162 EOF ··· 1183 1199 HEAD. 1184 1200 main. 1185 1201 matching-branch. 1202 + other/HEAD. 1186 1203 other/branch-in-other. 1187 1204 other/main-in-other. 1188 1205 matching-tag. ··· 1198 1215 test_expect_success '__git_complete_fetch_refspecs - simple' ' 1199 1216 sed -e "s/Z$//" >expected <<-EOF && 1200 1217 HEAD:HEAD Z 1218 + HEAD:HEAD Z 1201 1219 branch-in-other:branch-in-other Z 1202 1220 main-in-other:main-in-other Z 1203 1221 EOF ··· 1223 1241 1224 1242 test_expect_success '__git_complete_fetch_refspecs - prefix' ' 1225 1243 sed -e "s/Z$//" >expected <<-EOF && 1244 + +HEAD:HEAD Z 1226 1245 +HEAD:HEAD Z 1227 1246 +branch-in-other:branch-in-other Z 1228 1247 +main-in-other:main-in-other Z ··· 1288 1307 1289 1308 test_expect_success 'git switch - with no options, complete local branches and unique remote branch names for DWIM logic' ' 1290 1309 test_completion "git switch " <<-\EOF 1310 + HEAD Z 1291 1311 branch-in-other Z 1292 1312 main Z 1293 1313 main-in-other Z ··· 1433 1453 1434 1454 test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' ' 1435 1455 test_completion "git checkout " <<-\EOF 1456 + HEAD Z 1436 1457 HEAD Z 1437 1458 branch-in-other Z 1438 1459 main Z 1439 1460 main-in-other Z 1440 1461 matching-branch Z 1441 1462 matching-tag Z 1463 + other/HEAD Z 1442 1464 other/branch-in-other Z 1443 1465 other/main-in-other Z 1444 1466 EOF ··· 1460 1482 1461 1483 test_expect_success 'git switch - --guess overrides GIT_COMPLETION_CHECKOUT_NO_GUESS=1, complete local branches and unique remote names for DWIM logic' ' 1462 1484 GIT_COMPLETION_CHECKOUT_NO_GUESS=1 test_completion "git switch --guess " <<-\EOF 1485 + HEAD Z 1463 1486 branch-in-other Z 1464 1487 main Z 1465 1488 main-in-other Z ··· 1469 1492 1470 1493 test_expect_success 'git switch - a later --guess overrides previous --no-guess, complete local and remote unique branches for DWIM' ' 1471 1494 test_completion "git switch --no-guess --guess " <<-\EOF 1495 + HEAD Z 1472 1496 branch-in-other Z 1473 1497 main Z 1474 1498 main-in-other Z ··· 1489 1513 main Z 1490 1514 matching-branch Z 1491 1515 matching-tag Z 1516 + other/HEAD Z 1492 1517 other/branch-in-other Z 1493 1518 other/main-in-other Z 1494 1519 EOF ··· 1497 1522 test_expect_success 'git checkout - --guess overrides GIT_COMPLETION_NO_GUESS=1, complete refs and unique remote branches for DWIM' ' 1498 1523 GIT_COMPLETION_CHECKOUT_NO_GUESS=1 test_completion "git checkout --guess " <<-\EOF 1499 1524 HEAD Z 1525 + HEAD Z 1500 1526 branch-in-other Z 1501 1527 main Z 1502 1528 main-in-other Z 1503 1529 matching-branch Z 1504 1530 matching-tag Z 1531 + other/HEAD Z 1505 1532 other/branch-in-other Z 1506 1533 other/main-in-other Z 1507 1534 EOF ··· 1513 1540 main Z 1514 1541 matching-branch Z 1515 1542 matching-tag Z 1543 + other/HEAD Z 1516 1544 other/branch-in-other Z 1517 1545 other/main-in-other Z 1518 1546 EOF ··· 1520 1548 1521 1549 test_expect_success 'git checkout - a later --guess overrides previous --no-guess, complete refs and unique remote branches for DWIM' ' 1522 1550 test_completion "git checkout --no-guess --guess " <<-\EOF 1551 + HEAD Z 1523 1552 HEAD Z 1524 1553 branch-in-other Z 1525 1554 main Z 1526 1555 main-in-other Z 1527 1556 matching-branch Z 1528 1557 matching-tag Z 1558 + other/HEAD Z 1529 1559 other/branch-in-other Z 1530 1560 other/main-in-other Z 1531 1561 EOF ··· 1537 1567 main Z 1538 1568 matching-branch Z 1539 1569 matching-tag Z 1570 + other/HEAD Z 1540 1571 other/branch-in-other Z 1541 1572 other/main-in-other Z 1542 1573 EOF ··· 1549 1580 main Z 1550 1581 matching-branch Z 1551 1582 matching-tag Z 1583 + other/HEAD Z 1552 1584 other/branch-in-other Z 1553 1585 other/main-in-other Z 1554 1586 EOF ··· 1557 1589 test_expect_success 'git checkout - with checkout.guess = true, completes refs and unique remote branches for DWIM' ' 1558 1590 test_config checkout.guess true && 1559 1591 test_completion "git checkout " <<-\EOF 1592 + HEAD Z 1560 1593 HEAD Z 1561 1594 branch-in-other Z 1562 1595 main Z 1563 1596 main-in-other Z 1564 1597 matching-branch Z 1565 1598 matching-tag Z 1599 + other/HEAD Z 1566 1600 other/branch-in-other Z 1567 1601 other/main-in-other Z 1568 1602 EOF ··· 1572 1606 test_config checkout.guess false && 1573 1607 test_completion "git checkout --guess " <<-\EOF 1574 1608 HEAD Z 1609 + HEAD Z 1575 1610 branch-in-other Z 1576 1611 main Z 1577 1612 main-in-other Z 1578 1613 matching-branch Z 1579 1614 matching-tag Z 1615 + other/HEAD Z 1580 1616 other/branch-in-other Z 1581 1617 other/main-in-other Z 1582 1618 EOF ··· 1589 1625 main Z 1590 1626 matching-branch Z 1591 1627 matching-tag Z 1628 + other/HEAD Z 1592 1629 other/branch-in-other Z 1593 1630 other/main-in-other Z 1594 1631 EOF ··· 1600 1637 main Z 1601 1638 matching-branch Z 1602 1639 matching-tag Z 1640 + other/HEAD Z 1603 1641 other/branch-in-other Z 1604 1642 other/main-in-other Z 1605 1643 EOF ··· 1611 1649 main Z 1612 1650 matching-branch Z 1613 1651 matching-tag Z 1652 + other/HEAD Z 1614 1653 other/branch-in-other Z 1615 1654 other/main-in-other Z 1616 1655 EOF ··· 1782 1821 main Z 1783 1822 matching-branch Z 1784 1823 matching-tag Z 1824 + other/HEAD Z 1785 1825 other/branch-in-other Z 1786 1826 other/main-in-other Z 1787 1827 EOF ··· 1793 1833 main Z 1794 1834 matching-branch Z 1795 1835 matching-tag Z 1836 + other/HEAD Z 1796 1837 other/branch-in-other Z 1797 1838 other/main-in-other Z 1798 1839 EOF ··· 1800 1841 1801 1842 test_expect_success 'git switch - with --track, complete only remote branches' ' 1802 1843 test_completion "git switch --track " <<-\EOF && 1844 + other/HEAD Z 1803 1845 other/branch-in-other Z 1804 1846 other/main-in-other Z 1805 1847 EOF 1806 1848 test_completion "git switch -t " <<-\EOF 1849 + other/HEAD Z 1807 1850 other/branch-in-other Z 1808 1851 other/main-in-other Z 1809 1852 EOF ··· 1811 1854 1812 1855 test_expect_success 'git checkout - with --track, complete only remote branches' ' 1813 1856 test_completion "git checkout --track " <<-\EOF && 1857 + other/HEAD Z 1814 1858 other/branch-in-other Z 1815 1859 other/main-in-other Z 1816 1860 EOF 1817 1861 test_completion "git checkout -t " <<-\EOF 1862 + other/HEAD Z 1818 1863 other/branch-in-other Z 1819 1864 other/main-in-other Z 1820 1865 EOF ··· 1833 1878 main Z 1834 1879 matching-branch Z 1835 1880 matching-tag Z 1881 + other/HEAD Z 1836 1882 other/branch-in-other Z 1837 1883 other/main-in-other Z 1838 1884 EOF ··· 1844 1890 main Z 1845 1891 matching-branch Z 1846 1892 matching-tag Z 1893 + other/HEAD Z 1847 1894 other/branch-in-other Z 1848 1895 other/main-in-other Z 1849 1896 EOF ··· 1855 1902 main Z 1856 1903 matching-branch Z 1857 1904 matching-tag Z 1905 + other/HEAD Z 1858 1906 other/branch-in-other Z 1859 1907 other/main-in-other Z 1860 1908 EOF ··· 1866 1914 main Z 1867 1915 matching-branch Z 1868 1916 matching-tag Z 1917 + other/HEAD Z 1869 1918 other/branch-in-other Z 1870 1919 other/main-in-other Z 1871 1920 EOF ··· 1877 1926 main Z 1878 1927 matching-branch Z 1879 1928 matching-tag Z 1929 + other/HEAD Z 1880 1930 other/branch-in-other Z 1881 1931 other/main-in-other Z 1882 1932 EOF ··· 1888 1938 main Z 1889 1939 matching-branch Z 1890 1940 matching-tag Z 1941 + other/HEAD Z 1891 1942 other/branch-in-other Z 1892 1943 other/main-in-other Z 1893 1944 EOF ··· 1899 1950 main Z 1900 1951 matching-branch Z 1901 1952 matching-tag Z 1953 + other/HEAD Z 1902 1954 other/branch-in-other Z 1903 1955 other/main-in-other Z 1904 1956 EOF ··· 1910 1962 main Z 1911 1963 matching-branch Z 1912 1964 matching-tag Z 1965 + other/HEAD Z 1913 1966 other/branch-in-other Z 1914 1967 other/main-in-other Z 1915 1968 EOF ··· 1921 1974 main Z 1922 1975 matching-branch Z 1923 1976 matching-tag Z 1977 + other/HEAD Z 1924 1978 other/branch-in-other Z 1925 1979 other/main-in-other Z 1926 1980 EOF ··· 1932 1986 main Z 1933 1987 matching-branch Z 1934 1988 matching-tag Z 1989 + other/HEAD Z 1935 1990 other/branch-in-other Z 1936 1991 other/main-in-other Z 1937 1992 EOF ··· 1943 1998 main Z 1944 1999 matching-branch Z 1945 2000 matching-tag Z 2001 + other/HEAD Z 1946 2002 other/branch-in-other Z 1947 2003 other/main-in-other Z 1948 2004 EOF ··· 1954 2010 main Z 1955 2011 matching-branch Z 1956 2012 matching-tag Z 2013 + other/HEAD Z 1957 2014 other/branch-in-other Z 1958 2015 other/main-in-other Z 1959 2016 EOF ··· 1965 2022 main Z 1966 2023 matching-branch Z 1967 2024 matching-tag Z 2025 + other/HEAD Z 1968 2026 other/branch-in-other Z 1969 2027 other/main-in-other Z 1970 2028 EOF ··· 1972 2030 1973 2031 test_expect_success 'git switch - for -c, complete local branches and unique remote branches' ' 1974 2032 test_completion "git switch -c " <<-\EOF 2033 + HEAD Z 1975 2034 branch-in-other Z 1976 2035 main Z 1977 2036 main-in-other Z ··· 1981 2040 1982 2041 test_expect_success 'git switch - for -C, complete local branches and unique remote branches' ' 1983 2042 test_completion "git switch -C " <<-\EOF 2043 + HEAD Z 1984 2044 branch-in-other Z 1985 2045 main Z 1986 2046 main-in-other Z ··· 2018 2078 2019 2079 test_expect_success 'git checkout - for -b, complete local branches and unique remote branches' ' 2020 2080 test_completion "git checkout -b " <<-\EOF 2081 + HEAD Z 2021 2082 branch-in-other Z 2022 2083 main Z 2023 2084 main-in-other Z ··· 2027 2088 2028 2089 test_expect_success 'git checkout - for -B, complete local branches and unique remote branches' ' 2029 2090 test_completion "git checkout -B " <<-\EOF 2091 + HEAD Z 2030 2092 branch-in-other Z 2031 2093 main Z 2032 2094 main-in-other Z ··· 2064 2126 2065 2127 test_expect_success 'git switch - with --orphan completes local branch names and unique remote branch names' ' 2066 2128 test_completion "git switch --orphan " <<-\EOF 2129 + HEAD Z 2067 2130 branch-in-other Z 2068 2131 main Z 2069 2132 main-in-other Z ··· 2079 2142 2080 2143 test_expect_success 'git checkout - with --orphan completes local branch names and unique remote branch names' ' 2081 2144 test_completion "git checkout --orphan " <<-\EOF 2145 + HEAD Z 2082 2146 branch-in-other Z 2083 2147 main Z 2084 2148 main-in-other Z ··· 2092 2156 main Z 2093 2157 matching-branch Z 2094 2158 matching-tag Z 2159 + other/HEAD Z 2095 2160 other/branch-in-other Z 2096 2161 other/main-in-other Z 2097 2162 EOF