Git fork

Merge branch 'ps/config-error'

Many codepaths forget to check return value from git_config_set();
the function is made to die() to make sure we do not proceed when
setting a configuration variable failed.

* ps/config-error:
config: rename git_config_set_or_die to git_config_set
config: rename git_config_set to git_config_set_gently
compat: die when unable to set core.precomposeunicode
sequencer: die on config error when saving replay opts
init-db: die on config errors when initializing empty repo
clone: die on config error in cmd_clone
remote: die on config error when manipulating remotes
remote: die on config error when setting/adding branches
remote: die on config error when setting URL
submodule--helper: die on config error when cloning module
submodule: die on config error when linking modules
branch: die on config error when editing branch description
branch: die on config error when unsetting upstream
branch: report errors in tracking branch setup
config: introduce set_or_die wrappers

+159 -105
+36 -14
branch.c
··· 49 49 return 0; 50 50 } 51 51 52 - void install_branch_config(int flag, const char *local, const char *origin, const char *remote) 52 + static const char tracking_advice[] = 53 + N_("\n" 54 + "After fixing the error cause you may try to fix up\n" 55 + "the remote tracking information by invoking\n" 56 + "\"git branch --set-upstream-to=%s%s%s\"."); 57 + 58 + int install_branch_config(int flag, const char *local, const char *origin, const char *remote) 53 59 { 54 60 const char *shortname = NULL; 55 61 struct strbuf key = STRBUF_INIT; ··· 60 66 && !origin) { 61 67 warning(_("Not setting branch %s as its own upstream."), 62 68 local); 63 - return; 69 + return 0; 64 70 } 65 71 66 72 strbuf_addf(&key, "branch.%s.remote", local); 67 - git_config_set(key.buf, origin ? origin : "."); 73 + if (git_config_set_gently(key.buf, origin ? origin : ".") < 0) 74 + goto out_err; 68 75 69 76 strbuf_reset(&key); 70 77 strbuf_addf(&key, "branch.%s.merge", local); 71 - git_config_set(key.buf, remote); 78 + if (git_config_set_gently(key.buf, remote) < 0) 79 + goto out_err; 72 80 73 81 if (rebasing) { 74 82 strbuf_reset(&key); 75 83 strbuf_addf(&key, "branch.%s.rebase", local); 76 - git_config_set(key.buf, "true"); 84 + if (git_config_set_gently(key.buf, "true") < 0) 85 + goto out_err; 77 86 } 78 87 strbuf_release(&key); 79 88 ··· 102 111 local, remote); 103 112 } 104 113 } 114 + 115 + return 0; 116 + 117 + out_err: 118 + strbuf_release(&key); 119 + error(_("Unable to write upstream branch configuration")); 120 + 121 + advise(_(tracking_advice), 122 + origin ? origin : "", 123 + origin ? "/" : "", 124 + shortname ? shortname : remote); 125 + 126 + return -1; 105 127 } 106 128 107 129 /* ··· 109 131 * to infer the settings for branch.<new_ref>.{remote,merge} from the 110 132 * config. 111 133 */ 112 - static int setup_tracking(const char *new_ref, const char *orig_ref, 113 - enum branch_track track, int quiet) 134 + static void setup_tracking(const char *new_ref, const char *orig_ref, 135 + enum branch_track track, int quiet) 114 136 { 115 137 struct tracking tracking; 116 138 int config_flags = quiet ? 0 : BRANCH_CONFIG_VERBOSE; ··· 118 140 memset(&tracking, 0, sizeof(tracking)); 119 141 tracking.spec.dst = (char *)orig_ref; 120 142 if (for_each_remote(find_tracked_branch, &tracking)) 121 - return 1; 143 + return; 122 144 123 145 if (!tracking.matches) 124 146 switch (track) { ··· 127 149 case BRANCH_TRACK_OVERRIDE: 128 150 break; 129 151 default: 130 - return 1; 152 + return; 131 153 } 132 154 133 155 if (tracking.matches > 1) 134 - return error(_("Not tracking: ambiguous information for ref %s"), 135 - orig_ref); 156 + die(_("Not tracking: ambiguous information for ref %s"), 157 + orig_ref); 136 158 137 - install_branch_config(config_flags, new_ref, tracking.remote, 138 - tracking.src ? tracking.src : orig_ref); 159 + if (install_branch_config(config_flags, new_ref, tracking.remote, 160 + tracking.src ? tracking.src : orig_ref) < 0) 161 + exit(-1); 139 162 140 163 free(tracking.src); 141 - return 0; 142 164 } 143 165 144 166 int read_branch_desc(struct strbuf *buf, const char *branch_name)
+2 -1
branch.h
··· 43 43 /* 44 44 * Configure local branch "local" as downstream to branch "remote" 45 45 * from remote "origin". Used by git branch --set-upstream. 46 + * Returns 0 on success. 46 47 */ 47 48 #define BRANCH_CONFIG_VERBOSE 01 48 - extern void install_branch_config(int flag, const char *local, const char *origin, const char *remote); 49 + extern int install_branch_config(int flag, const char *local, const char *origin, const char *remote); 49 50 50 51 /* 51 52 * Read branch description
+2 -3
builtin/branch.c
··· 570 570 571 571 static int edit_branch_description(const char *branch_name) 572 572 { 573 - int status; 574 573 struct strbuf buf = STRBUF_INIT; 575 574 struct strbuf name = STRBUF_INIT; 576 575 ··· 595 594 strbuf_stripspace(&buf, 1); 596 595 597 596 strbuf_addf(&name, "branch.%s.description", branch_name); 598 - status = git_config_set(name.buf, buf.len ? buf.buf : NULL); 597 + git_config_set(name.buf, buf.len ? buf.buf : NULL); 599 598 strbuf_release(&name); 600 599 strbuf_release(&buf); 601 600 602 - return status; 601 + return 0; 603 602 } 604 603 605 604 int cmd_branch(int argc, const char **argv, const char *prefix)
+1 -1
builtin/clone.c
··· 740 740 741 741 static int write_one_config(const char *key, const char *value, void *data) 742 742 { 743 - return git_config_set_multivar(key, value ? value : "true", "^$", 0); 743 + return git_config_set_multivar_gently(key, value ? value : "true", "^$", 0); 744 744 } 745 745 746 746 static void write_config(struct string_list *config)
+14 -14
builtin/config.c
··· 615 615 check_write(); 616 616 check_argc(argc, 2, 2); 617 617 value = normalize_value(argv[0], argv[1]); 618 - ret = git_config_set_in_file(given_config_source.file, argv[0], value); 618 + ret = git_config_set_in_file_gently(given_config_source.file, argv[0], value); 619 619 if (ret == CONFIG_NOTHING_SET) 620 620 error("cannot overwrite multiple values with a single value\n" 621 621 " Use a regexp, --add or --replace-all to change %s.", argv[0]); ··· 625 625 check_write(); 626 626 check_argc(argc, 2, 3); 627 627 value = normalize_value(argv[0], argv[1]); 628 - return git_config_set_multivar_in_file(given_config_source.file, 629 - argv[0], value, argv[2], 0); 628 + return git_config_set_multivar_in_file_gently(given_config_source.file, 629 + argv[0], value, argv[2], 0); 630 630 } 631 631 else if (actions == ACTION_ADD) { 632 632 check_write(); 633 633 check_argc(argc, 2, 2); 634 634 value = normalize_value(argv[0], argv[1]); 635 - return git_config_set_multivar_in_file(given_config_source.file, 636 - argv[0], value, 637 - CONFIG_REGEX_NONE, 0); 635 + return git_config_set_multivar_in_file_gently(given_config_source.file, 636 + argv[0], value, 637 + CONFIG_REGEX_NONE, 0); 638 638 } 639 639 else if (actions == ACTION_REPLACE_ALL) { 640 640 check_write(); 641 641 check_argc(argc, 2, 3); 642 642 value = normalize_value(argv[0], argv[1]); 643 - return git_config_set_multivar_in_file(given_config_source.file, 644 - argv[0], value, argv[2], 1); 643 + return git_config_set_multivar_in_file_gently(given_config_source.file, 644 + argv[0], value, argv[2], 1); 645 645 } 646 646 else if (actions == ACTION_GET) { 647 647 check_argc(argc, 1, 2); ··· 667 667 check_write(); 668 668 check_argc(argc, 1, 2); 669 669 if (argc == 2) 670 - return git_config_set_multivar_in_file(given_config_source.file, 671 - argv[0], NULL, argv[1], 0); 670 + return git_config_set_multivar_in_file_gently(given_config_source.file, 671 + argv[0], NULL, argv[1], 0); 672 672 else 673 - return git_config_set_in_file(given_config_source.file, 674 - argv[0], NULL); 673 + return git_config_set_in_file_gently(given_config_source.file, 674 + argv[0], NULL); 675 675 } 676 676 else if (actions == ACTION_UNSET_ALL) { 677 677 check_write(); 678 678 check_argc(argc, 1, 2); 679 - return git_config_set_multivar_in_file(given_config_source.file, 680 - argv[0], NULL, argv[1], 1); 679 + return git_config_set_multivar_in_file_gently(given_config_source.file, 680 + argv[0], NULL, argv[1], 1); 681 681 } 682 682 else if (actions == ACTION_RENAME_SECTION) { 683 683 int ret;
+1 -1
builtin/init-db.c
··· 250 250 git_config_set("core.bare", "false"); 251 251 /* allow template config file to override the default */ 252 252 if (log_all_ref_updates == -1) 253 - git_config_set("core.logallrefupdates", "true"); 253 + git_config_set("core.logallrefupdates", "true"); 254 254 if (needs_work_tree_config(get_git_dir(), work_tree)) 255 255 git_config_set("core.worktree", work_tree); 256 256 }
+24 -46
builtin/remote.c
··· 108 108 #define MIRROR_PUSH 2 109 109 #define MIRROR_BOTH (MIRROR_FETCH|MIRROR_PUSH) 110 110 111 - static int add_branch(const char *key, const char *branchname, 112 - const char *remotename, int mirror, struct strbuf *tmp) 111 + static void add_branch(const char *key, const char *branchname, 112 + const char *remotename, int mirror, struct strbuf *tmp) 113 113 { 114 114 strbuf_reset(tmp); 115 115 strbuf_addch(tmp, '+'); ··· 119 119 else 120 120 strbuf_addf(tmp, "refs/heads/%s:refs/remotes/%s/%s", 121 121 branchname, remotename, branchname); 122 - return git_config_set_multivar(key, tmp->buf, "^$", 0); 122 + git_config_set_multivar(key, tmp->buf, "^$", 0); 123 123 } 124 124 125 125 static const char mirror_advice[] = ··· 194 194 die(_("'%s' is not a valid remote name"), name); 195 195 196 196 strbuf_addf(&buf, "remote.%s.url", name); 197 - if (git_config_set(buf.buf, url)) 198 - return 1; 197 + git_config_set(buf.buf, url); 199 198 200 199 if (!mirror || mirror & MIRROR_FETCH) { 201 200 strbuf_reset(&buf); ··· 203 202 if (track.nr == 0) 204 203 string_list_append(&track, "*"); 205 204 for (i = 0; i < track.nr; i++) { 206 - if (add_branch(buf.buf, track.items[i].string, 207 - name, mirror, &buf2)) 208 - return 1; 205 + add_branch(buf.buf, track.items[i].string, 206 + name, mirror, &buf2); 209 207 } 210 208 } 211 209 212 210 if (mirror & MIRROR_PUSH) { 213 211 strbuf_reset(&buf); 214 212 strbuf_addf(&buf, "remote.%s.mirror", name); 215 - if (git_config_set(buf.buf, "true")) 216 - return 1; 213 + git_config_set(buf.buf, "true"); 217 214 } 218 215 219 216 if (fetch_tags != TAGS_DEFAULT) { 220 217 strbuf_reset(&buf); 221 218 strbuf_addf(&buf, "remote.%s.tagopt", name); 222 - if (git_config_set(buf.buf, 223 - fetch_tags == TAGS_SET ? "--tags" : "--no-tags")) 224 - return 1; 219 + git_config_set(buf.buf, 220 + fetch_tags == TAGS_SET ? "--tags" : "--no-tags"); 225 221 } 226 222 227 223 if (fetch && fetch_remote(name)) ··· 589 585 590 586 strbuf_addf(&buf, "remote.%s.url", remote->name); 591 587 for (i = 0; i < remote->url_nr; i++) 592 - if (git_config_set_multivar(buf.buf, remote->url[i], "^$", 0)) 593 - return error(_("Could not append '%s' to '%s'"), 594 - remote->url[i], buf.buf); 588 + git_config_set_multivar(buf.buf, remote->url[i], "^$", 0); 595 589 strbuf_reset(&buf); 596 590 strbuf_addf(&buf, "remote.%s.push", remote->name); 597 591 for (i = 0; i < remote->push_refspec_nr; i++) 598 - if (git_config_set_multivar(buf.buf, remote->push_refspec[i], "^$", 0)) 599 - return error(_("Could not append '%s' to '%s'"), 600 - remote->push_refspec[i], buf.buf); 592 + git_config_set_multivar(buf.buf, remote->push_refspec[i], "^$", 0); 601 593 strbuf_reset(&buf); 602 594 strbuf_addf(&buf, "remote.%s.fetch", remote->name); 603 595 for (i = 0; i < remote->fetch_refspec_nr; i++) 604 - if (git_config_set_multivar(buf.buf, remote->fetch_refspec[i], "^$", 0)) 605 - return error(_("Could not append '%s' to '%s'"), 606 - remote->fetch_refspec[i], buf.buf); 596 + git_config_set_multivar(buf.buf, remote->fetch_refspec[i], "^$", 0); 607 597 if (remote->origin == REMOTE_REMOTES) 608 598 unlink_or_warn(git_path("remotes/%s", remote->name)); 609 599 else if (remote->origin == REMOTE_BRANCHES) 610 600 unlink_or_warn(git_path("branches/%s", remote->name)); 601 + 611 602 return 0; 612 603 } 613 604 ··· 654 645 655 646 strbuf_reset(&buf); 656 647 strbuf_addf(&buf, "remote.%s.fetch", rename.new); 657 - if (git_config_set_multivar(buf.buf, NULL, NULL, 1)) 658 - return error(_("Could not remove config section '%s'"), buf.buf); 648 + git_config_set_multivar(buf.buf, NULL, NULL, 1); 659 649 strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old); 660 650 for (i = 0; i < oldremote->fetch_refspec_nr; i++) { 661 651 char *ptr; ··· 675 665 "\tPlease update the configuration manually if necessary."), 676 666 buf2.buf); 677 667 678 - if (git_config_set_multivar(buf.buf, buf2.buf, "^$", 0)) 679 - return error(_("Could not append '%s'"), buf.buf); 668 + git_config_set_multivar(buf.buf, buf2.buf, "^$", 0); 680 669 } 681 670 682 671 read_branches(); ··· 686 675 if (info->remote_name && !strcmp(info->remote_name, rename.old)) { 687 676 strbuf_reset(&buf); 688 677 strbuf_addf(&buf, "branch.%s.remote", item->string); 689 - if (git_config_set(buf.buf, rename.new)) { 690 - return error(_("Could not set '%s'"), buf.buf); 691 - } 678 + git_config_set(buf.buf, rename.new); 692 679 } 693 680 } 694 681 ··· 786 773 strbuf_reset(&buf); 787 774 strbuf_addf(&buf, "branch.%s.%s", 788 775 item->string, *k); 789 - if (git_config_set(buf.buf, NULL)) { 790 - strbuf_release(&buf); 791 - return -1; 792 - } 776 + git_config_set(buf.buf, NULL); 793 777 } 794 778 } 795 779 } ··· 1410 1394 1411 1395 static int remove_all_fetch_refspecs(const char *remote, const char *key) 1412 1396 { 1413 - return git_config_set_multivar(key, NULL, NULL, 1); 1397 + return git_config_set_multivar_gently(key, NULL, NULL, 1); 1414 1398 } 1415 1399 1416 - static int add_branches(struct remote *remote, const char **branches, 1417 - const char *key) 1400 + static void add_branches(struct remote *remote, const char **branches, 1401 + const char *key) 1418 1402 { 1419 1403 const char *remotename = remote->name; 1420 1404 int mirror = remote->mirror; 1421 1405 struct strbuf refspec = STRBUF_INIT; 1422 1406 1423 1407 for (; *branches; branches++) 1424 - if (add_branch(key, *branches, remotename, mirror, &refspec)) { 1425 - strbuf_release(&refspec); 1426 - return 1; 1427 - } 1408 + add_branch(key, *branches, remotename, mirror, &refspec); 1428 1409 1429 1410 strbuf_release(&refspec); 1430 - return 0; 1431 1411 } 1432 1412 1433 1413 static int set_remote_branches(const char *remotename, const char **branches, ··· 1446 1426 strbuf_release(&key); 1447 1427 return 1; 1448 1428 } 1449 - if (add_branches(remote, branches, key.buf)) { 1450 - strbuf_release(&key); 1451 - return 1; 1452 - } 1429 + add_branches(remote, branches, key.buf); 1453 1430 1454 1431 strbuf_release(&key); 1455 1432 return 0; ··· 1581 1558 if ((!oldurl && !delete_mode) || add_mode) { 1582 1559 if (add_mode) 1583 1560 git_config_set_multivar(name_buf.buf, newurl, 1584 - "^$", 0); 1561 + "^$", 0); 1585 1562 else 1586 1563 git_config_set(name_buf.buf, newurl); 1587 1564 strbuf_release(&name_buf); 1565 + 1588 1566 return 0; 1589 1567 } 1590 1568
+9 -5
cache.h
··· 1489 1489 /* git_config_parse_key() returns these negated: */ 1490 1490 #define CONFIG_INVALID_KEY 1 1491 1491 #define CONFIG_NO_SECTION_OR_NAME 2 1492 - /* git_config_set(), git_config_set_multivar() return the above or these: */ 1492 + /* git_config_set_gently(), git_config_set_multivar_gently() return the above or these: */ 1493 1493 #define CONFIG_NO_LOCK -1 1494 1494 #define CONFIG_INVALID_FILE 3 1495 1495 #define CONFIG_NO_WRITE 4 ··· 1527 1527 extern int git_config_maybe_bool(const char *, const char *); 1528 1528 extern int git_config_string(const char **, const char *, const char *); 1529 1529 extern int git_config_pathname(const char **, const char *, const char *); 1530 - extern int git_config_set_in_file(const char *, const char *, const char *); 1531 - extern int git_config_set(const char *, const char *); 1530 + extern int git_config_set_in_file_gently(const char *, const char *, const char *); 1531 + extern void git_config_set_in_file(const char *, const char *, const char *); 1532 + extern int git_config_set_gently(const char *, const char *); 1533 + extern void git_config_set(const char *, const char *); 1532 1534 extern int git_config_parse_key(const char *, char **, int *); 1533 1535 extern int git_config_key_is_valid(const char *key); 1534 - extern int git_config_set_multivar(const char *, const char *, const char *, int); 1535 - extern int git_config_set_multivar_in_file(const char *, const char *, const char *, const char *, int); 1536 + extern int git_config_set_multivar_gently(const char *, const char *, const char *, int); 1537 + extern void git_config_set_multivar(const char *, const char *, const char *, int); 1538 + extern int git_config_set_multivar_in_file_gently(const char *, const char *, const char *, const char *, int); 1539 + extern void git_config_set_multivar_in_file(const char *, const char *, const char *, const char *, int); 1536 1540 extern int git_config_rename_section(const char *, const char *); 1537 1541 extern int git_config_rename_section_in_file(const char *, const char *, const char *); 1538 1542 extern const char *git_etc_gitconfig(void);
+2 -1
compat/precompose_utf8.c
··· 50 50 close(output_fd); 51 51 git_path_buf(&path, "%s", auml_nfd); 52 52 precomposed_unicode = access(path.buf, R_OK) ? 0 : 1; 53 - git_config_set("core.precomposeunicode", precomposed_unicode ? "true" : "false"); 53 + git_config_set("core.precomposeunicode", 54 + precomposed_unicode ? "true" : "false"); 54 55 git_path_buf(&path, "%s", auml_nfc); 55 56 if (unlink(path.buf)) 56 57 die_errno(_("failed to unlink '%s'"), path.buf);
+40 -12
config.c
··· 1853 1853 return offset; 1854 1854 } 1855 1855 1856 - int git_config_set_in_file(const char *config_filename, 1857 - const char *key, const char *value) 1856 + int git_config_set_in_file_gently(const char *config_filename, 1857 + const char *key, const char *value) 1858 + { 1859 + return git_config_set_multivar_in_file_gently(config_filename, key, value, NULL, 0); 1860 + } 1861 + 1862 + void git_config_set_in_file(const char *config_filename, 1863 + const char *key, const char *value) 1864 + { 1865 + git_config_set_multivar_in_file(config_filename, key, value, NULL, 0); 1866 + } 1867 + 1868 + int git_config_set_gently(const char *key, const char *value) 1858 1869 { 1859 - return git_config_set_multivar_in_file(config_filename, key, value, NULL, 0); 1870 + return git_config_set_multivar_gently(key, value, NULL, 0); 1860 1871 } 1861 1872 1862 - int git_config_set(const char *key, const char *value) 1873 + void git_config_set(const char *key, const char *value) 1863 1874 { 1864 - return git_config_set_multivar(key, value, NULL, 0); 1875 + git_config_set_multivar(key, value, NULL, 0); 1865 1876 } 1866 1877 1867 1878 /* ··· 1976 1987 * - the config file is removed and the lock file rename()d to it. 1977 1988 * 1978 1989 */ 1979 - int git_config_set_multivar_in_file(const char *config_filename, 1980 - const char *key, const char *value, 1981 - const char *value_regex, int multi_replace) 1990 + int git_config_set_multivar_in_file_gently(const char *config_filename, 1991 + const char *key, const char *value, 1992 + const char *value_regex, 1993 + int multi_replace) 1982 1994 { 1983 1995 int fd = -1, in_fd = -1; 1984 1996 int ret; ··· 2205 2217 2206 2218 } 2207 2219 2208 - int git_config_set_multivar(const char *key, const char *value, 2209 - const char *value_regex, int multi_replace) 2220 + void git_config_set_multivar_in_file(const char *config_filename, 2221 + const char *key, const char *value, 2222 + const char *value_regex, int multi_replace) 2210 2223 { 2211 - return git_config_set_multivar_in_file(NULL, key, value, value_regex, 2212 - multi_replace); 2224 + if (git_config_set_multivar_in_file_gently(config_filename, key, value, 2225 + value_regex, multi_replace) < 0) 2226 + die(_("Could not set '%s' to '%s'"), key, value); 2227 + } 2228 + 2229 + int git_config_set_multivar_gently(const char *key, const char *value, 2230 + const char *value_regex, int multi_replace) 2231 + { 2232 + return git_config_set_multivar_in_file_gently(NULL, key, value, value_regex, 2233 + multi_replace); 2234 + } 2235 + 2236 + void git_config_set_multivar(const char *key, const char *value, 2237 + const char *value_regex, int multi_replace) 2238 + { 2239 + git_config_set_multivar_in_file(NULL, key, value, value_regex, 2240 + multi_replace); 2213 2241 } 2214 2242 2215 2243 static int section_name_match (const char *buf, const char *name)
+4 -6
submodule.c
··· 69 69 strbuf_addstr(&entry, "submodule."); 70 70 strbuf_addstr(&entry, submodule->name); 71 71 strbuf_addstr(&entry, ".path"); 72 - if (git_config_set_in_file(".gitmodules", entry.buf, newpath) < 0) { 72 + if (git_config_set_in_file_gently(".gitmodules", entry.buf, newpath) < 0) { 73 73 /* Maybe the user already did that, don't error out here */ 74 74 warning(_("Could not update .gitmodules entry %s"), entry.buf); 75 75 strbuf_release(&entry); ··· 1087 1087 /* Update core.worktree setting */ 1088 1088 strbuf_reset(&file_name); 1089 1089 strbuf_addf(&file_name, "%s/config", git_dir); 1090 - if (git_config_set_in_file(file_name.buf, "core.worktree", 1091 - relative_path(real_work_tree, git_dir, 1092 - &rel_path))) 1093 - die(_("Could not set core.worktree in %s"), 1094 - file_name.buf); 1090 + git_config_set_in_file(file_name.buf, "core.worktree", 1091 + relative_path(real_work_tree, git_dir, 1092 + &rel_path)); 1095 1093 1096 1094 strbuf_release(&file_name); 1097 1095 strbuf_release(&rel_path);
+15 -1
t/t3200-branch.sh
··· 446 446 test_must_fail git branch --set-upstream-to HEAD^{} 447 447 ' 448 448 449 + test_expect_success '--set-upstream-to fails on locked config' ' 450 + test_when_finished "rm -f .git/config.lock" && 451 + >.git/config.lock && 452 + git branch locked && 453 + test_must_fail git branch --set-upstream-to locked 454 + ' 455 + 449 456 test_expect_success 'use --set-upstream-to modify HEAD' ' 450 457 test_config branch.master.remote foo && 451 458 test_config branch.master.merge foo && ··· 464 471 465 472 test_expect_success '--unset-upstream should fail if given a non-existent branch' ' 466 473 test_must_fail git branch --unset-upstream i-dont-exist 474 + ' 475 + 476 + test_expect_success '--unset-upstream should fail if config is locked' ' 477 + test_when_finished "rm -f .git/config.lock" && 478 + git branch --set-upstream-to locked && 479 + >.git/config.lock && 480 + test_must_fail git branch --unset-upstream 467 481 ' 468 482 469 483 test_expect_success 'test --unset-upstream on HEAD' ' ··· 579 593 git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master && 580 594 git config remote.ambi2.url lilili && 581 595 git config remote.ambi2.fetch refs/heads/lilili:refs/heads/master && 582 - git branch all1 master && 596 + test_must_fail git branch all1 master && 583 597 test -z "$(git config branch.all1.merge)" 584 598 ' 585 599
+9
t/t5505-remote.sh
··· 970 970 echo foo | get_url_test --push --all someremote 971 971 ' 972 972 973 + test_expect_success 'remote set-url with locked config' ' 974 + test_when_finished "rm -f .git/config.lock" && 975 + git config --get-all remote.someremote.url >expect && 976 + >.git/config.lock && 977 + test_must_fail git remote set-url someremote baz && 978 + git config --get-all remote.someremote.url >actual && 979 + cmp expect actual 980 + ' 981 + 973 982 test_expect_success 'remote set-url bar' ' 974 983 git remote set-url someremote bar && 975 984 echo bar >expect &&