Skip to content

Commit aa13bf0

Browse files
committed
Major submodule rewrite
This replaces the old submodule API with a new extended API that supports most of the things that can be done with `git submodule`.
1 parent decff7b commit aa13bf0

File tree

13 files changed

+2292
-219
lines changed

13 files changed

+2292
-219
lines changed

include/git2/errors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ typedef enum {
5454
GITERR_TREE,
5555
GITERR_INDEXER,
5656
GITERR_SSL,
57+
GITERR_SUBMODULE,
5758
} git_error_t;
5859

5960
/**

include/git2/submodule.h

Lines changed: 420 additions & 45 deletions
Large diffs are not rendered by default.

src/config_file.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,17 @@ static int config_set(git_config_file *cfg, const char *name, const char *value)
253253
char *tmp = NULL;
254254

255255
git__free(key);
256+
256257
if (existing->next != NULL) {
257258
giterr_set(GITERR_CONFIG, "Multivar incompatible with simple set");
258259
return -1;
259260
}
260261

262+
/* don't update if old and new values already match */
263+
if ((!existing->value && !value) ||
264+
(existing->value && value && !strcmp(existing->value, value)))
265+
return 0;
266+
261267
if (value) {
262268
tmp = git__strdup(value);
263269
GITERR_CHECK_ALLOC(tmp);

src/config_file.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,24 @@ GIT_INLINE(void) git_config_file_free(git_config_file *cfg)
1919
cfg->free(cfg);
2020
}
2121

22+
GIT_INLINE(int) git_config_file_get_string(
23+
const char **out, git_config_file *cfg, const char *name)
24+
{
25+
return cfg->get(cfg, name, out);
26+
}
27+
2228
GIT_INLINE(int) git_config_file_set_string(
2329
git_config_file *cfg, const char *name, const char *value)
2430
{
2531
return cfg->set(cfg, name, value);
2632
}
2733

34+
GIT_INLINE(int) git_config_file_delete(
35+
git_config_file *cfg, const char *name)
36+
{
37+
return cfg->del(cfg, name);
38+
}
39+
2840
GIT_INLINE(int) git_config_file_foreach(
2941
git_config_file *cfg,
3042
int (*fn)(const char *key, const char *value, void *data),

src/diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ static int maybe_modified(
530530
status = GIT_DELTA_UNMODIFIED;
531531
else if (git_submodule_lookup(&sub, diff->repo, nitem->path) < 0)
532532
return -1;
533-
else if (sub->ignore == GIT_SUBMODULE_IGNORE_ALL)
533+
else if (git_submodule_ignore(sub) == GIT_SUBMODULE_IGNORE_ALL)
534534
status = GIT_DELTA_UNMODIFIED;
535535
else {
536536
/* TODO: support other GIT_SUBMODULE_IGNORE values */

0 commit comments

Comments
 (0)