| 990 | } |
| 991 | |
| 992 | static int submodule_has_commits(struct repository *r, |
| 993 | const char *path, |
| 994 | const struct object_id *super_oid, |
| 995 | struct oid_array *commits) |
| 996 | { |
| 997 | struct has_commit_data has_commit = { |
| 998 | .repo = r, |
| 999 | .result = 1, |
| 1000 | .path = path, |
| 1001 | .super_oid = super_oid |
| 1002 | }; |
| 1003 | |
| 1004 | if (validate_submodule_path(path) < 0) |
| 1005 | exit(128); |
| 1006 | |
| 1007 | oid_array_for_each_unique(commits, check_has_commit, &has_commit); |
| 1008 | |
| 1009 | if (has_commit.result) { |
| 1010 | /* |
| 1011 | * Even if the submodule is checked out and the commit is |
| 1012 | * present, make sure it exists in the submodule's object store |
| 1013 | * and that it is reachable from a ref. |
| 1014 | */ |
| 1015 | struct child_process cp = CHILD_PROCESS_INIT; |
| 1016 | struct strbuf out = STRBUF_INIT; |
| 1017 | |
| 1018 | strvec_pushl(&cp.args, "rev-list", "-n", "1", NULL); |
| 1019 | oid_array_for_each_unique(commits, append_oid_to_argv, &cp.args); |
| 1020 | strvec_pushl(&cp.args, "--not", "--all", NULL); |
| 1021 | |
| 1022 | prepare_submodule_repo_env(&cp.env); |
| 1023 | cp.git_cmd = 1; |
| 1024 | cp.no_stdin = 1; |
| 1025 | cp.dir = path; |
| 1026 | |
| 1027 | if (capture_command(&cp, &out, GIT_MAX_HEXSZ + 1) || out.len) |
| 1028 | has_commit.result = 0; |
| 1029 | |
| 1030 | strbuf_release(&out); |
| 1031 | } |
| 1032 | |
| 1033 | return has_commit.result; |
| 1034 | } |
| 1035 | |
| 1036 | static int submodule_needs_pushing(struct repository *r, |
| 1037 | const char *path, |
no test coverage detected