output_header:
strbuf_addf(&sb, "Submodule %s ", path);
- strbuf_add_unique_abbrev(&sb, one->hash, DEFAULT_ABBREV);
+ strbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);
strbuf_addstr(&sb, (fast_backward || fast_forward) ? ".." : "...");
- strbuf_add_unique_abbrev(&sb, two->hash, DEFAULT_ABBREV);
+ strbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);
if (message)
strbuf_addf(&sb, " %s\n", message);
else
struct object_id *one, struct object_id *two,
unsigned dirty_submodule)
{
- const struct object_id *old = the_hash_algo->empty_tree, *new = the_hash_algo->empty_tree;
+ const struct object_id *old_oid = the_hash_algo->empty_tree, *new_oid = the_hash_algo->empty_tree;
struct commit *left = NULL, *right = NULL;
struct commit_list *merge_bases = NULL;
struct child_process cp = CHILD_PROCESS_INIT;
goto done;
if (left)
- old = one;
+ old_oid = one;
if (right)
- new = two;
+ new_oid = two;
cp.git_cmd = 1;
cp.dir = path;
argv_array_pushf(&cp.args, "--dst-prefix=%s%s/",
o->b_prefix, path);
}
- argv_array_push(&cp.args, oid_to_hex(old));
+ argv_array_push(&cp.args, oid_to_hex(old_oid));
/*
* If the submodule has modified content, we will diff against the
* work tree, under the assumption that the user has asked for the
* haven't yet been committed to the submodule yet.
*/
if (!(dirty_submodule & DIRTY_SUBMODULE_MODIFIED))
- argv_array_push(&cp.args, oid_to_hex(new));
+ argv_array_push(&cp.args, oid_to_hex(new_oid));
prepare_submodule_repo_env(&cp.env_array);
if (start_command(&cp))
return 0;
default:
die(_("submodule entry '%s' (%s) is a %s, not a commit"),
- cb->path, oid_to_hex(oid), typename(type));
+ cb->path, oid_to_hex(oid), type_name(type));
}
}
* pass NULL for old or new respectively.
*/
int submodule_move_head(const char *path,
- const char *old,
- const char *new,
+ const char *old_head,
+ const char *new_head,
unsigned flags)
{
int ret = 0;
else
error_code_ptr = NULL;
- if (old && !is_submodule_populated_gently(path, error_code_ptr))
+ if (old_head && !is_submodule_populated_gently(path, error_code_ptr))
return 0;
sub = submodule_from_path(&null_oid, path);
if (!sub)
die("BUG: could not get submodule information for '%s'", path);
- if (old && !(flags & SUBMODULE_MOVE_HEAD_FORCE)) {
+ if (old_head && !(flags & SUBMODULE_MOVE_HEAD_FORCE)) {
/* Check if the submodule has a dirty index. */
if (submodule_has_dirty_index(sub))
return error(_("submodule '%s' has dirty index"), path);
}
if (!(flags & SUBMODULE_MOVE_HEAD_DRY_RUN)) {
- if (old) {
+ if (old_head) {
if (!submodule_uses_gitfile(path))
absorb_git_dir_into_superproject("", path,
ABSORB_GITDIR_RECURSE_SUBMODULES);
submodule_reset_index(path);
}
- if (old && (flags & SUBMODULE_MOVE_HEAD_FORCE)) {
+ if (old_head && (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);
else
argv_array_push(&cp.args, "-m");
- argv_array_push(&cp.args, old ? old : EMPTY_TREE_SHA1_HEX);
- argv_array_push(&cp.args, new ? new : EMPTY_TREE_SHA1_HEX);
+ if (!(flags & SUBMODULE_MOVE_HEAD_FORCE))
+ argv_array_push(&cp.args, old_head ? old_head : EMPTY_TREE_SHA1_HEX);
+
+ argv_array_push(&cp.args, new_head ? new_head : EMPTY_TREE_SHA1_HEX);
if (run_command(&cp)) {
ret = -1;
}
if (!(flags & SUBMODULE_MOVE_HEAD_DRY_RUN)) {
- if (new) {
+ if (new_head) {
child_process_init(&cp);
/* also set the HEAD accordingly */
cp.git_cmd = 1;
prepare_submodule_repo_env(&cp.env_array);
argv_array_pushl(&cp.args, "update-ref", "HEAD",
- "--no-deref", new, NULL);
+ "--no-deref", new_head, NULL);
if (run_command(&cp)) {
ret = -1;