summaryrefslogtreecommitdiff
path: root/contrib/svn-fe/svnrdump_sim.py
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2025-08-04 22:31:13 -0700
committerJunio C Hamano <gitster@pobox.com>2025-08-05 08:22:35 -0700
commiteb883b05da4489cef3fe7961a61faaa7533a9541 (patch)
treeb7decd24ca73dcb3f086cce26cafb04dce2a47a4 /contrib/svn-fe/svnrdump_sim.py
parentf368df439b31b422169975cc3c95f7db6a46eada (diff)
remote: bail early from set_head() if missing remote name
In "git remote set-head", we can take varying numbers of arguments depending on whether we saw the "-d" or "-a" options. But the first argument is always the remote name. The current code is somewhat awkward in that it conditionally handles the remote name up-front like this: if (argc) remote = ...from argv[0]... and then only later decides to bail if we do not have the right number of arguments for the options we saw. This makes it hard to figure out if "remote" is always set when it needs to be. Both for humans, but also for compilers; with -Og, gcc complains that "remote" can be accessed without being initialized (although this is not true, as we'd always die with a usage message in that case). Let's instead enforce the presence of the remote argument up front, which fixes the compiler warning and is easier to understand. It does mean duplicating the code to print a usage message, but it's a single line. Noticed-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Jeff King <peff@peff.net> Tested-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/svn-fe/svnrdump_sim.py')
0 files changed, 0 insertions, 0 deletions