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 /builtin | |
| 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
Diffstat (limited to 'builtin')
| -rw-r--r-- | builtin/remote.c | 11 |
1 files changed, 7 insertions, 4 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]); |
