]> git.ipfire.org Git - thirdparty/git.git/commit
connect: use "service" enum for "name" argument
authorJeff King <peff@peff.net>
Tue, 19 May 2026 05:22:19 +0000 (01:22 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 May 2026 06:05:46 +0000 (15:05 +0900)
commit3198237bf3ce3c1eae845ac8e13a2da813800c77
tree57e670fc73af1f5d4178f143186531546328bbbf
parent94f057755b7941b321fd11fec1b2e3ca5313a4e0
connect: use "service" enum for "name" argument

The git_connect() function takes a "name" argument which is a bit
confusing. It is _not_ the program to run on the remote repo, which is
specified by the "prog" argument. It should instead be one of a few
well-known strings specifying the type of operation (e.g.,
"git-upload-pack"). But to add to the confusion, unless otherwise
configured, those well-known strings will also be the same as the
programs we run, making it easy to mistake which variable is which.

This confusion comes from eaa0fd6584 (git_connect(): fix corner cases in
downgrading v2 to v0, 2023-03-17), though in its defense, the term
"name" and the use of a string are found in other connect code, going
all the way back to b236752a87 (Support remote archive from all smart
transports, 2009-12-09).

But let's see if we can clean things up a bit. The term "name" is overly
vague. We use "service" in other places, including in the smart-http
protocol, so let's use it here, too.

Using a string invites the notion that it can be anything, not one of a
defined set. Let's instead introduce an enum, which has the added bonus
that the compiler can catch typos for us, rather than quietly choosing
the wrong service from an unexpected strcmp() result.

We do still have to turn our enum into those well-known strings to pass
along in the remote-helper protocol (e.g., for a stateless-connect
directive). But now we do so explicitly and in a way that I think is
much more obvious to follow.

This is a pure cleanup; there should be no behavior change.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/archive.c
builtin/fetch-pack.c
builtin/send-pack.c
connect.c
connect.h
transport-helper.c
transport-internal.h
transport.c
transport.h