Skip to content

Commit 3d18064

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 30598ad commit 3d18064

File tree

10 files changed

+67
-67
lines changed

10 files changed

+67
-67
lines changed

builtin/branch.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ static int edit_branch_description(const char *branch_name)
594594
strbuf_stripspace(&buf, 1);
595595

596596
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);
598598
strbuf_release(&name);
599599
strbuf_release(&buf);
600600

@@ -790,10 +790,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
790790
die(_("Branch '%s' has no upstream information"), branch->name);
791791

792792
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);
794794
strbuf_reset(&buf);
795795
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);
797797
strbuf_release(&buf);
798798
} else if (argc > 0 && argc <= 2) {
799799
struct branch *branch = branch_get(argv[0]);

builtin/clone.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,12 +783,12 @@ static void write_refspec_config(const char *src_ref_prefix,
783783
/* Configure the remote */
784784
if (value.len) {
785785
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);
787787
strbuf_reset(&key);
788788

789789
if (option_mirror) {
790790
strbuf_addf(&key, "remote.%s.mirror", option_origin);
791-
git_config_set_or_die(key.buf, "true");
791+
git_config_set(key.buf, "true");
792792
strbuf_reset(&key);
793793
}
794794
}
@@ -946,14 +946,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
946946
src_ref_prefix = "refs/";
947947
strbuf_addstr(&branch_top, src_ref_prefix);
948948

949-
git_config_set_or_die("core.bare", "true");
949+
git_config_set("core.bare", "true");
950950
} else {
951951
strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
952952
}
953953

954954
strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
955955
strbuf_addf(&key, "remote.%s.url", option_origin);
956-
git_config_set_or_die(key.buf, repo);
956+
git_config_set(key.buf, repo);
957957
strbuf_reset(&key);
958958

959959
if (option_reference.nr)

builtin/init-db.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static int create_default_files(const char *template_path)
227227
/* This forces creation of new config file */
228228
xsnprintf(repo_version_string, sizeof(repo_version_string),
229229
"%d", GIT_REPO_VERSION);
230-
git_config_set_or_die("core.repositoryformatversion", repo_version_string);
230+
git_config_set("core.repositoryformatversion", repo_version_string);
231231

232232
/* Check filemode trustability */
233233
path = git_path_buf(&buf, "config");
@@ -241,18 +241,18 @@ static int create_default_files(const char *template_path)
241241
if (filemode && !reinit && (st1.st_mode & S_IXUSR))
242242
filemode = 0;
243243
}
244-
git_config_set_or_die("core.filemode", filemode ? "true" : "false");
244+
git_config_set("core.filemode", filemode ? "true" : "false");
245245

246246
if (is_bare_repository())
247-
git_config_set_or_die("core.bare", "true");
247+
git_config_set("core.bare", "true");
248248
else {
249249
const char *work_tree = get_git_work_tree();
250-
git_config_set_or_die("core.bare", "false");
250+
git_config_set("core.bare", "false");
251251
/* allow template config file to override the default */
252252
if (log_all_ref_updates == -1)
253-
git_config_set_or_die("core.logallrefupdates", "true");
253+
git_config_set("core.logallrefupdates", "true");
254254
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);
256256
}
257257

258258
if (!reinit) {
@@ -265,12 +265,12 @@ static int create_default_files(const char *template_path)
265265
S_ISLNK(st1.st_mode))
266266
unlink(path); /* good */
267267
else
268-
git_config_set_or_die("core.symlinks", "false");
268+
git_config_set("core.symlinks", "false");
269269

270270
/* Check if the filesystem is case-insensitive */
271271
path = git_path_buf(&buf, "CoNfIg");
272272
if (!access(path, F_OK))
273-
git_config_set_or_die("core.ignorecase", "true");
273+
git_config_set("core.ignorecase", "true");
274274
probe_utf8_pathname_composition();
275275
}
276276

@@ -386,8 +386,8 @@ int init_db(const char *template_dir, unsigned int flags)
386386
xsnprintf(buf, sizeof(buf), "%d", OLD_PERM_EVERYBODY);
387387
else
388388
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");
391391
}
392392

393393
if (!(flags & INIT_DB_QUIET)) {

builtin/remote.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static void add_branch(const char *key, const char *branchname,
119119
else
120120
strbuf_addf(tmp, "refs/heads/%s:refs/remotes/%s/%s",
121121
branchname, remotename, branchname);
122-
git_config_set_multivar_or_die(key, tmp->buf, "^$", 0);
122+
git_config_set_multivar(key, tmp->buf, "^$", 0);
123123
}
124124

125125
static const char mirror_advice[] =
@@ -197,7 +197,7 @@ static int add(int argc, const char **argv)
197197
die(_("'%s' is not a valid remote name"), name);
198198

199199
strbuf_addf(&buf, "remote.%s.url", name);
200-
git_config_set_or_die(buf.buf, url);
200+
git_config_set(buf.buf, url);
201201

202202
if (!mirror || mirror & MIRROR_FETCH) {
203203
strbuf_reset(&buf);
@@ -213,14 +213,14 @@ static int add(int argc, const char **argv)
213213
if (mirror & MIRROR_PUSH) {
214214
strbuf_reset(&buf);
215215
strbuf_addf(&buf, "remote.%s.mirror", name);
216-
git_config_set_or_die(buf.buf, "true");
216+
git_config_set(buf.buf, "true");
217217
}
218218

219219
if (fetch_tags != TAGS_DEFAULT) {
220220
strbuf_reset(&buf);
221221
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");
224224
}
225225

226226
if (fetch && fetch_remote(name))
@@ -586,15 +586,15 @@ static int migrate_file(struct remote *remote)
586586

587587
strbuf_addf(&buf, "remote.%s.url", remote->name);
588588
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);
590590
strbuf_reset(&buf);
591591
strbuf_addf(&buf, "remote.%s.push", remote->name);
592592
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);
594594
strbuf_reset(&buf);
595595
strbuf_addf(&buf, "remote.%s.fetch", remote->name);
596596
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);
598598
if (remote->origin == REMOTE_REMOTES)
599599
unlink_or_warn(git_path("remotes/%s", remote->name));
600600
else if (remote->origin == REMOTE_BRANCHES)
@@ -646,7 +646,7 @@ static int mv(int argc, const char **argv)
646646

647647
strbuf_reset(&buf);
648648
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);
650650
strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old);
651651
for (i = 0; i < oldremote->fetch_refspec_nr; i++) {
652652
char *ptr;
@@ -666,7 +666,7 @@ static int mv(int argc, const char **argv)
666666
"\tPlease update the configuration manually if necessary."),
667667
buf2.buf);
668668

669-
git_config_set_multivar_or_die(buf.buf, buf2.buf, "^$", 0);
669+
git_config_set_multivar(buf.buf, buf2.buf, "^$", 0);
670670
}
671671

672672
read_branches();
@@ -676,7 +676,7 @@ static int mv(int argc, const char **argv)
676676
if (info->remote_name && !strcmp(info->remote_name, rename.old)) {
677677
strbuf_reset(&buf);
678678
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);
680680
}
681681
}
682682

@@ -774,7 +774,7 @@ static int rm(int argc, const char **argv)
774774
strbuf_reset(&buf);
775775
strbuf_addf(&buf, "branch.%s.%s",
776776
item->string, *k);
777-
git_config_set_or_die(buf.buf, NULL);
777+
git_config_set(buf.buf, NULL);
778778
}
779779
}
780780
}
@@ -1556,10 +1556,10 @@ static int set_url(int argc, const char **argv)
15561556
/* Special cases that add new entry. */
15571557
if ((!oldurl && !delete_mode) || add_mode) {
15581558
if (add_mode)
1559-
git_config_set_multivar_or_die(name_buf.buf, newurl,
1559+
git_config_set_multivar(name_buf.buf, newurl,
15601560
"^$", 0);
15611561
else
1562-
git_config_set_or_die(name_buf.buf, newurl);
1562+
git_config_set(name_buf.buf, newurl);
15631563
strbuf_release(&name_buf);
15641564

15651565
return 0;
@@ -1582,9 +1582,9 @@ static int set_url(int argc, const char **argv)
15821582
regfree(&old_regex);
15831583

15841584
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);
15861586
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);
15881588
return 0;
15891589
}
15901590

builtin/submodule--helper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
245245
p = git_pathdup_submodule(path, "config");
246246
if (!p)
247247
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));
250250
strbuf_release(&sb);
251251
strbuf_release(&rel_path);
252252
free(sm_gitdir);

cache.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,15 +1523,15 @@ extern int git_config_maybe_bool(const char *, const char *);
15231523
extern int git_config_string(const char **, const char *, const char *);
15241524
extern int git_config_pathname(const char **, const char *, const char *);
15251525
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 *);
15271527
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 *);
15291529
extern int git_config_parse_key(const char *, char **, int *);
15301530
extern int git_config_key_is_valid(const char *key);
15311531
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);
15331533
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);
15351535
extern int git_config_rename_section(const char *, const char *);
15361536
extern int git_config_rename_section_in_file(const char *, const char *, const char *);
15371537
extern const char *git_etc_gitconfig(void);

compat/precompose_utf8.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ void probe_utf8_pathname_composition(void)
5050
close(output_fd);
5151
git_path_buf(&path, "%s", auml_nfd);
5252
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");
5555
git_path_buf(&path, "%s", auml_nfc);
5656
if (unlink(path.buf))
5757
die_errno(_("failed to unlink '%s'"), path.buf);

config.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,20 +1831,20 @@ int git_config_set_in_file_gently(const char *config_filename,
18311831
return git_config_set_multivar_in_file_gently(config_filename, key, value, NULL, 0);
18321832
}
18331833

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)
18361836
{
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);
18381838
}
18391839

18401840
int git_config_set_gently(const char *key, const char *value)
18411841
{
18421842
return git_config_set_multivar_gently(key, value, NULL, 0);
18431843
}
18441844

1845-
void git_config_set_or_die(const char *key, const char *value)
1845+
void git_config_set(const char *key, const char *value)
18461846
{
1847-
git_config_set_multivar_or_die(key, value, NULL, 0);
1847+
git_config_set_multivar(key, value, NULL, 0);
18481848
}
18491849

18501850
/*
@@ -2191,9 +2191,9 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
21912191

21922192
}
21932193

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)
21972197
{
21982198
if (git_config_set_multivar_in_file_gently(config_filename, key, value,
21992199
value_regex, multi_replace) < 0)
@@ -2207,11 +2207,11 @@ int git_config_set_multivar_gently(const char *key, const char *value,
22072207
multi_replace);
22082208
}
22092209

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)
22122212
{
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);
22152215
}
22162216

22172217
static int section_name_match (const char *buf, const char *name)

sequencer.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -933,31 +933,31 @@ static void save_opts(struct replay_opts *opts)
933933
const char *opts_file = git_path_opts_file();
934934

935935
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");
937937
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");
939939
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");
941941
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");
943943
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");
945945
if (opts->mainline) {
946946
struct strbuf buf = STRBUF_INIT;
947947
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);
949949
strbuf_release(&buf);
950950
}
951951
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);
953953
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);
955955
if (opts->xopts) {
956956
int i;
957957
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);
961961
}
962962
}
963963

submodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,9 +1034,9 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)
10341034
/* Update core.worktree setting */
10351035
strbuf_reset(&file_name);
10361036
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));
10401040

10411041
strbuf_release(&file_name);
10421042
strbuf_release(&rel_path);

0 commit comments

Comments
 (0)