Skip to content

Commit

Permalink
upload-pack: fix how ALLOW_ANY_SHA1 flag is disabled
Browse files Browse the repository at this point in the history
ALLOW_ANY_SHA1 implies ALLOW_TIP_SHA1 and ALLOW_REACHABLE_SHA1.
Yet ALLOW_TIP_SHA1 and ALLOW_REACHABLE_SHA1 flags can be enabled
independently.
If uploadpack.allowAnySHA1InWant is not enabled in config file,
other flags should not be disabled together with ALLOW_ANY_SHA1.
They should be kept enabled if they were separately enabled in
config file with they respective options.

Signed-off-by: Piotr Szlazak <[email protected]>
  • Loading branch information
pszlazak committed Oct 16, 2024
1 parent ef8ce8f commit 8a2673b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion upload-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ enum allow_uor {
/* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */
ALLOW_REACHABLE_SHA1 = 0x02,
/* Allow request of any sha1. Implies ALLOW_TIP_SHA1 and ALLOW_REACHABLE_SHA1. */
/* As this flag implies other two flags, be careful when it must be disabled. */
ALLOW_ANY_SHA1 = 0x07
};

Expand Down Expand Up @@ -1368,7 +1369,7 @@ static int upload_pack_config(const char *var, const char *value,
if (git_config_bool(var, value))
data->allow_uor |= ALLOW_ANY_SHA1;
else
data->allow_uor &= ~ALLOW_ANY_SHA1;
data->allow_uor &= ~(ALLOW_ANY_SHA1 -(ALLOW_TIP_SHA1|ALLOW_REACHABLE_SHA1));
} else if (!strcmp("uploadpack.keepalive", var)) {
data->keepalive = git_config_int(var, value, ctx->kvi);
if (!data->keepalive)
Expand Down

0 comments on commit 8a2673b

Please sign in to comment.