Staging
v0.5.2
v0.5.2
https://github.com/git/git
Revision 7ac4f3a007e2567f9d2492806186aa063f9a08d6 authored by Jeff King on 02 May 2018, 19:44:51 UTC, committed by Jeff King on 22 May 2018, 03:55:12 UTC
Because fscking a blob has always been a noop, we didn't bother passing around the blob data. In preparation for content-level checks, let's fix up a few things: 1. The fsck_object() function just returns success for any blob. Let's a noop fsck_blob(), which we can fill in with actual logic later. 2. The fsck_loose() function in builtin/fsck.c just threw away blob content after loading it. Let's hold onto it until after we've called fsck_object(). The easiest way to do this is to just drop the parse_loose_object() helper entirely. Incidentally, this also fixes a memory leak: if we successfully loaded the object data but did not parse it, we would have left the function without freeing it. 3. When fsck_loose() loads the object data, it does so with a custom read_loose_object() helper. This function streams any blobs, regardless of size, under the assumption that we're only checking the sha1. Instead, let's actually load blobs smaller than big_file_threshold, as the normal object-reading code-paths would do. This lets us fsck small files, and a NULL return is an indication that the blob was so big that it needed to be streamed, and we can pass that information along to fsck_blob(). Signed-off-by: Jeff King <peff@peff.net>
1 parent ed9c322
Tip revision: 7ac4f3a007e2567f9d2492806186aa063f9a08d6 authored by Jeff King on 02 May 2018, 19:44:51 UTC
fsck: actually fsck blob data
fsck: actually fsck blob data
Tip revision: 7ac4f3a
sub-process.h
#ifndef SUBPROCESS_H
#define SUBPROCESS_H
#include "git-compat-util.h"
#include "hashmap.h"
#include "run-command.h"
/*
* The sub-process API makes it possible to run background sub-processes
* for the entire lifetime of a Git invocation. If Git needs to communicate
* with an external process multiple times, then this can reduces the process
* invocation overhead. Git and the sub-process communicate through stdin and
* stdout.
*
* The sub-processes are kept in a hashmap by command name and looked up
* via the subprocess_find_entry function. If an existing instance can not
* be found then a new process should be created and started. When the
* parent git command terminates, all sub-processes are also terminated.
*
* This API is based on the run-command API.
*/
/* data structures */
/* Members should not be accessed directly. */
struct subprocess_entry {
struct hashmap_entry ent; /* must be the first member! */
const char *cmd;
struct child_process process;
};
struct subprocess_capability {
const char *name;
/*
* subprocess_handshake will "|=" this value to supported_capabilities
* if the server reports that it supports this capability.
*/
unsigned int flag;
};
/* subprocess functions */
/* Function to test two subprocess hashmap entries for equality. */
extern int cmd2process_cmp(const void *unused_cmp_data,
const void *e1,
const void *e2,
const void *unused_keydata);
/*
* User-supplied function to initialize the sub-process. This is
* typically used to negotiate the interface version and capabilities.
*/
typedef int(*subprocess_start_fn)(struct subprocess_entry *entry);
/* Start a subprocess and add it to the subprocess hashmap. */
int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, const char *cmd,
subprocess_start_fn startfn);
/* Kill a subprocess and remove it from the subprocess hashmap. */
void subprocess_stop(struct hashmap *hashmap, struct subprocess_entry *entry);
/* Find a subprocess in the subprocess hashmap. */
struct subprocess_entry *subprocess_find_entry(struct hashmap *hashmap, const char *cmd);
/* subprocess helper functions */
/* Get the underlying `struct child_process` from a subprocess. */
static inline struct child_process *subprocess_get_child_process(
struct subprocess_entry *entry)
{
return &entry->process;
}
/*
* Perform the version and capability negotiation as described in the
* "Handshake" section of long-running-process-protocol.txt using the
* given requested versions and capabilities. The "versions" and "capabilities"
* parameters are arrays terminated by a 0 or blank struct.
*
* This function is typically called when a subprocess is started (as part of
* the "startfn" passed to subprocess_start).
*/
int subprocess_handshake(struct subprocess_entry *entry,
const char *welcome_prefix,
int *versions,
int *chosen_version,
struct subprocess_capability *capabilities,
unsigned int *supported_capabilities);
/*
* Helper function that will read packets looking for "status=<foo>"
* key/value pairs and return the value from the last "status" packet
*/
int subprocess_read_status(int fd, struct strbuf *status);
#endif
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...