Merge branch 'nd/complete-config-vars'
authorJunio C Hamano <gitster@pobox.com>
Mon, 27 Aug 2018 21:33:42 +0000 (14:33 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Aug 2018 21:33:42 +0000 (14:33 -0700)
"git help --config" (which is used in command line completion)
missed the configuration variables not described in the main
config.txt file but are described in another file that is included
by it, which has been corrected.

* nd/complete-config-vars:
generate-cmdlist.sh: collect config from all config.txt files

16 files changed:
Documentation/config.txt
Documentation/git-branch.txt
Documentation/git-worktree.txt
blame.c
branch.c
builtin/branch.c
builtin/pack-objects.c
builtin/worktree.c
ci/run-build-and-tests.sh
http.c
pack-objects.c
pack-objects.h
t/README
t/t2025-worktree-add.sh
t/t3200-branch.sh
tree-diff.c
index 45c102c9639f5d9c5e18b275a5f4b4ad27cd4e96..322d93262f2ecd003f1364056b84bb5c4922905e 100644 (file)
@@ -462,10 +462,20 @@ core.untrackedCache::
        See linkgit:git-update-index[1]. `keep` by default.
 
 core.checkStat::
-       Determines which stat fields to match between the index
-       and work tree. The user can set this to 'default' or
-       'minimal'. Default (or explicitly 'default'), is to check
-       all fields, including the sub-second part of mtime and ctime.
+       When missing or is set to `default`, many fields in the stat
+       structure are checked to detect if a file has been modified
+       since Git looked at it.  When this configuration variable is
+       set to `minimal`, sub-second part of mtime and ctime, the
+       uid and gid of the owner of the file, the inode number (and
+       the device number, if Git was compiled to use it), are
+       excluded from the check among these fields, leaving only the
+       whole-second part of mtime (and ctime, if `core.trustCtime`
+       is set) and the filesize to be checked.
++
+There are implementations of Git that do not leave usable values in
+some fields (e.g. JGit); by excluding these fields from the
+comparison, the `minimal` mode may help interoperability when the
+same repository is used by these other systems at the same time.
 
 core.quotePath::
        Commands that output paths (e.g. 'ls-files', 'diff'), will
@@ -1044,6 +1054,12 @@ branch.autoSetupRebase::
        branch to track another branch.
        This option defaults to never.
 
+branch.sort::
+       This variable controls the sort ordering of branches when displayed by
+       linkgit:git-branch[1]. Without the "--sort=<value>" option provided, the
+       value of this variable will be used as the default.
+       See linkgit:git-for-each-ref[1] field names for valid values.
+
 branch.<name>.remote::
        When on branch <name>, it tells 'git fetch' and 'git push'
        which remote to fetch from/push to.  The remote to push to
index 1072ca0eb61e45f5049fedfd24a7512ff81ee957..9767b2b483dbe634db1a700e4b3529593f8189ec 100644 (file)
@@ -268,10 +268,11 @@ start-point is either a local or remote-tracking branch.
        order of the value. You may use the --sort=<key> option
        multiple times, in which case the last key becomes the primary
        key. The keys supported are the same as those in `git
-       for-each-ref`. Sort order defaults to sorting based on the
+       for-each-ref`. Sort order defaults to the value configured for the
+       `branch.sort` variable if exists, or to sorting based on the
        full refname (including `refs/...` prefix). This lists
        detached HEAD (if present) first, then local branches and
-       finally remote-tracking branches.
+       finally remote-tracking branches. See linkgit:git-config[1].
 
 
 --points-at <object>::
index 9c26be40f4412b5f0a9c478236b9d3c38fcb14ec..29a5b7e252a378b2f992bdeeb6c26cfe6f01f6b4 100644 (file)
@@ -173,6 +173,10 @@ This can also be set up as the default behaviour by using the
        This format will remain stable across Git versions and regardless of user
        configuration.  See below for details.
 
+-q::
+--quiet::
+       With 'add', suppress feedback messages.
+
 -v::
 --verbose::
        With `prune`, report all removals.
diff --git a/blame.c b/blame.c
index 08c0c6cf73c349a2b7ad6fe129443852318a5044..aca06f4b1227a4930a2dbb13b87068a618a76f97 100644 (file)
--- a/blame.c
+++ b/blame.c
@@ -337,9 +337,7 @@ static void fill_origin_blob(struct diff_options *opt,
 
 static void drop_origin_blob(struct blame_origin *o)
 {
-       if (o->file.ptr) {
-               FREE_AND_NULL(o->file.ptr);
-       }
+       FREE_AND_NULL(o->file.ptr);
 }
 
 /*
index ecd710d7308c9d2be85cd3bcde4fd9d38dec0edc..776f55fc66fb7d782f30b05ca9bdff4a55028f49 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -25,9 +25,7 @@ static int find_tracked_branch(struct remote *remote, void *priv)
                        tracking->remote = remote->name;
                } else {
                        free(tracking->spec.src);
-                       if (tracking->src) {
-                               FREE_AND_NULL(tracking->src);
-                       }
+                       FREE_AND_NULL(tracking->src);
                }
                tracking->spec.src = NULL;
        }
index 4fc55c3508c2fff3e92e6235ed35ba582caf4b15..bbd006aab4b4798b7e86530fe3562c753e879bc1 100644 (file)
@@ -74,6 +74,14 @@ define_list_config_array(color_branch_slots);
 static int git_branch_config(const char *var, const char *value, void *cb)
 {
        const char *slot_name;
+       struct ref_sorting **sorting_tail = (struct ref_sorting **)cb;
+
+       if (!strcmp(var, "branch.sort")) {
+               if (!value)
+                       return config_error_nonbool(var);
+               parse_ref_sorting(sorting_tail, value);
+               return 0;
+       }
 
        if (starts_with(var, "column."))
                return git_column_config(var, value, "branch", &colopts);
@@ -653,7 +661,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
        if (argc == 2 && !strcmp(argv[1], "-h"))
                usage_with_options(builtin_branch_usage, options);
 
-       git_config(git_branch_config, NULL);
+       git_config(git_branch_config, sorting_tail);
 
        track = git_branch_track;
 
index 0d80dee2ba1ad82fd21622f73dac86b6010da4b6..d1144a8f7ef79f7efa5bf64141a9133cfeee66d1 100644 (file)
@@ -2041,10 +2041,6 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
        delta_buf = create_delta(src->index, trg->data, trg_size, &delta_size, max_size);
        if (!delta_buf)
                return 0;
-       if (delta_size >= (1U << OE_DELTA_SIZE_BITS)) {
-               free(delta_buf);
-               return 0;
-       }
 
        if (DELTA(trg_entry)) {
                /* Prefer only shallower same-sized deltas. */
@@ -2303,6 +2299,7 @@ static void init_threaded_search(void)
        pthread_mutex_init(&cache_mutex, NULL);
        pthread_mutex_init(&progress_mutex, NULL);
        pthread_cond_init(&progress_cond, NULL);
+       pthread_mutex_init(&to_pack.lock, NULL);
        old_try_to_free_routine = set_try_to_free_routine(try_to_free_from_threads);
 }
 
index a763dbdccb490ab6707c247d618203ffd37d4052..41e7714396dc3334bcb29f2454d210d63a649243 100644 (file)
@@ -27,6 +27,7 @@ static const char * const worktree_usage[] = {
 struct add_opts {
        int force;
        int detach;
+       int quiet;
        int checkout;
        int keep_locked;
 };
@@ -303,9 +304,13 @@ static int add_worktree(const char *path, const char *refname,
        if (!is_branch)
                argv_array_pushl(&cp.args, "update-ref", "HEAD",
                                 oid_to_hex(&commit->object.oid), NULL);
-       else
+       else {
                argv_array_pushl(&cp.args, "symbolic-ref", "HEAD",
                                 symref.buf, NULL);
+               if (opts->quiet)
+                       argv_array_push(&cp.args, "--quiet");
+       }
+
        cp.env = child_env.argv;
        ret = run_command(&cp);
        if (ret)
@@ -315,6 +320,8 @@ static int add_worktree(const char *path, const char *refname,
                cp.argv = NULL;
                argv_array_clear(&cp.args);
                argv_array_pushl(&cp.args, "reset", "--hard", NULL);
+               if (opts->quiet)
+                       argv_array_push(&cp.args, "--quiet");
                cp.env = child_env.argv;
                ret = run_command(&cp);
                if (ret)
@@ -437,6 +444,7 @@ static int add(int ac, const char **av, const char *prefix)
                OPT_BOOL(0, "detach", &opts.detach, N_("detach HEAD at named commit")),
                OPT_BOOL(0, "checkout", &opts.checkout, N_("populate the new working tree")),
                OPT_BOOL(0, "lock", &opts.keep_locked, N_("keep the new working tree locked")),
+               OPT__QUIET(&opts.quiet, N_("suppress progress reporting")),
                OPT_PASSTHRU(0, "track", &opt_track, NULL,
                             N_("set up tracking mode (see git-branch(1))"),
                             PARSE_OPT_NOARG | PARSE_OPT_OPTARG),
@@ -491,8 +499,8 @@ static int add(int ac, const char **av, const char *prefix)
                        }
                }
        }
-
-       print_preparing_worktree_line(opts.detach, branch, new_branch, !!new_branch_force);
+       if (!opts.quiet)
+               print_preparing_worktree_line(opts.detach, branch, new_branch, !!new_branch_force);
 
        if (new_branch) {
                struct child_process cp = CHILD_PROCESS_INIT;
@@ -500,6 +508,8 @@ static int add(int ac, const char **av, const char *prefix)
                argv_array_push(&cp.args, "branch");
                if (new_branch_force)
                        argv_array_push(&cp.args, "--force");
+               if (opts.quiet)
+                       argv_array_push(&cp.args, "--quiet");
                argv_array_push(&cp.args, new_branch);
                argv_array_push(&cp.args, branch);
                if (opt_track)
index 4b04c75b7f81a749c0d48674b8e2042abe5769eb..2a5bff4a1ca3de1dfca6cecb9d2016173f4fdea5 100755 (executable)
@@ -14,6 +14,7 @@ then
        export GIT_TEST_SPLIT_INDEX=yes
        export GIT_TEST_FULL_IN_PACK_ARRAY=true
        export GIT_TEST_OE_SIZE=10
+       export GIT_TEST_OE_DELTA_SIZE=5
        make --quiet test
 fi
 
diff --git a/http.c b/http.c
index b4bfbceaeb7e58e79cac17f8768a7e36cff3405e..4162860ee316365091ac3978a83d2311682b8079 100644 (file)
--- a/http.c
+++ b/http.c
@@ -2418,9 +2418,7 @@ void release_http_object_request(struct http_object_request *freq)
                close(freq->localfile);
                freq->localfile = -1;
        }
-       if (freq->url != NULL) {
-               FREE_AND_NULL(freq->url);
-       }
+       FREE_AND_NULL(freq->url);
        if (freq->slot != NULL) {
                freq->slot->callback_func = NULL;
                freq->slot->callback_data = NULL;
index 92708522e76b4565882177f899612d72a3f6d75a..6ef87e5683aacdf738c86679712078988c0899fd 100644 (file)
@@ -146,6 +146,8 @@ void prepare_packing_data(struct packing_data *pdata)
 
        pdata->oe_size_limit = git_env_ulong("GIT_TEST_OE_SIZE",
                                             1U << OE_SIZE_BITS);
+       pdata->oe_delta_size_limit = git_env_ulong("GIT_TEST_OE_DELTA_SIZE",
+                                                  1UL << OE_DELTA_SIZE_BITS);
 }
 
 struct object_entry *packlist_alloc(struct packing_data *pdata,
@@ -160,6 +162,8 @@ struct object_entry *packlist_alloc(struct packing_data *pdata,
 
                if (!pdata->in_pack_by_idx)
                        REALLOC_ARRAY(pdata->in_pack, pdata->nr_alloc);
+               if (pdata->delta_size)
+                       REALLOC_ARRAY(pdata->delta_size, pdata->nr_alloc);
        }
 
        new_entry = pdata->objects + pdata->nr_objects++;
index 08c6b57d49791556f323ebf8654e98689a19593c..62806ccc39ea31b425089f4f38121d81a02fe5dd 100644 (file)
@@ -2,6 +2,7 @@
 #define PACK_OBJECTS_H
 
 #include "object-store.h"
+#include "thread-utils.h"
 #include "pack.h"
 
 #define DEFAULT_DELTA_CACHE_SIZE (256 * 1024 * 1024)
@@ -15,7 +16,7 @@
  * above this limit. Don't lower it too much.
  */
 #define OE_SIZE_BITS           31
-#define OE_DELTA_SIZE_BITS     20
+#define OE_DELTA_SIZE_BITS     23
 
 /*
  * State flags for depth-first search used for analyzing delta cycles.
@@ -95,11 +96,12 @@ struct object_entry {
                                     */
        unsigned delta_size_:OE_DELTA_SIZE_BITS; /* delta data size (uncompressed) */
        unsigned delta_size_valid:1;
+       unsigned char in_pack_header_size;
        unsigned in_pack_idx:OE_IN_PACK_BITS;   /* already in pack */
        unsigned z_delta_size:OE_Z_DELTA_BITS;
        unsigned type_valid:1;
-       unsigned type_:TYPE_BITS;
        unsigned no_try_delta:1;
+       unsigned type_:TYPE_BITS;
        unsigned in_pack_type:TYPE_BITS; /* could be delta */
        unsigned preferred_base:1; /*
                                    * we do not pack this, but is available
@@ -109,17 +111,16 @@ struct object_entry {
        unsigned tagged:1; /* near the very tip of refs */
        unsigned filled:1; /* assigned write-order */
        unsigned dfs_state:OE_DFS_STATE_BITS;
-       unsigned char in_pack_header_size;
        unsigned depth:OE_DEPTH_BITS;
 
        /*
         * pahole results on 64-bit linux (gcc and clang)
         *
-        *   size: 80, bit_padding: 20 bits, holes: 8 bits
+        *   size: 80, bit_padding: 9 bits
         *
         * and on 32-bit (gcc)
         *
-        *   size: 76, bit_padding: 20 bits, holes: 8 bits
+        *   size: 76, bit_padding: 9 bits
         */
 };
 
@@ -131,6 +132,7 @@ struct packing_data {
        uint32_t index_size;
 
        unsigned int *in_pack_pos;
+       unsigned long *delta_size;
 
        /*
         * Only one of these can be non-NULL and they have different
@@ -141,10 +143,29 @@ struct packing_data {
        struct packed_git **in_pack_by_idx;
        struct packed_git **in_pack;
 
+#ifndef NO_PTHREADS
+       pthread_mutex_t lock;
+#endif
+
        uintmax_t oe_size_limit;
+       uintmax_t oe_delta_size_limit;
 };
 
 void prepare_packing_data(struct packing_data *pdata);
+
+static inline void packing_data_lock(struct packing_data *pdata)
+{
+#ifndef NO_PTHREADS
+       pthread_mutex_lock(&pdata->lock);
+#endif
+}
+static inline void packing_data_unlock(struct packing_data *pdata)
+{
+#ifndef NO_PTHREADS
+       pthread_mutex_unlock(&pdata->lock);
+#endif
+}
+
 struct object_entry *packlist_alloc(struct packing_data *pdata,
                                    const unsigned char *sha1,
                                    uint32_t index_pos);
@@ -333,18 +354,34 @@ static inline unsigned long oe_delta_size(struct packing_data *pack,
 {
        if (e->delta_size_valid)
                return e->delta_size_;
-       return oe_size(pack, e);
+
+       /*
+        * pack->detla_size[] can't be NULL because oe_set_delta_size()
+        * must have been called when a new delta is saved with
+        * oe_set_delta().
+        * If oe_delta() returns NULL (i.e. default state, which means
+        * delta_size_valid is also false), then the caller must never
+        * call oe_delta_size().
+        */
+       return pack->delta_size[e - pack->objects];
 }
 
 static inline void oe_set_delta_size(struct packing_data *pack,
                                     struct object_entry *e,
                                     unsigned long size)
 {
-       e->delta_size_ = size;
-       e->delta_size_valid = e->delta_size_ == size;
-       if (!e->delta_size_valid && size != oe_size(pack, e))
-               BUG("this can only happen in check_object() "
-                   "where delta size is the same as entry size");
+       if (size < pack->oe_delta_size_limit) {
+               e->delta_size_ = size;
+               e->delta_size_valid = 1;
+       } else {
+               packing_data_lock(pack);
+               if (!pack->delta_size)
+                       ALLOC_ARRAY(pack->delta_size, pack->nr_alloc);
+               packing_data_unlock(pack);
+
+               pack->delta_size[e - pack->objects] = size;
+               e->delta_size_valid = 0;
+       }
 }
 
 #endif
index 8373a27fea38b1ec111e80d203bf61f1143b7861..9028b47d923ca027a146da82060dae395d3f7999 100644 (file)
--- a/t/README
+++ b/t/README
@@ -315,6 +315,10 @@ packs on demand. This normally only happens when the object size is
 over 2GB. This variable forces the code path on any object larger than
 <n> bytes.
 
+GIT_TEST_OE_DELTA_SIZE=<n> exercises the uncomon pack-objects code
+path where deltas larger than this limit require extra memory
+allocation for bookkeeping.
+
 Naming Tests
 ------------
 
index 166942c1bd2943b778b7df66e21d2e84861ef958..07d292317cdfcbca784a19c6c8f130d09c98fe98 100755 (executable)
@@ -252,6 +252,11 @@ test_expect_success 'add -B' '
        test_cmp_rev master^ poodle
 '
 
+test_expect_success 'add --quiet' '
+       git worktree add --quiet another-worktree master 2>actual &&
+       test_must_be_empty actual
+'
+
 test_expect_success 'local clone from linked checkout' '
        git clone --local here here-clone &&
        ( cd here-clone && git fsck )
index dbca665da41908e7e3014564dc8ddb901030715b..93f21ab078080d00100cd63f6b5ee5cdfd636d29 100755 (executable)
@@ -1305,4 +1305,50 @@ test_expect_success 'tracking with unexpected .fetch refspec' '
        )
 '
 
+test_expect_success 'configured committerdate sort' '
+       git init sort &&
+       (
+               cd sort &&
+               git config branch.sort committerdate &&
+               test_commit initial &&
+               git checkout -b a &&
+               test_commit a &&
+               git checkout -b c &&
+               test_commit c &&
+               git checkout -b b &&
+               test_commit b &&
+               git branch >actual &&
+               cat >expect <<-\EOF &&
+                 master
+                 a
+                 c
+               * b
+               EOF
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'option override configured sort' '
+       (
+               cd sort &&
+               git config branch.sort committerdate &&
+               git branch --sort=refname >actual &&
+               cat >expect <<-\EOF &&
+                 a
+               * b
+                 c
+                 master
+               EOF
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'invalid sort parameter in configuration' '
+       (
+               cd sort &&
+               git config branch.sort "v:notvalid" &&
+               test_must_fail git branch
+       )
+'
+
 test_done
index fe2e466ac1dcb164b214ce4856ed9d62884ddbd3..553bc0e63ae37ada1c3e19ae748d1228561f00f6 100644 (file)
@@ -557,9 +557,7 @@ struct combine_diff_path *diff_tree_paths(
         * free pre-allocated last element, if any
         * (see path_appendnew() for details about why)
         */
-       if (p->next) {
-               FREE_AND_NULL(p->next);
-       }
+       FREE_AND_NULL(p->next);
 
        return p;
 }