Merge tag 'ko-next' into next
authorJunio C Hamano <junkio@cox.net>
Sat, 4 Mar 2006 08:39:50 +0000 (00:39 -0800)
committerJunio C Hamano <junkio@cox.net>
Sat, 4 Mar 2006 08:41:39 +0000 (00:41 -0800)
I just rebuilt my 'next' branch from scratch, based on master without
the delta topics that were there. This would rewind the head which is
a no-no. This merges the original 'next' back in, to finish the "reverting"
of these two topic branches.
nothing to commit

Documentation/git-tools.txt [new file with mode: 0644]
count-delta.c
delta.h
diff-delta.c
diffcore.h
git-cvsserver.perl
pack-objects.c
test-delta.c
diff --git a/Documentation/git-tools.txt b/Documentation/git-tools.txt
new file mode 100644 (file)
index 0000000..00e57a6
--- /dev/null
@@ -0,0 +1,97 @@
+A short git tools survey
+========================
+
+
+Introduction
+------------
+
+Apart from git contrib/ area there are some others third-party tools
+you may want to look.
+
+This document presents a brief summary of each tool and the corresponding
+link.
+
+
+Alternative/Augmentative Procelains
+-----------------------------------
+
+   - *Cogito* (http://www.kernel.org/pub/software/scm/cogito/)
+
+   Cogito is a version control system layered on top of the git tree history
+   storage system. It aims at seamless user interface and ease of use,
+   providing generally smoother user experience than the "raw" Core GIT
+   itself and indeed many other version control systems.
+
+
+   - *pg* (http://www.spearce.org/category/projects/scm/pg/)
+
+   pg is a shell script wrapper around GIT to help the user manage a set of
+   patches to files. pg is somewhat like quilt or StGIT, but it does have a
+   slightly different feature set.
+
+
+   - *StGit* (http://www.procode.org/stgit/)
+
+   Stacked GIT provides a quilt-like patch management functionality in the
+    GIT environment. You can easily manage your patches in the scope of GIT
+   until they get merged upstream.
+
+
+History Viewers
+---------------
+
+   - *gitk* (shipped with git-core)
+
+   gitk is a simple TK GUI for browsing history of GIT repositories easily.
+
+
+   - *gitview*  (contrib/)
+
+   gitview is a GTK based repository browser for git
+
+
+   - *gitweb* (ftp://ftp.kernel.org/pub/software/scm/gitweb/)
+
+   GITweb provides full-fledged web interface for GIT repositories.
+
+
+   - *qgit* (http://digilander.libero.it/mcostalba/)
+
+   QGit is a git/StGIT GUI viewer built on Qt/C++. QGit could be used
+   to browse history and directory tree, view annotated files, commit
+   changes cherry picking single files or applying patches.
+   Currently it is the fastest and most feature rich among the git
+   viewers and commit tools.
+
+
+
+Foreign SCM interface
+---------------------
+
+   - *git-svn* (contrib/)
+
+   git-svn is a simple conduit for changesets between a single Subversion
+   branch and git.
+
+
+   - *quilt2git / git2quilt* (http://home-tj.org/wiki/index.php/Misc)
+
+   These utilities convert patch series in a quilt repository and commit
+   series in git back and forth.
+
+
+Others
+------
+
+   - *(h)gct* (http://www.cyd.liu.se/users/~freku045/gct/)
+
+   Commit Tool or (h)gct is a GUI enabled commit tool for git and
+   Mercurial (hg). It allows the user to view diffs, select which files
+   to committed (or ignored / reverted) write commit messages and
+   perform the commit itself.
+
+   - *git.el* (contrib/)
+
+   This is an Emacs interface for git. The user interface is modeled on
+   pcl-cvs. It has been developed on Emacs 21 and will probably need some
+   tweaking to work on XEmacs.
index 3ee3a0ccf1b92f3f8838ca2e728bde9f60d1b8e8..058a2aadb1475801ea7573837867fa79bf1766c1 100644 (file)
@@ -3,74 +3,11 @@
  * The delta-parsing part is almost straight copy of patch-delta.c
  * which is (C) 2005 Nicolas Pitre <nico@cam.org>.
  */
-#include "cache.h"
-#include "delta.h"
-#include "count-delta.h"
 #include <stdlib.h>
 #include <string.h>
 #include <limits.h>
-
-struct span {
-       struct span *next;
-       unsigned long ofs;
-       unsigned long end;
-};
-
-static void touch_range(struct span **span,
-                       unsigned long ofs, unsigned long end)
-{
-       struct span *e = *span;
-       struct span *p = NULL;
-
-       while (e && e->ofs <= ofs) {
-               again:
-               if (ofs < e->end) {
-                       while (e->end < end) {
-                               if (e->next && e->next->ofs <= end) {
-                                       e->end = e->next->ofs;
-                                       e = e->next;
-                               }
-                               else {
-                                       e->end = end;
-                                       return;
-                               }
-                       }
-                       return;
-               }
-               p = e;
-               e = e->next;
-       }
-       if (e && e->ofs <= end) {
-               e->ofs = ofs;
-               goto again;
-       }
-       else {
-               e = xmalloc(sizeof(*e));
-               e->ofs = ofs;
-               e->end = end;
-               if (p) {
-                       e->next = p->next;
-                       p->next = e;
-               }
-               else {
-                       e->next = *span;
-                       *span = e;
-               }
-       }
-}
-
-static unsigned long count_range(struct span *s)
-{
-       struct span *t;
-       unsigned long sz = 0;
-       while (s) {
-               t = s;
-               sz += s->end - s->ofs;
-               s = s->next;
-               free(t);
-       }
-       return sz;
-}
+#include "delta.h"
+#include "count-delta.h"
 
 /*
  * NOTE.  We do not _interpret_ delta fully.  As an approximation, we
@@ -84,11 +21,10 @@ static unsigned long count_range(struct span *s)
 int count_delta(void *delta_buf, unsigned long delta_size,
                unsigned long *src_copied, unsigned long *literal_added)
 {
-       unsigned long added_literal;
+       unsigned long copied_from_source, added_literal;
        const unsigned char *data, *top;
        unsigned char cmd;
        unsigned long src_size, dst_size, out;
-       struct span *span = NULL;
 
        if (delta_size < DELTA_SIZE_MIN)
                return -1;
@@ -99,7 +35,7 @@ int count_delta(void *delta_buf, unsigned long delta_size,
        src_size = get_delta_hdr_size(&data);
        dst_size = get_delta_hdr_size(&data);
 
-       added_literal = out = 0;
+       added_literal = copied_from_source = out = 0;
        while (data < top) {
                cmd = *data++;
                if (cmd & 0x80) {
@@ -113,7 +49,7 @@ int count_delta(void *delta_buf, unsigned long delta_size,
                        if (cmd & 0x40) cp_size |= (*data++ << 16);
                        if (cp_size == 0) cp_size = 0x10000;
 
-                       touch_range(&span, cp_off, cp_off+cp_size);
+                       copied_from_source += cp_size;
                        out += cp_size;
                } else {
                        /* write literal into dst */
@@ -123,8 +59,6 @@ int count_delta(void *delta_buf, unsigned long delta_size,
                }
        }
 
-       *src_copied = count_range(span);
-
        /* sanity check */
        if (data != top || out != dst_size)
                return -1;
@@ -132,6 +66,7 @@ int count_delta(void *delta_buf, unsigned long delta_size,
        /* delete size is what was _not_ copied from source.
         * edit size is that and literal additions.
         */
+       *src_copied = copied_from_source;
        *literal_added = added_literal;
        return 0;
 }
diff --git a/delta.h b/delta.h
index 00fef0b8d739702c6cf664b35679c4897c0ca13f..a15350dabcd497d4cb21261721706eca072de034 100644 (file)
--- a/delta.h
+++ b/delta.h
@@ -4,8 +4,7 @@
 /* handling of delta buffers */
 extern void *diff_delta(void *from_buf, unsigned long from_size,
                        void *to_buf, unsigned long to_size,
-                       unsigned long *delta_size, unsigned long max_size,
-                       void **from_index);
+                       unsigned long *delta_size, unsigned long max_size);
 extern void *patch_delta(void *src_buf, unsigned long src_size,
                         void *delta_buf, unsigned long delta_size,
                         unsigned long *dst_size);
index 676288701ec429805d887cf59e1683652dc70cba..2ed5984b1c360194d53fd287962d7857e19a097c 100644 (file)
 
 #include <stdlib.h>
 #include <string.h>
+#include <zlib.h>
 #include "delta.h"
 
 
+/* block size: min = 16, max = 64k, power of 2 */
+#define BLK_SIZE 16
+
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+
+#define GR_PRIME 0x9e370001
+#define HASH(v, shift) (((unsigned int)(v) * GR_PRIME) >> (shift))
+
 struct index {
        const unsigned char *ptr;
+       unsigned int val;
        struct index *next;
 };
 
 static struct index ** delta_index(const unsigned char *buf,
                                   unsigned long bufsize,
-                                  unsigned long trg_bufsize)
+                                  unsigned int *hash_shift)
 {
-       unsigned long hsize;
-       unsigned int i, hshift, hlimit, *hash_count;
+       unsigned int hsize, hshift, entries, blksize, i;
        const unsigned char *data;
        struct index *entry, **hash;
        void *mem;
 
        /* determine index hash size */
-       hsize = bufsize / 4;
-       for (i = 8; (1 << i) < hsize && i < 24; i += 2);
+       entries = (bufsize + BLK_SIZE - 1) / BLK_SIZE;
+       hsize = entries / 4;
+       for (i = 4; (1 << i) < hsize && i < 16; i++);
        hsize = 1 << i;
-       hshift = (i - 8) / 2;
+       hshift = 32 - i;
+       *hash_shift = hshift;
 
-       /*
-        * Allocate lookup index.  Note the first hash pointer
-        * is used to store the hash shift value.
-        */
-       mem = malloc((1 + hsize) * sizeof(*hash) + bufsize * sizeof(*entry));
+       /* allocate lookup index */
+       mem = malloc(hsize * sizeof(*hash) + entries * sizeof(*entry));
        if (!mem)
                return NULL;
        hash = mem;
-       *hash++ = (void *)hshift;
-       entry = mem + (1 + hsize) * sizeof(*hash);
+       entry = mem + hsize * sizeof(*hash);
        memset(hash, 0, hsize * sizeof(*hash));
 
-       /* allocate an array to count hash entries */
-       hash_count = calloc(hsize, sizeof(*hash_count));
-       if (!hash_count) {
-               free(hash);
-               return NULL;
-       }
-
-       /* then populate the index */
-       data = buf + bufsize - 2;
-       while (data > buf) {
-               entry->ptr = --data;
-               i = data[0] ^ ((data[1] ^ (data[2] << hshift)) << hshift);
+       /* then populate it */
+       data = buf + entries * BLK_SIZE - BLK_SIZE;
+       blksize = bufsize - (data - buf);
+       while (data >= buf) {
+               unsigned int val = adler32(0, data, blksize);
+               i = HASH(val, hshift);
+               entry->ptr = data;
+               entry->val = val;
                entry->next = hash[i];
                hash[i] = entry++;
-               hash_count[i]++;
+               blksize = BLK_SIZE;
+               data -= BLK_SIZE;
        }
 
-       /*
-        * Determine a limit on the number of entries in the same hash
-        * bucket.  This guard us against patological data sets causing
-        * really bad hash distribution with most entries in the same hash
-        * bucket that would bring us to O(m*n) computing costs (m and n
-        * corresponding to reference and target buffer sizes).
-        *
-        * The more the target buffer is large, the more it is important to
-        * have small entry lists for each hash buckets.  With such a limit
-        * the cost is bounded to something more like O(m+n).
-        */
-       hlimit = (1 << 26) / trg_bufsize;
-       if (hlimit < 16)
-               hlimit = 16;
-
-       /*
-        * Now make sure none of the hash buckets has more entries than
-        * we're willing to test.  Otherwise we cull the entry list to
-        * limit identical three byte prefixes to still preserve a good
-        * repartition across the reference buffer.
-        */
-       for (i = 0; i < hsize; i++) {
-               struct index **list, *bucket, *remaining;
-               int cnt;
-               if (hash_count[i] < hlimit)
-                       continue;
-
-               bucket = NULL;
-               list = &bucket;
-               remaining = hash[i];
-               cnt = 0;
-               while (cnt < hlimit && remaining) {
-                       struct index *this = remaining, *that;
-                       remaining = remaining->next;
-                       for (that = bucket; that; that = that->next) {
-                               if (!memcmp(that->ptr, this->ptr, 3))
-                                       break;
-                       }
-                       if (that)
-                               continue; /* discard */
-                       cnt++;
-                       *list = this;
-                       list = &(this->next);
-                       this->next = NULL;
-               }
-               hash[i] = bucket;
-       }
-       free(hash_count);
-
-       return hash-1;
+       return hash;
 }
 
 /* provide the size of the copy opcode given the block offset and size */
@@ -136,8 +91,7 @@ static struct index ** delta_index(const unsigned char *buf,
 void *diff_delta(void *from_buf, unsigned long from_size,
                 void *to_buf, unsigned long to_size,
                 unsigned long *delta_size,
-                unsigned long max_size,
-                void **from_index)
+                unsigned long max_size)
 {
        unsigned int i, outpos, outsize, inscnt, hash_shift;
        const unsigned char *ref_data, *ref_top, *data, *top;
@@ -146,16 +100,9 @@ void *diff_delta(void *from_buf, unsigned long from_size,
 
        if (!from_size || !to_size)
                return NULL;
-       if (from_index && *from_index) {
-               hash = *from_index;
-       } else {
-               hash = delta_index(from_buf, from_size, to_size);
-               if (!hash)
-                       return NULL;
-               if (from_index)
-                       *from_index = hash;
-       }
-       hash_shift = (unsigned int)(*hash++);
+       hash = delta_index(from_buf, from_size, &hash_shift);
+       if (!hash)
+               return NULL;
 
        outpos = 0;
        outsize = 8192;
@@ -163,8 +110,7 @@ void *diff_delta(void *from_buf, unsigned long from_size,
                outsize = max_size + MAX_OP_SIZE + 1;
        out = malloc(outsize);
        if (!out) {
-               if (!from_index)
-                       free(hash-1);
+               free(hash);
                return NULL;
        }
 
@@ -195,25 +141,29 @@ void *diff_delta(void *from_buf, unsigned long from_size,
 
        while (data < top) {
                unsigned int moff = 0, msize = 0;
-               if (data + 3 <= top) {
-                       i = data[0] ^ ((data[1] ^ (data[2] << hash_shift)) << hash_shift);
-                       for (entry = hash[i]; entry; entry = entry->next) {
-                               const unsigned char *ref = entry->ptr;
-                               const unsigned char *src = data;
-                               unsigned int ref_size = ref_top - ref;
-                               if (ref_size > top - src)
-                                       ref_size = top - src;
-                               if (ref_size > 0x10000)
-                                       ref_size = 0x10000;
-                               if (ref_size <= msize)
+               unsigned int blksize = MIN(top - data, BLK_SIZE);
+               unsigned int val = adler32(0, data, blksize);
+               i = HASH(val, hash_shift);
+               for (entry = hash[i]; entry; entry = entry->next) {
+                       const unsigned char *ref = entry->ptr;
+                       const unsigned char *src = data;
+                       unsigned int ref_size = ref_top - ref;
+                       if (entry->val != val)
+                               continue;
+                       if (ref_size > top - src)
+                               ref_size = top - src;
+                       while (ref_size && *src++ == *ref) {
+                               ref++;
+                               ref_size--;
+                       }
+                       ref_size = ref - entry->ptr;
+                       if (ref_size > msize) {
+                               /* this is our best match so far */
+                               moff = entry->ptr - ref_data;
+                               msize = ref_size;
+                               if (msize >= 0x10000) {
+                                       msize = 0x10000;
                                        break;
-                               if (*ref != *src)
-                                       continue;
-                               while (ref_size-- && *++src == *++ref);
-                               if (msize < ref - entry->ptr) {
-                                       /* this is our best match so far */
-                                       msize = ref - entry->ptr;
-                                       moff = entry->ptr - ref_data;
                                }
                        }
                }
@@ -265,8 +215,7 @@ void *diff_delta(void *from_buf, unsigned long from_size,
                                out = realloc(out, outsize);
                        if (!out) {
                                free(tmp);
-                               if (!from_index)
-                                       free(hash-1);
+                               free(hash);
                                return NULL;
                        }
                }
@@ -275,8 +224,7 @@ void *diff_delta(void *from_buf, unsigned long from_size,
        if (inscnt)
                out[outpos - inscnt - 1] = inscnt;
 
-       if (!from_index)
-               free(hash-1);
+       free(hash);
        *delta_size = outpos;
        return out;
 }
index 7f9889daf375a0c310fddefeffa0bad5f4d1393c..dba4f17658e6b3b7e1853ca024f8cfe9eae9c92e 100644 (file)
@@ -18,7 +18,7 @@
 #define MAX_SCORE 60000.0
 #define DEFAULT_RENAME_SCORE 30000 /* rename/copy similarity minimum (50%) */
 #define DEFAULT_BREAK_SCORE  30000 /* minimum for break to happen (50%)*/
-#define DEFAULT_MERGE_SCORE  45000 /* maximum for break-merge to happen (75%)*/
+#define DEFAULT_MERGE_SCORE  48000 /* maximum for break-merge to happen (80%)*/
 
 #define MINIMUM_BREAK_SIZE     400 /* do not break a file smaller than this */
 
index b45079246a5328c1f69905de84e1128459a63bf8..7d3f78e375066c27f0881a92c23fda8d5c8d6dff 100755 (executable)
 my $TEMP_DIR = tempdir( CLEANUP => 1 );
 $log->debug("Temporary directory is '$TEMP_DIR'");
 
+# if we are called with a pserver argument,
+# deal with the authentication cat before entereing the
+# main loop
+if (@ARGV && $ARGV[0] eq 'pserver') {
+    my $line = <STDIN>; chomp $line;
+    unless( $line eq 'BEGIN AUTH REQUEST') {
+       die "E Do not understand $line - expecting BEGIN AUTH REQUEST\n";
+    }
+    $line = <STDIN>; chomp $line;
+    req_Root('root', $line) # reuse Root
+       or die "E Invalid root $line \n";
+    $line = <STDIN>; chomp $line;
+    unless ($line eq 'anonymous') {
+       print "E Only anonymous user allowed via pserver\n";
+       print "I HATE YOU\n";
+    }
+    $line = <STDIN>; chomp $line;    # validate the password?
+    $line = <STDIN>; chomp $line;
+    unless ($line eq 'END AUTH REQUEST') {
+       die "E Do not understand $line -- expecting END AUTH REQUEST\n";
+    }
+    print "I LOVE YOU\n";
+    # and now back to our regular programme...
+}
+
 # Keep going until the client closes the connection
 while (<STDIN>)
 {
@@ -165,6 +190,7 @@ sub req_Root
         print "E the repo config file needs a [gitcvs] section added, and the parameter 'enabled' set to 1\n";
         print "E \n";
         print "error 1 GITCVS emulation disabled\n";
+        return 0;
     }
 
     if ( defined ( $cfg->{gitcvs}{logfile} ) )
@@ -173,6 +199,8 @@ sub req_Root
     } else {
         $log->nofile();
     }
+
+    return 1;
 }
 
 # Global_option option \n
@@ -914,6 +942,12 @@ sub req_ci
 
     $log->info("req_ci : " . ( defined($data) ? $data : "[NULL]" ));
 
+    if ( @ARGV && $ARGV[0] eq 'pserver')
+    {
+        print "error 1 pserver access cannot commit\n";
+        exit;
+    }
+
     if ( -e $state->{CVSROOT} . "/index" )
     {
         print "error 1 Index already exists in git repo\n";
index d6a3463604bf3e61d8cf8b7d55947c229def8f07..136a7f5aad61e8a90866ee7d0b4bc22e387f0396 100644 (file)
@@ -204,7 +204,7 @@ static void *delta_against(void *buf, unsigned long size, struct object_entry *e
        if (!otherbuf)
                die("unable to read %s", sha1_to_hex(entry->delta->sha1));
         delta_buf = diff_delta(otherbuf, othersize,
-                              buf, size, &delta_size, 0, NULL);
+                              buf, size, &delta_size, 0);
         if (!delta_buf || delta_size != entry->delta_size)
                die("delta size changed");
         free(buf);
@@ -810,7 +810,6 @@ static int type_size_sort(const struct object_entry *a, const struct object_entr
 struct unpacked {
        struct object_entry *entry;
        void *data;
-       void **delta_index;
 };
 
 /*
@@ -892,8 +891,7 @@ static int try_delta(struct unpacked *cur, struct unpacked *old, unsigned max_de
        if (sizediff >= max_size)
                return -1;
        delta_buf = diff_delta(old->data, oldsize,
-                              cur->data, size, &delta_size,
-                              max_size, old->delta_index);
+                              cur->data, size, &delta_size, max_size);
        if (!delta_buf)
                return 0;
        cur_entry->delta = old_entry;
@@ -950,7 +948,6 @@ static void find_deltas(struct object_entry **list, int window, int depth)
                         */
                        continue;
 
-               free(n->delta_index);
                free(n->data);
                n->entry = entry;
                n->data = read_sha1_file(entry->sha1, type, &size);
@@ -977,10 +974,8 @@ static void find_deltas(struct object_entry **list, int window, int depth)
        if (progress)
                fputc('\n', stderr);
 
-       for (i = 0; i < window; ++i) {
-               free(array[i].delta_index);
+       for (i = 0; i < window; ++i)
                free(array[i].data);
-       }
        free(array);
 }
 
index 89eb68ed21545e4001c08dd21b5e907e22b979bb..1be8ee0c721ec35372fee4e686d9664b143b4345 100644 (file)
@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
        if (argv[1][1] == 'd')
                out_buf = diff_delta(from_buf, from_size,
                                     data_buf, data_size,
-                                    &out_size, 0, NULL);
+                                    &out_size, 0);
        else
                out_buf = patch_delta(from_buf, from_size,
                                      data_buf, data_size,