Commit 1ca3e49f889a3732922e6f2b303dfe0d9f74300a

Russell Belfer 2013-09-23T13:34:01

Clean up newly introduced warnings The attempt to "clean up warnings" seems to have introduced some new warnings on compliant compilers. This fixes those in a way that I suspect will also be okay for the non-compliant compilers. Also this fixes what appears to be an extra semicolon in the repo initialization template dir handling (and as part of that fix, handles the case where an error occurs correctly).

diff --git a/include/git2/index.h b/include/git2/index.h
index ba0bcc9..131d049 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -120,9 +120,9 @@ typedef struct git_index_entry {
 
 /** Capabilities of system that affect index actions. */
 typedef enum {
-	GIT_INDEXCAP_IGNORE_CASE = 1,
-	GIT_INDEXCAP_NO_FILEMODE = 2,
-	GIT_INDEXCAP_NO_SYMLINKS = 4,
+	GIT_INDEXCAP_IGNORE_CASE = 1u,
+	GIT_INDEXCAP_NO_FILEMODE = 2u,
+	GIT_INDEXCAP_NO_SYMLINKS = 4u,
 	GIT_INDEXCAP_FROM_OWNER  = ~0u
 } git_indexcap_t;
 
@@ -219,7 +219,7 @@ GIT_EXTERN(unsigned int) git_index_caps(const git_index *index);
  * @param caps A combination of GIT_INDEXCAP values
  * @return 0 on success, -1 on failure
  */
-GIT_EXTERN(int) git_index_set_caps(git_index *index, int caps);
+GIT_EXTERN(int) git_index_set_caps(git_index *index, unsigned int caps);
 
 /**
  * Update the contents of an existing index object in memory
diff --git a/src/index.c b/src/index.c
index b4f2a3b..21a8d31 100644
--- a/src/index.c
+++ b/src/index.c
@@ -408,7 +408,7 @@ static int create_index_error(int error, const char *msg)
 	return error;
 }
 
-int git_index_set_caps(git_index *index, int caps)
+int git_index_set_caps(git_index *index, unsigned int caps)
 {
 	unsigned int old_ignore_case;
 
diff --git a/src/repository.c b/src/repository.c
index 6dea487..0d7c094 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1145,17 +1145,19 @@ static int repo_init_structure(
 		}
 
 		if (!tdir) {
-			if ((error = git_futils_find_template_dir(&template_buf)) >= 0);
+			if (!(error = git_futils_find_template_dir(&template_buf)))
 				tdir = template_buf.ptr;
 			default_template = true;
 		}
 
-		error = git_futils_cp_r(tdir, repo_dir,
-			GIT_CPDIR_COPY_SYMLINKS | GIT_CPDIR_CHMOD_DIRS |
-			GIT_CPDIR_SIMPLE_TO_MODE, dmode);
+		if (tdir)
+			error = git_futils_cp_r(tdir, repo_dir,
+				GIT_CPDIR_COPY_SYMLINKS | GIT_CPDIR_CHMOD_DIRS |
+				GIT_CPDIR_SIMPLE_TO_MODE, dmode);
 
 		git_buf_free(&template_buf);
 		git_config_free(cfg);
+
 		if (error < 0) {
 			if (!default_template)
 				return error;