Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/helper/test-submodule-config.c # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / helper / test-submodule-config.c` 71 lines ยท 1603 bytes Raw Blame History 1 #define USE_THE_REPOSITORY_VARIABLE 2 3 #include "test-tool.h" 4 #include "config.h" 5 #include "hash.h" 6 #include "object-name.h" 7 #include "repository.h" 8 #include "setup.h" 9 #include "submodule-config.h" 10 #include "submodule.h" 11 12 static void die_usage(int argc UNUSED, const char **argv, const char *msg) 13 { 14 fprintf(stderr, "%s\n", msg); 15 fprintf(stderr, "Usage: %s [ ] ...\n", argv[0]); 16 exit(1); 17 } 18 19 int cmd__submodule_config(int argc, const char **argv) 20 { 21 const char **arg = argv; 22 int my_argc = argc; 23 int lookup_name = 0; 24 25 arg++; 26 my_argc--; 27 while (arg[0] && starts_with(arg[0], "--")) { 28 if (!strcmp(arg[0], "--name")) 29 lookup_name = 1; 30 arg++; 31 my_argc--; 32 } 33 34 if (my_argc % 2 != 0) 35 die_usage(argc, argv, "Wrong number of arguments."); 36 37 setup_git_directory(the_repository); 38 39 while (*arg) { 40 struct object_id commit_oid; 41 const struct submodule *submodule; 42 const char *commit; 43 const char *path_or_name; 44 45 commit = arg[0]; 46 path_or_name = arg[1]; 47 48 if (commit[0] == '\0') 49 oidclr(&commit_oid, the_repository->hash_algo); 50 else if (repo_get_oid(the_repository, commit, &commit_oid) < 0) 51 die_usage(argc, argv, "Commit not found."); 52 53 if (lookup_name) { 54 submodule = submodule_from_name(the_repository, 55 &commit_oid, path_or_name); 56 } else 57 submodule = submodule_from_path(the_repository, 58 &commit_oid, path_or_name); 59 if (!submodule) 60 die_usage(argc, argv, "Submodule not found."); 61 62 printf("Submodule name: '%s' for path '%s'\n", submodule->name, 63 submodule->path); 64 65 arg += 2; 66 } 67 68 submodule_free(the_repository); 69 70 return 0; 71 }