]> git.ipfire.org Git - thirdparty/git.git/blobdiff - config.c
config: do not ungetc EOF
[thirdparty/git.git] / config.c
index 5272fc6f0b0c3825650c8b0fcca91415af62f43e..5eca17b24264573a04eebe8be3b397ec1e804954 100644 (file)
--- a/config.c
+++ b/config.c
@@ -228,7 +228,8 @@ static int get_next_char(void)
                /* DOS like systems */
                c = cf->do_fgetc(cf);
                if (c != '\n') {
-                       cf->do_ungetc(c, cf);
+                       if (c != EOF)
+                               cf->do_ungetc(c, cf);
                        c = '\r';
                }
        }
@@ -874,6 +875,16 @@ static int git_default_core_config(const char *var, const char *value)
                return 0;
        }
 
+       if (!strcmp(var, "core.protecthfs")) {
+               protect_hfs = git_config_bool(var, value);
+               return 0;
+       }
+
+       if (!strcmp(var, "core.protectntfs")) {
+               protect_ntfs = git_config_bool(var, value);
+               return 0;
+       }
+
        /* Add other config variables here and to Documentation/config.txt. */
        return 0;
 }
@@ -1538,7 +1549,7 @@ int git_config_set_multivar_in_file(const char *config_filename,
         * The lock serves a purpose in addition to locking: the new
         * contents of .git/config will be written into it.
         */
-       lock = xcalloc(sizeof(struct lock_file), 1);
+       lock = xcalloc(1, sizeof(struct lock_file));
        fd = hold_lock_file_for_update(lock, config_filename, 0);
        if (fd < 0) {
                error("could not lock config file %s: %s", config_filename, strerror(errno));
@@ -1793,7 +1804,7 @@ int git_config_rename_section_in_file(const char *config_filename,
        if (!config_filename)
                config_filename = filename_buf = git_pathdup("config");
 
-       lock = xcalloc(sizeof(struct lock_file), 1);
+       lock = xcalloc(1, sizeof(struct lock_file));
        out_fd = hold_lock_file_for_update(lock, config_filename, 0);
        if (out_fd < 0) {
                ret = error("could not lock config file %s", config_filename);