1123
int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
1124
#define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)
1125
1126
-extern const struct object_id null_oid;
1127
-
1128
-static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
1129
-{
1130
- /*
1131
- * Teach the compiler that there are only two possibilities of hash size
1132
- * here, so that it can optimize for this case as much as possible.
1133
- */
1134
- if (the_hash_algo->rawsz == GIT_MAX_RAWSZ)
1135
- return memcmp(sha1, sha2, GIT_MAX_RAWSZ);
1136
- return memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
1137
-}
1138
-
1139
-static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)
1140
-{
1141
- return hashcmp(oid1->hash, oid2->hash);
1142
-}
1143
-
1144
-static inline int hasheq(const unsigned char *sha1, const unsigned char *sha2)
1145
-{
1146
- /*
1147
- * We write this here instead of deferring to hashcmp so that the
1148
- * compiler can properly inline it and avoid calling memcmp.
1149
- */
1150
- if (the_hash_algo->rawsz == GIT_MAX_RAWSZ)
1151
- return !memcmp(sha1, sha2, GIT_MAX_RAWSZ);
1152
- return !memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
1153
-}
1154
-
1155
-static inline int oideq(const struct object_id *oid1, const struct object_id *oid2)
1156
-{
1157
- return hasheq(oid1->hash, oid2->hash);
1158
-}
1159
-
1160
-static inline int is_null_oid(const struct object_id *oid)
1161
-{
1162
- return oideq(oid, &null_oid);
1163
-}
1164
-
1165
-static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
1166
-{
1167
- memcpy(sha_dst, sha_src, the_hash_algo->rawsz);
1168
-}
1169
-
1170
-static inline void oidcpy(struct object_id *dst, const struct object_id *src)
1171
-{
1172
- memcpy(dst->hash, src->hash, GIT_MAX_RAWSZ);
1173
-}
1174
-
1175
-static inline struct object_id *oiddup(const struct object_id *src)
1176
-{
1177
- struct object_id *dst = xmalloc(sizeof(struct object_id));
1178
- oidcpy(dst, src);
1179
- return dst;
1180
-}
1181
-
1182
-static inline void hashclr(unsigned char *hash)
1183
-{
1184
- memset(hash, 0, the_hash_algo->rawsz);
1185
-}
1186
-
1187
-static inline void oidclr(struct object_id *oid)
1188
-{
1189
- memset(oid->hash, 0, GIT_MAX_RAWSZ);
1190
-}
1191
-
1192
-static inline void oidread(struct object_id *oid, const unsigned char *hash)
1193
-{
1194
- memcpy(oid->hash, hash, the_hash_algo->rawsz);
1195
-}
1196
-
1197
-static inline int is_empty_blob_sha1(const unsigned char *sha1)
1198
-{
1199
- return hasheq(sha1, the_hash_algo->empty_blob->hash);
1200
-}
1201
-
1202
-static inline int is_empty_blob_oid(const struct object_id *oid)
1203
-{
1204
- return oideq(oid, the_hash_algo->empty_blob);
1205
-}
1206
-
1207
-static inline int is_empty_tree_sha1(const unsigned char *sha1)
1208
-{
1209
- return hasheq(sha1, the_hash_algo->empty_tree->hash);
1210
-}
1211
-
1212
-static inline int is_empty_tree_oid(const struct object_id *oid)
1213
-{
1214
- return oideq(oid, the_hash_algo->empty_tree);
1215
-}
1216
-
1217
-const char *empty_tree_oid_hex(void);
1218
-const char *empty_blob_oid_hex(void);
1219
-
1126
/* set default permissions by passing mode arguments to open(2) */
1127
int git_mkstemps_mode(char *pattern, int suffix_len, int mode);
1128
int git_mkstemp_mode(char *pattern, int mode);