mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
csum-file: rename sha1file to hashfile
Rename struct sha1file to struct hashfile, along with all of its related functions. The transformation in this commit was made by global search-and-replace. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
aab6135906
commit
98a3beab6a
36
csum-file.c
36
csum-file.c
@@ -11,7 +11,7 @@
|
||||
#include "progress.h"
|
||||
#include "csum-file.h"
|
||||
|
||||
static void flush(struct sha1file *f, const void *buf, unsigned int count)
|
||||
static void flush(struct hashfile *f, const void *buf, unsigned int count)
|
||||
{
|
||||
if (0 <= f->check_fd && count) {
|
||||
unsigned char check_buffer[8192];
|
||||
@@ -42,7 +42,7 @@ static void flush(struct sha1file *f, const void *buf, unsigned int count)
|
||||
}
|
||||
}
|
||||
|
||||
void sha1flush(struct sha1file *f)
|
||||
void hashflush(struct hashfile *f)
|
||||
{
|
||||
unsigned offset = f->offset;
|
||||
|
||||
@@ -53,11 +53,11 @@ void sha1flush(struct sha1file *f)
|
||||
}
|
||||
}
|
||||
|
||||
int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)
|
||||
int hashclose(struct hashfile *f, unsigned char *result, unsigned int flags)
|
||||
{
|
||||
int fd;
|
||||
|
||||
sha1flush(f);
|
||||
hashflush(f);
|
||||
git_SHA1_Final(f->buffer, &f->ctx);
|
||||
if (result)
|
||||
hashcpy(result, f->buffer);
|
||||
@@ -86,7 +86,7 @@ int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)
|
||||
return fd;
|
||||
}
|
||||
|
||||
void sha1write(struct sha1file *f, const void *buf, unsigned int count)
|
||||
void hashwrite(struct hashfile *f, const void *buf, unsigned int count)
|
||||
{
|
||||
while (count) {
|
||||
unsigned offset = f->offset;
|
||||
@@ -118,15 +118,15 @@ void sha1write(struct sha1file *f, const void *buf, unsigned int count)
|
||||
}
|
||||
}
|
||||
|
||||
struct sha1file *sha1fd(int fd, const char *name)
|
||||
struct hashfile *hashfd(int fd, const char *name)
|
||||
{
|
||||
return sha1fd_throughput(fd, name, NULL);
|
||||
return hashfd_throughput(fd, name, NULL);
|
||||
}
|
||||
|
||||
struct sha1file *sha1fd_check(const char *name)
|
||||
struct hashfile *hashfd_check(const char *name)
|
||||
{
|
||||
int sink, check;
|
||||
struct sha1file *f;
|
||||
struct hashfile *f;
|
||||
|
||||
sink = open("/dev/null", O_WRONLY);
|
||||
if (sink < 0)
|
||||
@@ -134,14 +134,14 @@ struct sha1file *sha1fd_check(const char *name)
|
||||
check = open(name, O_RDONLY);
|
||||
if (check < 0)
|
||||
die_errno("unable to open '%s'", name);
|
||||
f = sha1fd(sink, name);
|
||||
f = hashfd(sink, name);
|
||||
f->check_fd = check;
|
||||
return f;
|
||||
}
|
||||
|
||||
struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp)
|
||||
struct hashfile *hashfd_throughput(int fd, const char *name, struct progress *tp)
|
||||
{
|
||||
struct sha1file *f = xmalloc(sizeof(*f));
|
||||
struct hashfile *f = xmalloc(sizeof(*f));
|
||||
f->fd = fd;
|
||||
f->check_fd = -1;
|
||||
f->offset = 0;
|
||||
@@ -153,14 +153,14 @@ struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp
|
||||
return f;
|
||||
}
|
||||
|
||||
void sha1file_checkpoint(struct sha1file *f, struct sha1file_checkpoint *checkpoint)
|
||||
void hashfile_checkpoint(struct hashfile *f, struct hashfile_checkpoint *checkpoint)
|
||||
{
|
||||
sha1flush(f);
|
||||
hashflush(f);
|
||||
checkpoint->offset = f->total;
|
||||
checkpoint->ctx = f->ctx;
|
||||
}
|
||||
|
||||
int sha1file_truncate(struct sha1file *f, struct sha1file_checkpoint *checkpoint)
|
||||
int hashfile_truncate(struct hashfile *f, struct hashfile_checkpoint *checkpoint)
|
||||
{
|
||||
off_t offset = checkpoint->offset;
|
||||
|
||||
@@ -169,17 +169,17 @@ int sha1file_truncate(struct sha1file *f, struct sha1file_checkpoint *checkpoint
|
||||
return -1;
|
||||
f->total = offset;
|
||||
f->ctx = checkpoint->ctx;
|
||||
f->offset = 0; /* sha1flush() was called in checkpoint */
|
||||
f->offset = 0; /* hashflush() was called in checkpoint */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void crc32_begin(struct sha1file *f)
|
||||
void crc32_begin(struct hashfile *f)
|
||||
{
|
||||
f->crc32 = crc32(0, NULL, 0);
|
||||
f->do_crc = 1;
|
||||
}
|
||||
|
||||
uint32_t crc32_end(struct sha1file *f)
|
||||
uint32_t crc32_end(struct hashfile *f)
|
||||
{
|
||||
f->do_crc = 0;
|
||||
return f->crc32;
|
||||
|
||||
Reference in New Issue
Block a user