]> git.ipfire.org Git - thirdparty/git.git/commitdiff
object-name.h: move declarations for object-name.c functions from cache.h
authorElijah Newren <newren@gmail.com>
Tue, 11 Apr 2023 07:41:49 +0000 (00:41 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Apr 2023 15:52:09 +0000 (08:52 -0700)
Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
91 files changed:
add-patch.c
apply.c
archive.h
bisect.c
branch.c
builtin/am.c
builtin/bisect.c
builtin/blame.c
builtin/branch.c
builtin/cat-file.c
builtin/check-attr.c
builtin/checkout.c
builtin/commit-tree.c
builtin/commit.c
builtin/describe.c
builtin/fast-import.c
builtin/fetch.c
builtin/fsck.c
builtin/grep.c
builtin/log.c
builtin/ls-files.c
builtin/ls-tree.c
builtin/merge-base.c
builtin/merge-recursive.c
builtin/merge-tree.c
builtin/merge.c
builtin/name-rev.c
builtin/notes.c
builtin/prune.c
builtin/pull.c
builtin/range-diff.c
builtin/read-tree.c
builtin/rebase.c
builtin/receive-pack.c
builtin/replace.c
builtin/reset.c
builtin/rev-list.c
builtin/rev-parse.c
builtin/rm.c
builtin/show-branch.c
builtin/show-ref.c
builtin/sparse-checkout.c
builtin/stash.c
builtin/submodule--helper.c
builtin/tag.c
builtin/unpack-file.c
builtin/update-ref.c
builtin/verify-commit.c
builtin/verify-tag.c
builtin/worktree.c
cache.h
checkout.c
combine-diff.c
commit.c
config.c
diff-lib.c
diff.c
fmt-merge-msg.c
list-objects-filter.c
log-tree.c
mailmap.c
merge-ort.c
merge-recursive.c
notes-merge.c
notes.c
object-name.c
object-name.h [new file with mode: 0644]
parse-options-cb.c
range-diff.c
read-cache.c
rebase-interactive.c
ref-filter.c
refs.c
remote.c
reset.c
revision.c
sequencer.c
setup.c
strbuf.c
submodule-config.c
submodule.c
t/helper/test-fast-rebase.c
t/helper/test-match-trees.c
t/helper/test-oidmap.c
t/helper/test-reach.c
t/helper/test-submodule-config.c
tag.c
transport-helper.c
transport.c
tree.c
wt-status.c

index b381f14a7de525d296af3d10871281dd80e5761d..b01ba8fa81d6647bf1625f5cc81a78ac9846b2a0 100644 (file)
@@ -4,6 +4,7 @@
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "strbuf.h"
 #include "run-command.h"
 #include "strvec.h"
diff --git a/apply.c b/apply.c
index 9b7288bc9270754447b1750142c58946ba9b04c6..7e40f53ec4c2b568df44ba87b584ccaed99e9b15 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -22,6 +22,7 @@
 #include "xdiff-interface.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "quote.h"
 #include "rerere.h"
index 7178e2a9a2d06c5c3eaaa8884464e6f4cc26fbde..f96839ef383c468e6f2182a461f4ad01c2b5a6e5 100644 (file)
--- a/archive.h
+++ b/archive.h
@@ -2,6 +2,7 @@
 #define ARCHIVE_H
 
 #include "cache.h"
+#include "object-name.h"
 #include "pathspec.h"
 
 struct repository;
index 0a5f2ed35467e47f80a7c1968b5c7de3035ed64a..e708e8b6aa140570c6899d96e856f5f3c4665bfc 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -17,6 +17,7 @@
 #include "strvec.h"
 #include "commit-slab.h"
 #include "commit-reach.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "dir.h"
 
index 3a087b8b4c1870e45293db26dba413a945d6f019..f29743b161972dea2df79b55aaa7d7289c09ee95 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -6,6 +6,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "refs.h"
 #include "refspec.h"
 #include "remote.h"
index 8d876f315463e7931eb5252b81b4851b66703b87..0d7ee28bddc39a1fbb83e6c728e6c741f42a25a6 100644 (file)
@@ -27,6 +27,7 @@
 #include "diffcore.h"
 #include "unpack-trees.h"
 #include "branch.h"
+#include "object-name.h"
 #include "sequencer.h"
 #include "revision.h"
 #include "merge-recursive.h"
index 7dc175c65707c63d6befc37246444ab601e66268..4b2143d4557a8de9007b4885866c1d4ca9668cc8 100644 (file)
@@ -3,6 +3,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "bisect.h"
 #include "refs.h"
index a8d2114adc90f84de3610019d3599192f0be4f4d..a628388c2ce94915780c7ab44893e6b0323d5994 100644 (file)
@@ -28,6 +28,7 @@
 #include "line-log.h"
 #include "dir.h"
 #include "progress.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blame.h"
 #include "refs.h"
index 5706eb009744ee1a561defc138cd0c40f4af8193..7c1c872708f46cead6885923def31837fff3f9ed 100644 (file)
@@ -13,6 +13,7 @@
 #include "commit.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "remote.h"
 #include "parse-options.h"
 #include "branch.h"
index 1e4b4798f40ec749d893d4cfefdb7ce05815b006..60b7a55dfc190868b3e9e1a06458c3db92208fe2 100644 (file)
@@ -20,6 +20,7 @@
 #include "tree-walk.h"
 #include "oid-array.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
index 1dbe9d6ca887811134b77df04c8bc6ff453d3625..037bf1aaa2ab3b8202902a3dec30ff1b2b519321 100644 (file)
@@ -5,6 +5,7 @@
 #include "attr.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "quote.h"
 #include "setup.h"
 #include "parse-options.h"
index 65988fd8a3b534338ed495e02493d1a14feeb2bf..6f5d82ed3d3b8944676739b99325c7ad28e9b425 100644 (file)
@@ -17,6 +17,7 @@
 #include "lockfile.h"
 #include "mem-pool.h"
 #include "merge-recursive.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
 #include "refs.h"
index 15be167f87a47915530996248cb95fcedaf30b95..d1d251c3ded2798ecb6667034bb7e21477be847d 100644 (file)
@@ -7,6 +7,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "commit.h"
index b09017e04f98e8acb0c5b306fb838d5b2fa50a97..682f47c8d5a6eec65d0ae3a93b530da1132d9189 100644 (file)
@@ -27,6 +27,7 @@
 #include "log-tree.h"
 #include "strbuf.h"
 #include "utf8.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "string-list.h"
 #include "rerere.h"
index 0125d4ddbac0037178e51d500ceee80b9fac71bf..d360b1d12af935e6cfab9aed5a1049bb70037fba 100644 (file)
@@ -11,6 +11,7 @@
 #include "refs.h"
 #include "builtin.h"
 #include "exec-cmd.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "revision.h"
 #include "diff.h"
index 68b1a539870c3a27cd70fd662a9bf82b1fdef698..31b8732128d0afcb193518732952e049922ca8ae 100644 (file)
@@ -19,6 +19,7 @@
 #include "dir.h"
 #include "run-command.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "mem-pool.h"
 #include "commit-reach.h"
index e09366292139d0b2a3ebf9e400b8008584fa9ca9..8a8ab6799e88a5febafed69b1216731e56a7248e 100644 (file)
@@ -10,6 +10,7 @@
 #include "repository.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "oidset.h"
 #include "oid-array.h"
index 095b39d39803492fd8142269d0b26cefb580b37e..04bc71d148c24b8be488e5c3b49cbdbe22326c2d 100644 (file)
@@ -19,6 +19,7 @@
 #include "streaming.h"
 #include "decorate.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "resolve-undo.h"
index a1b68d90bdb630327f08273b4f3658db86e2eb6a..f66e14389e145eb0b292d5a7ab45bf8137e8eb1a 100644 (file)
@@ -26,6 +26,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "packfile.h"
 #include "write-or-die.h"
index 094897df236b2e261479cf2cf18616a0609927cc..5cdc2276cc4dcde807c1b3ebfb2502d015ba9796 100644 (file)
@@ -12,6 +12,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "color.h"
 #include "commit.h"
index 7f228353febfedfce6900a9b1e6536b0989d93fb..ce083cb8efddd0db49f546b5ac0ab60a3fb4ec4a 100644 (file)
@@ -13,6 +13,7 @@
 #include "dir.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "strbuf.h"
 #include "tree.h"
 #include "cache-tree.h"
index f32e6be21983cff504ac46cc727bc076cae4026c..077977a46100327e9d611e8badb9d0c9190de33f 100644 (file)
@@ -7,6 +7,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blob.h"
 #include "tree.h"
index 3f22273b40076df9432f5b435b92461badda064d..854019a32dcc63c9e2504f7aa9e96e7cd7a86762 100644 (file)
@@ -7,6 +7,7 @@
 #include "refs.h"
 #include "diff.h"
 #include "revision.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "repository.h"
 #include "commit-reach.h"
index 25f42f2be7ed73233f0a0cc6b3c38b7f82c0f9d8..fa1035405c3840a8be0a81836c76850d29108ebe 100644 (file)
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "tag.h"
 #include "merge-recursive.h"
+#include "object-name.h"
 #include "xdiff-interface.h"
 
 static const char builtin_merge_recursive_usage[] =
index 803e380856edf087ca06bb42bef1813d2c6b11ba..6b9f006ec190d734ce8ee5a2aee1652aebf15ae8 100644 (file)
@@ -8,6 +8,7 @@
 #include "commit.h"
 #include "commit-reach.h"
 #include "merge-ort.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
 #include "repository.h"
index 225b70640660c59395a6731c4a7e646439f7c112..693f185d4d38f1f0f903ae0ba47c15a073732193 100644 (file)
@@ -15,6 +15,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "builtin.h"
 #include "lockfile.h"
index 831d360a78a6a706cd1e6b4cc5b9d3eced21bea6..41fd56b9ba969f0b6259e0fb110c6948ce396a8f 100644 (file)
@@ -8,6 +8,7 @@
 #include "commit.h"
 #include "tag.h"
 #include "refs.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "prio-queue.h"
 #include "hash-lookup.h"
index 4ff44f1e3d09bf277546a63281b6e2c300c29173..896140b9055ce25a4eba970557d127544c4a260f 100644 (file)
@@ -13,6 +13,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "notes.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "blob.h"
index 5c0952f5c647c255c2b29e41c4f349a4ecbfc9ff..09891832fb3f7a8a43016e0837053c7c2ef72f37 100644 (file)
@@ -11,6 +11,7 @@
 #include "progress.h"
 #include "prune-packed.h"
 #include "replace-object.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "shallow.h"
 
index 636ce12c94d5e00126d9c24ce01c5fad70327b1b..967368ebc65e6eb36562b4d4c690694cea71eeb0 100644 (file)
@@ -12,6 +12,7 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "exec-cmd.h"
 #include "run-command.h"
index b72af527f08bc1275d4e1ccf4c56870c3c0dc822..04339a92ea5d1a62df2aa63b73619c2a6c2167ae 100644 (file)
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "range-diff.h"
 #include "config.h"
index 600d4f748fcff432f05bbeb318d7007f5b551c7f..d61cbad96de6a40136ccdbedd8aa2be5fadb5fca 100644 (file)
@@ -11,6 +11,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "object.h"
+#include "object-name.h"
 #include "tree.h"
 #include "tree-walk.h"
 #include "cache-tree.h"
index fb859f93a303e4cc9ad92e0ff9d5a6811764c885..ff5dd77608d03f2840022049fdcaa3c7d5efd203 100644 (file)
@@ -21,6 +21,7 @@
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "commit.h"
 #include "diff.h"
index aa5b6fe861f496195f34e77ad9871756f2598845..7d921170f1ca5919cb720d8106a77dc3b0b01da9 100644 (file)
@@ -29,6 +29,7 @@
 #include "tmp-objdir.h"
 #include "oidset.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "protocol.h"
 #include "commit-reach.h"
index d2adc8ab613401db7dcd8bf05aff5830ded984c7..134f738a4503e96fb8b0f35e65500a4ce90e93c9 100644 (file)
@@ -17,6 +17,7 @@
 #include "refs.h"
 #include "parse-options.h"
 #include "run-command.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "repository.h"
index d8c52cc6edf1b2d3c8a79a27983198e200369d21..f99f32d5802fc537441982e45ec6539cc0241e94 100644 (file)
@@ -24,6 +24,7 @@
 #include "diffcore.h"
 #include "tree.h"
 #include "branch.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "unpack-trees.h"
 #include "cache-tree.h"
index a3dbbb6338ebe5ac297b807c87f0d06effd48a86..c17f0282ae86e0d602ad0cf3607f15eacdfd5c68 100644 (file)
@@ -10,6 +10,7 @@
 #include "list-objects-filter.h"
 #include "list-objects-filter-options.h"
 #include "object.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "pack.h"
 #include "pack-bitmap.h"
index 1af2089f9bd04810cb057b94371f67e45523ad0b..852e49e3403119707118973f6285e26c0893c355 100644 (file)
@@ -15,6 +15,7 @@
 #include "refs.h"
 #include "quote.h"
 #include "builtin.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "diff.h"
 #include "revision.h"
index 6be92817429a880130b8d3604c43d75115b9b5e3..d36072252e72ab5d4aa90243b81df15e17bda08f 100644 (file)
@@ -13,6 +13,7 @@
 #include "cache-tree.h"
 #include "gettext.h"
 #include "tree-walk.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "string-list.h"
 #include "setup.h"
index 463a8d11c317cd5d47facf1cbe9386c474decf8e..20030b75e39ffd8cae40b6a743f7e23f364364d8 100644 (file)
@@ -8,6 +8,7 @@
 #include "builtin.h"
 #include "color.h"
 #include "strvec.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "dir.h"
 #include "commit-slab.h"
index 138d30a005e2de9067cc2f280ea5bf205a7b11be..a2243b42195b1b89c49a26f0c80b2bc09de142da 100644 (file)
@@ -4,6 +4,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "object.h"
 #include "tag.h"
index 090bf33510aed15582cab091d88aaf7c2e06b8e3..34b9d92fb131eefe4295ac0aa79ae2883c3af036 100644 (file)
@@ -4,6 +4,7 @@
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "pathspec.h"
 #include "repository.h"
index 14194b13bd176e6b5ed687ce81671594d1866d65..6442b5e20a6df290c1d484281c0598f9c706f78c 100644 (file)
@@ -5,6 +5,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "refs.h"
 #include "lockfile.h"
index 833770371554ddf2999d2761497d0a00ee350ed0..1f087d7bed2dfb9a82d80774337cd977a9af0e1f 100644 (file)
@@ -24,6 +24,7 @@
 #include "revision.h"
 #include "diffcore.h"
 #include "diff.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "advice.h"
 #include "branch.h"
index 3e801f54a07adeaa5e9094f5c3e038d182f2de61..88a259023091091a86d79cfce81f5abbb642adf1 100644 (file)
@@ -14,6 +14,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "tag.h"
 #include "run-command.h"
index 314761b0b4da783e809f8f06f849575a9a37d331..21082ceb6010a6b0c1c9d07f503812bdc4fc19cc 100644 (file)
@@ -1,6 +1,7 @@
 #include "builtin.h"
 #include "config.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "wrapper.h"
 
index 3ffd75b3e78ca96a4d8266b89588d29e9cffaa99..6ca85420c3b82f0eb92321679540d0c3a2fa1802 100644 (file)
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "refs.h"
 #include "builtin.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "quote.h"
 #include "strvec.h"
index 4d10aa98b109c04aa554647fea42144dd1596505..5d99b82a64f65efcc673ee8da144748f5e62fc82 100644 (file)
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "commit.h"
index 28d0da684542deaa68f71326300c4bae0f83ab9f..c6019a0ad8cf79f92df9e1e443df373516f67db9 100644 (file)
@@ -11,6 +11,7 @@
 #include "gettext.h"
 #include "tag.h"
 #include "run-command.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "gpg-interface.h"
 #include "ref-filter.h"
index 944dd40f94dfd1d18748bbe1ad94b2e3369118c5..69132bba319e41d49e458a7dc5673f5bb0103df9 100644 (file)
@@ -7,6 +7,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "strvec.h"
 #include "branch.h"
diff --git a/cache.h b/cache.h
index 66705dd469e744e5cb0fd1ced78dd609a4805517..21db5da39a54a2bf696be8beea3c374aa435703f 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -687,24 +687,6 @@ extern int quote_path_fully;
 #define DATA_CHANGED    0x0020
 #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
  * 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 */
 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,
                      const char *name2, size_t len2, int mode2);
 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,
                                 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_sequence_editor(void);
 const char *git_pager(int stdout_is_tty);
index 1247b8822481a6face3fc47a45ec2ce1bf298c06..9235073fc0d6f02f54acf92631e2773229946c4b 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "object-name.h"
 #include "remote.h"
 #include "refspec.h"
 #include "checkout.h"
index 6586e4508d6a292c23d7f57f072cd20e12841cca..cd5f39f22f40a5278ca4558ebd056b88fc0ea93b 100644 (file)
@@ -7,6 +7,7 @@
 #include "diffcore.h"
 #include "environment.h"
 #include "hex.h"
+#include "object-name.h"
 #include "quote.h"
 #include "xdiff-interface.h"
 #include "xdiff/xmacros.h"
index 6d844da9a6b4f7c86f77e5945803c5a6bd211155..bad31c423a46f0a28c2f576a2d178ece919d4eb1 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -6,6 +6,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "repository.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "pkt-line.h"
 #include "utf8.h"
index 9e74b5aec7fc2a2a6cf4db01f0c91c94e246f5c2..aac439530e94c4761f125dae091ce83945ca5ab7 100644 (file)
--- a/config.c
+++ b/config.c
@@ -23,6 +23,7 @@
 #include "quote.h"
 #include "hashmap.h"
 #include "string-list.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "utf8.h"
 #include "dir.h"
index 8b5cca96aceb2f08a429b6d4516f9e8625608adf..d292405a262495974eb7de0e8b6e590df024d1c8 100644 (file)
@@ -8,6 +8,7 @@
 #include "diffcore.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "revision.h"
 #include "cache-tree.h"
 #include "unpack-trees.h"
diff --git a/diff.c b/diff.c
index 89cd0b17da535035511923b9adc15a7c2e4f60be..9e6ad94bc66a19e6bc7f79b7b75478b289338ecf 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -35,6 +35,7 @@
 #include "help.h"
 #include "promisor-remote.h"
 #include "dir.h"
+#include "object-name.h"
 #include "setup.h"
 #include "strmap.h"
 #include "wrapper.h"
index 1886c92ddb9cd0cda98fcc945d6fa3eecf6d4931..21019c932b3a5f73e2c190a83f76e443b972277b 100644 (file)
@@ -3,6 +3,7 @@
 #include "config.h"
 #include "environment.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "diff.h"
 #include "diff-merges.h"
index 298ca08711e31a95cd594381c2d45e50079a373f..8b2a45e507d26aa8a7e49503f6cf4947ecd7f580 100644 (file)
@@ -15,6 +15,7 @@
 #include "list-objects-filter-options.h"
 #include "oidmap.h"
 #include "oidset.h"
+#include "object-name.h"
 #include "object-store.h"
 
 /* Remember to update object flag allocation in object.h */
index 627c711f70773792f5179ec700a01ca14ab95812..f0e885635e062cbea4abd3e456d259d39e3f2d72 100644 (file)
@@ -4,6 +4,7 @@
 #include "diff.h"
 #include "environment.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "tmp-objdir.h"
index 14f2c0f62ae7caacfc62d70f5715719057aa5f56..d62d7bf0e7f736f1d87c85d395b8a78078d20e3e 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
@@ -2,6 +2,7 @@
 #include "environment.h"
 #include "string-list.h"
 #include "mailmap.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "setup.h"
 
index 1008684fbbc6c535c7bbaa081da04c5c3af12723..2c6a9ed9a4163033f4964f851d78fe4e72103071 100644 (file)
@@ -32,6 +32,7 @@
 #include "entry.h"
 #include "ll-merge.h"
 #include "mem-pool.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "promisor-remote.h"
index ed5534eb57d4ffa874369bad189237d90a2f7cf5..748a6799a303f36184c2ce3cf2e594b10437a951 100644 (file)
@@ -22,6 +22,7 @@
 #include "hex.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "revision.h"
index 0258f87d21fbe5fa6926c5b9c6be281b9f635893..b496b77d9db128c40c4b30e40360cf9656696409 100644 (file)
@@ -3,6 +3,7 @@
 #include "commit.h"
 #include "gettext.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "diff.h"
diff --git a/notes.c b/notes.c
index 45fb7f22d1df011396ec86e56f1f1bd3bd1645b9..c07bcbe34865d88a7acdb677319cb58309fd62f6 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -3,6 +3,7 @@
 #include "environment.h"
 #include "hex.h"
 #include "notes.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blob.h"
 #include "tree.h"
index ff647d6c7b5a666f9bcdcbf9f4c21fbf92beb6ac..3cd5b327293b2b30cb47ffd0b34418fea6800133 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "object-name.h"
 #include "advice.h"
 #include "config.h"
 #include "environment.h"
diff --git a/object-name.h b/object-name.h
new file mode 100644 (file)
index 0000000..1d63698
--- /dev/null
@@ -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 */
index 666c2129797715523ccaef2e1d434c27454f406d..b4df4bcebedb30b4d52f13a5d8146f5a39af63cc 100644 (file)
@@ -6,6 +6,7 @@
 #include "color.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "string-list.h"
 #include "strvec.h"
 #include "oid-array.h"
index d1ed3b8ee569f7367ff9fab659febe24dfb67121..a2994331a14938ecc45789b5e2ee50a34df20f6c 100644 (file)
@@ -2,6 +2,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "range-diff.h"
+#include "object-name.h"
 #include "string-list.h"
 #include "run-command.h"
 #include "strvec.h"
index 4ada6d62b90331a9be56b2cd2e1ca7aba1d1f1db..cbbfc030da788deff1ad09fe7840cf95a8d4092f 100644 (file)
@@ -22,6 +22,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "mem-pool.h"
+#include "object-name.h"
 #include "resolve-undo.h"
 #include "run-command.h"
 #include "strbuf.h"
index 79ed61b9fa4a333d905fe1d5258d20e43ce86bb2..48467a7bc4a9246af273e94f7cc8ba1a4c7a2b05 100644 (file)
@@ -8,6 +8,7 @@
 #include "commit-slab.h"
 #include "config.h"
 #include "dir.h"
+#include "object-name.h"
 #include "wrapper.h"
 
 static const char edit_todo_list_advice[] =
index 1c6174c8aeda9ca32765c95d0b5468cdaa229d94..57a5884aec787bdf12402b46c2b7bc77349d92a8 100644 (file)
@@ -6,6 +6,7 @@
 #include "parse-options.h"
 #include "refs.h"
 #include "wildmatch.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "repository.h"
diff --git a/refs.c b/refs.c
index cfced6f174a86900b473a22efd5ad29b3f42f601..979ed3fbedced74e6a365ea6c57783a513193bcc 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -16,6 +16,7 @@
 #include "refs/refs-internal.h"
 #include "run-command.h"
 #include "hook.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "object.h"
 #include "tag.h"
index 6599d52de203e0b6e7e38ebe2acce2e92e759825..3afedce593e31c716e7a1e9ef8ffd890c79596bf 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -9,6 +9,7 @@
 #include "urlmatch.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "commit.h"
 #include "diff.h"
diff --git a/reset.c b/reset.c
index ab300923e04f6066cea56680cafa42306af954bd..48da0adf851e1b09edfc22ffbbc0b1128cbbc5ab 100644 (file)
--- a/reset.c
+++ b/reset.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "refs.h"
 #include "reset.h"
 #include "run-command.h"
index 7c34c93885e9c301be0d695bfc8fbf70147a3e90..7438b50e267f5ca436724447d01f215b2e67b168 100644 (file)
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "tag.h"
 #include "blob.h"
index eaba379e3ad570f1450190945aecd91e15ff320b..22b287be984b1dc2bf58be01688b8475cac21147 100644 (file)
@@ -8,6 +8,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "dir.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "object.h"
 #include "commit.h"
diff --git a/setup.c b/setup.c
index 3bb7a9fff62770fc74df31dde6e675384bfc02b8..8a297b3cb5c161b2dc93b73a6e5be81d3fc420bf 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "repository.h"
 #include "config.h"
 #include "dir.h"
index 70a83e7980e0e575cde2d9b8fed5eec1fa9f48e5..1b93d9d3c4741003c346891cfeb04c313192ef88 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "refs.h"
 #include "string-list.h"
 #include "utf8.h"
index ecf0fcf007481806d9e7f63c6d35f0218bca587e..252b90aa439c9014b1bbb3b0e641201d998def9c 100644 (file)
@@ -9,6 +9,7 @@
 #include "submodule-config.h"
 #include "submodule.h"
 #include "strbuf.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
 #include "tree-walk.h"
index 58c9d5e56730e8762f826ece985516a0de2cb1f3..4f403b9eeffdb417fdba984ff51676f17a38c132 100644 (file)
@@ -24,6 +24,7 @@
 #include "remote.h"
 #include "worktree.h"
 #include "parse-options.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "commit-reach.h"
 #include "setup.h"
index fd48e0ee2c8fdaeec535a5a35b26c36031fe32a6..d1d63feaa9e299ace44d228176cd2b4335193569 100644 (file)
@@ -20,6 +20,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "merge-ort.h"
+#include "object-name.h"
 #include "refs.h"
 #include "revision.h"
 #include "sequencer.h"
index 7066f3c71d2bcd79d154358c0656cf4f159f38e2..3808e1ac38b97d81b2c34ec841df3fc3237bbb20 100644 (file)
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "hex.h"
+#include "object-name.h"
 #include "setup.h"
 #include "tree.h"
 
index e2eb25ecdea991c9a65ec2a33f677b911625f492..bf4fcfe6efb0e75706ae0c80ce043c4a08f9bdb3 100644 (file)
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "hex.h"
+#include "object-name.h"
 #include "oidmap.h"
 #include "setup.h"
 #include "strbuf.h"
index b0deaa106a288cf57b10d8e818a575c40eb9fdf4..d4fa33ae751491d002ae8e3185e2113e2c334462 100644 (file)
@@ -6,6 +6,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "ref-filter.h"
 #include "setup.h"
index 66063b58ded71a319cc71effbf465aa943bf2562..4758c8654e0f85c69f0fb145ccd6f6612270f70a 100644 (file)
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "config.h"
+#include "object-name.h"
 #include "setup.h"
 #include "submodule-config.h"
 #include "submodule.h"
diff --git a/tag.c b/tag.c
index 01ed67d6fa6ac214393f887df1c4e9826e5dbe08..b9fc2fc99297c7ec826827da0dacea46041436e9 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "environment.h"
 #include "tag.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "commit.h"
 #include "tree.h"
index 76d146ee88b8ff1e96441873ffe8ea79bf6f2d25..ca8bec04bb3c3a4a087a95ecf8c841b4cd19305c 100644 (file)
@@ -7,6 +7,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "revision.h"
 #include "remote.h"
 #include "string-list.h"
index 82bf2496ba73374338ec8a0630545782fed81190..7374cfd1fa958333f200966ab8e406b69e3df0a8 100644 (file)
@@ -26,6 +26,7 @@
 #include "trace2.h"
 #include "transport-internal.h"
 #include "protocol.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "color.h"
 #include "bundle-uri.h"
diff --git a/tree.c b/tree.c
index 2b78708766bc275651d0289fe4646c3bbf19b79c..e9d51ce2e00c00bf2ae7e2bee8daf69cb809620a 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -2,6 +2,7 @@
 #include "cache-tree.h"
 #include "hex.h"
 #include "tree.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blob.h"
 #include "commit.h"
index 47f223c0f8df0e173257df22c9704551ecf81eac..97b9c1c035974c269f5b9d042155e196d8193b10 100644 (file)
@@ -8,6 +8,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "revision.h"
 #include "diffcore.h"
 #include "quote.h"