gitsubmodules: align html and nroff lists
[gitweb.git] / sha1-name.c
index 4acd406b0ad7ed448878fe416c1d0221032ca65e..6dda2c16df1026e50b7d9be255b6bbfc4e92725c 100644 (file)
@@ -1515,7 +1515,7 @@ int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
 int get_oid(const char *name, struct object_id *oid)
 {
        struct object_context unused;
-       return get_oid_with_context(name, 0, oid, &unused);
+       return get_oid_with_context(the_repository, name, 0, oid, &unused);
 }
 
 
@@ -1532,35 +1532,40 @@ int get_oid(const char *name, struct object_id *oid)
 int get_oid_committish(const char *name, struct object_id *oid)
 {
        struct object_context unused;
-       return get_oid_with_context(name, GET_OID_COMMITTISH,
+       return get_oid_with_context(the_repository,
+                                   name, GET_OID_COMMITTISH,
                                    oid, &unused);
 }
 
 int get_oid_treeish(const char *name, struct object_id *oid)
 {
        struct object_context unused;
-       return get_oid_with_context(name, GET_OID_TREEISH,
+       return get_oid_with_context(the_repository,
+                                   name, GET_OID_TREEISH,
                                    oid, &unused);
 }
 
 int get_oid_commit(const char *name, struct object_id *oid)
 {
        struct object_context unused;
-       return get_oid_with_context(name, GET_OID_COMMIT,
+       return get_oid_with_context(the_repository,
+                                   name, GET_OID_COMMIT,
                                    oid, &unused);
 }
 
 int get_oid_tree(const char *name, struct object_id *oid)
 {
        struct object_context unused;
-       return get_oid_with_context(name, GET_OID_TREE,
+       return get_oid_with_context(the_repository,
+                                   name, GET_OID_TREE,
                                    oid, &unused);
 }
 
 int get_oid_blob(const char *name, struct object_id *oid)
 {
        struct object_context unused;
-       return get_oid_with_context(name, GET_OID_BLOB,
+       return get_oid_with_context(the_repository,
+                                   name, GET_OID_BLOB,
                                    oid, &unused);
 }
 
@@ -1599,7 +1604,8 @@ static void diagnose_invalid_oid_path(const char *prefix,
 }
 
 /* Must be called only when :stage:filename doesn't exist. */
-static void diagnose_invalid_index_path(int stage,
+static void diagnose_invalid_index_path(struct index_state *istate,
+                                       int stage,
                                        const char *prefix,
                                        const char *filename)
 {
@@ -1612,11 +1618,11 @@ static void diagnose_invalid_index_path(int stage,
                prefix = "";
 
        /* Wrong stage number? */
-       pos = cache_name_pos(filename, namelen);
+       pos = index_name_pos(istate, filename, namelen);
        if (pos < 0)
                pos = -pos - 1;
-       if (pos < active_nr) {
-               ce = active_cache[pos];
+       if (pos < istate->cache_nr) {
+               ce = istate->cache[pos];
                if (ce_namelen(ce) == namelen &&
                    !memcmp(ce->name, filename, namelen))
                        die("Path '%s' is in the index, but not at stage %d.\n"
@@ -1628,11 +1634,11 @@ static void diagnose_invalid_index_path(int stage,
        /* Confusion between relative and absolute filenames? */
        strbuf_addstr(&fullname, prefix);
        strbuf_addstr(&fullname, filename);
-       pos = cache_name_pos(fullname.buf, fullname.len);
+       pos = index_name_pos(istate, fullname.buf, fullname.len);
        if (pos < 0)
                pos = -pos - 1;
-       if (pos < active_nr) {
-               ce = active_cache[pos];
+       if (pos < istate->cache_nr) {
+               ce = istate->cache[pos];
                if (ce_namelen(ce) == fullname.len &&
                    !memcmp(ce->name, fullname.buf, fullname.len))
                        die("Path '%s' is in the index, but not '%s'.\n"
@@ -1666,11 +1672,12 @@ static char *resolve_relative_path(const char *rel)
                           rel);
 }
 
-static enum get_oid_result get_oid_with_context_1(const char *name,
-                                                 unsigned flags,
-                                                 const char *prefix,
-                                                 struct object_id *oid,
-                                                 struct object_context *oc)
+static enum get_oid_result get_oid_with_context_1(struct repository *repo,
+                                 const char *name,
+                                 unsigned flags,
+                                 const char *prefix,
+                                 struct object_id *oid,
+                                 struct object_context *oc)
 {
        int ret, bracket_depth;
        int namelen = strlen(name);
@@ -1725,13 +1732,13 @@ static enum get_oid_result get_oid_with_context_1(const char *name,
                if (flags & GET_OID_RECORD_PATH)
                        oc->path = xstrdup(cp);
 
-               if (!active_cache)
-                       read_cache();
-               pos = cache_name_pos(cp, namelen);
+               if (!repo->index->cache)
+                       repo_read_index(the_repository);
+               pos = index_name_pos(repo->index, cp, namelen);
                if (pos < 0)
                        pos = -pos - 1;
-               while (pos < active_nr) {
-                       ce = active_cache[pos];
+               while (pos < repo->index->cache_nr) {
+                       ce = repo->index->cache[pos];
                        if (ce_namelen(ce) != namelen ||
                            memcmp(ce->name, cp, namelen))
                                break;
@@ -1744,7 +1751,7 @@ static enum get_oid_result get_oid_with_context_1(const char *name,
                        pos++;
                }
                if (only_to_die && name[1] && name[1] != '/')
-                       diagnose_invalid_index_path(stage, prefix, cp);
+                       diagnose_invalid_index_path(repo->index, stage, prefix, cp);
                free(new_path);
                return -1;
        }
@@ -1809,12 +1816,17 @@ void maybe_die_on_misspelt_object_name(const char *name, const char *prefix)
 {
        struct object_context oc;
        struct object_id oid;
-       get_oid_with_context_1(name, GET_OID_ONLY_TO_DIE, prefix, &oid, &oc);
+       get_oid_with_context_1(the_repository, name, GET_OID_ONLY_TO_DIE,
+                              prefix, &oid, &oc);
 }
 
-int get_oid_with_context(const char *str, unsigned flags, struct object_id *oid, struct object_context *oc)
+enum get_oid_result get_oid_with_context(struct repository *repo,
+                                        const char *str,
+                                        unsigned flags,
+                                        struct object_id *oid,
+                                        struct object_context *oc)
 {
        if (flags & GET_OID_FOLLOW_SYMLINKS && flags & GET_OID_ONLY_TO_DIE)
                BUG("incompatible flags for get_sha1_with_context");
-       return get_oid_with_context_1(str, flags, NULL, oid, oc);
+       return get_oid_with_context_1(repo, str, flags, NULL, oid, oc);
 }