Skip to content

Commit 73d8bfd

Browse files
committed
Merge branch 'jk/cleanup-failed-clone' into maint
An failure early in the "git clone" that started creating the working tree and repository could have resulted in some directories and files left without getting cleaned up. * jk/cleanup-failed-clone: clone: drop period from end of die_errno message clone: initialize atexit cleanup handler earlier
2 parents 591a1da + 16eff6c commit 73d8bfd

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

builtin/clone.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -842,20 +842,21 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
842842
git_dir = mkpathdup("%s/.git", dir);
843843
}
844844

845+
atexit(remove_junk);
846+
sigchain_push_common(remove_junk_on_signal);
847+
845848
if (!option_bare) {
846-
junk_work_tree = work_tree;
847849
if (safe_create_leading_directories_const(work_tree) < 0)
848850
die_errno(_("could not create leading directories of '%s'"),
849851
work_tree);
850852
if (!dest_exists && mkdir(work_tree, 0777))
851-
die_errno(_("could not create work tree dir '%s'."),
853+
die_errno(_("could not create work tree dir '%s'"),
852854
work_tree);
855+
junk_work_tree = work_tree;
853856
set_git_work_tree(work_tree);
854857
}
855-
junk_git_dir = git_dir;
856-
atexit(remove_junk);
857-
sigchain_push_common(remove_junk_on_signal);
858858

859+
junk_git_dir = git_dir;
859860
if (safe_create_leading_directories_const(git_dir) < 0)
860861
die(_("could not create leading directories of '%s'"), git_dir);
861862

0 commit comments

Comments
 (0)