Merge branch 'master' into js/merge
authorJunio C Hamano <junkio@cox.net>
Wed, 13 Dec 2006 05:52:19 +0000 (21:52 -0800)
committerJunio C Hamano <junkio@cox.net>
Wed, 13 Dec 2006 05:52:19 +0000 (21:52 -0800)
* master: (42 commits)
git-svn: correctly handle packed-refs in refs/remotes/
add test case for recursive merge
git-svn: correctly display fatal() error messages
git-svn: allow dcommit to take an alternate head
git-svn: enable logging of information not supported by git
Clarify fetch error for missing objects.
Move Fink and Ports check to after config file
shortlog: fix segfault on empty authorname
shortlog: remove "[PATCH]" prefix from shortlog output
Make sure the empty tree exists when needed in merge-recursive.
Don't use memcpy when source and dest. buffers may overlap
no need to install manpages as executable
Documentation: simpler shared repository creation
shortlog: fix segfault on empty authorname
Add branch.*.merge warning and documentation update
Fix perl/ build.
git-svn: use do_switch for --follow-parent if the SVN library supports it
Fix documentation copy&paste typo
git-svn: extra error check to ensure we open a file correctly
Documentation: update git-clone man page with new behavior
...

1  2 
Makefile
git-cvsserver.perl
merge-recursive.c
diff --combined Makefile
index 79cb91feec2ff3a95438fb622f350cb2f965682d,906e98492080d2fde9467a9970fc92d7a8cfeaf8..2d17fa702795ca08a8ffc3aeaf6393b300401e33
+++ b/Makefile
@@@ -91,6 -91,10 +91,10 @@@ all
  #
  # Define USE_STDEV below if you want git to care about the underlying device
  # change being considered an inode change from the update-cache perspective.
+ #
+ # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
+ # MakeMaker (e.g. using ActiveState under Cygwin).
+ #
  
  GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
        @$(SHELL_PATH) ./GIT-VERSION-GEN
@@@ -275,7 -279,6 +279,7 @@@ BUILTIN_OBJS = 
        builtin-ls-tree.o \
        builtin-mailinfo.o \
        builtin-mailsplit.o \
 +      builtin-merge-file.o \
        builtin-mv.o \
        builtin-name-rev.o \
        builtin-pack-objects.o \
@@@ -323,18 -326,6 +327,6 @@@ ifeq ($(uname_S),Darwin
        NEEDS_SSL_WITH_CRYPTO = YesPlease
        NEEDS_LIBICONV = YesPlease
        NO_STRLCPY = YesPlease
-       ifndef NO_FINK
-               ifeq ($(shell test -d /sw/lib && echo y),y)
-                       BASIC_CFLAGS += -I/sw/include
-                       BASIC_LDFLAGS += -L/sw/lib
-               endif
-       endif
-       ifndef NO_DARWIN_PORTS
-               ifeq ($(shell test -d /opt/local/lib && echo y),y)
-                       BASIC_CFLAGS += -I/opt/local/include
-                       BASIC_LDFLAGS += -L/opt/local/lib
-               endif
-       endif
  endif
  ifeq ($(uname_S),SunOS)
        NEEDS_SOCKET = YesPlease
@@@ -412,6 -403,21 +404,21 @@@ endi
  -include config.mak.autogen
  -include config.mak
  
+ ifeq ($(uname_S),Darwin)
+       ifndef NO_FINK
+               ifeq ($(shell test -d /sw/lib && echo y),y)
+                       BASIC_CFLAGS += -I/sw/include
+                       BASIC_LDFLAGS += -L/sw/lib
+               endif
+       endif
+       ifndef NO_DARWIN_PORTS
+               ifeq ($(shell test -d /opt/local/lib && echo y),y)
+                       BASIC_CFLAGS += -I/opt/local/include
+                       BASIC_LDFLAGS += -L/opt/local/lib
+               endif
+       endif
+ endif
  ifndef NO_CURL
        ifdef CURLDIR
                # This is still problematic -- gcc does not always want -R.
@@@ -540,6 -546,9 +547,9 @@@ endi
  ifdef NO_ACCURATE_DIFF
        BASIC_CFLAGS += -DNO_ACCURATE_DIFF
  endif
+ ifdef NO_PERL_MAKEMAKER
+       export NO_PERL_MAKEMAKER
+ endif
  
  # Shell quote (do not use $(call) to accommodate ancient setups);
  
@@@ -569,8 -578,8 +579,8 @@@ export prefix TAR INSTALL DESTDIR SHELL
  
  all: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk gitweb/gitweb.cgi
  
- all: perl/Makefile
-       $(MAKE) -C perl
+ all:
+       $(MAKE) -C perl PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
        $(MAKE) -C templates
  
  strip: $(PROGRAMS) git$X
@@@ -603,7 -612,11 +613,11 @@@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %
        chmod +x $@+
        mv $@+ $@
  
- $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/Makefile
+ $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
+ perl/perl.mak: GIT-CFLAGS
+       $(MAKE) -C perl PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
  $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
        rm -f $@ $@+
        INSTLIBDIR=`$(MAKE) -C perl -s --no-print-directory instlibdir` && \
@@@ -724,8 -737,7 +738,8 @@@ $(DIFF_OBJS): diffcore.
  $(LIB_FILE): $(LIB_OBJS)
        rm -f $@ && $(AR) rcs $@ $(LIB_OBJS)
  
 -XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o
 +XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 +      xdiff/xmerge.o
  $(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
        xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
  
@@@ -798,7 -810,7 +812,7 @@@ install: al
        $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
        $(INSTALL) git$X gitk '$(DESTDIR_SQ)$(bindir_SQ)'
        $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
-       $(MAKE) -C perl install
+       $(MAKE) -C perl prefix='$(prefix_SQ)' install
        if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
        then \
                ln -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
@@@ -868,8 -880,7 +882,7 @@@ clean
        rm -f $(htmldocs).tar.gz $(manpages).tar.gz
        rm -f gitweb/gitweb.cgi
        $(MAKE) -C Documentation/ clean
-       [ ! -f perl/Makefile ] || $(MAKE) -C perl/ clean || $(MAKE) -C perl/ clean
-       rm -f perl/ppport.h perl/Makefile.old
+       $(MAKE) -C perl clean
        $(MAKE) -C templates/ clean
        $(MAKE) -C t/ clean
        rm -f GIT-VERSION-FILE GIT-CFLAGS
diff --combined git-cvsserver.perl
index 55ff83b1a3fd90d030129aa83135889296476d27,197014d9e6cdf3285005262a9e53804860e489c7..2a8447e2534e93b4cec4e86c2dcbadfede99208a
@@@ -17,6 -17,7 +17,7 @@@
  
  use strict;
  use warnings;
+ use bytes;
  
  use Fcntl;
  use File::Temp qw/tempdir tempfile/;
@@@ -945,7 -946,7 +946,7 @@@ sub req_updat
  
              $log->debug("Temporary directory for merge is $dir");
  
 -            my $return = system("merge", $file_local, $file_old, $file_new);
 +            my $return = system("git merge-file", $file_local, $file_old, $file_new);
              $return >>= 8;
  
              if ( $return == 0 )
diff --combined merge-recursive.c
index 6e13b8ed5b7988f6379003242654a34b3ded6da6,32e186c15e7dcdaff99f09a7edcf50a691c7ee74..9d53bcd5d626834f103ddcff2b59767579e69051
@@@ -21,7 -21,6 +21,7 @@@
  #include "tag.h"
  #include "unpack-trees.h"
  #include "path-list.h"
 +#include "xdiff-interface.h"
  
  /*
   * A virtual commit has
@@@ -605,15 -604,24 +605,15 @@@ struct merge_file_inf
                 merge:1;
  };
  
 -static char *git_unpack_file(const unsigned char *sha1, char *path)
 +static void fill_mm(const unsigned char *sha1, mmfile_t *mm)
  {
 -      void *buf;
 -      char type[20];
        unsigned long size;
 -      int fd;
 +      char type[20];
  
 -      buf = read_sha1_file(sha1, type, &size);
 -      if (!buf || strcmp(type, blob_type))
 +      mm->ptr = read_sha1_file(sha1, type, &size);
 +      if (!mm->ptr || strcmp(type, blob_type))
                die("unable to read blob object %s", sha1_to_hex(sha1));
 -
 -      strcpy(path, ".merge_file_XXXXXX");
 -      fd = mkstemp(path);
 -      if (fd < 0)
 -              die("unable to create temp-file");
 -      flush_buffer(fd, buf, size);
 -      close(fd);
 -      return path;
 +      mm->size = size;
  }
  
  static struct merge_file_info merge_file(struct diff_filespec *o,
                else if (sha_eq(b->sha1, o->sha1))
                        hashcpy(result.sha, a->sha1);
                else if (S_ISREG(a->mode)) {
 -                      int code = 1, fd;
 -                      struct stat st;
 -                      char orig[PATH_MAX];
 -                      char src1[PATH_MAX];
 -                      char src2[PATH_MAX];
 -                      const char *argv[] = {
 -                              "merge", "-L", NULL, "-L", NULL, "-L", NULL,
 -                              NULL, NULL, NULL,
 -                              NULL
 -                      };
 -                      char *la, *lb, *lo;
 -
 -                      git_unpack_file(o->sha1, orig);
 -                      git_unpack_file(a->sha1, src1);
 -                      git_unpack_file(b->sha1, src2);
 -
 -                      argv[2] = la = xstrdup(mkpath("%s/%s", branch1, a->path));
 -                      argv[6] = lb = xstrdup(mkpath("%s/%s", branch2, b->path));
 -                      argv[4] = lo = xstrdup(mkpath("orig/%s", o->path));
 -                      argv[7] = src1;
 -                      argv[8] = orig;
 -                      argv[9] = src2,
 -
 -                      code = run_command_v(10, argv);
 -
 -                      free(la);
 -                      free(lb);
 -                      free(lo);
 -                      if (code && code < -256) {
 -                              die("Failed to execute 'merge'. merge(1) is used as the "
 -                                  "file-level merge tool. Is 'merge' in your path?");
 -                      }
 -                      fd = open(src1, O_RDONLY);
 -                      if (fd < 0 || fstat(fd, &st) < 0 ||
 -                                      index_fd(result.sha, fd, &st, 1,
 -                                              "blob"))
 -                              die("Unable to add %s to database", src1);
 -
 -                      unlink(orig);
 -                      unlink(src1);
 -                      unlink(src2);
 -
 -                      result.clean = WEXITSTATUS(code) == 0;
 +                      mmfile_t orig, src1, src2;
 +                      mmbuffer_t result_buf;
 +                      xpparam_t xpp;
 +                      char *name1, *name2;
 +                      int merge_status;
 +
 +                      name1 = xstrdup(mkpath("%s/%s", branch1, a->path));
 +                      name2 = xstrdup(mkpath("%s/%s", branch2, b->path));
 +
 +                      fill_mm(o->sha1, &orig);
 +                      fill_mm(a->sha1, &src1);
 +                      fill_mm(b->sha1, &src2);
 +
 +                      memset(&xpp, 0, sizeof(xpp));
 +                      merge_status = xdl_merge(&orig,
 +                                               &src1, name1,
 +                                               &src2, name2,
 +                                               &xpp, XDL_MERGE_ZEALOUS,
 +                                               &result_buf);
 +                      free(name1);
 +                      free(name2);
 +                      free(orig.ptr);
 +                      free(src1.ptr);
 +                      free(src2.ptr);
 +
 +                      if ((merge_status < 0) || !result_buf.ptr)
 +                              die("Failed to execute internal merge");
 +
 +                      if (write_sha1_file(result_buf.ptr, result_buf.size,
 +                                          blob_type, result.sha))
 +                              die("Unable to add %s to database",
 +                                  a->path);
 +
 +                      free(result_buf.ptr);
 +                      result.clean = (merge_status == 0);
                } else {
                        if (!(S_ISLNK(a->mode) || S_ISLNK(b->mode)))
                                die("cannot merge modes?");
@@@ -1222,7 -1238,7 +1222,7 @@@ static int merge(struct commit *h1
  
                tree->object.parsed = 1;
                tree->object.type = OBJ_TREE;
-               hash_sha1_file(NULL, 0, tree_type, tree->object.sha1);
+               write_sha1_file(NULL, 0, tree_type, tree->object.sha1);
                merged_common_ancestors = make_virtual_commit(tree, "ancestor");
        }