1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-28 12:59:41 +01:00

dir: convert struct untracked_cache_dir to object_id

Convert the exclude_sha1 member of struct untracked_cache_dir and rename
it to exclude_oid.  Eliminate several hard-coded integral constants, and
update a function name that referred to SHA-1.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
brian m. carlson 2018-05-02 00:25:48 +00:00 committed by Junio C Hamano
parent 26ea3e7dca
commit 70c369cde0
3 changed files with 16 additions and 14 deletions

23
dir.c
View file

@ -1240,11 +1240,11 @@ static void prep_exclude(struct dir_struct *dir,
(!untracked || !untracked->valid ||
/*
* .. and .gitignore does not exist before
* (i.e. null exclude_sha1). Then we can skip
* (i.e. null exclude_oid). Then we can skip
* loading .gitignore, which would result in
* ENOENT anyway.
*/
!is_null_sha1(untracked->exclude_sha1))) {
!is_null_oid(&untracked->exclude_oid))) {
/*
* dir->basebuf gets reused by the traversal, but we
* need fname to remain unchanged to ensure the src
@ -1275,9 +1275,9 @@ static void prep_exclude(struct dir_struct *dir,
* order, though, if you do that.
*/
if (untracked &&
hashcmp(oid_stat.oid.hash, untracked->exclude_sha1)) {
oidcmp(&oid_stat.oid, &untracked->exclude_oid)) {
invalidate_gitignore(dir->untracked, untracked);
hashcpy(untracked->exclude_sha1, oid_stat.oid.hash);
oidcpy(&untracked->exclude_oid, &oid_stat.oid);
}
dir->exclude_stack = stk;
current = stk->baselen;
@ -2622,9 +2622,10 @@ static void write_one_dir(struct untracked_cache_dir *untracked,
stat_data_to_disk(&stat_data, &untracked->stat_data);
strbuf_add(&wd->sb_stat, &stat_data, sizeof(stat_data));
}
if (!is_null_sha1(untracked->exclude_sha1)) {
if (!is_null_oid(&untracked->exclude_oid)) {
ewah_set(wd->sha1_valid, i);
strbuf_add(&wd->sb_sha1, untracked->exclude_sha1, 20);
strbuf_add(&wd->sb_sha1, untracked->exclude_oid.hash,
the_hash_algo->rawsz);
}
intlen = encode_varint(untracked->untracked_nr, intbuf);
@ -2825,16 +2826,16 @@ static void read_stat(size_t pos, void *cb)
ud->valid = 1;
}
static void read_sha1(size_t pos, void *cb)
static void read_oid(size_t pos, void *cb)
{
struct read_data *rd = cb;
struct untracked_cache_dir *ud = rd->ucd[pos];
if (rd->data + 20 > rd->end) {
if (rd->data + the_hash_algo->rawsz > rd->end) {
rd->data = rd->end + 1;
return;
}
hashcpy(ud->exclude_sha1, rd->data);
rd->data += 20;
hashcpy(ud->exclude_oid.hash, rd->data);
rd->data += the_hash_algo->rawsz;
}
static void load_oid_stat(struct oid_stat *oid_stat, const unsigned char *data,
@ -2917,7 +2918,7 @@ struct untracked_cache *read_untracked_extension(const void *data, unsigned long
ewah_each_bit(rd.check_only, set_check_only, &rd);
rd.data = next + len;
ewah_each_bit(rd.valid, read_stat, &rd);
ewah_each_bit(rd.sha1_valid, read_sha1, &rd);
ewah_each_bit(rd.sha1_valid, read_oid, &rd);
next = rd.data;
done:

5
dir.h
View file

@ -3,6 +3,7 @@
/* See Documentation/technical/api-directory-listing.txt */
#include "cache.h"
#include "strbuf.h"
struct dir_entry {
@ -118,8 +119,8 @@ struct untracked_cache_dir {
/* all data except 'dirs' in this struct are good */
unsigned int valid : 1;
unsigned int recurse : 1;
/* null SHA-1 means this directory does not have .gitignore */
unsigned char exclude_sha1[20];
/* null object ID means this directory does not have .gitignore */
struct object_id exclude_oid;
char name[FLEX_ARRAY];
};

View file

@ -23,7 +23,7 @@ static void dump(struct untracked_cache_dir *ucd, struct strbuf *base)
len = base->len;
strbuf_addf(base, "%s/", ucd->name);
printf("%s %s", base->buf,
sha1_to_hex(ucd->exclude_sha1));
oid_to_hex(&ucd->exclude_oid));
if (ucd->recurse)
fputs(" recurse", stdout);
if (ucd->check_only)