Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/imh-pyth.../include/git2
File: blob.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_blob_h__
[6] Fix | Delete
#define INCLUDE_git_blob_h__
[7] Fix | Delete
[8] Fix | Delete
#include "common.h"
[9] Fix | Delete
#include "types.h"
[10] Fix | Delete
#include "oid.h"
[11] Fix | Delete
#include "object.h"
[12] Fix | Delete
#include "buffer.h"
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* @file git2/blob.h
[16] Fix | Delete
* @brief Git blob load and write routines
[17] Fix | Delete
* @defgroup git_blob Git blob load and write routines
[18] Fix | Delete
* @ingroup Git
[19] Fix | Delete
* @{
[20] Fix | Delete
*/
[21] Fix | Delete
GIT_BEGIN_DECL
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Lookup a blob object from a repository.
[25] Fix | Delete
*
[26] Fix | Delete
* @param blob pointer to the looked up blob
[27] Fix | Delete
* @param repo the repo to use when locating the blob.
[28] Fix | Delete
* @param id identity of the blob to locate.
[29] Fix | Delete
* @return 0 or an error code
[30] Fix | Delete
*/
[31] Fix | Delete
GIT_EXTERN(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git_oid *id);
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* Lookup a blob object from a repository,
[35] Fix | Delete
* given a prefix of its identifier (short id).
[36] Fix | Delete
*
[37] Fix | Delete
* @see git_object_lookup_prefix
[38] Fix | Delete
*
[39] Fix | Delete
* @param blob pointer to the looked up blob
[40] Fix | Delete
* @param repo the repo to use when locating the blob.
[41] Fix | Delete
* @param id identity of the blob to locate.
[42] Fix | Delete
* @param len the length of the short identifier
[43] Fix | Delete
* @return 0 or an error code
[44] Fix | Delete
*/
[45] Fix | Delete
GIT_EXTERN(int) git_blob_lookup_prefix(git_blob **blob, git_repository *repo, const git_oid *id, size_t len);
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Close an open blob
[49] Fix | Delete
*
[50] Fix | Delete
* This is a wrapper around git_object_free()
[51] Fix | Delete
*
[52] Fix | Delete
* IMPORTANT:
[53] Fix | Delete
* It *is* necessary to call this method when you stop
[54] Fix | Delete
* using a blob. Failure to do so will cause a memory leak.
[55] Fix | Delete
*
[56] Fix | Delete
* @param blob the blob to close
[57] Fix | Delete
*/
[58] Fix | Delete
GIT_EXTERN(void) git_blob_free(git_blob *blob);
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* Get the id of a blob.
[62] Fix | Delete
*
[63] Fix | Delete
* @param blob a previously loaded blob.
[64] Fix | Delete
* @return SHA1 hash for this blob.
[65] Fix | Delete
*/
[66] Fix | Delete
GIT_EXTERN(const git_oid *) git_blob_id(const git_blob *blob);
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Get the repository that contains the blob.
[70] Fix | Delete
*
[71] Fix | Delete
* @param blob A previously loaded blob.
[72] Fix | Delete
* @return Repository that contains this blob.
[73] Fix | Delete
*/
[74] Fix | Delete
GIT_EXTERN(git_repository *) git_blob_owner(const git_blob *blob);
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* Get a read-only buffer with the raw content of a blob.
[78] Fix | Delete
*
[79] Fix | Delete
* A pointer to the raw content of a blob is returned;
[80] Fix | Delete
* this pointer is owned internally by the object and shall
[81] Fix | Delete
* not be free'd. The pointer may be invalidated at a later
[82] Fix | Delete
* time.
[83] Fix | Delete
*
[84] Fix | Delete
* @param blob pointer to the blob
[85] Fix | Delete
* @return the pointer
[86] Fix | Delete
*/
[87] Fix | Delete
GIT_EXTERN(const void *) git_blob_rawcontent(const git_blob *blob);
[88] Fix | Delete
[89] Fix | Delete
/**
[90] Fix | Delete
* Get the size in bytes of the contents of a blob
[91] Fix | Delete
*
[92] Fix | Delete
* @param blob pointer to the blob
[93] Fix | Delete
* @return size on bytes
[94] Fix | Delete
*/
[95] Fix | Delete
GIT_EXTERN(git_object_size_t) git_blob_rawsize(const git_blob *blob);
[96] Fix | Delete
[97] Fix | Delete
/**
[98] Fix | Delete
* Flags to control the functionality of `git_blob_filter`.
[99] Fix | Delete
*/
[100] Fix | Delete
typedef enum {
[101] Fix | Delete
/** When set, filters will not be applied to binary files. */
[102] Fix | Delete
GIT_BLOB_FILTER_CHECK_FOR_BINARY = (1 << 0),
[103] Fix | Delete
[104] Fix | Delete
/**
[105] Fix | Delete
* When set, filters will not load configuration from the
[106] Fix | Delete
* system-wide `gitattributes` in `/etc` (or system equivalent).
[107] Fix | Delete
*/
[108] Fix | Delete
GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES = (1 << 1),
[109] Fix | Delete
[110] Fix | Delete
/**
[111] Fix | Delete
* When set, filters will be loaded from a `.gitattributes` file
[112] Fix | Delete
* in the HEAD commit.
[113] Fix | Delete
*/
[114] Fix | Delete
GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD = (1 << 2),
[115] Fix | Delete
} git_blob_filter_flag_t;
[116] Fix | Delete
[117] Fix | Delete
/**
[118] Fix | Delete
* The options used when applying filter options to a file.
[119] Fix | Delete
*/
[120] Fix | Delete
typedef struct {
[121] Fix | Delete
int version;
[122] Fix | Delete
[123] Fix | Delete
/** Flags to control the filtering process, see `git_blob_filter_flag_t` above */
[124] Fix | Delete
uint32_t flags;
[125] Fix | Delete
} git_blob_filter_options;
[126] Fix | Delete
[127] Fix | Delete
#define GIT_BLOB_FILTER_OPTIONS_VERSION 1
[128] Fix | Delete
#define GIT_BLOB_FILTER_OPTIONS_INIT {GIT_BLOB_FILTER_OPTIONS_VERSION, GIT_BLOB_FILTER_CHECK_FOR_BINARY}
[129] Fix | Delete
[130] Fix | Delete
/**
[131] Fix | Delete
* Get a buffer with the filtered content of a blob.
[132] Fix | Delete
*
[133] Fix | Delete
* This applies filters as if the blob was being checked out to the
[134] Fix | Delete
* working directory under the specified filename. This may apply
[135] Fix | Delete
* CRLF filtering or other types of changes depending on the file
[136] Fix | Delete
* attributes set for the blob and the content detected in it.
[137] Fix | Delete
*
[138] Fix | Delete
* The output is written into a `git_buf` which the caller must free
[139] Fix | Delete
* when done (via `git_buf_dispose`).
[140] Fix | Delete
*
[141] Fix | Delete
* If no filters need to be applied, then the `out` buffer will just
[142] Fix | Delete
* be populated with a pointer to the raw content of the blob. In
[143] Fix | Delete
* that case, be careful to *not* free the blob until done with the
[144] Fix | Delete
* buffer or copy it into memory you own.
[145] Fix | Delete
*
[146] Fix | Delete
* @param out The git_buf to be filled in
[147] Fix | Delete
* @param blob Pointer to the blob
[148] Fix | Delete
* @param as_path Path used for file attribute lookups, etc.
[149] Fix | Delete
* @param opts Options to use for filtering the blob
[150] Fix | Delete
* @return 0 on success or an error code
[151] Fix | Delete
*/
[152] Fix | Delete
GIT_EXTERN(int) git_blob_filter(
[153] Fix | Delete
git_buf *out,
[154] Fix | Delete
git_blob *blob,
[155] Fix | Delete
const char *as_path,
[156] Fix | Delete
git_blob_filter_options *opts);
[157] Fix | Delete
[158] Fix | Delete
/**
[159] Fix | Delete
* Read a file from the working folder of a repository
[160] Fix | Delete
* and write it to the Object Database as a loose blob
[161] Fix | Delete
*
[162] Fix | Delete
* @param id return the id of the written blob
[163] Fix | Delete
* @param repo repository where the blob will be written.
[164] Fix | Delete
* this repository cannot be bare
[165] Fix | Delete
* @param relative_path file from which the blob will be created,
[166] Fix | Delete
* relative to the repository's working dir
[167] Fix | Delete
* @return 0 or an error code
[168] Fix | Delete
*/
[169] Fix | Delete
GIT_EXTERN(int) git_blob_create_from_workdir(git_oid *id, git_repository *repo, const char *relative_path);
[170] Fix | Delete
[171] Fix | Delete
/**
[172] Fix | Delete
* Read a file from the filesystem and write its content
[173] Fix | Delete
* to the Object Database as a loose blob
[174] Fix | Delete
*
[175] Fix | Delete
* @param id return the id of the written blob
[176] Fix | Delete
* @param repo repository where the blob will be written.
[177] Fix | Delete
* this repository can be bare or not
[178] Fix | Delete
* @param path file from which the blob will be created
[179] Fix | Delete
* @return 0 or an error code
[180] Fix | Delete
*/
[181] Fix | Delete
GIT_EXTERN(int) git_blob_create_from_disk(git_oid *id, git_repository *repo, const char *path);
[182] Fix | Delete
[183] Fix | Delete
/**
[184] Fix | Delete
* Create a stream to write a new blob into the object db
[185] Fix | Delete
*
[186] Fix | Delete
* This function may need to buffer the data on disk and will in
[187] Fix | Delete
* general not be the right choice if you know the size of the data
[188] Fix | Delete
* to write. If you have data in memory, use
[189] Fix | Delete
* `git_blob_create_from_buffer()`. If you do not, but know the size of
[190] Fix | Delete
* the contents (and don't want/need to perform filtering), use
[191] Fix | Delete
* `git_odb_open_wstream()`.
[192] Fix | Delete
*
[193] Fix | Delete
* Don't close this stream yourself but pass it to
[194] Fix | Delete
* `git_blob_create_from_stream_commit()` to commit the write to the
[195] Fix | Delete
* object db and get the object id.
[196] Fix | Delete
*
[197] Fix | Delete
* If the `hintpath` parameter is filled, it will be used to determine
[198] Fix | Delete
* what git filters should be applied to the object before it is written
[199] Fix | Delete
* to the object database.
[200] Fix | Delete
*
[201] Fix | Delete
* @param out the stream into which to write
[202] Fix | Delete
* @param repo Repository where the blob will be written.
[203] Fix | Delete
* This repository can be bare or not.
[204] Fix | Delete
* @param hintpath If not NULL, will be used to select data filters
[205] Fix | Delete
* to apply onto the content of the blob to be created.
[206] Fix | Delete
* @return 0 or error code
[207] Fix | Delete
*/
[208] Fix | Delete
GIT_EXTERN(int) git_blob_create_from_stream(
[209] Fix | Delete
git_writestream **out,
[210] Fix | Delete
git_repository *repo,
[211] Fix | Delete
const char *hintpath);
[212] Fix | Delete
[213] Fix | Delete
/**
[214] Fix | Delete
* Close the stream and write the blob to the object db
[215] Fix | Delete
*
[216] Fix | Delete
* The stream will be closed and freed.
[217] Fix | Delete
*
[218] Fix | Delete
* @param out the id of the new blob
[219] Fix | Delete
* @param stream the stream to close
[220] Fix | Delete
* @return 0 or an error code
[221] Fix | Delete
*/
[222] Fix | Delete
GIT_EXTERN(int) git_blob_create_from_stream_commit(
[223] Fix | Delete
git_oid *out,
[224] Fix | Delete
git_writestream *stream);
[225] Fix | Delete
[226] Fix | Delete
/**
[227] Fix | Delete
* Write an in-memory buffer to the ODB as a blob
[228] Fix | Delete
*
[229] Fix | Delete
* @param id return the id of the written blob
[230] Fix | Delete
* @param repo repository where to blob will be written
[231] Fix | Delete
* @param buffer data to be written into the blob
[232] Fix | Delete
* @param len length of the data
[233] Fix | Delete
* @return 0 or an error code
[234] Fix | Delete
*/
[235] Fix | Delete
GIT_EXTERN(int) git_blob_create_from_buffer(
[236] Fix | Delete
git_oid *id, git_repository *repo, const void *buffer, size_t len);
[237] Fix | Delete
[238] Fix | Delete
/**
[239] Fix | Delete
* Determine if the blob content is most certainly binary or not.
[240] Fix | Delete
*
[241] Fix | Delete
* The heuristic used to guess if a file is binary is taken from core git:
[242] Fix | Delete
* Searching for NUL bytes and looking for a reasonable ratio of printable
[243] Fix | Delete
* to non-printable characters among the first 8000 bytes.
[244] Fix | Delete
*
[245] Fix | Delete
* @param blob The blob which content should be analyzed
[246] Fix | Delete
* @return 1 if the content of the blob is detected
[247] Fix | Delete
* as binary; 0 otherwise.
[248] Fix | Delete
*/
[249] Fix | Delete
GIT_EXTERN(int) git_blob_is_binary(const git_blob *blob);
[250] Fix | Delete
[251] Fix | Delete
/**
[252] Fix | Delete
* Create an in-memory copy of a blob. The copy must be explicitly
[253] Fix | Delete
* free'd or it will leak.
[254] Fix | Delete
*
[255] Fix | Delete
* @param out Pointer to store the copy of the object
[256] Fix | Delete
* @param source Original object to copy
[257] Fix | Delete
*/
[258] Fix | Delete
GIT_EXTERN(int) git_blob_dup(git_blob **out, git_blob *source);
[259] Fix | Delete
[260] Fix | Delete
/** @} */
[261] Fix | Delete
GIT_END_DECL
[262] Fix | Delete
#endif
[263] Fix | Delete
[264] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function