diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-08-07 08:14:38 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-08-07 08:14:38 -0700 |
| commit | aa4fb2485c674ef943767ab00acdfe29a47de601 (patch) | |
| tree | fa74bd022836d5bf3ec598bb6aadd5f74e05fa2a | |
| parent | Merge branch 'jk/revert-squelch-compiler-warning' (diff) | |
| parent | t/unit-tests/clar: fix -Wmaybe-uninitialized with -Og (diff) | |
| download | git-aa4fb2485c674ef943767ab00acdfe29a47de601.tar.gz git-aa4fb2485c674ef943767ab00acdfe29a47de601.zip | |
Merge branch 'dl/squelch-maybe-uninitialized'
Squelch false-positive compiler warning.
* dl/squelch-maybe-uninitialized:
t/unit-tests/clar: fix -Wmaybe-uninitialized with -Og
remote: bail early from set_head() if missing remote name
| -rw-r--r-- | builtin/remote.c | 11 | ||||
| -rw-r--r-- | t/unit-tests/clar/clar.c | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/builtin/remote.c b/builtin/remote.c index 43a122740a..8961ae6a89 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -1474,10 +1474,13 @@ static int set_head(int argc, const char **argv, const char *prefix, }; argc = parse_options(argc, argv, prefix, options, builtin_remote_sethead_usage, 0); - if (argc) { - strbuf_addf(&b_head, "refs/remotes/%s/HEAD", argv[0]); - remote = remote_get(argv[0]); - } + + /* All modes require at least a remote name. */ + if (!argc) + usage_with_options(builtin_remote_sethead_usage, options); + + strbuf_addf(&b_head, "refs/remotes/%s/HEAD", argv[0]); + remote = remote_get(argv[0]); if (!opt_a && !opt_d && argc == 2) { head_name = xstrdup(argv[1]); diff --git a/t/unit-tests/clar/clar.c b/t/unit-tests/clar/clar.c index d54e455367..03a3aa8e87 100644 --- a/t/unit-tests/clar/clar.c +++ b/t/unit-tests/clar/clar.c @@ -350,7 +350,7 @@ static void clar_run_suite(const struct clar_suite *suite, const char *filter) { const struct clar_func *test = suite->tests; - size_t i, matchlen; + size_t i, matchlen = 0; struct clar_report *report; int exact = 0; |
