Skip to content

Commit

Permalink
feat(tag): Add submodule tagging
Browse files Browse the repository at this point in the history
Signed-off-by: dark0dave <dark0dave@mykolab.com>
  • Loading branch information
dark0dave committed Apr 14, 2024
1 parent 8f7582d commit d6ec296
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions submodule-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ static void free_one_config(struct submodule_entry *entry)
free((void *) entry->config->path);
free((void *) entry->config->name);
free((void *) entry->config->branch);
free((void *) entry->config->tag);
free((void *) entry->config->update_strategy.command);
free(entry->config);
}
Expand Down Expand Up @@ -413,6 +414,7 @@ static struct submodule *lookup_or_create_by_name(struct submodule_cache *cache,
submodule->fetch_recurse = RECURSE_SUBMODULES_NONE;
submodule->ignore = NULL;
submodule->branch = NULL;
submodule->tag = NULL;
submodule->recommend_shallow = -1;

oidcpy(&submodule->gitmodules_oid, gitmodules_oid);
Expand Down Expand Up @@ -658,13 +660,25 @@ static int parse_config(const char *var, const char *value,
} else if (!strcmp(item.buf, "branch")) {
if (!value)
ret = config_error_nonbool(var);
else if (submodule->branch && submodule->tag)
die(_("can not specify both tag and branch '%s'"), var);
else if (!me->overwrite && submodule->branch)
warn_multiple_config(me->treeish_name, submodule->name,
"branch");
else {
free((void *)submodule->branch);
submodule->branch = xstrdup(value);
}
} else if (!strcmp(item.buf, "tag")) {
if (!value)
ret = config_error_nonbool(var);
else if (!me->overwrite && submodule->tag)
warn_multiple_config(me->treeish_name, submodule->name,
"tag");
else {
free((void *)submodule->tag);
submodule->tag = xstrdup(value);
}
}

strbuf_release(&name);
Expand Down
1 change: 1 addition & 0 deletions submodule-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct submodule {
enum submodule_recurse_mode fetch_recurse;
const char *ignore;
const char *branch;
const char *tag;
struct submodule_update_strategy update_strategy;
/* the object id of the responsible .gitmodules file */
struct object_id gitmodules_oid;
Expand Down

0 comments on commit d6ec296

Please sign in to comment.