зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
98374a07c9
Коммит
5d3679ee02
|
@ -147,35 +147,3 @@ expression E1, E2;
|
|||
- hashcmp(E1, E2) != 0
|
||||
+ !hasheq(E1, E2)
|
||||
...>}
|
||||
|
||||
@@
|
||||
struct object_id OID;
|
||||
@@
|
||||
- has_sha1_file(OID.hash)
|
||||
+ has_object_file(&OID)
|
||||
|
||||
@@
|
||||
identifier f != has_object_file;
|
||||
struct object_id *OIDPTR;
|
||||
@@
|
||||
f(...) {<...
|
||||
- has_sha1_file(OIDPTR->hash)
|
||||
+ has_object_file(OIDPTR)
|
||||
...>}
|
||||
|
||||
@@
|
||||
struct object_id OID;
|
||||
expression E;
|
||||
@@
|
||||
- has_sha1_file_with_flags(OID.hash, E)
|
||||
+ has_object_file_with_flags(&OID, E)
|
||||
|
||||
@@
|
||||
identifier f != has_object_file_with_flags;
|
||||
struct object_id *OIDPTR;
|
||||
expression E;
|
||||
@@
|
||||
f(...) {<...
|
||||
- has_sha1_file_with_flags(OIDPTR->hash, E)
|
||||
+ has_object_file_with_flags(OIDPTR, E)
|
||||
...>}
|
||||
|
|
|
@ -202,20 +202,16 @@ int read_loose_object(const char *path,
|
|||
void **contents);
|
||||
|
||||
/*
|
||||
* Convenience for sha1_object_info_extended() with a NULL struct
|
||||
* Convenience for oid_object_info_extended() with a NULL struct
|
||||
* object_info. OBJECT_INFO_SKIP_CACHED is automatically set; pass
|
||||
* nonzero flags to also set other flags.
|
||||
*/
|
||||
extern int has_sha1_file_with_flags(const unsigned char *sha1, int flags);
|
||||
static inline int has_sha1_file(const unsigned char *sha1)
|
||||
int has_object_file_with_flags(const struct object_id *oid, int flags);
|
||||
static inline int has_object_file(const struct object_id *oid)
|
||||
{
|
||||
return has_sha1_file_with_flags(sha1, 0);
|
||||
return has_object_file_with_flags(oid, 0);
|
||||
}
|
||||
|
||||
/* Same as the above, except for struct object_id. */
|
||||
extern int has_object_file(const struct object_id *oid);
|
||||
extern int has_object_file_with_flags(const struct object_id *oid, int flags);
|
||||
|
||||
/*
|
||||
* Return true iff an alternate object database has a loose object
|
||||
* with the specified name. This function does not respect replace
|
||||
|
|
20
sha1-file.c
20
sha1-file.c
|
@ -1752,24 +1752,12 @@ int force_object_loose(const struct object_id *oid, time_t mtime)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int has_sha1_file_with_flags(const unsigned char *sha1, int flags)
|
||||
{
|
||||
struct object_id oid;
|
||||
if (!startup_info->have_repository)
|
||||
return 0;
|
||||
hashcpy(oid.hash, sha1);
|
||||
return oid_object_info_extended(the_repository, &oid, NULL,
|
||||
flags | OBJECT_INFO_SKIP_CACHED) >= 0;
|
||||
}
|
||||
|
||||
int has_object_file(const struct object_id *oid)
|
||||
{
|
||||
return has_sha1_file(oid->hash);
|
||||
}
|
||||
|
||||
int has_object_file_with_flags(const struct object_id *oid, int flags)
|
||||
{
|
||||
return has_sha1_file_with_flags(oid->hash, flags);
|
||||
if (!startup_info->have_repository)
|
||||
return 0;
|
||||
return oid_object_info_extended(the_repository, oid, NULL,
|
||||
flags | OBJECT_INFO_SKIP_CACHED) >= 0;
|
||||
}
|
||||
|
||||
static void check_tree(const void *buf, size_t size)
|
||||
|
|
Загрузка…
Ссылка в новой задаче