| 1839 | } |
| 1840 | |
| 1841 | static int merge_submodule(struct merge_options *opt, |
| 1842 | const char *path, |
| 1843 | const struct object_id *o, |
| 1844 | const struct object_id *a, |
| 1845 | const struct object_id *b, |
| 1846 | struct object_id *result) |
| 1847 | { |
| 1848 | struct repository subrepo; |
| 1849 | struct strbuf sb = STRBUF_INIT; |
| 1850 | int ret = 0, ret2; |
| 1851 | struct commit *commit_o, *commit_a, *commit_b; |
| 1852 | int parent_count; |
| 1853 | struct object_array merges; |
| 1854 | |
| 1855 | int i; |
| 1856 | int search = !opt->priv->call_depth; |
| 1857 | int sub_not_initialized = 1; |
| 1858 | int sub_flag = CONFLICT_SUBMODULE_FAILED_TO_MERGE; |
| 1859 | |
| 1860 | /* store fallback answer in result in case we fail */ |
| 1861 | oidcpy(result, opt->priv->call_depth ? o : a); |
| 1862 | |
| 1863 | /* we can not handle deletion conflicts */ |
| 1864 | if (is_null_oid(a) || is_null_oid(b)) |
| 1865 | BUG("submodule deleted on one side; this should be handled outside of merge_submodule()"); |
| 1866 | |
| 1867 | if ((sub_not_initialized = repo_submodule_init(&subrepo, |
| 1868 | opt->repo, path, null_oid(opt->repo->hash_algo)))) { |
| 1869 | path_msg(opt, CONFLICT_SUBMODULE_NOT_INITIALIZED, 0, |
| 1870 | path, NULL, NULL, NULL, |
| 1871 | _("Failed to merge submodule %s (not checked out)"), |
| 1872 | path); |
| 1873 | sub_flag = CONFLICT_SUBMODULE_NOT_INITIALIZED; |
| 1874 | goto cleanup; |
| 1875 | } |
| 1876 | |
| 1877 | if (is_null_oid(o)) { |
| 1878 | path_msg(opt, CONFLICT_SUBMODULE_NULL_MERGE_BASE, 0, |
| 1879 | path, NULL, NULL, NULL, |
| 1880 | _("Failed to merge submodule %s (no merge base)"), |
| 1881 | path); |
| 1882 | goto cleanup; |
| 1883 | } |
| 1884 | |
| 1885 | if (!(commit_o = lookup_commit_reference(&subrepo, o)) || |
| 1886 | !(commit_a = lookup_commit_reference(&subrepo, a)) || |
| 1887 | !(commit_b = lookup_commit_reference(&subrepo, b))) { |
| 1888 | path_msg(opt, CONFLICT_SUBMODULE_HISTORY_NOT_AVAILABLE, 0, |
| 1889 | path, NULL, NULL, NULL, |
| 1890 | _("Failed to merge submodule %s (commits not present)"), |
| 1891 | path); |
| 1892 | sub_flag = CONFLICT_SUBMODULE_HISTORY_NOT_AVAILABLE; |
| 1893 | goto cleanup; |
| 1894 | } |
| 1895 | |
| 1896 | /* check whether both changes are forward */ |
| 1897 | ret2 = repo_in_merge_bases(&subrepo, commit_o, commit_a); |
| 1898 | if (ret2 < 0) { |
no test coverage detected