提交 b31d2022 编写于 作者: N Nguyễn Thái Ngọc Duy 提交者: Junio C Hamano

init: remove unnecessary check

git_dir must always be non-NULL so "if (git_dir)" is unnecessary.
Before this code, if git_dir == NULL, it will default to
DEFAULT_GIT_DIR_ENVIRONMENT.
Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 ec48d4bb
......@@ -498,13 +498,11 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
is_bare_repository_cfg = guess_repository_type(git_dir);
if (!is_bare_repository_cfg) {
if (git_dir) {
const char *git_dir_parent = strrchr(git_dir, '/');
if (git_dir_parent) {
char *rel = xstrndup(git_dir, git_dir_parent - git_dir);
git_work_tree_cfg = xstrdup(make_absolute_path(rel));
free(rel);
}
const char *git_dir_parent = strrchr(git_dir, '/');
if (git_dir_parent) {
char *rel = xstrndup(git_dir, git_dir_parent - git_dir);
git_work_tree_cfg = xstrdup(make_absolute_path(rel));
free(rel);
}
if (!git_work_tree_cfg) {
git_work_tree_cfg = xcalloc(PATH_MAX, 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册