commit 93f8a3371abdcbfdc9e411ff44942acb0198ca47 from: Christian Weisgerber date: Mon Aug 30 16:34:04 2021 UTC tweak implementation of separate send {} and fetch {} conf blocks Tweak man page. Factor out repeated code in if/else branches in send_gotconfig_remotes(). ok stsp@ commit - f08eaca092150217800d58a98ee47b078ef8689b commit + 93f8a3371abdcbfdc9e411ff44942acb0198ca47 blob - 7b400d18d82d02aba5e0b4d7b7dad40a43b51be5 blob + fdf75268f1fdfc0967b0af46ec9fcf6efa3c5327 --- got/got.conf.5 +++ got/got.conf.5 @@ -112,7 +112,7 @@ Specify one or more branches which .Cm got fetch and .Cm got send -should fetch and send from the remote repository by default. +should fetch from and send to the remote repository by default. The list of branches specified here can be overridden at the .Cm got fetch and blob - 87b6e325e90f1a5df5293fea97f21d0e0ec8ecdd blob + 3eb4560b62d19ac09c049067c235bc7051c1216c --- libexec/got-read-gotconfig/got-read-gotconfig.c +++ libexec/got-read-gotconfig/got-read-gotconfig.c @@ -255,32 +255,22 @@ send_gotconfig_remotes(struct imsgbuf *ibuf, struct node_ref *ref; int nfetch_branches = 0, nsend_branches = 0, nfetch_refs = 0; - if (repo->fetch_config && repo->fetch_config->branch) { + if (repo->fetch_config && repo->fetch_config->branch) branch = repo->fetch_config->branch; - while (branch) { - branch = branch->next; - nfetch_branches++; - } - } else { + else branch = repo->branch; - while (branch) { - branch = branch->next; - nfetch_branches++; - } + while (branch) { + branch = branch->next; + nfetch_branches++; } - if (repo->send_config && repo->send_config->branch) { + if (repo->send_config && repo->send_config->branch) branch = repo->send_config->branch; - while (branch) { - branch = branch->next; - nsend_branches++; - } - } else { + else branch = repo->branch; - while (branch) { - branch = branch->next; - nsend_branches++; - } + while (branch) { + branch = branch->next; + nsend_branches++; } ref = repo->fetch_ref; @@ -354,44 +344,26 @@ send_gotconfig_remotes(struct imsgbuf *ibuf, free(send_url); send_url = NULL; - if (repo->fetch_config && repo->fetch_config->branch) { + if (repo->fetch_config && repo->fetch_config->branch) branch = repo->fetch_config->branch; - while (branch) { - err = send_gotconfig_str(ibuf, - branch->branch_name); - if (err) - break; - branch = branch->next; - } - } else { + else branch = repo->branch; - while (branch) { - err = send_gotconfig_str(ibuf, - branch->branch_name); - if (err) - break; - branch = branch->next; - } + while (branch) { + err = send_gotconfig_str(ibuf, branch->branch_name); + if (err) + break; + branch = branch->next; } - if (repo->send_config && repo->send_config->branch) { + if (repo->send_config && repo->send_config->branch) branch = repo->send_config->branch; - while (branch) { - err = send_gotconfig_str(ibuf, - branch->branch_name); - if (err) - break; - branch = branch->next; - } - } else { + else branch = repo->branch; - while (branch) { - err = send_gotconfig_str(ibuf, - branch->branch_name); - if (err) - break; - branch = branch->next; - } + while (branch) { + err = send_gotconfig_str(ibuf, branch->branch_name); + if (err) + break; + branch = branch->next; } ref = repo->fetch_ref;