object-name.h: move declarations for object-name.c functions from cache.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Elijah Newren 2023-04-11 00:41:49 -07:00 committed by Junio C Hamano
parent 5579f44d2f
commit dabab1d6e6
91 changed files with 210 additions and 110 deletions

View File

@ -4,6 +4,7 @@
#include "alloc.h" #include "alloc.h"
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "object-name.h"
#include "strbuf.h" #include "strbuf.h"
#include "run-command.h" #include "run-command.h"
#include "strvec.h" #include "strvec.h"

View File

@ -22,6 +22,7 @@
#include "xdiff-interface.h" #include "xdiff-interface.h"
#include "ll-merge.h" #include "ll-merge.h"
#include "lockfile.h" #include "lockfile.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "quote.h" #include "quote.h"
#include "rerere.h" #include "rerere.h"

View File

@ -2,6 +2,7 @@
#define ARCHIVE_H #define ARCHIVE_H
#include "cache.h" #include "cache.h"
#include "object-name.h"
#include "pathspec.h" #include "pathspec.h"
struct repository; struct repository;

View File

@ -17,6 +17,7 @@
#include "strvec.h" #include "strvec.h"
#include "commit-slab.h" #include "commit-slab.h"
#include "commit-reach.h" #include "commit-reach.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "dir.h" #include "dir.h"

View File

@ -6,6 +6,7 @@
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "refs.h" #include "refs.h"
#include "refspec.h" #include "refspec.h"
#include "remote.h" #include "remote.h"

View File

@ -27,6 +27,7 @@
#include "diffcore.h" #include "diffcore.h"
#include "unpack-trees.h" #include "unpack-trees.h"
#include "branch.h" #include "branch.h"
#include "object-name.h"
#include "sequencer.h" #include "sequencer.h"
#include "revision.h" #include "revision.h"
#include "merge-recursive.h" #include "merge-recursive.h"

View File

@ -3,6 +3,7 @@
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "bisect.h" #include "bisect.h"
#include "refs.h" #include "refs.h"

View File

@ -28,6 +28,7 @@
#include "line-log.h" #include "line-log.h"
#include "dir.h" #include "dir.h"
#include "progress.h" #include "progress.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "blame.h" #include "blame.h"
#include "refs.h" #include "refs.h"

View File

@ -13,6 +13,7 @@
#include "commit.h" #include "commit.h"
#include "builtin.h" #include "builtin.h"
#include "gettext.h" #include "gettext.h"
#include "object-name.h"
#include "remote.h" #include "remote.h"
#include "parse-options.h" #include "parse-options.h"
#include "branch.h" #include "branch.h"

View File

@ -20,6 +20,7 @@
#include "tree-walk.h" #include "tree-walk.h"
#include "oid-array.h" #include "oid-array.h"
#include "packfile.h" #include "packfile.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "replace-object.h" #include "replace-object.h"
#include "promisor-remote.h" #include "promisor-remote.h"

View File

@ -5,6 +5,7 @@
#include "attr.h" #include "attr.h"
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "object-name.h"
#include "quote.h" #include "quote.h"
#include "setup.h" #include "setup.h"
#include "parse-options.h" #include "parse-options.h"

View File

@ -17,6 +17,7 @@
#include "lockfile.h" #include "lockfile.h"
#include "mem-pool.h" #include "mem-pool.h"
#include "merge-recursive.h" #include "merge-recursive.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "parse-options.h" #include "parse-options.h"
#include "refs.h" #include "refs.h"

View File

@ -7,6 +7,7 @@
#include "config.h" #include "config.h"
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "repository.h" #include "repository.h"
#include "commit.h" #include "commit.h"

View File

@ -27,6 +27,7 @@
#include "log-tree.h" #include "log-tree.h"
#include "strbuf.h" #include "strbuf.h"
#include "utf8.h" #include "utf8.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "string-list.h" #include "string-list.h"
#include "rerere.h" #include "rerere.h"

View File

@ -11,6 +11,7 @@
#include "refs.h" #include "refs.h"
#include "builtin.h" #include "builtin.h"
#include "exec-cmd.h" #include "exec-cmd.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "revision.h" #include "revision.h"
#include "diff.h" #include "diff.h"

View File

@ -19,6 +19,7 @@
#include "dir.h" #include "dir.h"
#include "run-command.h" #include "run-command.h"
#include "packfile.h" #include "packfile.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "mem-pool.h" #include "mem-pool.h"
#include "commit-reach.h" #include "commit-reach.h"

View File

@ -10,6 +10,7 @@
#include "repository.h" #include "repository.h"
#include "refs.h" #include "refs.h"
#include "refspec.h" #include "refspec.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "oidset.h" #include "oidset.h"
#include "oid-array.h" #include "oid-array.h"

View File

@ -19,6 +19,7 @@
#include "streaming.h" #include "streaming.h"
#include "decorate.h" #include "decorate.h"
#include "packfile.h" #include "packfile.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "replace-object.h" #include "replace-object.h"
#include "resolve-undo.h" #include "resolve-undo.h"

View File

@ -26,6 +26,7 @@
#include "setup.h" #include "setup.h"
#include "submodule.h" #include "submodule.h"
#include "submodule-config.h" #include "submodule-config.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "packfile.h" #include "packfile.h"
#include "write-or-die.h" #include "write-or-die.h"

View File

@ -12,6 +12,7 @@
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "refs.h" #include "refs.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "color.h" #include "color.h"
#include "commit.h" #include "commit.h"

View File

@ -13,6 +13,7 @@
#include "dir.h" #include "dir.h"
#include "builtin.h" #include "builtin.h"
#include "gettext.h" #include "gettext.h"
#include "object-name.h"
#include "strbuf.h" #include "strbuf.h"
#include "tree.h" #include "tree.h"
#include "cache-tree.h" #include "cache-tree.h"

View File

@ -7,6 +7,7 @@
#include "config.h" #include "config.h"
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "blob.h" #include "blob.h"
#include "tree.h" #include "tree.h"

View File

@ -7,6 +7,7 @@
#include "refs.h" #include "refs.h"
#include "diff.h" #include "diff.h"
#include "revision.h" #include "revision.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "repository.h" #include "repository.h"
#include "commit-reach.h" #include "commit-reach.h"

View File

@ -5,6 +5,7 @@
#include "gettext.h" #include "gettext.h"
#include "tag.h" #include "tag.h"
#include "merge-recursive.h" #include "merge-recursive.h"
#include "object-name.h"
#include "xdiff-interface.h" #include "xdiff-interface.h"
static const char builtin_merge_recursive_usage[] = static const char builtin_merge_recursive_usage[] =

View File

@ -8,6 +8,7 @@
#include "commit.h" #include "commit.h"
#include "commit-reach.h" #include "commit-reach.h"
#include "merge-ort.h" #include "merge-ort.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "parse-options.h" #include "parse-options.h"
#include "repository.h" #include "repository.h"

View File

@ -15,6 +15,7 @@
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "builtin.h" #include "builtin.h"
#include "lockfile.h" #include "lockfile.h"

View File

@ -8,6 +8,7 @@
#include "commit.h" #include "commit.h"
#include "tag.h" #include "tag.h"
#include "refs.h" #include "refs.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "prio-queue.h" #include "prio-queue.h"
#include "hash-lookup.h" #include "hash-lookup.h"

View File

@ -13,6 +13,7 @@
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "notes.h" #include "notes.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "repository.h" #include "repository.h"
#include "blob.h" #include "blob.h"

View File

@ -11,6 +11,7 @@
#include "progress.h" #include "progress.h"
#include "prune-packed.h" #include "prune-packed.h"
#include "replace-object.h" #include "replace-object.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "shallow.h" #include "shallow.h"

View File

@ -12,6 +12,7 @@
#include "builtin.h" #include "builtin.h"
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "exec-cmd.h" #include "exec-cmd.h"
#include "run-command.h" #include "run-command.h"

View File

@ -1,6 +1,7 @@
#include "cache.h" #include "cache.h"
#include "builtin.h" #include "builtin.h"
#include "gettext.h" #include "gettext.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "range-diff.h" #include "range-diff.h"
#include "config.h" #include "config.h"

View File

@ -11,6 +11,7 @@
#include "hex.h" #include "hex.h"
#include "lockfile.h" #include "lockfile.h"
#include "object.h" #include "object.h"
#include "object-name.h"
#include "tree.h" #include "tree.h"
#include "tree-walk.h" #include "tree-walk.h"
#include "cache-tree.h" #include "cache-tree.h"

View File

@ -21,6 +21,7 @@
#include "cache-tree.h" #include "cache-tree.h"
#include "unpack-trees.h" #include "unpack-trees.h"
#include "lockfile.h" #include "lockfile.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "commit.h" #include "commit.h"
#include "diff.h" #include "diff.h"

View File

@ -29,6 +29,7 @@
#include "tmp-objdir.h" #include "tmp-objdir.h"
#include "oidset.h" #include "oidset.h"
#include "packfile.h" #include "packfile.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "protocol.h" #include "protocol.h"
#include "commit-reach.h" #include "commit-reach.h"

View File

@ -17,6 +17,7 @@
#include "refs.h" #include "refs.h"
#include "parse-options.h" #include "parse-options.h"
#include "run-command.h" #include "run-command.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "replace-object.h" #include "replace-object.h"
#include "repository.h" #include "repository.h"

View File

@ -24,6 +24,7 @@
#include "diffcore.h" #include "diffcore.h"
#include "tree.h" #include "tree.h"
#include "branch.h" #include "branch.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "unpack-trees.h" #include "unpack-trees.h"
#include "cache-tree.h" #include "cache-tree.h"

View File

@ -10,6 +10,7 @@
#include "list-objects-filter.h" #include "list-objects-filter.h"
#include "list-objects-filter-options.h" #include "list-objects-filter-options.h"
#include "object.h" #include "object.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "pack.h" #include "pack.h"
#include "pack-bitmap.h" #include "pack-bitmap.h"

View File

@ -15,6 +15,7 @@
#include "refs.h" #include "refs.h"
#include "quote.h" #include "quote.h"
#include "builtin.h" #include "builtin.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "diff.h" #include "diff.h"
#include "revision.h" #include "revision.h"

View File

@ -13,6 +13,7 @@
#include "cache-tree.h" #include "cache-tree.h"
#include "gettext.h" #include "gettext.h"
#include "tree-walk.h" #include "tree-walk.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "string-list.h" #include "string-list.h"
#include "setup.h" #include "setup.h"

View File

@ -8,6 +8,7 @@
#include "builtin.h" #include "builtin.h"
#include "color.h" #include "color.h"
#include "strvec.h" #include "strvec.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "dir.h" #include "dir.h"
#include "commit-slab.h" #include "commit-slab.h"

View File

@ -4,6 +4,7 @@
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "refs.h" #include "refs.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "object.h" #include "object.h"
#include "tag.h" #include "tag.h"

View File

@ -4,6 +4,7 @@
#include "dir.h" #include "dir.h"
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "pathspec.h" #include "pathspec.h"
#include "repository.h" #include "repository.h"

View File

@ -5,6 +5,7 @@
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "refs.h" #include "refs.h"
#include "lockfile.h" #include "lockfile.h"

View File

@ -24,6 +24,7 @@
#include "revision.h" #include "revision.h"
#include "diffcore.h" #include "diffcore.h"
#include "diff.h" #include "diff.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "advice.h" #include "advice.h"
#include "branch.h" #include "branch.h"

View File

@ -14,6 +14,7 @@
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "refs.h" #include "refs.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "tag.h" #include "tag.h"
#include "run-command.h" #include "run-command.h"

View File

@ -1,6 +1,7 @@
#include "builtin.h" #include "builtin.h"
#include "config.h" #include "config.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "wrapper.h" #include "wrapper.h"

View File

@ -3,6 +3,7 @@
#include "gettext.h" #include "gettext.h"
#include "refs.h" #include "refs.h"
#include "builtin.h" #include "builtin.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "quote.h" #include "quote.h"
#include "strvec.h" #include "strvec.h"

View File

@ -9,6 +9,7 @@
#include "config.h" #include "config.h"
#include "builtin.h" #include "builtin.h"
#include "gettext.h" #include "gettext.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "repository.h" #include "repository.h"
#include "commit.h" #include "commit.h"

View File

@ -11,6 +11,7 @@
#include "gettext.h" #include "gettext.h"
#include "tag.h" #include "tag.h"
#include "run-command.h" #include "run-command.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "gpg-interface.h" #include "gpg-interface.h"
#include "ref-filter.h" #include "ref-filter.h"

View File

@ -7,6 +7,7 @@
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "strvec.h" #include "strvec.h"
#include "branch.h" #include "branch.h"

110
cache.h
View File

@ -687,24 +687,6 @@ extern int quote_path_fully;
#define DATA_CHANGED 0x0020 #define DATA_CHANGED 0x0020
#define TYPE_CHANGED 0x0040 #define TYPE_CHANGED 0x0040
/*
* Return an abbreviated sha1 unique within this repository's object database.
* The result will be at least `len` characters long, and will be NUL
* terminated.
*
* The non-`_r` version returns a static buffer which remains valid until 4
* more calls to repo_find_unique_abbrev are made.
*
* The `_r` variant writes to a buffer supplied by the caller, which must be at
* least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
* written (excluding the NUL terminator).
*
* Note that while this version avoids the static buffer, it is not fully
* reentrant, as it calls into other non-reentrant git code.
*/
const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
/* /*
* Create the directory containing the named path, using care to be * Create the directory containing the named path, using care to be
* somewhat safe against races. Return one of the scld_error values to * somewhat safe against races. Return one of the scld_error values to
@ -806,94 +788,6 @@ int finalize_object_file(const char *tmpfile, const char *filename);
/* Helper to check and "touch" a file */ /* Helper to check and "touch" a file */
int check_and_freshen_file(const char *fn, int freshen); int check_and_freshen_file(const char *fn, int freshen);
/* Convert to/from hex/sha1 representation */
#define MINIMUM_ABBREV minimum_abbrev
#define DEFAULT_ABBREV default_abbrev
/* used when the code does not know or care what the default abbrev is */
#define FALLBACK_DEFAULT_ABBREV 7
struct object_context {
unsigned short mode;
/*
* symlink_path is only used by get_tree_entry_follow_symlinks,
* and only for symlinks that point outside the repository.
*/
struct strbuf symlink_path;
/*
* If GET_OID_RECORD_PATH is set, this will record path (if any)
* found when resolving the name. The caller is responsible for
* releasing the memory.
*/
char *path;
};
int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
__attribute__((format (printf, 2, 3)))
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);
enum get_oid_result get_oid_with_context(struct repository *repo, const char *str,
unsigned flags, struct object_id *oid,
struct object_context *oc);
typedef int each_abbrev_fn(const struct object_id *oid, void *);
int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
int set_disambiguate_hint_config(const char *var, const char *value);
/*
* This reads short-hand syntax that not only evaluates to a commit
* object name, but also can act as if the end user spelled the name
* of the branch from the command line.
*
* - "@{-N}" finds the name of the Nth previous branch we were on, and
* places the name of the branch in the given buf and returns the
* number of characters parsed if successful.
*
* - "<branch>@{upstream}" finds the name of the other ref that
* <branch> is configured to merge with (missing <branch> defaults
* to the current branch), and places the name of the branch in the
* given buf and returns the number of characters parsed if
* successful.
*
* If the input is not of the accepted format, it returns a negative
* number to signal an error.
*
* If the input was ok but there are not N branch switches in the
* reflog, it returns 0.
*/
#define INTERPRET_BRANCH_LOCAL (1<<0)
#define INTERPRET_BRANCH_REMOTE (1<<1)
#define INTERPRET_BRANCH_HEAD (1<<2)
struct interpret_branch_name_options {
/*
* If "allowed" is non-zero, it is a treated as a bitfield of allowable
* expansions: local branches ("refs/heads/"), remote branches
* ("refs/remotes/"), or "HEAD". If no "allowed" bits are set, any expansion is
* allowed, even ones to refs outside of those namespaces.
*/
unsigned allowed;
/*
* If ^{upstream} or ^{push} (or equivalent) is requested, and the
* branch in question does not have such a reference, return -1 instead
* of die()-ing.
*/
unsigned nonfatal_dangling_mark : 1;
};
int repo_interpret_branch_name(struct repository *r,
const char *str, int len,
struct strbuf *buf,
const struct interpret_branch_name_options *options);
int base_name_compare(const char *name1, size_t len1, int mode1, int base_name_compare(const char *name1, size_t len1, int mode1,
const char *name2, size_t len2, int mode2); const char *name2, size_t len2, int mode2);
int df_name_compare(const char *name1, size_t len1, int mode1, int df_name_compare(const char *name1, size_t len1, int mode1,
@ -907,10 +801,6 @@ void *read_object_with_reference(struct repository *r,
unsigned long *size, unsigned long *size,
struct object_id *oid_ret); struct object_id *oid_ret);
struct object *repo_peel_to_type(struct repository *r,
const char *name, int namelen,
struct object *o, enum object_type);
const char *git_editor(void); const char *git_editor(void);
const char *git_sequence_editor(void); const char *git_sequence_editor(void);
const char *git_pager(int stdout_is_tty); const char *git_pager(int stdout_is_tty);

View File

@ -1,4 +1,5 @@
#include "cache.h" #include "cache.h"
#include "object-name.h"
#include "remote.h" #include "remote.h"
#include "refspec.h" #include "refspec.h"
#include "checkout.h" #include "checkout.h"

View File

@ -7,6 +7,7 @@
#include "diffcore.h" #include "diffcore.h"
#include "environment.h" #include "environment.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "quote.h" #include "quote.h"
#include "xdiff-interface.h" #include "xdiff-interface.h"
#include "xdiff/xmacros.h" #include "xdiff/xmacros.h"

View File

@ -6,6 +6,7 @@
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "repository.h" #include "repository.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "pkt-line.h" #include "pkt-line.h"
#include "utf8.h" #include "utf8.h"

View File

@ -23,6 +23,7 @@
#include "quote.h" #include "quote.h"
#include "hashmap.h" #include "hashmap.h"
#include "string-list.h" #include "string-list.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "utf8.h" #include "utf8.h"
#include "dir.h" #include "dir.h"

View File

@ -8,6 +8,7 @@
#include "diffcore.h" #include "diffcore.h"
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "revision.h" #include "revision.h"
#include "cache-tree.h" #include "cache-tree.h"
#include "unpack-trees.h" #include "unpack-trees.h"

1
diff.c
View File

@ -35,6 +35,7 @@
#include "help.h" #include "help.h"
#include "promisor-remote.h" #include "promisor-remote.h"
#include "dir.h" #include "dir.h"
#include "object-name.h"
#include "setup.h" #include "setup.h"
#include "strmap.h" #include "strmap.h"
#include "wrapper.h" #include "wrapper.h"

View File

@ -3,6 +3,7 @@
#include "config.h" #include "config.h"
#include "environment.h" #include "environment.h"
#include "refs.h" #include "refs.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "diff.h" #include "diff.h"
#include "diff-merges.h" #include "diff-merges.h"

View File

@ -15,6 +15,7 @@
#include "list-objects-filter-options.h" #include "list-objects-filter-options.h"
#include "oidmap.h" #include "oidmap.h"
#include "oidset.h" #include "oidset.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
/* Remember to update object flag allocation in object.h */ /* Remember to update object flag allocation in object.h */

View File

@ -4,6 +4,7 @@
#include "diff.h" #include "diff.h"
#include "environment.h" #include "environment.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "repository.h" #include "repository.h"
#include "tmp-objdir.h" #include "tmp-objdir.h"

View File

@ -2,6 +2,7 @@
#include "environment.h" #include "environment.h"
#include "string-list.h" #include "string-list.h"
#include "mailmap.h" #include "mailmap.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "setup.h" #include "setup.h"

View File

@ -32,6 +32,7 @@
#include "entry.h" #include "entry.h"
#include "ll-merge.h" #include "ll-merge.h"
#include "mem-pool.h" #include "mem-pool.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "oid-array.h" #include "oid-array.h"
#include "promisor-remote.h" #include "promisor-remote.h"

View File

@ -22,6 +22,7 @@
#include "hex.h" #include "hex.h"
#include "ll-merge.h" #include "ll-merge.h"
#include "lockfile.h" #include "lockfile.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "repository.h" #include "repository.h"
#include "revision.h" #include "revision.h"

View File

@ -3,6 +3,7 @@
#include "commit.h" #include "commit.h"
#include "gettext.h" #include "gettext.h"
#include "refs.h" #include "refs.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "repository.h" #include "repository.h"
#include "diff.h" #include "diff.h"

View File

@ -3,6 +3,7 @@
#include "environment.h" #include "environment.h"
#include "hex.h" #include "hex.h"
#include "notes.h" #include "notes.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "blob.h" #include "blob.h"
#include "tree.h" #include "tree.h"

View File

@ -1,4 +1,5 @@
#include "cache.h" #include "cache.h"
#include "object-name.h"
#include "advice.h" #include "advice.h"
#include "config.h" #include "config.h"
#include "environment.h" #include "environment.h"

121
object-name.h Normal file
View File

@ -0,0 +1,121 @@
#ifndef OBJECT_NAME_H
#define OBJECT_NAME_H
#include "object.h"
#include "strbuf.h"
struct object_id;
struct repository;
struct object_context {
unsigned short mode;
/*
* symlink_path is only used by get_tree_entry_follow_symlinks,
* and only for symlinks that point outside the repository.
*/
struct strbuf symlink_path;
/*
* If GET_OID_RECORD_PATH is set, this will record path (if any)
* found when resolving the name. The caller is responsible for
* releasing the memory.
*/
char *path;
};
/*
* Return an abbreviated sha1 unique within this repository's object database.
* The result will be at least `len` characters long, and will be NUL
* terminated.
*
* The non-`_r` version returns a static buffer which remains valid until 4
* more calls to repo_find_unique_abbrev are made.
*
* The `_r` variant writes to a buffer supplied by the caller, which must be at
* least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
* written (excluding the NUL terminator).
*
* Note that while this version avoids the static buffer, it is not fully
* reentrant, as it calls into other non-reentrant git code.
*/
const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
__attribute__((format (printf, 2, 3)))
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);
enum get_oid_result get_oid_with_context(struct repository *repo, const char *str,
unsigned flags, struct object_id *oid,
struct object_context *oc);
typedef int each_abbrev_fn(const struct object_id *oid, void *);
int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
int set_disambiguate_hint_config(const char *var, const char *value);
/*
* This reads short-hand syntax that not only evaluates to a commit
* object name, but also can act as if the end user spelled the name
* of the branch from the command line.
*
* - "@{-N}" finds the name of the Nth previous branch we were on, and
* places the name of the branch in the given buf and returns the
* number of characters parsed if successful.
*
* - "<branch>@{upstream}" finds the name of the other ref that
* <branch> is configured to merge with (missing <branch> defaults
* to the current branch), and places the name of the branch in the
* given buf and returns the number of characters parsed if
* successful.
*
* If the input is not of the accepted format, it returns a negative
* number to signal an error.
*
* If the input was ok but there are not N branch switches in the
* reflog, it returns 0.
*/
#define INTERPRET_BRANCH_LOCAL (1<<0)
#define INTERPRET_BRANCH_REMOTE (1<<1)
#define INTERPRET_BRANCH_HEAD (1<<2)
struct interpret_branch_name_options {
/*
* If "allowed" is non-zero, it is a treated as a bitfield of allowable
* expansions: local branches ("refs/heads/"), remote branches
* ("refs/remotes/"), or "HEAD". If no "allowed" bits are set, any expansion is
* allowed, even ones to refs outside of those namespaces.
*/
unsigned allowed;
/*
* If ^{upstream} or ^{push} (or equivalent) is requested, and the
* branch in question does not have such a reference, return -1 instead
* of die()-ing.
*/
unsigned nonfatal_dangling_mark : 1;
};
int repo_interpret_branch_name(struct repository *r,
const char *str, int len,
struct strbuf *buf,
const struct interpret_branch_name_options *options);
struct object *repo_peel_to_type(struct repository *r,
const char *name, int namelen,
struct object *o, enum object_type);
/* Convert to/from hex/sha1 representation */
#define MINIMUM_ABBREV minimum_abbrev
#define DEFAULT_ABBREV default_abbrev
/* used when the code does not know or care what the default abbrev is */
#define FALLBACK_DEFAULT_ABBREV 7
#endif /* OBJECT_NAME_H */

View File

@ -6,6 +6,7 @@
#include "color.h" #include "color.h"
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "object-name.h"
#include "string-list.h" #include "string-list.h"
#include "strvec.h" #include "strvec.h"
#include "oid-array.h" #include "oid-array.h"

View File

@ -2,6 +2,7 @@
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "range-diff.h" #include "range-diff.h"
#include "object-name.h"
#include "string-list.h" #include "string-list.h"
#include "run-command.h" #include "run-command.h"
#include "strvec.h" #include "strvec.h"

View File

@ -22,6 +22,7 @@
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "mem-pool.h" #include "mem-pool.h"
#include "object-name.h"
#include "resolve-undo.h" #include "resolve-undo.h"
#include "run-command.h" #include "run-command.h"
#include "strbuf.h" #include "strbuf.h"

View File

@ -8,6 +8,7 @@
#include "commit-slab.h" #include "commit-slab.h"
#include "config.h" #include "config.h"
#include "dir.h" #include "dir.h"
#include "object-name.h"
#include "wrapper.h" #include "wrapper.h"
static const char edit_todo_list_advice[] = static const char edit_todo_list_advice[] =

View File

@ -6,6 +6,7 @@
#include "parse-options.h" #include "parse-options.h"
#include "refs.h" #include "refs.h"
#include "wildmatch.h" #include "wildmatch.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "oid-array.h" #include "oid-array.h"
#include "repository.h" #include "repository.h"

1
refs.c
View File

@ -16,6 +16,7 @@
#include "refs/refs-internal.h" #include "refs/refs-internal.h"
#include "run-command.h" #include "run-command.h"
#include "hook.h" #include "hook.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "object.h" #include "object.h"
#include "tag.h" #include "tag.h"

View File

@ -9,6 +9,7 @@
#include "urlmatch.h" #include "urlmatch.h"
#include "refs.h" #include "refs.h"
#include "refspec.h" #include "refspec.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "commit.h" #include "commit.h"
#include "diff.h" #include "diff.h"

View File

@ -3,6 +3,7 @@
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "lockfile.h" #include "lockfile.h"
#include "object-name.h"
#include "refs.h" #include "refs.h"
#include "reset.h" #include "reset.h"
#include "run-command.h" #include "run-command.h"

View File

@ -4,6 +4,7 @@
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "tag.h" #include "tag.h"
#include "blob.h" #include "blob.h"

View File

@ -8,6 +8,7 @@
#include "hex.h" #include "hex.h"
#include "lockfile.h" #include "lockfile.h"
#include "dir.h" #include "dir.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "object.h" #include "object.h"
#include "commit.h" #include "commit.h"

View File

@ -2,6 +2,7 @@
#include "abspath.h" #include "abspath.h"
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "object-name.h"
#include "repository.h" #include "repository.h"
#include "config.h" #include "config.h"
#include "dir.h" #include "dir.h"

View File

@ -4,6 +4,7 @@
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "refs.h" #include "refs.h"
#include "string-list.h" #include "string-list.h"
#include "utf8.h" #include "utf8.h"

View File

@ -9,6 +9,7 @@
#include "submodule-config.h" #include "submodule-config.h"
#include "submodule.h" #include "submodule.h"
#include "strbuf.h" #include "strbuf.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "parse-options.h" #include "parse-options.h"
#include "tree-walk.h" #include "tree-walk.h"

View File

@ -24,6 +24,7 @@
#include "remote.h" #include "remote.h"
#include "worktree.h" #include "worktree.h"
#include "parse-options.h" #include "parse-options.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "commit-reach.h" #include "commit-reach.h"
#include "setup.h" #include "setup.h"

View File

@ -20,6 +20,7 @@
#include "hex.h" #include "hex.h"
#include "lockfile.h" #include "lockfile.h"
#include "merge-ort.h" #include "merge-ort.h"
#include "object-name.h"
#include "refs.h" #include "refs.h"
#include "revision.h" #include "revision.h"
#include "sequencer.h" #include "sequencer.h"

View File

@ -1,6 +1,7 @@
#include "test-tool.h" #include "test-tool.h"
#include "cache.h" #include "cache.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "setup.h" #include "setup.h"
#include "tree.h" #include "tree.h"

View File

@ -1,6 +1,7 @@
#include "test-tool.h" #include "test-tool.h"
#include "cache.h" #include "cache.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "oidmap.h" #include "oidmap.h"
#include "setup.h" #include "setup.h"
#include "strbuf.h" #include "strbuf.h"

View File

@ -6,6 +6,7 @@
#include "config.h" #include "config.h"
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "parse-options.h" #include "parse-options.h"
#include "ref-filter.h" #include "ref-filter.h"
#include "setup.h" #include "setup.h"

View File

@ -1,6 +1,7 @@
#include "test-tool.h" #include "test-tool.h"
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "object-name.h"
#include "setup.h" #include "setup.h"
#include "submodule-config.h" #include "submodule-config.h"
#include "submodule.h" #include "submodule.h"

1
tag.c
View File

@ -1,6 +1,7 @@
#include "cache.h" #include "cache.h"
#include "environment.h" #include "environment.h"
#include "tag.h" #include "tag.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "commit.h" #include "commit.h"
#include "tree.h" #include "tree.h"

View File

@ -7,6 +7,7 @@
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "revision.h" #include "revision.h"
#include "remote.h" #include "remote.h"
#include "string-list.h" #include "string-list.h"

View File

@ -26,6 +26,7 @@
#include "trace2.h" #include "trace2.h"
#include "transport-internal.h" #include "transport-internal.h"
#include "protocol.h" #include "protocol.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "color.h" #include "color.h"
#include "bundle-uri.h" #include "bundle-uri.h"

1
tree.c
View File

@ -2,6 +2,7 @@
#include "cache-tree.h" #include "cache-tree.h"
#include "hex.h" #include "hex.h"
#include "tree.h" #include "tree.h"
#include "object-name.h"
#include "object-store.h" #include "object-store.h"
#include "blob.h" #include "blob.h"
#include "commit.h" #include "commit.h"

View File

@ -8,6 +8,7 @@
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "hex.h" #include "hex.h"
#include "object-name.h"
#include "revision.h" #include "revision.h"
#include "diffcore.h" #include "diffcore.h"
#include "quote.h" #include "quote.h"