Merge branch 'master'
* master: Merge branch 'jc/ls-files-o' count-delta.c: Match the delta data semantics change in version 3. remove delta-against-self bit stat() for existence in safe_create_leading_directories() call git_config() after setup_git_directory() Add --diff-filter= documentation paragraph
This commit is contained in:
commit
3acfbd7cf8
@ -35,6 +35,17 @@
|
||||
-C::
|
||||
Detect copies as well as renames.
|
||||
|
||||
--diff-filter=[ACDMRTUXB*]::
|
||||
Select only files that are Added (`A`), Copied (`C`),
|
||||
Deleted (`D`), Modified (`M`), Renamed (`R`), have their
|
||||
type (mode) changed (`T`), are Unmerged (`U`), are
|
||||
Unknown (`X`), or have had their pairing Broken (`B`).
|
||||
Any combination of the filter characters may be used.
|
||||
When `*` (All-or-none) is added to the combination, all
|
||||
paths are selected if there is any file that matches
|
||||
other criteria in the comparison; if there is no file
|
||||
that matches other criteria, nothing is selected.
|
||||
|
||||
--find-copies-harder::
|
||||
For performance reasons, by default, -C option finds copies only
|
||||
if the original file of the copy was modified in the same
|
||||
|
@ -86,13 +86,13 @@ int main(int argc, char **argv)
|
||||
unsigned int size;
|
||||
|
||||
setup_ident();
|
||||
setup_git_directory();
|
||||
|
||||
git_config(git_default_config);
|
||||
|
||||
if (argc < 2 || get_sha1_hex(argv[1], tree_sha1) < 0)
|
||||
usage(commit_tree_usage);
|
||||
|
||||
setup_git_directory();
|
||||
|
||||
check_valid(tree_sha1, "tree");
|
||||
for (i = 2; i < argc; i += 2) {
|
||||
char *a, *b;
|
||||
|
@ -50,12 +50,9 @@ int count_delta(void *delta_buf, unsigned long delta_size,
|
||||
if (cmd & 0x08) cp_off |= (*data++ << 24);
|
||||
if (cmd & 0x10) cp_size = *data++;
|
||||
if (cmd & 0x20) cp_size |= (*data++ << 8);
|
||||
if (cmd & 0x40) cp_size |= (*data++ << 16);
|
||||
if (cp_size == 0) cp_size = 0x10000;
|
||||
|
||||
if (cmd & 0x40)
|
||||
/* copy from dst */
|
||||
;
|
||||
else
|
||||
copied_from_source += cp_size;
|
||||
out += cp_size;
|
||||
} else {
|
||||
|
@ -68,9 +68,9 @@ static void parse_pack_header(void)
|
||||
hdr = (void *)pack_base;
|
||||
if (hdr->hdr_signature != htonl(PACK_SIGNATURE))
|
||||
die("packfile '%s' signature mismatch", pack_name);
|
||||
if (hdr->hdr_version != htonl(PACK_VERSION))
|
||||
die("packfile '%s' version %d different from ours %d",
|
||||
pack_name, ntohl(hdr->hdr_version), PACK_VERSION);
|
||||
if (!pack_version_ok(hdr->hdr_version))
|
||||
die("packfile '%s' version %d unsupported",
|
||||
pack_name, ntohl(hdr->hdr_version));
|
||||
|
||||
nr_objects = ntohl(hdr->hdr_entries);
|
||||
|
||||
|
@ -16,9 +16,9 @@ static int verify_packfile(struct packed_git *p)
|
||||
hdr = p->pack_base;
|
||||
if (hdr->hdr_signature != htonl(PACK_SIGNATURE))
|
||||
return error("Packfile %s signature mismatch", p->pack_name);
|
||||
if (hdr->hdr_version != htonl(PACK_VERSION))
|
||||
return error("Packfile version %d different from ours %d",
|
||||
ntohl(hdr->hdr_version), PACK_VERSION);
|
||||
if (!pack_version_ok(hdr->hdr_version))
|
||||
return error("Packfile version %d unsupported",
|
||||
ntohl(hdr->hdr_version));
|
||||
nr_objects = ntohl(hdr->hdr_entries);
|
||||
if (num_packed_objects(p) != nr_objects)
|
||||
return error("Packfile claims to have %d objects, "
|
||||
|
1
pack.h
1
pack.h
@ -21,6 +21,7 @@ enum object_type {
|
||||
*/
|
||||
#define PACK_SIGNATURE 0x5041434b /* "PACK" */
|
||||
#define PACK_VERSION 2
|
||||
#define pack_version_ok(v) ((v) == htonl(2) || (v) == htonl(3))
|
||||
struct pack_header {
|
||||
unsigned int hdr_signature;
|
||||
unsigned int hdr_version;
|
||||
|
@ -44,16 +44,15 @@ void *patch_delta(void *src_buf, unsigned long src_size,
|
||||
cmd = *data++;
|
||||
if (cmd & 0x80) {
|
||||
unsigned long cp_off = 0, cp_size = 0;
|
||||
const unsigned char *buf;
|
||||
if (cmd & 0x01) cp_off = *data++;
|
||||
if (cmd & 0x02) cp_off |= (*data++ << 8);
|
||||
if (cmd & 0x04) cp_off |= (*data++ << 16);
|
||||
if (cmd & 0x08) cp_off |= (*data++ << 24);
|
||||
if (cmd & 0x10) cp_size = *data++;
|
||||
if (cmd & 0x20) cp_size |= (*data++ << 8);
|
||||
if (cmd & 0x40) cp_size |= (*data++ << 16);
|
||||
if (cp_size == 0) cp_size = 0x10000;
|
||||
buf = (cmd & 0x40) ? dst_buf : src_buf;
|
||||
memcpy(out, buf + cp_off, cp_size);
|
||||
memcpy(out, src_buf + cp_off, cp_size);
|
||||
out += cp_size;
|
||||
} else {
|
||||
memcpy(out, data, cmd);
|
||||
|
15
sha1_file.c
15
sha1_file.c
@ -6,8 +6,6 @@
|
||||
* This handles basic git sha1 object files - packing, unpacking,
|
||||
* creation etc.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include "cache.h"
|
||||
#include "delta.h"
|
||||
#include "pack.h"
|
||||
@ -74,6 +72,8 @@ int adjust_shared_perm(const char *path)
|
||||
int safe_create_leading_directories(char *path)
|
||||
{
|
||||
char *pos = path;
|
||||
struct stat st;
|
||||
|
||||
if (*pos == '/')
|
||||
pos++;
|
||||
|
||||
@ -82,12 +82,17 @@ int safe_create_leading_directories(char *path)
|
||||
if (!pos)
|
||||
break;
|
||||
*pos = 0;
|
||||
if (mkdir(path, 0777) < 0) {
|
||||
if (errno != EEXIST) {
|
||||
if (!stat(path, &st)) {
|
||||
/* path exists */
|
||||
if (!S_ISDIR(st.st_mode)) {
|
||||
*pos = '/';
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
else if (mkdir(path, 0777)) {
|
||||
*pos = '/';
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (adjust_shared_perm(path)) {
|
||||
*pos = '/';
|
||||
return -2;
|
||||
|
@ -548,8 +548,8 @@ int main(int ac, char **av)
|
||||
int with_current_branch = 0;
|
||||
int head_at = -1;
|
||||
|
||||
git_config(git_show_branch_config);
|
||||
setup_git_directory();
|
||||
git_config(git_show_branch_config);
|
||||
|
||||
/* If nothing is specified, try the default first */
|
||||
if (ac == 1 && default_num) {
|
||||
|
@ -246,13 +246,12 @@ static void unpack_all(void)
|
||||
{
|
||||
int i;
|
||||
struct pack_header *hdr = fill(sizeof(struct pack_header));
|
||||
unsigned version = ntohl(hdr->hdr_version);
|
||||
unsigned nr_objects = ntohl(hdr->hdr_entries);
|
||||
|
||||
if (ntohl(hdr->hdr_signature) != PACK_SIGNATURE)
|
||||
die("bad pack file");
|
||||
if (version != PACK_VERSION)
|
||||
die("unable to handle pack file version %d", version);
|
||||
if (!pack_version_ok(hdr->hdr_version))
|
||||
die("unknown pack file version %d", ntohl(hdr->hdr_version));
|
||||
fprintf(stderr, "Unpacking %d objects\n", nr_objects);
|
||||
|
||||
use(sizeof(struct pack_header));
|
||||
|
Loading…
Reference in New Issue
Block a user