config: rename git_config_set_or_die to git_config_set
Rename git_config_set_or_die functions to git_config_set, leading to the new default behavior of dying whenever a configuration error occurs. By now all callers that shall die on error have been transitioned to the _or_die variants, thus making this patch a simple rename of the functions. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Feb 22, 2016 at 12:23 UTC
3d1806487af395fb33d1de92633e96571b296305
10 files changed
+67
-67
builtin/branch.c
+3
-3
@@ -594,7 +594,7 @@ static int edit_branch_description(const char *branch_name)
594
strbuf_stripspace(&buf, 1);
595
596
strbuf_addf(&name, "branch.%s.description", branch_name);
597
- git_config_set_or_die(name.buf, buf.len ? buf.buf : NULL);
597
+ git_config_set(name.buf, buf.len ? buf.buf : NULL);
598
strbuf_release(&name);
599
strbuf_release(&buf);
600
@@ -790,10 +790,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
790
die(_("Branch '%s' has no upstream information"), branch->name);
791
792
strbuf_addf(&buf, "branch.%s.remote", branch->name);
793
- git_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);
793
+ git_config_set_multivar(buf.buf, NULL, NULL, 1);
794
strbuf_reset(&buf);
795
strbuf_addf(&buf, "branch.%s.merge", branch->name);
796
- git_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);
796
+ git_config_set_multivar(buf.buf, NULL, NULL, 1);
797
strbuf_release(&buf);
798
} else if (argc > 0 && argc <= 2) {
799
struct branch *branch = branch_get(argv[0]);
builtin/clone.c
+4
-4
@@ -783,12 +783,12 @@ static void write_refspec_config(const char *src_ref_prefix,
783
/* Configure the remote */
784
if (value.len) {
785
strbuf_addf(&key, "remote.%s.fetch", option_origin);
786
- git_config_set_multivar_or_die(key.buf, value.buf, "^$", 0);
786
+ git_config_set_multivar(key.buf, value.buf, "^$", 0);
787
strbuf_reset(&key);
788
789
if (option_mirror) {
790
strbuf_addf(&key, "remote.%s.mirror", option_origin);
791
- git_config_set_or_die(key.buf, "true");
791
+ git_config_set(key.buf, "true");
792
strbuf_reset(&key);
793
}
794
}
@@ -946,14 +946,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
946
src_ref_prefix = "refs/";
947
strbuf_addstr(&branch_top, src_ref_prefix);
948
949
- git_config_set_or_die("core.bare", "true");
949
+ git_config_set("core.bare", "true");
950
} else {
951
strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
952
}
953
954
strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
955
strbuf_addf(&key, "remote.%s.url", option_origin);
956
- git_config_set_or_die(key.buf, repo);
956
+ git_config_set(key.buf, repo);
957
strbuf_reset(&key);
958
959
if (option_reference.nr)
builtin/init-db.c
+10
-10
@@ -227,7 +227,7 @@ static int create_default_files(const char *template_path)
227
/* This forces creation of new config file */
228
xsnprintf(repo_version_string, sizeof(repo_version_string),
229
"%d", GIT_REPO_VERSION);
230
- git_config_set_or_die("core.repositoryformatversion", repo_version_string);
230
+ git_config_set("core.repositoryformatversion", repo_version_string);
231
232
/* Check filemode trustability */
233
path = git_path_buf(&buf, "config");
@@ -241,18 +241,18 @@ static int create_default_files(const char *template_path)
241
if (filemode && !reinit && (st1.st_mode & S_IXUSR))
242
filemode = 0;
243
}
244
- git_config_set_or_die("core.filemode", filemode ? "true" : "false");
244
+ git_config_set("core.filemode", filemode ? "true" : "false");
245
246
if (is_bare_repository())
247
- git_config_set_or_die("core.bare", "true");
247
+ git_config_set("core.bare", "true");
248
else {
249
const char *work_tree = get_git_work_tree();
250
- git_config_set_or_die("core.bare", "false");
250
+ git_config_set("core.bare", "false");
251
/* allow template config file to override the default */
252
if (log_all_ref_updates == -1)
253
- git_config_set_or_die("core.logallrefupdates", "true");
253
+ git_config_set("core.logallrefupdates", "true");
254
if (needs_work_tree_config(get_git_dir(), work_tree))
255
- git_config_set_or_die("core.worktree", work_tree);
255
+ git_config_set("core.worktree", work_tree);
256
}
257
258
if (!reinit) {
@@ -265,12 +265,12 @@ static int create_default_files(const char *template_path)
265
S_ISLNK(st1.st_mode))
266
unlink(path); /* good */
267
else
268
- git_config_set_or_die("core.symlinks", "false");
268
+ git_config_set("core.symlinks", "false");
269
270
/* Check if the filesystem is case-insensitive */
271
path = git_path_buf(&buf, "CoNfIg");
272
if (!access(path, F_OK))
273
- git_config_set_or_die("core.ignorecase", "true");
273
+ git_config_set("core.ignorecase", "true");
274
probe_utf8_pathname_composition();
275
}
276
@@ -386,8 +386,8 @@ int init_db(const char *template_dir, unsigned int flags)
386
xsnprintf(buf, sizeof(buf), "%d", OLD_PERM_EVERYBODY);
387
else
388
die("BUG: invalid value for shared_repository");
389
- git_config_set_or_die("core.sharedrepository", buf);
390
- git_config_set_or_die("receive.denyNonFastforwards", "true");
389
+ git_config_set("core.sharedrepository", buf);
390
+ git_config_set("receive.denyNonFastforwards", "true");
391
}
392
393
if (!(flags & INIT_DB_QUIET)) {
builtin/remote.c
+16
-16
@@ -119,7 +119,7 @@ static void add_branch(const char *key, const char *branchname,
119
else
120
strbuf_addf(tmp, "refs/heads/%s:refs/remotes/%s/%s",
121
branchname, remotename, branchname);
122
- git_config_set_multivar_or_die(key, tmp->buf, "^$", 0);
122
+ git_config_set_multivar(key, tmp->buf, "^$", 0);
123
}
124
125
static const char mirror_advice[] =
@@ -197,7 +197,7 @@ static int add(int argc, const char **argv)
197
die(_("'%s' is not a valid remote name"), name);
198
199
strbuf_addf(&buf, "remote.%s.url", name);
200
- git_config_set_or_die(buf.buf, url);
200
+ git_config_set(buf.buf, url);
201
202
if (!mirror || mirror & MIRROR_FETCH) {
203
strbuf_reset(&buf);
@@ -213,14 +213,14 @@ static int add(int argc, const char **argv)
213
if (mirror & MIRROR_PUSH) {
214
strbuf_reset(&buf);
215
strbuf_addf(&buf, "remote.%s.mirror", name);
216
- git_config_set_or_die(buf.buf, "true");
216
+ git_config_set(buf.buf, "true");
217
}
218
219
if (fetch_tags != TAGS_DEFAULT) {
220
strbuf_reset(&buf);
221
strbuf_addf(&buf, "remote.%s.tagopt", name);
222
- git_config_set_or_die(buf.buf,
223
- fetch_tags == TAGS_SET ? "--tags" : "--no-tags");
222
+ git_config_set(buf.buf,
223
+ fetch_tags == TAGS_SET ? "--tags" : "--no-tags");
224
}
225
226
if (fetch && fetch_remote(name))
@@ -586,15 +586,15 @@ static int migrate_file(struct remote *remote)
586
587
strbuf_addf(&buf, "remote.%s.url", remote->name);
588
for (i = 0; i < remote->url_nr; i++)
589
- git_config_set_multivar_or_die(buf.buf, remote->url[i], "^$", 0);
589
+ git_config_set_multivar(buf.buf, remote->url[i], "^$", 0);
590
strbuf_reset(&buf);
591
strbuf_addf(&buf, "remote.%s.push", remote->name);
592
for (i = 0; i < remote->push_refspec_nr; i++)
593
- git_config_set_multivar_or_die(buf.buf, remote->push_refspec[i], "^$", 0);
593
+ git_config_set_multivar(buf.buf, remote->push_refspec[i], "^$", 0);
594
strbuf_reset(&buf);
595
strbuf_addf(&buf, "remote.%s.fetch", remote->name);
596
for (i = 0; i < remote->fetch_refspec_nr; i++)
597
- git_config_set_multivar_or_die(buf.buf, remote->fetch_refspec[i], "^$", 0);
597
+ git_config_set_multivar(buf.buf, remote->fetch_refspec[i], "^$", 0);
598
if (remote->origin == REMOTE_REMOTES)
599
unlink_or_warn(git_path("remotes/%s", remote->name));
600
else if (remote->origin == REMOTE_BRANCHES)
@@ -646,7 +646,7 @@ static int mv(int argc, const char **argv)
646
647
strbuf_reset(&buf);
648
strbuf_addf(&buf, "remote.%s.fetch", rename.new);
649
- git_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);
649
+ git_config_set_multivar(buf.buf, NULL, NULL, 1);
650
strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old);
651
for (i = 0; i < oldremote->fetch_refspec_nr; i++) {
652
char *ptr;
@@ -666,7 +666,7 @@ static int mv(int argc, const char **argv)
666
"\tPlease update the configuration manually if necessary."),
667
buf2.buf);
668
669
- git_config_set_multivar_or_die(buf.buf, buf2.buf, "^$", 0);
669
+ git_config_set_multivar(buf.buf, buf2.buf, "^$", 0);
670
}
671
672
read_branches();
@@ -676,7 +676,7 @@ static int mv(int argc, const char **argv)
676
if (info->remote_name && !strcmp(info->remote_name, rename.old)) {
677
strbuf_reset(&buf);
678
strbuf_addf(&buf, "branch.%s.remote", item->string);
679
- git_config_set_or_die(buf.buf, rename.new);
679
+ git_config_set(buf.buf, rename.new);
680
}
681
}
682
@@ -774,7 +774,7 @@ static int rm(int argc, const char **argv)
774
strbuf_reset(&buf);
775
strbuf_addf(&buf, "branch.%s.%s",
776
item->string, *k);
777
- git_config_set_or_die(buf.buf, NULL);
777
+ git_config_set(buf.buf, NULL);
778
}
779
}
780
}
@@ -1556,10 +1556,10 @@ static int set_url(int argc, const char **argv)
1556
/* Special cases that add new entry. */
1557
if ((!oldurl && !delete_mode) || add_mode) {
1558
if (add_mode)
1559
- git_config_set_multivar_or_die(name_buf.buf, newurl,
1559
+ git_config_set_multivar(name_buf.buf, newurl,
1560
"^$", 0);
1561
else
1562
- git_config_set_or_die(name_buf.buf, newurl);
1562
+ git_config_set(name_buf.buf, newurl);
1563
strbuf_release(&name_buf);
1564
1565
return 0;
@@ -1582,9 +1582,9 @@ static int set_url(int argc, const char **argv)
1582
regfree(&old_regex);
1583
1584
if (!delete_mode)
1585
- git_config_set_multivar_or_die(name_buf.buf, newurl, oldurl, 0);
1585
+ git_config_set_multivar(name_buf.buf, newurl, oldurl, 0);
1586
else
1587
- git_config_set_multivar_or_die(name_buf.buf, NULL, oldurl, 1);
1587
+ git_config_set_multivar(name_buf.buf, NULL, oldurl, 1);
1588
return 0;
1589
}
1590
builtin/submodule--helper.c
+2
-2
@@ -245,8 +245,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
245
p = git_pathdup_submodule(path, "config");
246
if (!p)
247
die(_("could not get submodule directory for '%s'"), path);
248
- git_config_set_in_file_or_die(p, "core.worktree",
249
- relative_path(sb.buf, sm_gitdir, &rel_path));
248
+ git_config_set_in_file(p, "core.worktree",
249
+ relative_path(sb.buf, sm_gitdir, &rel_path));
250
strbuf_release(&sb);
251
strbuf_release(&rel_path);
252
free(sm_gitdir);
cache.h
+4
-4
@@ -1523,15 +1523,15 @@ extern int git_config_maybe_bool(const char *, const char *);
1523
extern int git_config_string(const char **, const char *, const char *);
1524
extern int git_config_pathname(const char **, const char *, const char *);
1525
extern int git_config_set_in_file_gently(const char *, const char *, const char *);
1526
-extern void git_config_set_in_file_or_die(const char *, const char *, const char *);
1526
+extern void git_config_set_in_file(const char *, const char *, const char *);
1527
extern int git_config_set_gently(const char *, const char *);
1528
-extern void git_config_set_or_die(const char *, const char *);
1528
+extern void git_config_set(const char *, const char *);
1529
extern int git_config_parse_key(const char *, char **, int *);
1530
extern int git_config_key_is_valid(const char *key);
1531
extern int git_config_set_multivar_gently(const char *, const char *, const char *, int);
1532
-extern void git_config_set_multivar_or_die(const char *, const char *, const char *, int);
1532
+extern void git_config_set_multivar(const char *, const char *, const char *, int);
1533
extern int git_config_set_multivar_in_file_gently(const char *, const char *, const char *, const char *, int);
1534
-extern void git_config_set_multivar_in_file_or_die(const char *, const char *, const char *, const char *, int);
1534
+extern void git_config_set_multivar_in_file(const char *, const char *, const char *, const char *, int);
1535
extern int git_config_rename_section(const char *, const char *);
1536
extern int git_config_rename_section_in_file(const char *, const char *, const char *);
1537
extern const char *git_etc_gitconfig(void);
compat/precompose_utf8.c
+2
-2
@@ -50,8 +50,8 @@ void probe_utf8_pathname_composition(void)
50
close(output_fd);
51
git_path_buf(&path, "%s", auml_nfd);
52
precomposed_unicode = access(path.buf, R_OK) ? 0 : 1;
53
- git_config_set_or_die("core.precomposeunicode",
54
- precomposed_unicode ? "true" : "false");
53
+ git_config_set("core.precomposeunicode",
54
+ precomposed_unicode ? "true" : "false");
55
git_path_buf(&path, "%s", auml_nfc);
56
if (unlink(path.buf))
57
die_errno(_("failed to unlink '%s'"), path.buf);
config.c
+12
-12
@@ -1831,10 +1831,10 @@ int git_config_set_in_file_gently(const char *config_filename,
1831
return git_config_set_multivar_in_file_gently(config_filename, key, value, NULL, 0);
1832
}
1833
1834
-void git_config_set_in_file_or_die(const char *config_filename,
1835
- const char *key, const char *value)
1834
+void git_config_set_in_file(const char *config_filename,
1835
+ const char *key, const char *value)
1836
{
1837
- git_config_set_multivar_in_file_or_die(config_filename, key, value, NULL, 0);
1837
+ git_config_set_multivar_in_file(config_filename, key, value, NULL, 0);
1838
}
1839
1840
int git_config_set_gently(const char *key, const char *value)
@@ -1842,9 +1842,9 @@ int git_config_set_gently(const char *key, const char *value)
1842
return git_config_set_multivar_gently(key, value, NULL, 0);
1843
}
1844
1845
-void git_config_set_or_die(const char *key, const char *value)
1845
+void git_config_set(const char *key, const char *value)
1846
{
1847
- git_config_set_multivar_or_die(key, value, NULL, 0);
1847
+ git_config_set_multivar(key, value, NULL, 0);
1848
}
1849
1850
/*
@@ -2191,9 +2191,9 @@ write_err_out:
2191
2192
}
2193
2194
-void git_config_set_multivar_in_file_or_die(const char *config_filename,
2195
- const char *key, const char *value,
2196
- const char *value_regex, int multi_replace)
2194
+void git_config_set_multivar_in_file(const char *config_filename,
2195
+ const char *key, const char *value,
2196
+ const char *value_regex, int multi_replace)
2197
{
2198
if (git_config_set_multivar_in_file_gently(config_filename, key, value,
2199
value_regex, multi_replace) < 0)
@@ -2207,11 +2207,11 @@ int git_config_set_multivar_gently(const char *key, const char *value,
2207
multi_replace);
2208
}
2209
2210
-void git_config_set_multivar_or_die(const char *key, const char *value,
2211
- const char *value_regex, int multi_replace)
2210
+void git_config_set_multivar(const char *key, const char *value,
2211
+ const char *value_regex, int multi_replace)
2212
{
2213
- git_config_set_multivar_in_file_or_die(NULL, key, value, value_regex,
2214
- multi_replace);
2213
+ git_config_set_multivar_in_file(NULL, key, value, value_regex,
2214
+ multi_replace);
2215
}
2216
2217
static int section_name_match (const char *buf, const char *name)
sequencer.c
+11
-11
@@ -933,31 +933,31 @@ static void save_opts(struct replay_opts *opts)
933
const char *opts_file = git_path_opts_file();
934
935
if (opts->no_commit)
936
- git_config_set_in_file_or_die(opts_file, "options.no-commit", "true");
936
+ git_config_set_in_file(opts_file, "options.no-commit", "true");
937
if (opts->edit)
938
- git_config_set_in_file_or_die(opts_file, "options.edit", "true");
938
+ git_config_set_in_file(opts_file, "options.edit", "true");
939
if (opts->signoff)
940
- git_config_set_in_file_or_die(opts_file, "options.signoff", "true");
940
+ git_config_set_in_file(opts_file, "options.signoff", "true");
941
if (opts->record_origin)
942
- git_config_set_in_file_or_die(opts_file, "options.record-origin", "true");
942
+ git_config_set_in_file(opts_file, "options.record-origin", "true");
943
if (opts->allow_ff)
944
- git_config_set_in_file_or_die(opts_file, "options.allow-ff", "true");
944
+ git_config_set_in_file(opts_file, "options.allow-ff", "true");
945
if (opts->mainline) {
946
struct strbuf buf = STRBUF_INIT;
947
strbuf_addf(&buf, "%d", opts->mainline);
948
- git_config_set_in_file_or_die(opts_file, "options.mainline", buf.buf);
948
+ git_config_set_in_file(opts_file, "options.mainline", buf.buf);
949
strbuf_release(&buf);
950
}
951
if (opts->strategy)
952
- git_config_set_in_file_or_die(opts_file, "options.strategy", opts->strategy);
952
+ git_config_set_in_file(opts_file, "options.strategy", opts->strategy);
953
if (opts->gpg_sign)
954
- git_config_set_in_file_or_die(opts_file, "options.gpg-sign", opts->gpg_sign);
954
+ git_config_set_in_file(opts_file, "options.gpg-sign", opts->gpg_sign);
955
if (opts->xopts) {
956
int i;
957
for (i = 0; i < opts->xopts_nr; i++)
958
- git_config_set_multivar_in_file_or_die(opts_file,
959
- "options.strategy-option",
960
- opts->xopts[i], "^$", 0);
958
+ git_config_set_multivar_in_file(opts_file,
959
+ "options.strategy-option",
960
+ opts->xopts[i], "^$", 0);
961
}
962
}
963
submodule.c
+3
-3
@@ -1034,9 +1034,9 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)
1034
/* Update core.worktree setting */
1035
strbuf_reset(&file_name);
1036
strbuf_addf(&file_name, "%s/config", git_dir);
1037
- git_config_set_in_file_or_die(file_name.buf, "core.worktree",
1038
- relative_path(real_work_tree, git_dir,
1039
- &rel_path));
1037
+ git_config_set_in_file(file_name.buf, "core.worktree",
1038
+ relative_path(real_work_tree, git_dir,
1039
+ &rel_path));
1040
1041
strbuf_release(&file_name);
1042
strbuf_release(&rel_path);