On Wed, 13 May 2020 at 02:56, brian m. carlson <sandals@xxxxxxxxxxxxxxxxxxxx> wrote: > Add a function, server_supports_hash, to see if the remote server > supports a particular hash algorithm when speaking protocol v1. > +int server_supports_hash(const char *desired, int *feature_supported) > +{ > + int offset = 0; > + int len, found = 0; > + const char *hash; > + > + hash = next_server_feature_value("object-format", &len, &offset); > + if (feature_supported) > + *feature_supported = !!hash; If we got something, anything, the server supports this feature. It just remains to see if it supports the exact algorithm we're after. > + if (!hash) { > + hash = hash_algos[GIT_HASH_SHA1].name; > + len = strlen(hash); > + } OK, if the server doesn't say anything, we fall back to SHA-1. If it's the desired one, we'll return 1 accordingly below. > + while (hash) { > + if (!xstrncmpz(desired, hash, len)) > + found = 1; > + > + if (found) > + return 1; I first thought this structure was because this loop body would learn to do something else later in the series. But this is it. This looks like it could just be "if (!xstrncmpz(...)) return 1;" and drop "found". > + hash = next_server_feature_value("object-format", &len, &offset); > + } > + return 0; > +} Martin