Merge branch 'jc/ls-files-o'
authorJunio C Hamano <junkio@cox.net>
Fri, 10 Feb 2006 06:19:07 +0000 (22:19 -0800)
committerJunio C Hamano <junkio@cox.net>
Fri, 10 Feb 2006 06:19:07 +0000 (22:19 -0800)
* jc/ls-files-o:
  ls-files: honour per-directory ignore file from higher directories.

Documentation/diff-options.txt
commit-tree.c
count-delta.c
index-pack.c
pack-check.c
pack.h
patch-delta.c
sha1_file.c
show-branch.c
unpack-objects.c

index 5c85167..2a0275e 100644 (file)
 -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 
index 4634b50..b1c8dca 100644 (file)
@@ -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;
index 7559ff6..978a60c 100644 (file)
@@ -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 */
index 541d7bc..babe34b 100644 (file)
@@ -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);
 
index 511f294..67a7ecd 100644 (file)
@@ -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 657deaa..9dafa2b 100644 (file)
--- 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;
index 98c27be..c0e1311 100644 (file)
@@ -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);
index 20f6419..3d11a9b 100644 (file)
@@ -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 -1;
+                               return -3;
                        }
                }
+               else if (mkdir(path, 0777)) {
+                       *pos = '/';
+                       return -1;
+               }
                else if (adjust_shared_perm(path)) {
                        *pos = '/';
                        return -2;
index ffe7456..511fd3b 100644 (file)
@@ -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) {
index 4b5b5cb..815a1b3 100644 (file)
@@ -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));