sha1-file: drop has_sha1_file()

There are no callers left of has_sha1_file() or its with_flags() variant. Let's drop them, and convert has_object_file() from a wrapper into the "real" function. Ironically, the sha1 variant was just copying into an object_id internally, so the resulting code is actually shorter! We can also drop the coccinelle rules for catching has_sha1_file() callers. Since the function no longer exists, the compiler will do that for us. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jan 7, 2019 at 03:39 UTC 5d3679ee023642825a5d3c0ca1eec251588a1848
3 files changed +6 -54
contrib/coccinelle/object_id.cocci
-32
@@ -147,35 +147,3 @@ expression E1, E2;
147 - hashcmp(E1, E2) != 0
148 + !hasheq(E1, E2)
149 ...>}
150 -
151 -@@
152 -struct object_id OID;
153 -@@
154 -- has_sha1_file(OID.hash)
155 -+ has_object_file(&OID)
156 -
157 -@@
158 -identifier f != has_object_file;
159 -struct object_id *OIDPTR;
160 -@@
161 - f(...) {<...
162 -- has_sha1_file(OIDPTR->hash)
163 -+ has_object_file(OIDPTR)
164 - ...>}
165 -
166 -@@
167 -struct object_id OID;
168 -expression E;
169 -@@
170 -- has_sha1_file_with_flags(OID.hash, E)
171 -+ has_object_file_with_flags(&OID, E)
172 -
173 -@@
174 -identifier f != has_object_file_with_flags;
175 -struct object_id *OIDPTR;
176 -expression E;
177 -@@
178 - f(...) {<...
179 -- has_sha1_file_with_flags(OIDPTR->hash, E)
180 -+ has_object_file_with_flags(OIDPTR, E)
181 - ...>}
object-store.h
+4 -8
@@ -202,20 +202,16 @@ int read_loose_object(const char *path,
202 void **contents);
203
204 /*
205 - * Convenience for sha1_object_info_extended() with a NULL struct
205 + * Convenience for oid_object_info_extended() with a NULL struct
206 * object_info. OBJECT_INFO_SKIP_CACHED is automatically set; pass
207 * nonzero flags to also set other flags.
208 */
209 -extern int has_sha1_file_with_flags(const unsigned char *sha1, int flags);
210 -static inline int has_sha1_file(const unsigned char *sha1)
209 +int has_object_file_with_flags(const struct object_id *oid, int flags);
210 +static inline int has_object_file(const struct object_id *oid)
211 {
212 - return has_sha1_file_with_flags(sha1, 0);
212 + return has_object_file_with_flags(oid, 0);
213 }
214
215 -/* Same as the above, except for struct object_id. */
216 -extern int has_object_file(const struct object_id *oid);
217 -extern int has_object_file_with_flags(const struct object_id *oid, int flags);
218 -
215 /*
216 * Return true iff an alternate object database has a loose object
217 * with the specified name. This function does not respect replace
sha1-file.c
+2 -14
@@ -1752,26 +1752,14 @@ int force_object_loose(const struct object_id *oid, time_t mtime)
1752 return ret;
1753 }
1754
1755 -int has_sha1_file_with_flags(const unsigned char *sha1, int flags)
1755 +int has_object_file_with_flags(const struct object_id *oid, int flags)
1756 {
1757 - struct object_id oid;
1757 if (!startup_info->have_repository)
1758 return 0;
1760 - hashcpy(oid.hash, sha1);
1761 - return oid_object_info_extended(the_repository, &oid, NULL,
1759 + return oid_object_info_extended(the_repository, oid, NULL,
1760 flags | OBJECT_INFO_SKIP_CACHED) >= 0;
1761 }
1762
1765 -int has_object_file(const struct object_id *oid)
1766 -{
1767 - return has_sha1_file(oid->hash);
1768 -}
1769 -
1770 -int has_object_file_with_flags(const struct object_id *oid, int flags)
1771 -{
1772 - return has_sha1_file_with_flags(oid->hash, flags);
1773 -}
1774 -
1763 static void check_tree(const void *buf, size_t size)
1764 {
1765 struct tree_desc desc;