Correct a few types to be unsigned in fast-import.
[gitweb.git] / config.c
index 2cd0263e13cab1b445498d82e73d1ca09b0b58f0..b6082f597c118d75a9342d1e0bf5788c7a8257ee 100644 (file)
--- a/config.c
+++ b/config.c
@@ -269,6 +269,11 @@ int git_default_config(const char *var, const char *value)
                return 0;
        }
 
+       if (!strcmp(var, "core.bare")) {
+               is_bare_repository_cfg = git_config_bool(var, value);
+               return 0;
+       }
+
        if (!strcmp(var, "core.ignorestat")) {
                assume_unchanged = git_config_bool(var, value);
                return 0;
@@ -694,11 +699,9 @@ int git_config_set_multivar(const char* key, const char* value,
 
                store.key = (char*)key;
                if (!store_write_section(fd, key) ||
-                   !store_write_pair(fd, key, value)) {
-                       ret = write_error();
-                       goto out_free;
-               }
-       } else{
+                   !store_write_pair(fd, key, value))
+                       goto write_err_out;
+       } else {
                struct stat st;
                char* contents;
                int i, copy_begin, copy_end, new_line = 0;
@@ -777,31 +780,33 @@ int git_config_set_multivar(const char* key, const char* value,
 
                        /* write the first part of the config */
                        if (copy_end > copy_begin) {
-                               write_in_full(fd, contents + copy_begin,
-                               copy_end - copy_begin);
-                               if (new_line)
-                                       write_in_full(fd, "\n", 1);
+                               if (write_in_full(fd, contents + copy_begin,
+                                                 copy_end - copy_begin) <
+                                   copy_end - copy_begin)
+                                       goto write_err_out;
+                               if (new_line &&
+                                   write_in_full(fd, "\n", 1) != 1)
+                                       goto write_err_out;
                        }
                        copy_begin = store.offset[i];
                }
 
                /* write the pair (value == NULL means unset) */
                if (value != NULL) {
-                       if (store.state == START)
-                               if (!store_write_section(fd, key)) {
-                                       ret = write_error();
-                                       goto out_free;
-                               }
-                       if (!store_write_pair(fd, key, value)) {
-                               ret = write_error();
-                               goto out_free;
+                       if (store.state == START) {
+                               if (!store_write_section(fd, key))
+                                       goto write_err_out;
                        }
+                       if (!store_write_pair(fd, key, value))
+                               goto write_err_out;
                }
 
                /* write the rest of the config */
                if (copy_begin < st.st_size)
-                       write_in_full(fd, contents + copy_begin,
-                               st.st_size - copy_begin);
+                       if (write_in_full(fd, contents + copy_begin,
+                                         st.st_size - copy_begin) <
+                           st.st_size - copy_begin)
+                               goto write_err_out;
 
                munmap(contents, st.st_size);
                unlink(config_filename);
@@ -824,6 +829,11 @@ int git_config_set_multivar(const char* key, const char* value,
                free(lock_file);
        }
        return ret;
+
+write_err_out:
+       ret = write_error();
+       goto out_free;
+
 }
 
 int git_config_rename_section(const char *old_name, const char *new_name)