summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2017-06-22 00:40:24 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-26 17:28:58 (GMT)
commite83e71c5e15f2c6aaf9bdb8ee9593a46c3bb9a5b (patch)
tree933f4dd4f8205411367bc2f24208a1a632fd2267 /sha1_file.c
parentcd585e2a33841d725b821adbb9b48654fc7d0b61 (diff)
downloadgit-e83e71c5e15f2c6aaf9bdb8ee9593a46c3bb9a5b.zip
git-e83e71c5e15f2c6aaf9bdb8ee9593a46c3bb9a5b.tar.gz
git-e83e71c5e15f2c6aaf9bdb8ee9593a46c3bb9a5b.tar.bz2
sha1_file: refactor has_sha1_file_with_flags
has_sha1_file_with_flags() implements many mechanisms in common with sha1_object_info_extended(). Make has_sha1_file_with_flags() a convenience function for sha1_object_info_extended() instead. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/sha1_file.c b/sha1_file.c
index bf6b64e..778f01d 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -3494,18 +3494,10 @@ int has_sha1_pack(const unsigned char *sha1)
int has_sha1_file_with_flags(const unsigned char *sha1, int flags)
{
- struct pack_entry e;
-
if (!startup_info->have_repository)
return 0;
- if (find_pack_entry(sha1, &e))
- return 1;
- if (has_loose_object(sha1))
- return 1;
- if (flags & HAS_SHA1_QUICK)
- return 0;
- reprepare_packed_git();
- return find_pack_entry(sha1, &e);
+ return sha1_object_info_extended(sha1, NULL,
+ flags | OBJECT_INFO_SKIP_CACHED) >= 0;
}
int has_object_file(const struct object_id *oid)