*/
};
- extern int get_oid(const char *str, struct object_id *oid);
- extern int get_oidf(struct object_id *oid, const char *fmt, ...);
- extern int get_oid_commit(const char *str, struct object_id *oid);
- extern int get_oid_committish(const char *str, struct object_id *oid);
- extern int get_oid_tree(const char *str, struct object_id *oid);
- extern int get_oid_treeish(const char *str, struct object_id *oid);
- extern int get_oid_blob(const char *str, struct object_id *oid);
- extern void maybe_die_on_misspelt_object_name(const char *name, const char *prefix);
+ int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
++int get_oidf(struct object_id *oid, const char *fmt, ...);
+ int repo_get_oid_commit(struct repository *r, const char *str, struct object_id *oid);
+ int repo_get_oid_committish(struct repository *r, const char *str, struct object_id *oid);
+ int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid);
+ int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid);
+ int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid);
+ int repo_get_oid_mb(struct repository *r, const char *str, struct object_id *oid);
+ void maybe_die_on_misspelt_object_name(struct repository *repo,
+ const char *name,
+ const char *prefix);
extern enum get_oid_result get_oid_with_context(struct repository *repo, const char *str,
unsigned flags, struct object_id *oid,
struct object_context *oc);
* Give a rough count of objects in the repository. This sacrifices accuracy
* for speed.
*/
- unsigned long approximate_object_count(void);
+ unsigned long repo_approximate_object_count(struct repository *r);
+ #define approximate_object_count() repo_approximate_object_count(the_repository)
-extern struct packed_git *find_sha1_pack(const unsigned char *sha1,
- struct packed_git *packs);
+struct packed_git *find_sha1_pack(const unsigned char *sha1,
+ struct packed_git *packs);
-extern void pack_report(void);
+void pack_report(void);
/*
* mmap the index file for the specified packfile (if it is not
* This is like "get_oid_basic()", except it allows "object ID expressions",
* notably "xyz^" for "parent of xyz"
*/
- int get_oid(const char *name, struct object_id *oid)
+ int repo_get_oid(struct repository *r, const char *name, struct object_id *oid)
{
struct object_context unused;
- return get_oid_with_context(the_repository, name, 0, oid, &unused);
+ return get_oid_with_context(r, name, 0, oid, &unused);
}
+/*
+ * This returns a non-zero value if the string (built using printf
+ * format and the given arguments) is not a valid object.
+ */
+int get_oidf(struct object_id *oid, const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
+ struct strbuf sb = STRBUF_INIT;
+
+ va_start(ap, fmt);
+ strbuf_vaddf(&sb, fmt, ap);
+ va_end(ap);
+
+ ret = get_oid(sb.buf, oid);
+ strbuf_release(&sb);
+
+ return ret;
+}
/*
* Many callers know that the user meant to name a commit-ish by