]> git.ipfire.org Git - thirdparty/git.git/blobdiff - ref-filter.c
Merge branch 'nd/the-index'
[thirdparty/git.git] / ref-filter.c
index c4eaf3031388fce5ff5f57027ed3fb6e84c03743..61d75d5c86c644225a6a9549ca54d64a117d0c61 100644 (file)
@@ -534,6 +534,10 @@ static int parse_ref_filter_atom(const struct ref_format *format,
        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;
@@ -878,7 +882,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_
                        v->s = xstrdup(type_name(oi->type));
                else if (!strcmp(name, "objectsize")) {
                        v->value = oi->size;
-                       v->s = xstrfmt("%lu", oi->size);
+                       v->s = xstrfmt("%"PRIuMAX , (uintmax_t)oi->size);
                }
                else if (deref)
                        grab_objectname(name, &oi->oid, v, &used_atom[i]);
@@ -2316,11 +2320,15 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
        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);
+                       return error(_("option `%s' is incompatible with --merged"),
+                                    opt->long_name);
                } else {
-                       return opterror(opt, "is incompatible with --no-merged", 0);
+                       return error(_("option `%s' is incompatible with --no-merged"),
+                                    opt->long_name);
                }
        }
 
@@ -2334,7 +2342,7 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
        rf->merge_commit = lookup_commit_reference_gently(the_repository,
                                                          &oid, 0);
        if (!rf->merge_commit)
-               return opterror(opt, "must point to a commit", 0);
+               return error(_("option `%s' must point to a commit"), opt->long_name);
 
        return 0;
 }