зеркало из https://github.com/microsoft/git.git
Merge branch 'jk/mv-submodules-fix' into maint
* jk/mv-submodules-fix: mv: prevent mismatched data when ignoring errors. builtin/mv: fix out of bounds write Conflicts: t/t7001-mv.sh
This commit is contained in:
Коммит
3097b687be
|
@ -179,6 +179,9 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
|
||||||
modes = xrealloc(modes,
|
modes = xrealloc(modes,
|
||||||
(argc + last - first)
|
(argc + last - first)
|
||||||
* sizeof(enum update_mode));
|
* sizeof(enum update_mode));
|
||||||
|
submodule_gitfile = xrealloc(submodule_gitfile,
|
||||||
|
(argc + last - first)
|
||||||
|
* sizeof(char *));
|
||||||
}
|
}
|
||||||
|
|
||||||
dst = add_slash(dst);
|
dst = add_slash(dst);
|
||||||
|
@ -192,6 +195,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
|
||||||
prefix_path(dst, dst_len,
|
prefix_path(dst, dst_len,
|
||||||
path + length + 1);
|
path + length + 1);
|
||||||
modes[argc + j] = INDEX;
|
modes[argc + j] = INDEX;
|
||||||
|
submodule_gitfile[argc + j] = NULL;
|
||||||
}
|
}
|
||||||
argc += last - first;
|
argc += last - first;
|
||||||
}
|
}
|
||||||
|
@ -227,6 +231,11 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
|
||||||
memmove(destination + i,
|
memmove(destination + i,
|
||||||
destination + i + 1,
|
destination + i + 1,
|
||||||
(argc - i) * sizeof(char *));
|
(argc - i) * sizeof(char *));
|
||||||
|
memmove(modes + i, modes + i + 1,
|
||||||
|
(argc - i) * sizeof(enum update_mode));
|
||||||
|
memmove(submodule_gitfile + i,
|
||||||
|
submodule_gitfile + i + 1,
|
||||||
|
(argc - i) * sizeof(char *));
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -294,7 +294,8 @@ test_expect_success 'setup submodule' '
|
||||||
git submodule add ./. sub &&
|
git submodule add ./. sub &&
|
||||||
echo content >file &&
|
echo content >file &&
|
||||||
git add file &&
|
git add file &&
|
||||||
git commit -m "added sub and file"
|
git commit -m "added sub and file" &&
|
||||||
|
git branch submodule
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'git mv cannot move a submodule in a file' '
|
test_expect_success 'git mv cannot move a submodule in a file' '
|
||||||
|
@ -463,4 +464,14 @@ test_expect_success 'checking out a commit before submodule moved needs manual u
|
||||||
! test -s actual
|
! test -s actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'mv -k does not accidentally destroy submodules' '
|
||||||
|
git checkout submodule &&
|
||||||
|
mkdir dummy dest &&
|
||||||
|
git mv -k dummy sub dest &&
|
||||||
|
git status --porcelain >actual &&
|
||||||
|
grep "^R sub -> dest/sub" actual &&
|
||||||
|
git reset --hard &&
|
||||||
|
git checkout .
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Загрузка…
Ссылка в новой задаче