Commit 9a46c77739e9add922fca8f7798786a6bd2893e8

Ariel Davis 2017-06-16T21:02:26

repository: do not initialize templates if dir is an empty string

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/src/repository.c b/src/repository.c
index 7ecb00e..197ce6a 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1784,7 +1784,13 @@ static int repo_init_structure(
 			default_template = true;
 		}
 
-		if (tdir) {
+		/*
+		 * If tdir was the empty string, treat it like tdir was a path to an
+		 * empty directory (so, don't do any copying). This is the behavior
+		 * that git(1) exhibits, although it doesn't seem to be officially
+		 * documented.
+		 */
+		if (tdir && git__strcmp(tdir, "") != 0) {
 			uint32_t cpflags = GIT_CPDIR_COPY_SYMLINKS |
 				GIT_CPDIR_SIMPLE_TO_MODE |
 				GIT_CPDIR_COPY_DOTFILES;