From 147cf31738e5e66aa304897ede6b556d4e204967 Mon Sep 17 00:00:00 2001 From: Jon Loeliger Date: Thu, 9 Feb 2006 09:12:11 -0600 Subject: [PATCH 1/5] Add --diff-filter= documentation paragraph Signed-off-by: Jon Loeliger Signed-off-by: Junio C Hamano --- Documentation/diff-options.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 From ce1610ead63221738225c415300f3d32620ced04 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 9 Feb 2006 14:41:39 -0800 Subject: [PATCH 2/5] call git_config() after setup_git_directory() If you call setup_git_directory() to work from a subdirectory, that should be run first before running git_config(). Otherwise you would not read the configuration file from the correct place. Signed-off-by: Junio C Hamano --- commit-tree.c | 4 ++-- show-branch.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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/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) { From 67d42212ff104aaafa97b943cb369b8444f61581 Mon Sep 17 00:00:00 2001 From: Jason Riedy Date: Thu, 9 Feb 2006 17:56:13 -0800 Subject: [PATCH 3/5] stat() for existence in safe_create_leading_directories() Use stat() to explicitly check for existence rather than relying on the non-portable EEXIST error in sha1_file.c's safe_create_leading_directories(). There certainly are optimizations possible, but then the code becomes almost the same as that in coreutil's lib/mkdir-p.c. Other uses of EEXIST seem ok. Tested on Solaris 8, AIX 5.2L, and a few Linux versions. AIX has some unrelated (I think) failures right now; I haven't tried many recent gits there. Anyone have an old Ultrix box to break everything? ;) Also remove extraneous #includes. Everything's already in git-compat-util.h, included through cache.h. Signed-off-by: Jason Riedy Signed-off-by: Junio C Hamano --- sha1_file.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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; From d60fc1c8649f80c006b9f493c542461e81608d4b Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Thu, 9 Feb 2006 17:50:04 -0500 Subject: [PATCH 4/5] remove delta-against-self bit After experimenting with code to add the ability to encode a delta against part of the deltified file, it turns out that resulting packs are _bigger_ than when this ability is not used. The raw delta output might be smaller, but it doesn't compress as well using gzip with a negative net saving on average. Said bit would in fact be more useful to allow for encoding the copying of chunks larger than 64KB providing more savings with large files. This will correspond to packs version 3. While the current code still produces packs version 2, it is made future proof so pack versions 2 and 3 are accepted. Any pack version 2 are compatible with version 3 since the redefined bit was never used before. When enough time has passed, code to use that bit to produce version 3 packs could be added. Signed-off-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- index-pack.c | 6 +++--- pack-check.c | 6 +++--- pack.h | 1 + patch-delta.c | 5 ++--- unpack-objects.c | 5 ++--- 5 files changed, 11 insertions(+), 12 deletions(-) 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/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)); From 91c7674371c101766242b52ea1880cd919cb3075 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 9 Feb 2006 17:15:59 -0800 Subject: [PATCH 5/5] count-delta.c: Match the delta data semantics change in version 3. This matches the count_delta() logic to the change previous commit introduces to patch_delta(). Signed-off-by: Junio C Hamano --- count-delta.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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 */