MCPcopy Index your code
hub / github.com/git/git / submodule_needs_pushing

Function submodule_needs_pushing

submodule.c:1036–1080  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1034}
1035
1036static int submodule_needs_pushing(struct repository *r,
1037 const char *path,
1038 struct oid_array *commits)
1039{
1040 if (!submodule_has_commits(r, path, null_oid(the_hash_algo), commits))
1041 /*
1042 * NOTE: We do consider it safe to return "no" here. The
1043 * correct answer would be "We do not know" instead of
1044 * "No push needed", but it is quite hard to change
1045 * the submodule pointer without having the submodule
1046 * around. If a user did however change the submodules
1047 * without having the submodule around, this indicates
1048 * an expert who knows what they are doing or a
1049 * maintainer integrating work from other people. In
1050 * both cases it should be safe to skip this check.
1051 */
1052 return 0;
1053
1054 if (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) {
1055 struct child_process cp = CHILD_PROCESS_INIT;
1056 struct strbuf buf = STRBUF_INIT;
1057 int needs_pushing = 0;
1058
1059 strvec_push(&cp.args, "rev-list");
1060 oid_array_for_each_unique(commits, append_oid_to_argv, &cp.args);
1061 strvec_pushl(&cp.args, "--not", "--remotes", "-n", "1" , NULL);
1062
1063 prepare_submodule_repo_env(&cp.env);
1064 cp.git_cmd = 1;
1065 cp.no_stdin = 1;
1066 cp.out = -1;
1067 cp.dir = path;
1068 if (start_command(&cp))
1069 die(_("Could not run 'git rev-list <commits> --not --remotes -n 1' command in submodule %s"),
1070 path);
1071 if (strbuf_read(&buf, cp.out, the_hash_algo->hexsz + 1))
1072 needs_pushing = 1;
1073 finish_command(&cp);
1074 close(cp.out);
1075 strbuf_release(&buf);
1076 return needs_pushing;
1077 }
1078
1079 return 0;
1080}
1081
1082int find_unpushed_submodules(struct repository *r,
1083 struct oid_array *commits,

Callers 1

find_unpushed_submodulesFunction · 0.85

Calls 12

submodule_has_commitsFunction · 0.85
null_oidFunction · 0.85
strvec_pushFunction · 0.85
strvec_pushlFunction · 0.85
start_commandFunction · 0.85
strbuf_readFunction · 0.85
finish_commandFunction · 0.85
strbuf_releaseFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected