Update packedGit config option documentation.
[gitweb.git] / config.c
index 6a4224e98cf51f8ced2b8e942231012b42aaeef7..5cbd130be2664258b488d8b4ca914550e10906a0 100644 (file)
--- a/config.c
+++ b/config.c
@@ -6,7 +6,6 @@
  *
  */
 #include "cache.h"
-#include <regex.h>
 
 #define MAXNAME (256)
 
@@ -239,6 +238,12 @@ int git_config_int(const char *name, const char *value)
                int val = strtol(value, &end, 0);
                if (!*end)
                        return val;
+               if (!strcasecmp(end, "k"))
+                       return val * 1024;
+               if (!strcasecmp(end, "m"))
+                       return val * 1024 * 1024;
+               if (!strcasecmp(end, "g"))
+                       return val * 1024 * 1024 * 1024;
        }
        die("bad config value for '%s' in %s", name, config_file_name);
 }
@@ -299,6 +304,21 @@ int git_default_config(const char *var, const char *value)
                return 0;
        }
 
+       if (!strcmp(var, "core.packedgitwindowsize")) {
+               int pgsz = getpagesize();
+               packed_git_window_size = git_config_int(var, value);
+               packed_git_window_size /= pgsz;
+               if (packed_git_window_size < 2)
+                       packed_git_window_size = 2;
+               packed_git_window_size *= pgsz;
+               return 0;
+       }
+
+       if (!strcmp(var, "core.packedgitlimit")) {
+               packed_git_limit = git_config_int(var, value);
+               return 0;
+       }
+
        if (!strcmp(var, "user.name")) {
                strlcpy(git_default_name, value, sizeof(git_default_name));
                return 0;
@@ -310,10 +330,16 @@ int git_default_config(const char *var, const char *value)
        }
 
        if (!strcmp(var, "i18n.commitencoding")) {
-               strlcpy(git_commit_encoding, value, sizeof(git_commit_encoding));
+               git_commit_encoding = strdup(value);
                return 0;
        }
 
+       if (!strcmp(var, "i18n.logoutputencoding")) {
+               git_log_output_encoding = strdup(value);
+               return 0;
+       }
+
+
        if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) {
                pager_use_color = git_config_bool(var,value);
                return 0;
@@ -684,7 +710,7 @@ int git_config_set_multivar(const char* key, const char* value,
                }
 
                fstat(in_fd, &st);
-               contents = mmap(NULL, st.st_size, PROT_READ,
+               contents = xmmap(NULL, st.st_size, PROT_READ,
                        MAP_PRIVATE, in_fd, 0);
                close(in_fd);
 
@@ -749,7 +775,7 @@ int git_config_set_multivar(const char* key, const char* value,
 int git_config_rename_section(const char *old_name, const char *new_name)
 {
        int ret = 0;
-       const char *config_filename;
+       char *config_filename;
        struct lock_file *lock = xcalloc(sizeof(struct lock_file), 1);
        int out_fd;
        char buf[1024];
@@ -762,11 +788,15 @@ int git_config_rename_section(const char *old_name, const char *new_name)
        }
        config_filename = xstrdup(config_filename);
        out_fd = hold_lock_file_for_update(lock, config_filename, 0);
-       if (out_fd < 0)
-               return error("Could not lock config file!");
+       if (out_fd < 0) {
+               ret = error("Could not lock config file!");
+               goto out;
+       }
 
-       if (!(config_file = fopen(config_filename, "rb")))
-               return error("Could not open config file!");
+       if (!(config_file = fopen(config_filename, "rb"))) {
+               ret = error("Could not open config file!");
+               goto out;
+       }
 
        while (fgets(buf, sizeof(buf), config_file)) {
                int i;
@@ -806,8 +836,11 @@ int git_config_rename_section(const char *old_name, const char *new_name)
                }
                write(out_fd, buf, strlen(buf));
        }
+       fclose(config_file);
        if (close(out_fd) || commit_lock_file(lock) < 0)
-               return error("Cannot commit config file!");
+               ret = error("Cannot commit config file!");
+ out:
+       free(config_filename);
        return ret;
 }