diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 5c85167ff2..2a0275eeda 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -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 diff --git a/commit-tree.c b/commit-tree.c index 4634b50e6a..b1c8dca48d 100644 --- a/commit-tree.c +++ b/commit-tree.c @@ -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; diff --git a/count-delta.c b/count-delta.c index 7559ff68b1..978a60ca9d 100644 --- a/count-delta.c +++ b/count-delta.c @@ -50,13 +50,10 @@ 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; + copied_from_source += cp_size; out += cp_size; } else { /* write literal into dst */ diff --git a/index-pack.c b/index-pack.c index 541d7bc1c1..babe34b2db 100644 --- a/index-pack.c +++ b/index-pack.c @@ -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); diff --git a/pack-check.c b/pack-check.c index 511f29424a..67a7ecdf16 100644 --- a/pack-check.c +++ b/pack-check.c @@ -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, " diff --git a/pack.h b/pack.h index 657deaa3f4..9dafa2b6d2 100644 --- a/pack.h +++ b/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; diff --git a/patch-delta.c b/patch-delta.c index 98c27beb25..c0e1311435 100644 --- a/patch-delta.c +++ b/patch-delta.c @@ -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); diff --git a/sha1_file.c b/sha1_file.c index 20f6419bde..3d11a9bfdc 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -6,8 +6,6 @@ * This handles basic git sha1 object files - packing, unpacking, * creation etc. */ -#include -#include #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 -1; + return -3; } } + else if (mkdir(path, 0777)) { + *pos = '/'; + return -1; + } else if (adjust_shared_perm(path)) { *pos = '/'; return -2; diff --git a/show-branch.c b/show-branch.c index ffe7456a6a..511fd3b656 100644 --- a/show-branch.c +++ b/show-branch.c @@ -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) { diff --git a/unpack-objects.c b/unpack-objects.c index 4b5b5cb3e2..815a1b382b 100644 --- a/unpack-objects.c +++ b/unpack-objects.c @@ -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));