Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/smanonr..../opt/imh-pyth.../include/git2
File: oid.h
/*
[0] Fix | Delete
* Copyright (C) the libgit2 contributors. All rights reserved.
[1] Fix | Delete
*
[2] Fix | Delete
* This file is part of libgit2, distributed under the GNU GPL v2 with
[3] Fix | Delete
* a Linking Exception. For full terms see the included COPYING file.
[4] Fix | Delete
*/
[5] Fix | Delete
#ifndef INCLUDE_git_oid_h__
[6] Fix | Delete
#define INCLUDE_git_oid_h__
[7] Fix | Delete
[8] Fix | Delete
#include "common.h"
[9] Fix | Delete
#include "types.h"
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* @file git2/oid.h
[13] Fix | Delete
* @brief Git object id routines
[14] Fix | Delete
* @defgroup git_oid Git object id routines
[15] Fix | Delete
* @ingroup Git
[16] Fix | Delete
* @{
[17] Fix | Delete
*/
[18] Fix | Delete
GIT_BEGIN_DECL
[19] Fix | Delete
[20] Fix | Delete
/** Size (in bytes) of a raw/binary oid */
[21] Fix | Delete
#define GIT_OID_RAWSZ 20
[22] Fix | Delete
[23] Fix | Delete
/** Size (in bytes) of a hex formatted oid */
[24] Fix | Delete
#define GIT_OID_HEXSZ (GIT_OID_RAWSZ * 2)
[25] Fix | Delete
[26] Fix | Delete
/** Minimum length (in number of hex characters,
[27] Fix | Delete
* i.e. packets of 4 bits) of an oid prefix */
[28] Fix | Delete
#define GIT_OID_MINPREFIXLEN 4
[29] Fix | Delete
[30] Fix | Delete
/** Unique identity of any object (commit, tree, blob, tag). */
[31] Fix | Delete
typedef struct git_oid {
[32] Fix | Delete
/** raw binary formatted id */
[33] Fix | Delete
unsigned char id[GIT_OID_RAWSZ];
[34] Fix | Delete
} git_oid;
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Parse a hex formatted object id into a git_oid.
[38] Fix | Delete
*
[39] Fix | Delete
* @param out oid structure the result is written into.
[40] Fix | Delete
* @param str input hex string; must be pointing at the start of
[41] Fix | Delete
* the hex sequence and have at least the number of bytes
[42] Fix | Delete
* needed for an oid encoded in hex (40 bytes).
[43] Fix | Delete
* @return 0 or an error code
[44] Fix | Delete
*/
[45] Fix | Delete
GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str);
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Parse a hex formatted null-terminated string into a git_oid.
[49] Fix | Delete
*
[50] Fix | Delete
* @param out oid structure the result is written into.
[51] Fix | Delete
* @param str input hex string; must be null-terminated.
[52] Fix | Delete
* @return 0 or an error code
[53] Fix | Delete
*/
[54] Fix | Delete
GIT_EXTERN(int) git_oid_fromstrp(git_oid *out, const char *str);
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Parse N characters of a hex formatted object id into a git_oid.
[58] Fix | Delete
*
[59] Fix | Delete
* If N is odd, the last byte's high nibble will be read in and the
[60] Fix | Delete
* low nibble set to zero.
[61] Fix | Delete
*
[62] Fix | Delete
* @param out oid structure the result is written into.
[63] Fix | Delete
* @param str input hex string of at least size `length`
[64] Fix | Delete
* @param length length of the input string
[65] Fix | Delete
* @return 0 or an error code
[66] Fix | Delete
*/
[67] Fix | Delete
GIT_EXTERN(int) git_oid_fromstrn(git_oid *out, const char *str, size_t length);
[68] Fix | Delete
[69] Fix | Delete
/**
[70] Fix | Delete
* Copy an already raw oid into a git_oid structure.
[71] Fix | Delete
*
[72] Fix | Delete
* @param out oid structure the result is written into.
[73] Fix | Delete
* @param raw the raw input bytes to be copied.
[74] Fix | Delete
* @return 0 on success or error code
[75] Fix | Delete
*/
[76] Fix | Delete
GIT_EXTERN(int) git_oid_fromraw(git_oid *out, const unsigned char *raw);
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* Format a git_oid into a hex string.
[80] Fix | Delete
*
[81] Fix | Delete
* @param out output hex string; must be pointing at the start of
[82] Fix | Delete
* the hex sequence and have at least the number of bytes
[83] Fix | Delete
* needed for an oid encoded in hex (40 bytes). Only the
[84] Fix | Delete
* oid digits are written; a '\\0' terminator must be added
[85] Fix | Delete
* by the caller if it is required.
[86] Fix | Delete
* @param id oid structure to format.
[87] Fix | Delete
* @return 0 on success or error code
[88] Fix | Delete
*/
[89] Fix | Delete
GIT_EXTERN(int) git_oid_fmt(char *out, const git_oid *id);
[90] Fix | Delete
[91] Fix | Delete
/**
[92] Fix | Delete
* Format a git_oid into a partial hex string.
[93] Fix | Delete
*
[94] Fix | Delete
* @param out output hex string; you say how many bytes to write.
[95] Fix | Delete
* If the number of bytes is > GIT_OID_HEXSZ, extra bytes
[96] Fix | Delete
* will be zeroed; if not, a '\0' terminator is NOT added.
[97] Fix | Delete
* @param n number of characters to write into out string
[98] Fix | Delete
* @param id oid structure to format.
[99] Fix | Delete
* @return 0 on success or error code
[100] Fix | Delete
*/
[101] Fix | Delete
GIT_EXTERN(int) git_oid_nfmt(char *out, size_t n, const git_oid *id);
[102] Fix | Delete
[103] Fix | Delete
/**
[104] Fix | Delete
* Format a git_oid into a loose-object path string.
[105] Fix | Delete
*
[106] Fix | Delete
* The resulting string is "aa/...", where "aa" is the first two
[107] Fix | Delete
* hex digits of the oid and "..." is the remaining 38 digits.
[108] Fix | Delete
*
[109] Fix | Delete
* @param out output hex string; must be pointing at the start of
[110] Fix | Delete
* the hex sequence and have at least the number of bytes
[111] Fix | Delete
* needed for an oid encoded in hex (41 bytes). Only the
[112] Fix | Delete
* oid digits are written; a '\\0' terminator must be added
[113] Fix | Delete
* by the caller if it is required.
[114] Fix | Delete
* @param id oid structure to format.
[115] Fix | Delete
* @return 0 on success, non-zero callback return value, or error code
[116] Fix | Delete
*/
[117] Fix | Delete
GIT_EXTERN(int) git_oid_pathfmt(char *out, const git_oid *id);
[118] Fix | Delete
[119] Fix | Delete
/**
[120] Fix | Delete
* Format a git_oid into a statically allocated c-string.
[121] Fix | Delete
*
[122] Fix | Delete
* The c-string is owned by the library and should not be freed
[123] Fix | Delete
* by the user. If libgit2 is built with thread support, the string
[124] Fix | Delete
* will be stored in TLS (i.e. one buffer per thread) to allow for
[125] Fix | Delete
* concurrent calls of the function.
[126] Fix | Delete
*
[127] Fix | Delete
* @param oid The oid structure to format
[128] Fix | Delete
* @return the c-string
[129] Fix | Delete
*/
[130] Fix | Delete
GIT_EXTERN(char *) git_oid_tostr_s(const git_oid *oid);
[131] Fix | Delete
[132] Fix | Delete
/**
[133] Fix | Delete
* Format a git_oid into a buffer as a hex format c-string.
[134] Fix | Delete
*
[135] Fix | Delete
* If the buffer is smaller than GIT_OID_HEXSZ+1, then the resulting
[136] Fix | Delete
* oid c-string will be truncated to n-1 characters (but will still be
[137] Fix | Delete
* NUL-byte terminated).
[138] Fix | Delete
*
[139] Fix | Delete
* If there are any input parameter errors (out == NULL, n == 0, oid ==
[140] Fix | Delete
* NULL), then a pointer to an empty string is returned, so that the
[141] Fix | Delete
* return value can always be printed.
[142] Fix | Delete
*
[143] Fix | Delete
* @param out the buffer into which the oid string is output.
[144] Fix | Delete
* @param n the size of the out buffer.
[145] Fix | Delete
* @param id the oid structure to format.
[146] Fix | Delete
* @return the out buffer pointer, assuming no input parameter
[147] Fix | Delete
* errors, otherwise a pointer to an empty string.
[148] Fix | Delete
*/
[149] Fix | Delete
GIT_EXTERN(char *) git_oid_tostr(char *out, size_t n, const git_oid *id);
[150] Fix | Delete
[151] Fix | Delete
/**
[152] Fix | Delete
* Copy an oid from one structure to another.
[153] Fix | Delete
*
[154] Fix | Delete
* @param out oid structure the result is written into.
[155] Fix | Delete
* @param src oid structure to copy from.
[156] Fix | Delete
* @return 0 on success or error code
[157] Fix | Delete
*/
[158] Fix | Delete
GIT_EXTERN(int) git_oid_cpy(git_oid *out, const git_oid *src);
[159] Fix | Delete
[160] Fix | Delete
/**
[161] Fix | Delete
* Compare two oid structures.
[162] Fix | Delete
*
[163] Fix | Delete
* @param a first oid structure.
[164] Fix | Delete
* @param b second oid structure.
[165] Fix | Delete
* @return <0, 0, >0 if a < b, a == b, a > b.
[166] Fix | Delete
*/
[167] Fix | Delete
GIT_EXTERN(int) git_oid_cmp(const git_oid *a, const git_oid *b);
[168] Fix | Delete
[169] Fix | Delete
/**
[170] Fix | Delete
* Compare two oid structures for equality
[171] Fix | Delete
*
[172] Fix | Delete
* @param a first oid structure.
[173] Fix | Delete
* @param b second oid structure.
[174] Fix | Delete
* @return true if equal, false otherwise
[175] Fix | Delete
*/
[176] Fix | Delete
GIT_EXTERN(int) git_oid_equal(const git_oid *a, const git_oid *b);
[177] Fix | Delete
[178] Fix | Delete
/**
[179] Fix | Delete
* Compare the first 'len' hexadecimal characters (packets of 4 bits)
[180] Fix | Delete
* of two oid structures.
[181] Fix | Delete
*
[182] Fix | Delete
* @param a first oid structure.
[183] Fix | Delete
* @param b second oid structure.
[184] Fix | Delete
* @param len the number of hex chars to compare
[185] Fix | Delete
* @return 0 in case of a match
[186] Fix | Delete
*/
[187] Fix | Delete
GIT_EXTERN(int) git_oid_ncmp(const git_oid *a, const git_oid *b, size_t len);
[188] Fix | Delete
[189] Fix | Delete
/**
[190] Fix | Delete
* Check if an oid equals an hex formatted object id.
[191] Fix | Delete
*
[192] Fix | Delete
* @param id oid structure.
[193] Fix | Delete
* @param str input hex string of an object id.
[194] Fix | Delete
* @return 0 in case of a match, -1 otherwise.
[195] Fix | Delete
*/
[196] Fix | Delete
GIT_EXTERN(int) git_oid_streq(const git_oid *id, const char *str);
[197] Fix | Delete
[198] Fix | Delete
/**
[199] Fix | Delete
* Compare an oid to an hex formatted object id.
[200] Fix | Delete
*
[201] Fix | Delete
* @param id oid structure.
[202] Fix | Delete
* @param str input hex string of an object id.
[203] Fix | Delete
* @return -1 if str is not valid, <0 if id sorts before str,
[204] Fix | Delete
* 0 if id matches str, >0 if id sorts after str.
[205] Fix | Delete
*/
[206] Fix | Delete
GIT_EXTERN(int) git_oid_strcmp(const git_oid *id, const char *str);
[207] Fix | Delete
[208] Fix | Delete
/**
[209] Fix | Delete
* Check is an oid is all zeros.
[210] Fix | Delete
*
[211] Fix | Delete
* @return 1 if all zeros, 0 otherwise.
[212] Fix | Delete
*/
[213] Fix | Delete
GIT_EXTERN(int) git_oid_is_zero(const git_oid *id);
[214] Fix | Delete
[215] Fix | Delete
/**
[216] Fix | Delete
* OID Shortener object
[217] Fix | Delete
*/
[218] Fix | Delete
typedef struct git_oid_shorten git_oid_shorten;
[219] Fix | Delete
[220] Fix | Delete
/**
[221] Fix | Delete
* Create a new OID shortener.
[222] Fix | Delete
*
[223] Fix | Delete
* The OID shortener is used to process a list of OIDs
[224] Fix | Delete
* in text form and return the shortest length that would
[225] Fix | Delete
* uniquely identify all of them.
[226] Fix | Delete
*
[227] Fix | Delete
* E.g. look at the result of `git log --abbrev`.
[228] Fix | Delete
*
[229] Fix | Delete
* @param min_length The minimal length for all identifiers,
[230] Fix | Delete
* which will be used even if shorter OIDs would still
[231] Fix | Delete
* be unique.
[232] Fix | Delete
* @return a `git_oid_shorten` instance, NULL if OOM
[233] Fix | Delete
*/
[234] Fix | Delete
GIT_EXTERN(git_oid_shorten *) git_oid_shorten_new(size_t min_length);
[235] Fix | Delete
[236] Fix | Delete
/**
[237] Fix | Delete
* Add a new OID to set of shortened OIDs and calculate
[238] Fix | Delete
* the minimal length to uniquely identify all the OIDs in
[239] Fix | Delete
* the set.
[240] Fix | Delete
*
[241] Fix | Delete
* The OID is expected to be a 40-char hexadecimal string.
[242] Fix | Delete
* The OID is owned by the user and will not be modified
[243] Fix | Delete
* or freed.
[244] Fix | Delete
*
[245] Fix | Delete
* For performance reasons, there is a hard-limit of how many
[246] Fix | Delete
* OIDs can be added to a single set (around ~32000, assuming
[247] Fix | Delete
* a mostly randomized distribution), which should be enough
[248] Fix | Delete
* for any kind of program, and keeps the algorithm fast and
[249] Fix | Delete
* memory-efficient.
[250] Fix | Delete
*
[251] Fix | Delete
* Attempting to add more than those OIDs will result in a
[252] Fix | Delete
* GIT_ERROR_INVALID error
[253] Fix | Delete
*
[254] Fix | Delete
* @param os a `git_oid_shorten` instance
[255] Fix | Delete
* @param text_id an OID in text form
[256] Fix | Delete
* @return the minimal length to uniquely identify all OIDs
[257] Fix | Delete
* added so far to the set; or an error code (<0) if an
[258] Fix | Delete
* error occurs.
[259] Fix | Delete
*/
[260] Fix | Delete
GIT_EXTERN(int) git_oid_shorten_add(git_oid_shorten *os, const char *text_id);
[261] Fix | Delete
[262] Fix | Delete
/**
[263] Fix | Delete
* Free an OID shortener instance
[264] Fix | Delete
*
[265] Fix | Delete
* @param os a `git_oid_shorten` instance
[266] Fix | Delete
*/
[267] Fix | Delete
GIT_EXTERN(void) git_oid_shorten_free(git_oid_shorten *os);
[268] Fix | Delete
[269] Fix | Delete
/** @} */
[270] Fix | Delete
GIT_END_DECL
[271] Fix | Delete
#endif
[272] Fix | Delete
[273] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function