commit - 5de743f8fddcaaf2912ffc92dce239aa6227d6d0
commit + aaf30ee7d7d84dcb4161aea893265400f9f19c13
blob - bd2ea5938e70b3a5c5041becda02cdc86e73c4b3
blob + 1ce83bbcfa6c33daba6da2f078860f3a41659d38
--- libexec/got-read-gotconfig/gotconfig.h
+++ libexec/got-read-gotconfig/gotconfig.h
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-struct fetch_repo {
- char *fetch_repository;
- char *fetch_server;
- char *fetch_protocol;
- int fetch_port;
- struct node_branch *fetch_branch;
+/*
+ * We maintain two different structures for fetch and send configuration
+ * settings in case they diverge in the future.
+ */
+struct fetch_config {
+ char *repository;
+ char *server;
+ char *protocol;
+ int port;
+ struct node_branch *branch;
};
-
-struct send_repo {
- char *send_repository;
- char *send_server;
- char *send_protocol;
- int send_port;
- struct node_branch *send_branch;
+struct send_config {
+ char *repository;
+ char *server;
+ char *protocol;
+ int port;
+ struct node_branch *branch;
};
struct node_branch {
int fetch_all_branches;
struct node_branch *branch;
struct node_ref *ref;
- struct fetch_repo *fetch_repo;
- struct send_repo *send_repo;
+ struct fetch_config *fetch_config;
+ struct send_config *send_config;
};
TAILQ_HEAD(gotconfig_remote_repo_list, gotconfig_remote_repo);
blob - 32725fd8694ebfb52f55ac914f0be32ea01f317c
blob + b22c70ab9a554f6e0b28eacc450bfd4f8deaa056
--- libexec/got-read-gotconfig/parse.y
+++ libexec/got-read-gotconfig/parse.y
static struct gotconfig_remote_repo *remote;
static struct gotconfig gotconfig;
static const struct got_error* new_remote(struct gotconfig_remote_repo **);
-static const struct got_error* new_fetch(struct fetch_repo **);
-static const struct got_error* new_send(struct send_repo **);
+static const struct got_error* new_fetch_config(struct fetch_config **);
+static const struct got_error* new_send_config(struct send_config **);
typedef struct {
union {
| FETCH {
static const struct got_error* error;
- if (remote->fetch_repo != NULL) {
+ if (remote->fetch_config != NULL) {
yyerror("fetch block already exists");
YYERROR;
}
- error = new_fetch(&remote->fetch_repo);
+ error = new_fetch_config(&remote->fetch_config);
if (error) {
yyerror("%s", error->msg);
YYERROR;
| SEND {
static const struct got_error* error;
- if (remote->send_repo != NULL) {
+ if (remote->send_config != NULL) {
yyerror("send block already exists");
YYERROR;
}
- error = new_send(&remote->send_repo);
+ error = new_send_config(&remote->send_config);
if (error) {
yyerror("%s", error->msg);
YYERROR;
;
fetchopts1 : /* empty */
| REPOSITORY STRING {
- remote->fetch_repo->fetch_repository = strdup($2);
- if (remote->fetch_repo->fetch_repository == NULL) {
+ remote->fetch_config->repository = strdup($2);
+ if (remote->fetch_config->repository == NULL) {
free($2);
yyerror("strdup");
YYERROR;
free($2);
}
| SERVER STRING {
- remote->fetch_repo->fetch_server = strdup($2);
- if (remote->fetch_repo->fetch_server == NULL) {
+ remote->fetch_config->server = strdup($2);
+ if (remote->fetch_config->server == NULL) {
free($2);
yyerror("strdup");
YYERROR;
free($2);
}
| PROTOCOL STRING {
- remote->fetch_repo->fetch_protocol = strdup($2);
- if (remote->fetch_repo->fetch_protocol == NULL) {
+ remote->fetch_config->protocol = strdup($2);
+ if (remote->fetch_config->protocol == NULL) {
free($2);
yyerror("strdup");
YYERROR;
free($2);
}
| PORT portplain {
- remote->fetch_repo->fetch_port = $2;
+ remote->fetch_config->port = $2;
}
| BRANCH branch {
- remote->fetch_repo->fetch_branch = $2;
+ remote->fetch_config->branch = $2;
}
;
sendopts2 : sendopts2 sendopts1 nl
;
sendopts1 : /* empty */
| REPOSITORY STRING {
- remote->send_repo->send_repository = strdup($2);
- if (remote->send_repo->send_repository == NULL) {
+ remote->send_config->repository = strdup($2);
+ if (remote->send_config->repository == NULL) {
free($2);
yyerror("strdup");
YYERROR;
free($2);
}
| SERVER STRING {
- remote->send_repo->send_server = strdup($2);
- if (remote->send_repo->send_server == NULL) {
+ remote->send_config->server = strdup($2);
+ if (remote->send_config->server == NULL) {
free($2);
yyerror("strdup");
YYERROR;
free($2);
}
| PROTOCOL STRING {
- remote->send_repo->send_protocol = strdup($2);
- if (remote->send_repo->send_protocol == NULL) {
+ remote->send_config->protocol = strdup($2);
+ if (remote->send_config->protocol == NULL) {
free($2);
yyerror("strdup");
YYERROR;
free($2);
}
| PORT portplain {
- remote->send_repo->send_port = $2;
+ remote->send_config->port = $2;
}
| BRANCH branch {
- remote->send_repo->send_branch = $2;
+ remote->send_config->branch = $2;
}
;
remote : REMOTE STRING {
}
static const struct got_error*
-new_fetch(struct fetch_repo **fetch_repo)
+new_fetch_config(struct fetch_config **fetch_config)
{
const struct got_error *error = NULL;
- *fetch_repo = calloc(1, sizeof(**fetch_repo));
- if (*fetch_repo == NULL)
+ *fetch_config = calloc(1, sizeof(**fetch_config));
+ if (*fetch_config == NULL)
error = got_error_from_errno("calloc");
return error;
}
static const struct got_error*
-new_send(struct send_repo **send_repo)
+new_send_config(struct send_config **send_config)
{
const struct got_error *error = NULL;
- *send_repo = calloc(1, sizeof(**send_repo));
- if (*send_repo == NULL)
+ *send_config = calloc(1, sizeof(**send_config));
+ if (*send_config == NULL)
error = got_error_from_errno("calloc");
return error;
}
return gerror;
}
+static void
+free_fetch_config(struct fetch_config *fetch_config)
+{
+ free(remote->fetch_config->repository);
+ free(remote->fetch_config->server);
+ free(remote->fetch_config->protocol);
+ free(remote->fetch_config);
+}
+
+static void
+free_send_config(struct send_config *send_config)
+{
+ free(remote->send_config->repository);
+ free(remote->send_config->server);
+ free(remote->send_config->protocol);
+ free(remote->send_config);
+}
+
void
gotconfig_free(struct gotconfig *conf)
{
while (!TAILQ_EMPTY(&conf->remotes)) {
remote = TAILQ_FIRST(&conf->remotes);
TAILQ_REMOVE(&conf->remotes, remote, entry);
- if (remote->fetch_repo != NULL) {
- free(remote->fetch_repo->fetch_repository);
- free(remote->fetch_repo->fetch_server);
- free(remote->fetch_repo->fetch_protocol);
- }
- if (remote->send_repo != NULL) {
- free(remote->send_repo->send_repository);
- free(remote->send_repo->send_server);
- free(remote->send_repo->send_protocol);
- }
+ if (remote->fetch_config != NULL)
+ free_fetch_config(remote->fetch_config);
+ if (remote->send_config != NULL)
+ free_send_config(remote->send_config);
free(remote->name);
free(remote->repository);
free(remote->server);