mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-28 06:35:27 -05:00
The Git project is not exactly the easiest project to get started in: it's written in C and POSIX shell, with bits of Perl, Rust and other languages sprinkled into it. On top of that, the project has grown somewhat organically over time, making the codebase hard to navigate. These are problems that we're aware of, and there have been and still are efforts to clean up some of the technical debt that is natural to exist an a project that is more than 20 years old. Furthermore, we provide resources to newcomers that help them out like our coding guidelines, code of conduct or "MyFirstContribution.adoc". But there is a rather practical problem: finding your way around in our project's tree is not easy. Doing a directory listing in the top-level directory will present you with more than 550 files, which makes it extremely hard for a newcomer to figure out what files they are even supposed to look at. This makes the onboarding experience somewhat harder than it really needs to be. This isn't only a problem for newcomers though, as I myself struggle to find the files I am looking for because of the sheer number of files. Besides the problem of discoverability it also creates a problem of structure. It is not obvious at all which files are part of "libgit.a" and which files are only linked into our final executables. So while we have this split in our build systems, that split is not evident at all in our tree. Introduce a new "lib/" directory and move all of our sources for "libgit.a" into it to fix these issues. It makes the split we have evident and reduces the number of files in our top-level tree from 550 files to ~80 files. This is still a lot of files, but it's significantly easier to navigate already. Furthermore, we can further iterate after this step and think about introducing a better structure for remaining files, as well. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
98 lines
2.9 KiB
C
98 lines
2.9 KiB
C
/*
|
|
* Copyright (c) 2011, Google Inc.
|
|
*/
|
|
#ifndef STREAMING_H
|
|
#define STREAMING_H 1
|
|
|
|
#include "object.h"
|
|
#include "odb.h"
|
|
|
|
struct object_database;
|
|
struct odb_read_stream;
|
|
struct stream_filter;
|
|
|
|
typedef int (*odb_read_stream_close_fn)(struct odb_read_stream *);
|
|
typedef ssize_t (*odb_read_stream_read_fn)(struct odb_read_stream *, char *, size_t);
|
|
|
|
/*
|
|
* A stream that can be used to read an object from the object database without
|
|
* loading all of it into memory.
|
|
*/
|
|
struct odb_read_stream {
|
|
odb_read_stream_close_fn close;
|
|
odb_read_stream_read_fn read;
|
|
enum object_type type;
|
|
size_t size; /* inflated size of full object */
|
|
};
|
|
|
|
/*
|
|
* Create a new object stream for the given object database. An optional filter
|
|
* can be used to transform the object's content.
|
|
*
|
|
* Returns the stream on success, a `NULL` pointer otherwise.
|
|
*/
|
|
struct odb_read_stream *odb_read_stream_open(struct object_database *odb,
|
|
const struct object_id *oid,
|
|
struct stream_filter *filter);
|
|
|
|
/*
|
|
* Close the given read stream and release all resources associated with it.
|
|
* Returns 0 on success, a negative error code otherwise.
|
|
*/
|
|
int odb_read_stream_close(struct odb_read_stream *stream);
|
|
|
|
/*
|
|
* Read data from the stream into the buffer. Returns 0 on EOF and the number
|
|
* of bytes read on success. Returns a negative error code in case reading from
|
|
* the stream fails.
|
|
*/
|
|
ssize_t odb_read_stream_read(struct odb_read_stream *stream, void *buf, size_t len);
|
|
|
|
/*
|
|
* A stream that provides an object to be written to the object database without
|
|
* loading all of it into memory.
|
|
*/
|
|
struct odb_write_stream {
|
|
ssize_t (*read)(struct odb_write_stream *, unsigned char *, size_t);
|
|
void *data;
|
|
int is_finished;
|
|
};
|
|
|
|
/*
|
|
* Read data from the stream into the buffer. Returns 0 when finished and the
|
|
* number of bytes read on success. Returns a negative error code in case
|
|
* reading from the stream fails.
|
|
*/
|
|
ssize_t odb_write_stream_read(struct odb_write_stream *stream, void *buf,
|
|
size_t len);
|
|
|
|
/*
|
|
* Releases memory allocated for underlying stream data.
|
|
*/
|
|
void odb_write_stream_release(struct odb_write_stream *stream);
|
|
|
|
/*
|
|
* Look up the object by its ID and write the full contents to the file
|
|
* descriptor. The object must be a blob, or the function will fail. When
|
|
* provided, the filter is used to transform the blob contents.
|
|
*
|
|
* `can_seek` should be set to 1 in case the given file descriptor can be
|
|
* seek(3p)'d on. This is used to support files with holes in case a
|
|
* significant portion of the blob contains NUL bytes.
|
|
*
|
|
* Returns a negative error code on failure, 0 on success.
|
|
*/
|
|
int odb_stream_blob_to_fd(struct object_database *odb,
|
|
int fd,
|
|
const struct object_id *oid,
|
|
struct stream_filter *filter,
|
|
int can_seek);
|
|
|
|
/*
|
|
* Sets up an ODB write stream that reads from an fd.
|
|
*/
|
|
void odb_write_stream_from_fd(struct odb_write_stream *stream, int fd,
|
|
size_t size);
|
|
|
|
#endif /* STREAMING_H */
|