mirror of
https://github.com/git/git
synced 2024-10-30 14:03:28 +00:00
ccd12a3d6c
More header clean-up. * en/header-split-cache-h-part-2: (22 commits) reftable: ensure git-compat-util.h is the first (indirect) include diff.h: reduce unnecessary includes object-store.h: reduce unnecessary includes commit.h: reduce unnecessary includes fsmonitor: reduce includes of cache.h cache.h: remove unnecessary headers treewide: remove cache.h inclusion due to previous changes cache,tree: move basic name compare functions from read-cache to tree cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c hash-ll.h: split out of hash.h to remove dependency on repository.h tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.h dir.h: move DTYPE defines from cache.h versioncmp.h: move declarations for versioncmp.c functions from cache.h ws.h: move declarations for ws.c functions from cache.h match-trees.h: move declarations for match-trees.c functions from cache.h pkt-line.h: move declarations for pkt-line.c functions from cache.h base85.h: move declarations for base85.c functions from cache.h copy.h: move declarations for copy.c functions from cache.h server-info.h: move declarations for server-info.c functions from cache.h packfile.h: move pack_window and pack_entry from cache.h ...
69 lines
1.5 KiB
C
69 lines
1.5 KiB
C
#include "test-tool.h"
|
|
#include "config.h"
|
|
#include "hash.h"
|
|
#include "object-name.h"
|
|
#include "repository.h"
|
|
#include "setup.h"
|
|
#include "submodule-config.h"
|
|
#include "submodule.h"
|
|
|
|
static void die_usage(int argc UNUSED, const char **argv, const char *msg)
|
|
{
|
|
fprintf(stderr, "%s\n", msg);
|
|
fprintf(stderr, "Usage: %s [<commit> <submodulepath>] ...\n", argv[0]);
|
|
exit(1);
|
|
}
|
|
|
|
int cmd__submodule_config(int argc, const char **argv)
|
|
{
|
|
const char **arg = argv;
|
|
int my_argc = argc;
|
|
int lookup_name = 0;
|
|
|
|
arg++;
|
|
my_argc--;
|
|
while (arg[0] && starts_with(arg[0], "--")) {
|
|
if (!strcmp(arg[0], "--name"))
|
|
lookup_name = 1;
|
|
arg++;
|
|
my_argc--;
|
|
}
|
|
|
|
if (my_argc % 2 != 0)
|
|
die_usage(argc, argv, "Wrong number of arguments.");
|
|
|
|
setup_git_directory();
|
|
|
|
while (*arg) {
|
|
struct object_id commit_oid;
|
|
const struct submodule *submodule;
|
|
const char *commit;
|
|
const char *path_or_name;
|
|
|
|
commit = arg[0];
|
|
path_or_name = arg[1];
|
|
|
|
if (commit[0] == '\0')
|
|
oidclr(&commit_oid);
|
|
else if (repo_get_oid(the_repository, commit, &commit_oid) < 0)
|
|
die_usage(argc, argv, "Commit not found.");
|
|
|
|
if (lookup_name) {
|
|
submodule = submodule_from_name(the_repository,
|
|
&commit_oid, path_or_name);
|
|
} else
|
|
submodule = submodule_from_path(the_repository,
|
|
&commit_oid, path_or_name);
|
|
if (!submodule)
|
|
die_usage(argc, argv, "Submodule not found.");
|
|
|
|
printf("Submodule name: '%s' for path '%s'\n", submodule->name,
|
|
submodule->path);
|
|
|
|
arg += 2;
|
|
}
|
|
|
|
submodule_free(the_repository);
|
|
|
|
return 0;
|
|
}
|