Merge branch 'dl/complete-cherry-pick-revert-skip'
[gitweb.git] / builtin / cat-file.c
index 2ca56fd086bf6bef7595ad008d9eda2c64901cf5..d6a1aa74cd41fe17fdb9d92f6b55fb7d67b31726 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Copyright (C) Linus Torvalds, 2005
  */
+#define USE_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
@@ -14,6 +15,7 @@
 #include "sha1-array.h"
 #include "packfile.h"
 #include "object-store.h"
+#include "promisor-remote.h"
 
 struct batch_options {
        int enabled;
@@ -73,7 +75,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
        if (unknown_type)
                flags |= OBJECT_INFO_ALLOW_UNKNOWN_TYPE;
 
-       if (get_oid_with_context(obj_name, GET_OID_RECORD_PATH,
+       if (get_oid_with_context(the_repository, obj_name,
+                                GET_OID_RECORD_PATH,
                                 &oid, &obj_context))
                die("Not a valid object name %s", obj_name);
 
@@ -170,7 +173,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
                         * fall-back to the usual case.
                         */
                }
-               buf = read_object_with_reference(&oid, exp_type, &size, NULL);
+               buf = read_object_with_reference(the_repository,
+                                                &oid, exp_type, &size, NULL);
                break;
 
        default:
@@ -209,14 +213,14 @@ struct expand_data {
 
        /*
         * After a mark_query run, this object_info is set up to be
-        * passed to sha1_object_info_extended. It will point to the data
+        * passed to oid_object_info_extended. It will point to the data
         * elements above, so you can retrieve the response from there.
         */
        struct object_info info;
 
        /*
         * This flag will be true if the requested batch format and options
-        * don't require us to call sha1_object_info, which can then be
+        * don't require us to call oid_object_info, which can then be
         * optimized out.
         */
        unsigned skip_object_info : 1;
@@ -380,14 +384,18 @@ static void batch_one_object(const char *obj_name,
 {
        struct object_context ctx;
        int flags = opt->follow_symlinks ? GET_OID_FOLLOW_SYMLINKS : 0;
-       enum follow_symlinks_result result;
+       enum get_oid_result result;
 
-       result = get_oid_with_context(obj_name, flags, &data->oid, &ctx);
+       result = get_oid_with_context(the_repository, obj_name,
+                                     flags, &data->oid, &ctx);
        if (result != FOUND) {
                switch (result) {
                case MISSING_OBJECT:
                        printf("%s missing\n", obj_name);
                        break;
+               case SHORT_NAME_AMBIGUOUS:
+                       printf("%s ambiguous\n", obj_name);
+                       break;
                case DANGLING_SYMLINK:
                        printf("dangling %"PRIuMAX"\n%s\n",
                               (uintmax_t)strlen(obj_name), obj_name);
@@ -490,7 +498,7 @@ static int batch_objects(struct batch_options *opt)
 
        /*
         * Expand once with our special mark_query flag, which will prime the
-        * object_info to be handed to sha1_object_info_extended for each
+        * object_info to be handed to oid_object_info_extended for each
         * object.
         */
        memset(&data, 0, sizeof(data));
@@ -517,8 +525,8 @@ static int batch_objects(struct batch_options *opt)
        if (opt->all_objects) {
                struct object_cb_data cb;
 
-               if (repository_format_partial_clone)
-                       warning("This repository has extensions.partialClone set. Some objects may not be loaded.");
+               if (has_promisor_remote())
+                       warning("This repository uses promisor remotes. Some objects may not be loaded.");
 
                cb.opt = opt;
                cb.expand = &data;