Merge branch 'sg/ref-filter-wo-repository'
authorJunio C Hamano <gitster@pobox.com>
Sun, 18 Nov 2018 09:23:59 +0000 (18:23 +0900)
committerJunio C Hamano <gitster@pobox.com>
Sun, 18 Nov 2018 09:23:59 +0000 (18:23 +0900)
"git ls-remote --sort=<thing>" can feed an object that is not yet
available into the comparison machinery and segfault, which has
been corrected to check such a request upfront and reject it.

* sg/ref-filter-wo-repository:
ref-filter: don't look for objects when outside of a repository

1  2 
ref-filter.c
diff --combined ref-filter.c
index 7eca4362236cb6aee15999ee290a08c4ee06278d,a1290659afc730f0345d2586fffad4f9a39a658f..6c70d797a978077e27c13da7291e29c3947d3961
@@@ -534,6 -534,10 +534,10 @@@ static int parse_ref_filter_atom(const 
        if (ARRAY_SIZE(valid_atom) <= i)
                return strbuf_addf_ret(err, -1, _("unknown field name: %.*s"),
                                       (int)(ep-atom), atom);
+       if (valid_atom[i].source != SOURCE_NONE && !have_git_dir())
+               return strbuf_addf_ret(err, -1,
+                                      _("not a git repository, but the field '%.*s' requires access to object data"),
+                                      (int)(ep-atom), atom);
  
        /* Add it in, including the deref prefix */
        at = used_atom_cnt;
@@@ -2316,8 -2320,6 +2320,8 @@@ int parse_opt_merge_filter(const struc
        struct object_id oid;
        int no_merged = starts_with(opt->long_name, "no");
  
 +      BUG_ON_OPT_NEG(unset);
 +
        if (rf->merge) {
                if (no_merged) {
                        return opterror(opt, "is incompatible with --merged", 0);