git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
7985b94ae2cc10e84a198c340c6a203e02321aa7 blob 3347 bytes (raw)

  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
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
 
/*
Copyright 2020 Google LLC

Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file or at
https://developers.google.com/open-source/licenses/bsd
*/

#ifndef REFTABLE_RECORD_H
#define REFTABLE_RECORD_H

#include <stdint.h>

/*
 * Basic data types
 *
 * Reftables store the state of each ref in struct reftable_ref_record, and they
 * store a sequence of reflog updates in struct reftable_log_record.
 */

/* reftable_ref_record holds a ref database entry target_value */
struct reftable_ref_record {
	char *refname; /* Name of the ref, malloced. */
	uint64_t update_index; /* Logical timestamp at which this value is
				* written */

	enum {
		/* tombstone to hide deletions from earlier tables */
		REFTABLE_REF_DELETION = 0x0,

		/* a simple ref */
		REFTABLE_REF_VAL1 = 0x1,
		/* a tag, plus its peeled hash */
		REFTABLE_REF_VAL2 = 0x2,

		/* a symbolic reference */
		REFTABLE_REF_SYMREF = 0x3,
#define REFTABLE_NR_REF_VALUETYPES 4
	} value_type;
	union {
		uint8_t *val1; /* malloced hash. */
		struct {
			uint8_t *value; /* first value, malloced hash  */
			uint8_t *target_value; /* second value, malloced hash */
		} val2;
		char *symref; /* referent, malloced 0-terminated string */
	} value;
};

/* Returns the first hash, or NULL if `rec` is not of type
 * REFTABLE_REF_VAL1 or REFTABLE_REF_VAL2. */
uint8_t *reftable_ref_record_val1(struct reftable_ref_record *rec);

/* Returns the second hash, or NULL if `rec` is not of type
 * REFTABLE_REF_VAL2. */
uint8_t *reftable_ref_record_val2(struct reftable_ref_record *rec);

/* returns whether 'ref' represents a deletion */
int reftable_ref_record_is_deletion(const struct reftable_ref_record *ref);

/* prints a reftable_ref_record onto stdout. Useful for debugging. */
void reftable_ref_record_print(struct reftable_ref_record *ref,
			       uint32_t hash_id);

/* frees and nulls all pointer values inside `ref`. */
void reftable_ref_record_release(struct reftable_ref_record *ref);

/* returns whether two reftable_ref_records are the same. Useful for testing. */
int reftable_ref_record_equal(struct reftable_ref_record *a,
			      struct reftable_ref_record *b, int hash_size);

/* reftable_log_record holds a reflog entry */
struct reftable_log_record {
	char *refname;
	uint64_t update_index; /* logical timestamp of a transactional update.
				*/

	enum {
		/* tombstone to hide deletions from earlier tables */
		REFTABLE_LOG_DELETION = 0x0,

		/* a simple update */
		REFTABLE_LOG_UPDATE = 0x1,
#define REFTABLE_NR_LOG_VALUETYPES 2
	} value_type;

	union {
		struct {
			uint8_t *new_hash;
			uint8_t *old_hash;
			char *name;
			char *email;
			uint64_t time;
			int16_t tz_offset;
			char *message;
		} update;
	};
};

/* returns whether 'ref' represents the deletion of a log record. */
int reftable_log_record_is_deletion(const struct reftable_log_record *log);

/* frees and nulls all pointer values. */
void reftable_log_record_release(struct reftable_log_record *log);

/* returns whether two records are equal. Useful for testing. */
int reftable_log_record_equal(struct reftable_log_record *a,
			      struct reftable_log_record *b, int hash_size);

/* dumps a reftable_log_record on stdout, for debugging/testing. */
void reftable_log_record_print(struct reftable_log_record *log,
			       uint32_t hash_id);

#endif
debug log:

solving 7985b94ae2cc ...
found 7985b94ae2cc in https://public-inbox.org/git/028dd13e701bf82523cc6da1e68a9dab480c1b27.1618832277.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/390eaca4fc8cffe520cbb835582ab6d12de97253.1615580397.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/78a352c96f82d441d1c82ade032558283e867cbf.1618255553.git.gitgitgadget@gmail.com/

applying [1/3] https://public-inbox.org/git/028dd13e701bf82523cc6da1e68a9dab480c1b27.1618832277.git.gitgitgadget@gmail.com/
diff --git a/reftable/reftable-record.h b/reftable/reftable-record.h
new file mode 100644
index 000000000000..7985b94ae2cc

Checking patch reftable/reftable-record.h...
Applied patch reftable/reftable-record.h cleanly.

skipping https://public-inbox.org/git/390eaca4fc8cffe520cbb835582ab6d12de97253.1615580397.git.gitgitgadget@gmail.com/ for 7985b94ae2cc
skipping https://public-inbox.org/git/78a352c96f82d441d1c82ade032558283e867cbf.1618255553.git.gitgitgadget@gmail.com/ for 7985b94ae2cc
index at:
100644 7985b94ae2cc10e84a198c340c6a203e02321aa7	reftable/reftable-record.h

Code repositories for project(s) associated with this 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).