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>
Elijah Newren committed
Apr 11, 2023 at 00:41 UTC
dabab1d6e6c49f3d4a6393a9984e3f6a4e8fb991
91 files changed
+210
-110
add-patch.c
+1
@@ -4,6 +4,7 @@
4
#include "alloc.h"
5
#include "environment.h"
6
#include "gettext.h"
7
+#include "object-name.h"
8
#include "strbuf.h"
9
#include "run-command.h"
10
#include "strvec.h"
apply.c
+1
@@ -22,6 +22,7 @@
22
#include "xdiff-interface.h"
23
#include "ll-merge.h"
24
#include "lockfile.h"
25
+#include "object-name.h"
26
#include "parse-options.h"
27
#include "quote.h"
28
#include "rerere.h"
archive.h
+1
@@ -2,6 +2,7 @@
2
#define ARCHIVE_H
3
4
#include "cache.h"
5
+#include "object-name.h"
6
#include "pathspec.h"
7
8
struct repository;
bisect.c
+1
@@ -17,6 +17,7 @@
17
#include "strvec.h"
18
#include "commit-slab.h"
19
#include "commit-reach.h"
20
+#include "object-name.h"
21
#include "object-store.h"
22
#include "dir.h"
23
branch.c
+1
@@ -6,6 +6,7 @@
6
#include "environment.h"
7
#include "gettext.h"
8
#include "hex.h"
9
+#include "object-name.h"
10
#include "refs.h"
11
#include "refspec.h"
12
#include "remote.h"
builtin/am.c
+1
@@ -27,6 +27,7 @@
27
#include "diffcore.h"
28
#include "unpack-trees.h"
29
#include "branch.h"
30
+#include "object-name.h"
31
#include "sequencer.h"
32
#include "revision.h"
33
#include "merge-recursive.h"
builtin/bisect.c
+1
@@ -3,6 +3,7 @@
3
#include "environment.h"
4
#include "gettext.h"
5
#include "hex.h"
6
+#include "object-name.h"
7
#include "parse-options.h"
8
#include "bisect.h"
9
#include "refs.h"
builtin/blame.c
+1
@@ -28,6 +28,7 @@
28
#include "line-log.h"
29
#include "dir.h"
30
#include "progress.h"
31
+#include "object-name.h"
32
#include "object-store.h"
33
#include "blame.h"
34
#include "refs.h"
builtin/branch.c
+1
@@ -13,6 +13,7 @@
13
#include "commit.h"
14
#include "builtin.h"
15
#include "gettext.h"
16
+#include "object-name.h"
17
#include "remote.h"
18
#include "parse-options.h"
19
#include "branch.h"
builtin/cat-file.c
+1
@@ -20,6 +20,7 @@
20
#include "tree-walk.h"
21
#include "oid-array.h"
22
#include "packfile.h"
23
+#include "object-name.h"
24
#include "object-store.h"
25
#include "replace-object.h"
26
#include "promisor-remote.h"
builtin/check-attr.c
+1
@@ -5,6 +5,7 @@
5
#include "attr.h"
6
#include "environment.h"
7
#include "gettext.h"
8
+#include "object-name.h"
9
#include "quote.h"
10
#include "setup.h"
11
#include "parse-options.h"
builtin/checkout.c
+1
@@ -17,6 +17,7 @@
17
#include "lockfile.h"
18
#include "mem-pool.h"
19
#include "merge-recursive.h"
20
+#include "object-name.h"
21
#include "object-store.h"
22
#include "parse-options.h"
23
#include "refs.h"
builtin/commit-tree.c
+1
@@ -7,6 +7,7 @@
7
#include "config.h"
8
#include "gettext.h"
9
#include "hex.h"
10
+#include "object-name.h"
11
#include "object-store.h"
12
#include "repository.h"
13
#include "commit.h"
builtin/commit.c
+1
@@ -27,6 +27,7 @@
27
#include "log-tree.h"
28
#include "strbuf.h"
29
#include "utf8.h"
30
+#include "object-name.h"
31
#include "parse-options.h"
32
#include "string-list.h"
33
#include "rerere.h"
builtin/describe.c
+1
@@ -11,6 +11,7 @@
11
#include "refs.h"
12
#include "builtin.h"
13
#include "exec-cmd.h"
14
+#include "object-name.h"
15
#include "parse-options.h"
16
#include "revision.h"
17
#include "diff.h"
builtin/fast-import.c
+1
@@ -19,6 +19,7 @@
19
#include "dir.h"
20
#include "run-command.h"
21
#include "packfile.h"
22
+#include "object-name.h"
23
#include "object-store.h"
24
#include "mem-pool.h"
25
#include "commit-reach.h"
builtin/fetch.c
+1
@@ -10,6 +10,7 @@
10
#include "repository.h"
11
#include "refs.h"
12
#include "refspec.h"
13
+#include "object-name.h"
14
#include "object-store.h"
15
#include "oidset.h"
16
#include "oid-array.h"
builtin/fsck.c
+1
@@ -19,6 +19,7 @@
19
#include "streaming.h"
20
#include "decorate.h"
21
#include "packfile.h"
22
+#include "object-name.h"
23
#include "object-store.h"
24
#include "replace-object.h"
25
#include "resolve-undo.h"
builtin/grep.c
+1
@@ -26,6 +26,7 @@
26
#include "setup.h"
27
#include "submodule.h"
28
#include "submodule-config.h"
29
+#include "object-name.h"
30
#include "object-store.h"
31
#include "packfile.h"
32
#include "write-or-die.h"
builtin/log.c
+1
@@ -12,6 +12,7 @@
12
#include "gettext.h"
13
#include "hex.h"
14
#include "refs.h"
15
+#include "object-name.h"
16
#include "object-store.h"
17
#include "color.h"
18
#include "commit.h"
builtin/ls-files.c
+1
@@ -13,6 +13,7 @@
13
#include "dir.h"
14
#include "builtin.h"
15
#include "gettext.h"
16
+#include "object-name.h"
17
#include "strbuf.h"
18
#include "tree.h"
19
#include "cache-tree.h"
builtin/ls-tree.c
+1
@@ -7,6 +7,7 @@
7
#include "config.h"
8
#include "gettext.h"
9
#include "hex.h"
10
+#include "object-name.h"
11
#include "object-store.h"
12
#include "blob.h"
13
#include "tree.h"
builtin/merge-base.c
+1
@@ -7,6 +7,7 @@
7
#include "refs.h"
8
#include "diff.h"
9
#include "revision.h"
10
+#include "object-name.h"
11
#include "parse-options.h"
12
#include "repository.h"
13
#include "commit-reach.h"
builtin/merge-recursive.c
+1
@@ -5,6 +5,7 @@
5
#include "gettext.h"
6
#include "tag.h"
7
#include "merge-recursive.h"
8
+#include "object-name.h"
9
#include "xdiff-interface.h"
10
11
static const char builtin_merge_recursive_usage[] =
builtin/merge-tree.c
+1
@@ -8,6 +8,7 @@
8
#include "commit.h"
9
#include "commit-reach.h"
10
#include "merge-ort.h"
11
+#include "object-name.h"
12
#include "object-store.h"
13
#include "parse-options.h"
14
#include "repository.h"
builtin/merge.c
+1
@@ -15,6 +15,7 @@
15
#include "environment.h"
16
#include "gettext.h"
17
#include "hex.h"
18
+#include "object-name.h"
19
#include "parse-options.h"
20
#include "builtin.h"
21
#include "lockfile.h"
builtin/name-rev.c
+1
@@ -8,6 +8,7 @@
8
#include "commit.h"
9
#include "tag.h"
10
#include "refs.h"
11
+#include "object-name.h"
12
#include "parse-options.h"
13
#include "prio-queue.h"
14
#include "hash-lookup.h"
builtin/notes.c
+1
@@ -13,6 +13,7 @@
13
#include "gettext.h"
14
#include "hex.h"
15
#include "notes.h"
16
+#include "object-name.h"
17
#include "object-store.h"
18
#include "repository.h"
19
#include "blob.h"
builtin/prune.c
+1
@@ -11,6 +11,7 @@
11
#include "progress.h"
12
#include "prune-packed.h"
13
#include "replace-object.h"
14
+#include "object-name.h"
15
#include "object-store.h"
16
#include "shallow.h"
17
builtin/pull.c
+1
@@ -12,6 +12,7 @@
12
#include "builtin.h"
13
#include "gettext.h"
14
#include "hex.h"
15
+#include "object-name.h"
16
#include "parse-options.h"
17
#include "exec-cmd.h"
18
#include "run-command.h"
builtin/range-diff.c
+1
@@ -1,6 +1,7 @@
1
#include "cache.h"
2
#include "builtin.h"
3
#include "gettext.h"
4
+#include "object-name.h"
5
#include "parse-options.h"
6
#include "range-diff.h"
7
#include "config.h"
builtin/read-tree.c
+1
@@ -11,6 +11,7 @@
11
#include "hex.h"
12
#include "lockfile.h"
13
#include "object.h"
14
+#include "object-name.h"
15
#include "tree.h"
16
#include "tree-walk.h"
17
#include "cache-tree.h"
builtin/rebase.c
+1
@@ -21,6 +21,7 @@
21
#include "cache-tree.h"
22
#include "unpack-trees.h"
23
#include "lockfile.h"
24
+#include "object-name.h"
25
#include "parse-options.h"
26
#include "commit.h"
27
#include "diff.h"
builtin/receive-pack.c
+1
@@ -29,6 +29,7 @@
29
#include "tmp-objdir.h"
30
#include "oidset.h"
31
#include "packfile.h"
32
+#include "object-name.h"
33
#include "object-store.h"
34
#include "protocol.h"
35
#include "commit-reach.h"
builtin/replace.c
+1
@@ -17,6 +17,7 @@
17
#include "refs.h"
18
#include "parse-options.h"
19
#include "run-command.h"
20
+#include "object-name.h"
21
#include "object-store.h"
22
#include "replace-object.h"
23
#include "repository.h"
builtin/reset.c
+1
@@ -24,6 +24,7 @@
24
#include "diffcore.h"
25
#include "tree.h"
26
#include "branch.h"
27
+#include "object-name.h"
28
#include "parse-options.h"
29
#include "unpack-trees.h"
30
#include "cache-tree.h"
builtin/rev-list.c
+1
@@ -10,6 +10,7 @@
10
#include "list-objects-filter.h"
11
#include "list-objects-filter-options.h"
12
#include "object.h"
13
+#include "object-name.h"
14
#include "object-store.h"
15
#include "pack.h"
16
#include "pack-bitmap.h"
builtin/rev-parse.c
+1
@@ -15,6 +15,7 @@
15
#include "refs.h"
16
#include "quote.h"
17
#include "builtin.h"
18
+#include "object-name.h"
19
#include "parse-options.h"
20
#include "diff.h"
21
#include "revision.h"
builtin/rm.c
+1
@@ -13,6 +13,7 @@
13
#include "cache-tree.h"
14
#include "gettext.h"
15
#include "tree-walk.h"
16
+#include "object-name.h"
17
#include "parse-options.h"
18
#include "string-list.h"
19
#include "setup.h"
builtin/show-branch.c
+1
@@ -8,6 +8,7 @@
8
#include "builtin.h"
9
#include "color.h"
10
#include "strvec.h"
11
+#include "object-name.h"
12
#include "parse-options.h"
13
#include "dir.h"
14
#include "commit-slab.h"
builtin/show-ref.c
+1
@@ -4,6 +4,7 @@
4
#include "gettext.h"
5
#include "hex.h"
6
#include "refs.h"
7
+#include "object-name.h"
8
#include "object-store.h"
9
#include "object.h"
10
#include "tag.h"
builtin/sparse-checkout.c
+1
@@ -4,6 +4,7 @@
4
#include "dir.h"
5
#include "environment.h"
6
#include "gettext.h"
7
+#include "object-name.h"
8
#include "parse-options.h"
9
#include "pathspec.h"
10
#include "repository.h"
builtin/stash.c
+1
@@ -5,6 +5,7 @@
5
#include "environment.h"
6
#include "gettext.h"
7
#include "hex.h"
8
+#include "object-name.h"
9
#include "parse-options.h"
10
#include "refs.h"
11
#include "lockfile.h"
builtin/submodule--helper.c
+1
@@ -24,6 +24,7 @@
24
#include "revision.h"
25
#include "diffcore.h"
26
#include "diff.h"
27
+#include "object-name.h"
28
#include "object-store.h"
29
#include "advice.h"
30
#include "branch.h"
builtin/tag.c
+1
@@ -14,6 +14,7 @@
14
#include "gettext.h"
15
#include "hex.h"
16
#include "refs.h"
17
+#include "object-name.h"
18
#include "object-store.h"
19
#include "tag.h"
20
#include "run-command.h"
builtin/unpack-file.c
+1
@@ -1,6 +1,7 @@
1
#include "builtin.h"
2
#include "config.h"
3
#include "hex.h"
4
+#include "object-name.h"
5
#include "object-store.h"
6
#include "wrapper.h"
7
builtin/update-ref.c
+1
@@ -3,6 +3,7 @@
3
#include "gettext.h"
4
#include "refs.h"
5
#include "builtin.h"
6
+#include "object-name.h"
7
#include "parse-options.h"
8
#include "quote.h"
9
#include "strvec.h"
builtin/verify-commit.c
+1
@@ -9,6 +9,7 @@
9
#include "config.h"
10
#include "builtin.h"
11
#include "gettext.h"
12
+#include "object-name.h"
13
#include "object-store.h"
14
#include "repository.h"
15
#include "commit.h"
builtin/verify-tag.c
+1
@@ -11,6 +11,7 @@
11
#include "gettext.h"
12
#include "tag.h"
13
#include "run-command.h"
14
+#include "object-name.h"
15
#include "parse-options.h"
16
#include "gpg-interface.h"
17
#include "ref-filter.h"
builtin/worktree.c
+1
@@ -7,6 +7,7 @@
7
#include "environment.h"
8
#include "gettext.h"
9
#include "hex.h"
10
+#include "object-name.h"
11
#include "parse-options.h"
12
#include "strvec.h"
13
#include "branch.h"
cache.h
-110
@@ -687,24 +687,6 @@ extern int quote_path_fully;
687
#define DATA_CHANGED 0x0020
688
#define TYPE_CHANGED 0x0040
689
690
-/*
691
- * Return an abbreviated sha1 unique within this repository's object database.
692
- * The result will be at least `len` characters long, and will be NUL
693
- * terminated.
694
- *
695
- * The non-`_r` version returns a static buffer which remains valid until 4
696
- * more calls to repo_find_unique_abbrev are made.
697
- *
698
- * The `_r` variant writes to a buffer supplied by the caller, which must be at
699
- * least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
700
- * written (excluding the NUL terminator).
701
- *
702
- * Note that while this version avoids the static buffer, it is not fully
703
- * reentrant, as it calls into other non-reentrant git code.
704
- */
705
-const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
706
-int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
707
-
690
/*
691
* Create the directory containing the named path, using care to be
692
* 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);
788
/* Helper to check and "touch" a file */
789
int check_and_freshen_file(const char *fn, int freshen);
790
809
-/* Convert to/from hex/sha1 representation */
810
-#define MINIMUM_ABBREV minimum_abbrev
811
-#define DEFAULT_ABBREV default_abbrev
812
-
813
-/* used when the code does not know or care what the default abbrev is */
814
-#define FALLBACK_DEFAULT_ABBREV 7
815
-
816
-struct object_context {
817
- unsigned short mode;
818
- /*
819
- * symlink_path is only used by get_tree_entry_follow_symlinks,
820
- * and only for symlinks that point outside the repository.
821
- */
822
- struct strbuf symlink_path;
823
- /*
824
- * If GET_OID_RECORD_PATH is set, this will record path (if any)
825
- * found when resolving the name. The caller is responsible for
826
- * releasing the memory.
827
- */
828
- char *path;
829
-};
830
-
831
-int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
832
-__attribute__((format (printf, 2, 3)))
833
-int get_oidf(struct object_id *oid, const char *fmt, ...);
834
-int repo_get_oid_commit(struct repository *r, const char *str, struct object_id *oid);
835
-int repo_get_oid_committish(struct repository *r, const char *str, struct object_id *oid);
836
-int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid);
837
-int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid);
838
-int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid);
839
-int repo_get_oid_mb(struct repository *r, const char *str, struct object_id *oid);
840
-void maybe_die_on_misspelt_object_name(struct repository *repo,
841
- const char *name,
842
- const char *prefix);
843
-enum get_oid_result get_oid_with_context(struct repository *repo, const char *str,
844
- unsigned flags, struct object_id *oid,
845
- struct object_context *oc);
846
-
847
-typedef int each_abbrev_fn(const struct object_id *oid, void *);
848
-int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
849
-
850
-int set_disambiguate_hint_config(const char *var, const char *value);
851
-
852
-/*
853
- * This reads short-hand syntax that not only evaluates to a commit
854
- * object name, but also can act as if the end user spelled the name
855
- * of the branch from the command line.
856
- *
857
- * - "@{-N}" finds the name of the Nth previous branch we were on, and
858
- * places the name of the branch in the given buf and returns the
859
- * number of characters parsed if successful.
860
- *
861
- * - "<branch>@{upstream}" finds the name of the other ref that
862
- * <branch> is configured to merge with (missing <branch> defaults
863
- * to the current branch), and places the name of the branch in the
864
- * given buf and returns the number of characters parsed if
865
- * successful.
866
- *
867
- * If the input is not of the accepted format, it returns a negative
868
- * number to signal an error.
869
- *
870
- * If the input was ok but there are not N branch switches in the
871
- * reflog, it returns 0.
872
- */
873
-#define INTERPRET_BRANCH_LOCAL (1<<0)
874
-#define INTERPRET_BRANCH_REMOTE (1<<1)
875
-#define INTERPRET_BRANCH_HEAD (1<<2)
876
-struct interpret_branch_name_options {
877
- /*
878
- * If "allowed" is non-zero, it is a treated as a bitfield of allowable
879
- * expansions: local branches ("refs/heads/"), remote branches
880
- * ("refs/remotes/"), or "HEAD". If no "allowed" bits are set, any expansion is
881
- * allowed, even ones to refs outside of those namespaces.
882
- */
883
- unsigned allowed;
884
-
885
- /*
886
- * If ^{upstream} or ^{push} (or equivalent) is requested, and the
887
- * branch in question does not have such a reference, return -1 instead
888
- * of die()-ing.
889
- */
890
- unsigned nonfatal_dangling_mark : 1;
891
-};
892
-int repo_interpret_branch_name(struct repository *r,
893
- const char *str, int len,
894
- struct strbuf *buf,
895
- const struct interpret_branch_name_options *options);
896
-
791
int base_name_compare(const char *name1, size_t len1, int mode1,
792
const char *name2, size_t len2, int mode2);
793
int df_name_compare(const char *name1, size_t len1, int mode1,
@@ -907,10 +801,6 @@ void *read_object_with_reference(struct repository *r,
801
unsigned long *size,
802
struct object_id *oid_ret);
803
910
-struct object *repo_peel_to_type(struct repository *r,
911
- const char *name, int namelen,
912
- struct object *o, enum object_type);
913
-
804
const char *git_editor(void);
805
const char *git_sequence_editor(void);
806
const char *git_pager(int stdout_is_tty);
checkout.c
+1
@@ -1,4 +1,5 @@
1
#include "cache.h"
2
+#include "object-name.h"
3
#include "remote.h"
4
#include "refspec.h"
5
#include "checkout.h"
combine-diff.c
+1
@@ -7,6 +7,7 @@
7
#include "diffcore.h"
8
#include "environment.h"
9
#include "hex.h"
10
+#include "object-name.h"
11
#include "quote.h"
12
#include "xdiff-interface.h"
13
#include "xdiff/xmacros.h"
commit.c
+1
@@ -6,6 +6,7 @@
6
#include "gettext.h"
7
#include "hex.h"
8
#include "repository.h"
9
+#include "object-name.h"
10
#include "object-store.h"
11
#include "pkt-line.h"
12
#include "utf8.h"
config.c
+1
@@ -23,6 +23,7 @@
23
#include "quote.h"
24
#include "hashmap.h"
25
#include "string-list.h"
26
+#include "object-name.h"
27
#include "object-store.h"
28
#include "utf8.h"
29
#include "dir.h"
diff-lib.c
+1
@@ -8,6 +8,7 @@
8
#include "diffcore.h"
9
#include "gettext.h"
10
#include "hex.h"
11
+#include "object-name.h"
12
#include "revision.h"
13
#include "cache-tree.h"
14
#include "unpack-trees.h"
diff.c
+1
@@ -35,6 +35,7 @@
35
#include "help.h"
36
#include "promisor-remote.h"
37
#include "dir.h"
38
+#include "object-name.h"
39
#include "setup.h"
40
#include "strmap.h"
41
#include "wrapper.h"
fmt-merge-msg.c
+1
@@ -3,6 +3,7 @@
3
#include "config.h"
4
#include "environment.h"
5
#include "refs.h"
6
+#include "object-name.h"
7
#include "object-store.h"
8
#include "diff.h"
9
#include "diff-merges.h"
list-objects-filter.c
+1
@@ -15,6 +15,7 @@
15
#include "list-objects-filter-options.h"
16
#include "oidmap.h"
17
#include "oidset.h"
18
+#include "object-name.h"
19
#include "object-store.h"
20
21
/* Remember to update object flag allocation in object.h */
log-tree.c
+1
@@ -4,6 +4,7 @@
4
#include "diff.h"
5
#include "environment.h"
6
#include "hex.h"
7
+#include "object-name.h"
8
#include "object-store.h"
9
#include "repository.h"
10
#include "tmp-objdir.h"
mailmap.c
+1
@@ -2,6 +2,7 @@
2
#include "environment.h"
3
#include "string-list.h"
4
#include "mailmap.h"
5
+#include "object-name.h"
6
#include "object-store.h"
7
#include "setup.h"
8
merge-ort.c
+1
@@ -32,6 +32,7 @@
32
#include "entry.h"
33
#include "ll-merge.h"
34
#include "mem-pool.h"
35
+#include "object-name.h"
36
#include "object-store.h"
37
#include "oid-array.h"
38
#include "promisor-remote.h"
merge-recursive.c
+1
@@ -22,6 +22,7 @@
22
#include "hex.h"
23
#include "ll-merge.h"
24
#include "lockfile.h"
25
+#include "object-name.h"
26
#include "object-store.h"
27
#include "repository.h"
28
#include "revision.h"
notes-merge.c
+1
@@ -3,6 +3,7 @@
3
#include "commit.h"
4
#include "gettext.h"
5
#include "refs.h"
6
+#include "object-name.h"
7
#include "object-store.h"
8
#include "repository.h"
9
#include "diff.h"
notes.c
+1
@@ -3,6 +3,7 @@
3
#include "environment.h"
4
#include "hex.h"
5
#include "notes.h"
6
+#include "object-name.h"
7
#include "object-store.h"
8
#include "blob.h"
9
#include "tree.h"
object-name.c
+1
@@ -1,4 +1,5 @@
1
#include "cache.h"
2
+#include "object-name.h"
3
#include "advice.h"
4
#include "config.h"
5
#include "environment.h"
object-name.h
new
+121
@@ -0,0 +1,121 @@
1
+#ifndef OBJECT_NAME_H
2
+#define OBJECT_NAME_H
3
+
4
+#include "object.h"
5
+#include "strbuf.h"
6
+
7
+struct object_id;
8
+struct repository;
9
+
10
+struct object_context {
11
+ unsigned short mode;
12
+ /*
13
+ * symlink_path is only used by get_tree_entry_follow_symlinks,
14
+ * and only for symlinks that point outside the repository.
15
+ */
16
+ struct strbuf symlink_path;
17
+ /*
18
+ * If GET_OID_RECORD_PATH is set, this will record path (if any)
19
+ * found when resolving the name. The caller is responsible for
20
+ * releasing the memory.
21
+ */
22
+ char *path;
23
+};
24
+
25
+/*
26
+ * Return an abbreviated sha1 unique within this repository's object database.
27
+ * The result will be at least `len` characters long, and will be NUL
28
+ * terminated.
29
+ *
30
+ * The non-`_r` version returns a static buffer which remains valid until 4
31
+ * more calls to repo_find_unique_abbrev are made.
32
+ *
33
+ * The `_r` variant writes to a buffer supplied by the caller, which must be at
34
+ * least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
35
+ * written (excluding the NUL terminator).
36
+ *
37
+ * Note that while this version avoids the static buffer, it is not fully
38
+ * reentrant, as it calls into other non-reentrant git code.
39
+ */
40
+const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
41
+int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
42
+
43
+int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
44
+__attribute__((format (printf, 2, 3)))
45
+int get_oidf(struct object_id *oid, const char *fmt, ...);
46
+int repo_get_oid_commit(struct repository *r, const char *str, struct object_id *oid);
47
+int repo_get_oid_committish(struct repository *r, const char *str, struct object_id *oid);
48
+int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid);
49
+int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid);
50
+int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid);
51
+int repo_get_oid_mb(struct repository *r, const char *str, struct object_id *oid);
52
+void maybe_die_on_misspelt_object_name(struct repository *repo,
53
+ const char *name,
54
+ const char *prefix);
55
+enum get_oid_result get_oid_with_context(struct repository *repo, const char *str,
56
+ unsigned flags, struct object_id *oid,
57
+ struct object_context *oc);
58
+
59
+
60
+typedef int each_abbrev_fn(const struct object_id *oid, void *);
61
+int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
62
+
63
+int set_disambiguate_hint_config(const char *var, const char *value);
64
+
65
+/*
66
+ * This reads short-hand syntax that not only evaluates to a commit
67
+ * object name, but also can act as if the end user spelled the name
68
+ * of the branch from the command line.
69
+ *
70
+ * - "@{-N}" finds the name of the Nth previous branch we were on, and
71
+ * places the name of the branch in the given buf and returns the
72
+ * number of characters parsed if successful.
73
+ *
74
+ * - "<branch>@{upstream}" finds the name of the other ref that
75
+ * <branch> is configured to merge with (missing <branch> defaults
76
+ * to the current branch), and places the name of the branch in the
77
+ * given buf and returns the number of characters parsed if
78
+ * successful.
79
+ *
80
+ * If the input is not of the accepted format, it returns a negative
81
+ * number to signal an error.
82
+ *
83
+ * If the input was ok but there are not N branch switches in the
84
+ * reflog, it returns 0.
85
+ */
86
+#define INTERPRET_BRANCH_LOCAL (1<<0)
87
+#define INTERPRET_BRANCH_REMOTE (1<<1)
88
+#define INTERPRET_BRANCH_HEAD (1<<2)
89
+struct interpret_branch_name_options {
90
+ /*
91
+ * If "allowed" is non-zero, it is a treated as a bitfield of allowable
92
+ * expansions: local branches ("refs/heads/"), remote branches
93
+ * ("refs/remotes/"), or "HEAD". If no "allowed" bits are set, any expansion is
94
+ * allowed, even ones to refs outside of those namespaces.
95
+ */
96
+ unsigned allowed;
97
+
98
+ /*
99
+ * If ^{upstream} or ^{push} (or equivalent) is requested, and the
100
+ * branch in question does not have such a reference, return -1 instead
101
+ * of die()-ing.
102
+ */
103
+ unsigned nonfatal_dangling_mark : 1;
104
+};
105
+int repo_interpret_branch_name(struct repository *r,
106
+ const char *str, int len,
107
+ struct strbuf *buf,
108
+ const struct interpret_branch_name_options *options);
109
+
110
+struct object *repo_peel_to_type(struct repository *r,
111
+ const char *name, int namelen,
112
+ struct object *o, enum object_type);
113
+
114
+/* Convert to/from hex/sha1 representation */
115
+#define MINIMUM_ABBREV minimum_abbrev
116
+#define DEFAULT_ABBREV default_abbrev
117
+
118
+/* used when the code does not know or care what the default abbrev is */
119
+#define FALLBACK_DEFAULT_ABBREV 7
120
+
121
+#endif /* OBJECT_NAME_H */
parse-options-cb.c
+1
@@ -6,6 +6,7 @@
6
#include "color.h"
7
#include "environment.h"
8
#include "gettext.h"
9
+#include "object-name.h"
10
#include "string-list.h"
11
#include "strvec.h"
12
#include "oid-array.h"
range-diff.c
+1
@@ -2,6 +2,7 @@
2
#include "environment.h"
3
#include "gettext.h"
4
#include "range-diff.h"
5
+#include "object-name.h"
6
#include "string-list.h"
7
#include "run-command.h"
8
#include "strvec.h"
read-cache.c
+1
@@ -22,6 +22,7 @@
22
#include "environment.h"
23
#include "gettext.h"
24
#include "mem-pool.h"
25
+#include "object-name.h"
26
#include "resolve-undo.h"
27
#include "run-command.h"
28
#include "strbuf.h"
rebase-interactive.c
+1
@@ -8,6 +8,7 @@
8
#include "commit-slab.h"
9
#include "config.h"
10
#include "dir.h"
11
+#include "object-name.h"
12
#include "wrapper.h"
13
14
static const char edit_todo_list_advice[] =
ref-filter.c
+1
@@ -6,6 +6,7 @@
6
#include "parse-options.h"
7
#include "refs.h"
8
#include "wildmatch.h"
9
+#include "object-name.h"
10
#include "object-store.h"
11
#include "oid-array.h"
12
#include "repository.h"
refs.c
+1
@@ -16,6 +16,7 @@
16
#include "refs/refs-internal.h"
17
#include "run-command.h"
18
#include "hook.h"
19
+#include "object-name.h"
20
#include "object-store.h"
21
#include "object.h"
22
#include "tag.h"
remote.c
+1
@@ -9,6 +9,7 @@
9
#include "urlmatch.h"
10
#include "refs.h"
11
#include "refspec.h"
12
+#include "object-name.h"
13
#include "object-store.h"
14
#include "commit.h"
15
#include "diff.h"
reset.c
+1
@@ -3,6 +3,7 @@
3
#include "gettext.h"
4
#include "hex.h"
5
#include "lockfile.h"
6
+#include "object-name.h"
7
#include "refs.h"
8
#include "reset.h"
9
#include "run-command.h"
revision.c
+1
@@ -4,6 +4,7 @@
4
#include "environment.h"
5
#include "gettext.h"
6
#include "hex.h"
7
+#include "object-name.h"
8
#include "object-store.h"
9
#include "tag.h"
10
#include "blob.h"
sequencer.c
+1
@@ -8,6 +8,7 @@
8
#include "hex.h"
9
#include "lockfile.h"
10
#include "dir.h"
11
+#include "object-name.h"
12
#include "object-store.h"
13
#include "object.h"
14
#include "commit.h"
setup.c
+1
@@ -2,6 +2,7 @@
2
#include "abspath.h"
3
#include "environment.h"
4
#include "gettext.h"
5
+#include "object-name.h"
6
#include "repository.h"
7
#include "config.h"
8
#include "dir.h"
strbuf.c
+1
@@ -4,6 +4,7 @@
4
#include "environment.h"
5
#include "gettext.h"
6
#include "hex.h"
7
+#include "object-name.h"
8
#include "refs.h"
9
#include "string-list.h"
10
#include "utf8.h"
submodule-config.c
+1
@@ -9,6 +9,7 @@
9
#include "submodule-config.h"
10
#include "submodule.h"
11
#include "strbuf.h"
12
+#include "object-name.h"
13
#include "object-store.h"
14
#include "parse-options.h"
15
#include "tree-walk.h"
submodule.c
+1
@@ -24,6 +24,7 @@
24
#include "remote.h"
25
#include "worktree.h"
26
#include "parse-options.h"
27
+#include "object-name.h"
28
#include "object-store.h"
29
#include "commit-reach.h"
30
#include "setup.h"
t/helper/test-fast-rebase.c
+1
@@ -20,6 +20,7 @@
20
#include "hex.h"
21
#include "lockfile.h"
22
#include "merge-ort.h"
23
+#include "object-name.h"
24
#include "refs.h"
25
#include "revision.h"
26
#include "sequencer.h"
t/helper/test-match-trees.c
+1
@@ -1,6 +1,7 @@
1
#include "test-tool.h"
2
#include "cache.h"
3
#include "hex.h"
4
+#include "object-name.h"
5
#include "setup.h"
6
#include "tree.h"
7
t/helper/test-oidmap.c
+1
@@ -1,6 +1,7 @@
1
#include "test-tool.h"
2
#include "cache.h"
3
#include "hex.h"
4
+#include "object-name.h"
5
#include "oidmap.h"
6
#include "setup.h"
7
#include "strbuf.h"
t/helper/test-reach.c
+1
@@ -6,6 +6,7 @@
6
#include "config.h"
7
#include "gettext.h"
8
#include "hex.h"
9
+#include "object-name.h"
10
#include "parse-options.h"
11
#include "ref-filter.h"
12
#include "setup.h"
t/helper/test-submodule-config.c
+1
@@ -1,6 +1,7 @@
1
#include "test-tool.h"
2
#include "cache.h"
3
#include "config.h"
4
+#include "object-name.h"
5
#include "setup.h"
6
#include "submodule-config.h"
7
#include "submodule.h"
tag.c
+1
@@ -1,6 +1,7 @@
1
#include "cache.h"
2
#include "environment.h"
3
#include "tag.h"
4
+#include "object-name.h"
5
#include "object-store.h"
6
#include "commit.h"
7
#include "tree.h"
transport-helper.c
+1
@@ -7,6 +7,7 @@
7
#include "environment.h"
8
#include "gettext.h"
9
#include "hex.h"
10
+#include "object-name.h"
11
#include "revision.h"
12
#include "remote.h"
13
#include "string-list.h"
transport.c
+1
@@ -26,6 +26,7 @@
26
#include "trace2.h"
27
#include "transport-internal.h"
28
#include "protocol.h"
29
+#include "object-name.h"
30
#include "object-store.h"
31
#include "color.h"
32
#include "bundle-uri.h"
tree.c
+1
@@ -2,6 +2,7 @@
2
#include "cache-tree.h"
3
#include "hex.h"
4
#include "tree.h"
5
+#include "object-name.h"
6
#include "object-store.h"
7
#include "blob.h"
8
#include "commit.h"
wt-status.c
+1
@@ -8,6 +8,7 @@
8
#include "environment.h"
9
#include "gettext.h"
10
#include "hex.h"
11
+#include "object-name.h"
12
#include "revision.h"
13
#include "diffcore.h"
14
#include "quote.h"