| 2095 | } |
| 2096 | |
| 2097 | static void submodule_reset_index(const char *path, const char *super_prefix) |
| 2098 | { |
| 2099 | struct child_process cp = CHILD_PROCESS_INIT; |
| 2100 | |
| 2101 | if (validate_submodule_path(path) < 0) |
| 2102 | exit(128); |
| 2103 | |
| 2104 | prepare_submodule_repo_env(&cp.env); |
| 2105 | |
| 2106 | cp.git_cmd = 1; |
| 2107 | cp.no_stdin = 1; |
| 2108 | cp.dir = path; |
| 2109 | |
| 2110 | /* TODO: determine if this might overwright untracked files */ |
| 2111 | strvec_pushl(&cp.args, "read-tree", "-u", "--reset", NULL); |
| 2112 | strvec_pushf(&cp.args, "--super-prefix=%s%s/", |
| 2113 | (super_prefix ? super_prefix : ""), path); |
| 2114 | |
| 2115 | strvec_push(&cp.args, empty_tree_oid_hex(the_repository->hash_algo)); |
| 2116 | |
| 2117 | if (run_command(&cp)) |
| 2118 | die(_("could not reset submodule index")); |
| 2119 | } |
| 2120 | |
| 2121 | /** |
| 2122 | * Moves a submodule at a given path from a given head to another new head. |
no test coverage detected