Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Mon, 11 Feb 2008 21:23:06 +0000 (13:23 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 11 Feb 2008 21:23:06 +0000 (13:23 -0800)
* maint: (35 commits)
config.c: guard config parser from value=NULL
builtin-log.c: guard config parser from value=NULL
imap-send.c: guard config parser from value=NULL
wt-status.c: guard config parser from value=NULL
setup.c: guard config parser from value=NULL
remote.c: guard config parser from value=NULL
merge-recursive.c: guard config parser from value=NULL
http.c: guard config parser from value=NULL
help.c: guard config parser from value=NULL
git.c: guard config parser from value=NULL
diff.c: guard config parser from value=NULL
convert.c: guard config parser from value=NULL
connect.c: guard config parser from value=NULL
builtin-tag.c: guard config parser from value=NULL
builtin-show-branch.c: guard config parser from value=NULL
builtin-reflog.c: guard config parser from value=NULL
builtin-log.c: guard config parser from value=NULL
builtin-config.c: guard config parser from value=NULL
builtin-commit.c: guard config parser from value=NULL
builtin-branch.c: guard config parser from value=NULL
...

1  2 
Documentation/config.txt
builtin-pack-objects.c
config.c
t/t1300-repo-config.sh
diff --combined Documentation/config.txt
index 3e10feb9fbbf44c634c32f30dd23a4534535190d,6d8cca46ab934826a84647cbd6e441fee286f330..f9bdb164e054ec2d633baab3da69ddd47e14931f
@@@ -333,7 -333,7 +333,7 @@@ branch.autosetupmerge:
        so that linkgit:git-pull[1] will appropriately merge from that
        remote branch.  Note that even if this option is not set,
        this behavior can be chosen per-branch using the `--track`
-       and `--no-track` options.  This option defaults to false.
+       and `--no-track` options.  This option defaults to true.
  
  branch.<name>.remote::
        When in branch <name>, it tells `git fetch` which remote to fetch.
@@@ -766,12 -766,6 +766,12 @@@ pack.indexVersion:
        whenever the corresponding pack is larger than 2 GB.  Otherwise
        the default is 1.
  
 +pack.packSizeLimit:
 +      The default maximum size of a pack.  This setting only affects
 +      packing to a file, i.e. the git:// protocol is unaffected.  It
 +      can be overridden by the `\--max-pack-size` option of
 +      linkgit:git-repack[1].
 +
  pull.octopus::
        The default merge strategy to use when pulling multiple branches
        at once.
diff --combined builtin-pack-objects.c
index 692a76126b027133fd046f03003fe8e49218f192,4113f013cfae060cc21719a421e98d1741752f9b..acb05554d499598677bc1f0cec3b6ff37e796d88
@@@ -68,7 -68,7 +68,7 @@@ static int allow_ofs_delta
  static const char *base_name;
  static int progress = 1;
  static int window = 10;
 -static uint32_t pack_size_limit;
 +static uint32_t pack_size_limit, pack_size_limit_cfg;
  static int depth = 50;
  static int delta_search_threads = 1;
  static int pack_to_stdout;
@@@ -1464,7 -1464,7 +1464,7 @@@ static unsigned int check_delta_limit(s
        return m;
  }
  
- static unsigned long free_unpacked(struct unpacked *n)
+ static unsigned long free_unpacked_data(struct unpacked *n)
  {
        unsigned long freed_mem = sizeof_delta_index(n->index);
        free_delta_index(n->index);
                free(n->data);
                n->data = NULL;
        }
+       return freed_mem;
+ }
+ static unsigned long free_unpacked(struct unpacked *n)
+ {
+       unsigned long freed_mem = free_unpacked_data(n);
        n->entry = NULL;
        n->depth = 0;
        return freed_mem;
@@@ -1514,7 -1520,7 +1520,7 @@@ static void find_deltas(struct object_e
                       mem_usage > window_memory_limit &&
                       count > 1) {
                        uint32_t tail = (idx + window - count) % window;
-                       mem_usage -= free_unpacked(array + tail);
+                       mem_usage -= free_unpacked_data(array + tail);
                        count--;
                }
  
                        if (!m->entry)
                                break;
                        ret = try_delta(n, m, max_depth, &mem_usage);
+                       if (window_memory_limit &&
+                           mem_usage > window_memory_limit)
+                               mem_usage -= free_unpacked_data(m);
                        if (ret < 0)
                                break;
                        else if (ret > 0)
@@@ -1867,10 -1876,6 +1876,10 @@@ static int git_pack_config(const char *
                        die("bad pack.indexversion=%d", pack_idx_default_version);
                return 0;
        }
 +      if (!strcmp(k, "pack.packsizelimit")) {
 +              pack_size_limit_cfg = git_config_ulong(k, v);
 +              return 0;
 +      }
        return git_default_config(k, v);
  }
  
@@@ -2100,7 -2105,6 +2109,7 @@@ int cmd_pack_objects(int argc, const ch
                }
                if (!prefixcmp(arg, "--max-pack-size=")) {
                        char *end;
 +                      pack_size_limit_cfg = 0;
                        pack_size_limit = strtoul(arg+16, &end, 0) * 1024 * 1024;
                        if (!arg[16] || *end)
                                usage(pack_usage);
        if (pack_to_stdout != !base_name)
                usage(pack_usage);
  
 +      if (!pack_to_stdout && !pack_size_limit)
 +              pack_size_limit = pack_size_limit_cfg;
 +
        if (pack_to_stdout && pack_size_limit)
                die("--max-pack-size cannot be used to build a pack for transfer.");
  
diff --combined config.c
index 498259ebefb3ba61a75aa5a5ca03d75576a501c0,3f4d3b1602cf4764184fe7df70a232e71a5058ec..3e72778e94267044780a180145eae0a6a229e3a3
+++ b/config.c
@@@ -408,21 -408,29 +408,29 @@@ int git_default_config(const char *var
        }
  
        if (!strcmp(var, "user.name")) {
+               if (!value)
+                       return config_error_nonbool(var);
                strlcpy(git_default_name, value, sizeof(git_default_name));
                return 0;
        }
  
        if (!strcmp(var, "user.email")) {
+               if (!value)
+                       return config_error_nonbool(var);
                strlcpy(git_default_email, value, sizeof(git_default_email));
                return 0;
        }
  
        if (!strcmp(var, "i18n.commitencoding")) {
+               if (!value)
+                       return config_error_nonbool(var);
                git_commit_encoding = xstrdup(value);
                return 0;
        }
  
        if (!strcmp(var, "i18n.logoutputencoding")) {
+               if (!value)
+                       return config_error_nonbool(var);
                git_log_output_encoding = xstrdup(value);
                return 0;
        }
        }
  
        if (!strcmp(var, "core.pager")) {
+               if (!value)
+                       return config_error_nonbool(var);
                pager_program = xstrdup(value);
                return 0;
        }
  
        if (!strcmp(var, "core.editor")) {
+               if (!value)
+                       return config_error_nonbool(var);
                editor_program = xstrdup(value);
                return 0;
        }
  
        if (!strcmp(var, "core.excludesfile")) {
                if (!value)
-                       die("core.excludesfile without value");
+                       return config_error_nonbool(var);
                excludes_file = xstrdup(value);
                return 0;
        }
  
        if (!strcmp(var, "core.whitespace")) {
+               if (!value)
+                       return config_error_nonbool(var);
                whitespace_rule_cfg = parse_whitespace_rule(value);
                return 0;
        }
@@@ -484,9 -498,9 +498,9 @@@ const char *git_etc_gitconfig(void
                system_wide = ETC_GITCONFIG;
                if (!is_absolute_path(system_wide)) {
                        /* interpret path relative to exec-dir */
 -                      const char *exec_path = git_exec_path();
 -                      system_wide = prefix_path(exec_path, strlen(exec_path),
 -                                              system_wide);
 +                      struct strbuf d = STRBUF_INIT;
 +                      strbuf_addf(&d, "%s/%s", git_exec_path(), system_wide);
 +                      system_wide = strbuf_detach(&d, NULL);
                }
        }
        return system_wide;
@@@ -701,12 -715,17 +715,17 @@@ static ssize_t find_beginning_of_line(c
        size_t equal_offset = size, bracket_offset = size;
        ssize_t offset;
  
+ contline:
        for (offset = offset_-2; offset > 0
                        && contents[offset] != '\n'; offset--)
                switch (contents[offset]) {
                        case '=': equal_offset = offset; break;
                        case ']': bracket_offset = offset; break;
                }
+       if (offset > 0 && contents[offset-1] == '\\') {
+               offset_ = offset;
+               goto contline;
+       }
        if (bracket_offset < equal_offset) {
                *found_bracket = 1;
                offset = bracket_offset+1;
@@@ -1074,3 -1093,12 +1093,12 @@@ int git_config_rename_section(const cha
        free(config_filename);
        return ret;
  }
+ /*
+  * Call this to report error for your variable that should not
+  * get a boolean value (i.e. "[my] var" means "true").
+  */
+ int config_error_nonbool(const char *var)
+ {
+       return error("Missing value for '%s'", var);
+ }
diff --combined t/t1300-repo-config.sh
index 66aeb88db8f809cec4fd2916e6dbf86979b4598a,44dcc1f94f581660bcf04c75281d60466c95b0be..4928a571144b3fb9ec38312d917e9f95e40ceb99
@@@ -71,6 -71,25 +71,25 @@@ EO
  
  test_expect_success 'non-match result' 'cmp .git/config expect'
  
+ cat > .git/config <<\EOF
+ [alpha]
+ bar = foo
+ [beta]
+ baz = multiple \
+ lines
+ EOF
+ test_expect_success 'unset with cont. lines' \
+       'git config --unset beta.baz'
+ cat > expect <<\EOF
+ [alpha]
+ bar = foo
+ [beta]
+ EOF
+ test_expect_success 'unset with cont. lines is correct' 'cmp .git/config expect'
  cat > .git/config << EOF
  [beta] ; silly comment # another comment
  noIndent= sillyValue ; 'nother silly comment
@@@ -181,9 -200,8 +200,9 @@@ test_expect_success 'non-match' 
  test_expect_success 'non-match value' \
        'test wow = $(git config --get nextsection.nonewline !for)'
  
 -test_expect_failure 'ambiguous get' \
 -      'git config --get nextsection.nonewline'
 +test_expect_success 'ambiguous get' '
 +      ! git config --get nextsection.nonewline
 +'
  
  test_expect_success 'get multivar' \
        'git config --get-all nextsection.nonewline'
@@@ -203,17 -221,13 +222,17 @@@ EO
  
  test_expect_success 'multivar replace' 'cmp .git/config expect'
  
 -test_expect_failure 'ambiguous value' 'git config nextsection.nonewline'
 +test_expect_success 'ambiguous value' '
 +      ! git config nextsection.nonewline
 +'
  
 -test_expect_failure 'ambiguous unset' \
 -      'git config --unset nextsection.nonewline'
 +test_expect_success 'ambiguous unset' '
 +      ! git config --unset nextsection.nonewline
 +'
  
 -test_expect_failure 'invalid unset' \
 -      'git config --unset somesection.nonewline'
 +test_expect_success 'invalid unset' '
 +      ! git config --unset somesection.nonewline
 +'
  
  git config --unset nextsection.nonewline "wow3$"
  
@@@ -229,7 -243,7 +248,7 @@@ EO
  
  test_expect_success 'multivar unset' 'cmp .git/config expect'
  
 -test_expect_failure 'invalid key' 'git config inval.2key blabla'
 +test_expect_success 'invalid key' '! git config inval.2key blabla'
  
  test_expect_success 'correct key' 'git config 123456.a123 987'
  
@@@ -283,40 -297,17 +302,40 @@@ test_expect_success '--add' 
  cat > .git/config << EOF
  [novalue]
        variable
 +[emptyvalue]
 +      variable =
  EOF
  
  test_expect_success 'get variable with no value' \
        'git config --get novalue.variable ^$'
  
 +test_expect_success 'get variable with empty value' \
 +      'git config --get emptyvalue.variable ^$'
 +
  echo novalue.variable > expect
  
  test_expect_success 'get-regexp variable with no value' \
        'git config --get-regexp novalue > output &&
         cmp output expect'
  
 +echo 'emptyvalue.variable ' > expect
 +
 +test_expect_success 'get-regexp variable with empty value' \
 +      'git config --get-regexp emptyvalue > output &&
 +       cmp output expect'
 +
 +echo true > expect
 +
 +test_expect_success 'get bool variable with no value' \
 +      'git config --bool novalue.variable > output &&
 +       cmp output expect'
 +
 +echo false > expect
 +
 +test_expect_success 'get bool variable with empty value' \
 +      'git config --bool emptyvalue.variable > output &&
 +       cmp output expect'
 +
  git config > output 2>&1
  
  test_expect_success 'no arguments, but no crash' \
@@@ -410,9 -401,8 +429,9 @@@ EO
  
  test_expect_success "rename succeeded" "git diff expect .git/config"
  
 -test_expect_failure "rename non-existing section" \
 -      'git config --rename-section branch."world domination" branch.drei'
 +test_expect_success "rename non-existing section" '
 +      ! git config --rename-section branch."world domination" branch.drei
 +'
  
  test_expect_success "rename succeeded" "git diff expect .git/config"
  
@@@ -523,14 -513,14 +542,14 @@@ test_expect_success bool 
          done &&
        cmp expect result'
  
 -test_expect_failure 'invalid bool (--get)' '
 +test_expect_success 'invalid bool (--get)' '
  
        git config bool.nobool foobar &&
 -      git config --bool --get bool.nobool'
 +      git config --bool --get bool.nobool'
  
 -test_expect_failure 'invalid bool (set)' '
 +test_expect_success 'invalid bool (set)' '
  
 -      git config --bool bool.nobool foobar'
 +      git config --bool bool.nobool foobar'
  
  rm .git/config
  
@@@ -591,9 -581,8 +610,9 @@@ EO
  
  test_expect_success 'quoting' 'cmp .git/config expect'
  
 -test_expect_failure 'key with newline' 'git config key.with\\\
 -newline 123'
 +test_expect_success 'key with newline' '
 +      ! git config "key.with
 +newline" 123'
  
  test_expect_success 'value with newline' 'git config key.sub value.with\\\
  newline'