diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-05-15 09:52:55 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-05-15 09:52:55 -0700 |
| commit | 1e00d22ec514fdb1056314da4e8a4e2ce2d53ddd (patch) | |
| tree | 3b0baef0d6edae8dc5128e6cf8dadbac8bfc9643 /scalar.c | |
| parent | 754ae502191e3f9980b8583280c48368ee667b2c (diff) | |
| parent | b64b0df9dac14d8a9b498a6ecf899046eddf53ab (diff) | |
Merge branch 'ds/scalar-reconfigure-all-fix'
Scalar fix.
* ds/scalar-reconfigure-all-fix:
scalar: avoid segfault in reconfigure --all
Diffstat (limited to 'scalar.c')
| -rw-r--r-- | scalar.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -645,7 +645,6 @@ static int cmd_reconfigure(int argc, const char **argv) }; struct string_list scalar_repos = STRING_LIST_INIT_DUP; int i, res = 0; - struct repository r = { NULL }; struct strbuf commondir = STRBUF_INIT, gitdir = STRBUF_INIT; argc = parse_options(argc, argv, NULL, options, @@ -665,6 +664,7 @@ static int cmd_reconfigure(int argc, const char **argv) for (i = 0; i < scalar_repos.nr; i++) { int succeeded = 0; + struct repository *old_repo, r = { NULL }; const char *dir = scalar_repos.items[i].string; strbuf_reset(&commondir); @@ -712,13 +712,17 @@ static int cmd_reconfigure(int argc, const char **argv) git_config_clear(); + if (repo_init(&r, gitdir.buf, commondir.buf)) + goto loop_end; + + old_repo = the_repository; the_repository = &r; - r.commondir = commondir.buf; - r.gitdir = gitdir.buf; if (set_recommended_config(1) >= 0) succeeded = 1; + the_repository = old_repo; + loop_end: if (!succeeded) { res = -1; |
