git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
blob b8785e7ecb46b5645fda1a15695f15a37a2c9bb8 2068 bytes (raw)
name: csum-file.h 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
 
#ifndef CSUM_FILE_H
#define CSUM_FILE_H

#include "hash.h"

struct progress;

/* A SHA1-protected file */
struct hashfile {
	int fd;
	int check_fd;
	unsigned int offset;
	git_hash_ctx ctx;
	off_t total;
	struct progress *tp;
	const char *name;
	int do_crc;
	uint32_t crc32;
	struct hashfile *base;
	unsigned char buffer[8192];
};

/* Checkpoint */
struct hashfile_checkpoint {
	off_t offset;
	git_hash_ctx ctx;
};

void hashfile_checkpoint(struct hashfile *, struct hashfile_checkpoint *);
int hashfile_truncate(struct hashfile *, struct hashfile_checkpoint *);

/* finalize_hashfile flags */
#define CSUM_CLOSE		1
#define CSUM_FSYNC		2
#define CSUM_HASH_IN_STREAM	4

struct hashfile *hashfd(int fd, const char *name);
struct hashfile *hashfd_check(const char *name);
struct hashfile *hashfd_throughput(int fd, const char *name, struct progress *tp);
int finalize_hashfile(struct hashfile *, unsigned char *, unsigned int);
void hashwrite(struct hashfile *, const void *, unsigned int);
void hashflush(struct hashfile *f);
void crc32_begin(struct hashfile *);
uint32_t crc32_end(struct hashfile *);

/*
 * A nested hashfile uses the same interface as a hashfile, and computes
 * a hash for the input bytes while passing them to the base hashfile
 * instead of writing them to its own file. This is useful for computing
 * a hash of a region within a file during the write.
 */
struct hashfile *nested_hashfile(struct hashfile *f);

/*
 * Returns the total number of bytes fed to the hashfile so far (including ones
 * that have not been written out to the descriptor yet).
 */
static inline off_t hashfile_total(struct hashfile *f)
{
	return f->total + f->offset;
}

static inline void hashwrite_u8(struct hashfile *f, uint8_t data)
{
	hashwrite(f, &data, sizeof(data));
}

static inline void hashwrite_be32(struct hashfile *f, uint32_t data)
{
	data = htonl(data);
	hashwrite(f, &data, sizeof(data));
}

static inline size_t hashwrite_be64(struct hashfile *f, uint64_t data)
{
	data = htonll(data);
	hashwrite(f, &data, sizeof(data));
	return sizeof(data);
}

#endif

debug log:

solving b8785e7ecb46 ...
found b8785e7ecb46 in https://public-inbox.org/git/0eca529766fcbe70147bc28ce7f0692e645fd118.1616785928.git.gitgitgadget@gmail.com/
found e54d53d1d0b3 in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100644 e54d53d1d0b3537b4fb4b0f22f9699cf38a2c3cf	csum-file.h

applying [1/1] https://public-inbox.org/git/0eca529766fcbe70147bc28ce7f0692e645fd118.1616785928.git.gitgitgadget@gmail.com/
diff --git a/csum-file.h b/csum-file.h
index e54d53d1d0b3..b8785e7ecb46 100644

Checking patch csum-file.h...
Applied patch csum-file.h cleanly.

index at:
100644 b8785e7ecb46b5645fda1a15695f15a37a2c9bb8	csum-file.h

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).