hash: require hash algorithm in `is_empty_{blob,tree}_oid()`
Both functions `is_empty_{blob,tree}_oid()` use `the_repository` to
derive the hash function that shall be used. Require callers to pass in
the hash algorithm to get rid of this implicit dependency.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
parent
861e8c76f6
commit
9c34eb93fb
|
|
@ -2361,7 +2361,9 @@ static void file_change_m(const char *p, struct branch *b)
|
|||
parse_path_eol(&path, p, "path");
|
||||
|
||||
/* Git does not track empty, non-toplevel directories. */
|
||||
if (S_ISDIR(mode) && is_empty_tree_oid(&oid) && *path.buf) {
|
||||
if (S_ISDIR(mode) &&
|
||||
is_empty_tree_oid(&oid, the_repository->hash_algo) &&
|
||||
*path.buf) {
|
||||
tree_content_remove(&b->branch_tree, path.buf, NULL, 0);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ static int update_one(struct cache_tree *it,
|
|||
/*
|
||||
* "sub" can be an empty tree if all subentries are i-t-a.
|
||||
*/
|
||||
if (contains_ita && is_empty_tree_oid(oid))
|
||||
if (contains_ita && is_empty_tree_oid(oid, the_repository->hash_algo))
|
||||
continue;
|
||||
|
||||
strbuf_grow(&buffer, entlen + 100);
|
||||
|
|
|
|||
|
|
@ -1422,7 +1422,7 @@ void diffcore_rename_extended(struct diff_options *options,
|
|||
strcmp(options->single_follow, p->two->path))
|
||||
continue; /* not interested */
|
||||
else if (!options->flags.rename_empty &&
|
||||
is_empty_blob_oid(&p->two->oid))
|
||||
is_empty_blob_oid(&p->two->oid, the_repository->hash_algo))
|
||||
continue;
|
||||
else if (add_rename_dst(p) < 0) {
|
||||
warning("skipping rename detection, detected"
|
||||
|
|
@ -1432,7 +1432,7 @@ void diffcore_rename_extended(struct diff_options *options,
|
|||
}
|
||||
}
|
||||
else if (!options->flags.rename_empty &&
|
||||
is_empty_blob_oid(&p->one->oid))
|
||||
is_empty_blob_oid(&p->one->oid, the_repository->hash_algo))
|
||||
continue;
|
||||
else if (!DIFF_PAIR_UNMERGED(p) && !DIFF_FILE_VALID(p->two)) {
|
||||
/*
|
||||
|
|
|
|||
12
hash-ll.h
12
hash-ll.h
|
|
@ -350,4 +350,16 @@ static inline int is_null_oid(const struct object_id *oid)
|
|||
const char *empty_tree_oid_hex(void);
|
||||
const char *empty_blob_oid_hex(void);
|
||||
|
||||
static inline int is_empty_blob_oid(const struct object_id *oid,
|
||||
const struct git_hash_algo *algop)
|
||||
{
|
||||
return oideq(oid, algop->empty_blob);
|
||||
}
|
||||
|
||||
static inline int is_empty_tree_oid(const struct object_id *oid,
|
||||
const struct git_hash_algo *algop)
|
||||
{
|
||||
return oideq(oid, algop->empty_tree);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
10
hash.h
10
hash.h
|
|
@ -6,14 +6,4 @@
|
|||
|
||||
#define the_hash_algo the_repository->hash_algo
|
||||
|
||||
static inline int is_empty_blob_oid(const struct object_id *oid)
|
||||
{
|
||||
return oideq(oid, the_hash_algo->empty_blob);
|
||||
}
|
||||
|
||||
static inline int is_empty_tree_oid(const struct object_id *oid)
|
||||
{
|
||||
return oideq(oid, the_hash_algo->empty_tree);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)
|
|||
|
||||
/* Racily smudged entry? */
|
||||
if (!ce->ce_stat_data.sd_size) {
|
||||
if (!is_empty_blob_oid(&ce->oid))
|
||||
if (!is_empty_blob_oid(&ce->oid, the_repository->hash_algo))
|
||||
changed |= DATA_CHANGED;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue