Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-05-29 06:34:40 +0300
committerJunio C Hamano <gitster@pobox.com>2017-05-29 06:34:40 +0300
commit5f074ca7e8ddccb6471e457d7a3f85c1fe00e21a (patch)
treebe3c66e879a0278947e30089b376434c6af3a5d8 /submodule.c
parent1eb437020a2c098a7c12da4c05082fbea10d98c9 (diff)
parent35b96d1de8e795aeac8ec281e88e59f2778335e7 (diff)
Merge branch 'sb/reset-recurse-submodules'
"git reset" learned "--recurse-submodules" option. * sb/reset-recurse-submodules: builtin/reset: add --recurse-submodules switch submodule.c: submodule_move_head works with broken submodules submodule.c: uninitialized submodules are ignored in recursive commands entry.c: submodule recursing: respect force flag correctly
Diffstat (limited to 'submodule.c')
-rw-r--r--submodule.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/submodule.c b/submodule.c
index 7eaa3d384e..54825100b2 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1402,6 +1402,23 @@ int submodule_move_head(const char *path,
int ret = 0;
struct child_process cp = CHILD_PROCESS_INIT;
const struct submodule *sub;
+ int *error_code_ptr, error_code;
+
+ if (!is_submodule_initialized(path))
+ return 0;
+
+ if (flags & SUBMODULE_MOVE_HEAD_FORCE)
+ /*
+ * Pass non NULL pointer to is_submodule_populated_gently
+ * to prevent die()-ing. We'll use connect_work_tree_and_git_dir
+ * to fixup the submodule in the force case later.
+ */
+ error_code_ptr = &error_code;
+ else
+ error_code_ptr = NULL;
+
+ if (old && !is_submodule_populated_gently(path, error_code_ptr))
+ return 0;
sub = submodule_from_path(null_sha1, path);
@@ -1420,15 +1437,21 @@ int submodule_move_head(const char *path,
absorb_git_dir_into_superproject("", path,
ABSORB_GITDIR_RECURSE_SUBMODULES);
} else {
- struct strbuf sb = STRBUF_INIT;
- strbuf_addf(&sb, "%s/modules/%s",
+ char *gitdir = xstrfmt("%s/modules/%s",
get_git_common_dir(), sub->name);
- connect_work_tree_and_git_dir(path, sb.buf);
- strbuf_release(&sb);
+ connect_work_tree_and_git_dir(path, gitdir);
+ free(gitdir);
/* make sure the index is clean as well */
submodule_reset_index(path);
}
+
+ if (old && (flags & SUBMODULE_MOVE_HEAD_FORCE)) {
+ char *gitdir = xstrfmt("%s/modules/%s",
+ get_git_common_dir(), sub->name);
+ connect_work_tree_and_git_dir(path, gitdir);
+ free(gitdir);
+ }
}
prepare_submodule_repo_env_no_git_dir(&cp.env_array);