Merge branch 'master' into pb/gitpm
authorJunio C Hamano <junkio@cox.net>
Tue, 15 Aug 2006 10:13:34 +0000 (03:13 -0700)
committerJunio C Hamano <junkio@cox.net>
Tue, 15 Aug 2006 10:13:34 +0000 (03:13 -0700)
* master: (166 commits)
git-apply --binary: clean up and prepare for --reverse
Fix detection of ipv6 on Solaris
Look for sockaddr_storage in sys/socket.h
Solaris has strlcpy() at least since version 8
git-apply --reverse: simplify reverse option.
t4116 apply --reverse test
Make sha1flush void and remove conditional return.
Make upload_pack void and remove conditional return.
Make track_tree_refs void.
Make pack_objects void.
Make fsck_dir void.
Make checkout_all void.
Make show_entry void
Make pprint_tag void and cleans up call in cmd_cat_file.
Remove combine-diff.c::uninteresting()
read-cache.c cleanup
http-push.c cleanup
diff.c cleanup
builtin-push.c cleanup
builtin-grep.c cleanup
...

1  2 
INSTALL
Makefile
cache.h
sha1_file.c
sha1_name.c
diff --combined INSTALL
index f8dfa19edb062dd3b5ba857351d5aa8dc3671721,fa9bf74a208697bd4c6cd5c91f3335b2f5475a49..0d432d713f98c41bd1e40c015a31c366a13ad40b
+++ b/INSTALL
@@@ -16,7 -16,7 +16,7 @@@ install" would not work
  Alternatively you can use autoconf generated ./configure script to
  set up install paths (via config.mak.autogen), so you can write instead
  
-       $ autoconf ;# as yourself if ./configure doesn't exist yet
+       $ make configure ;# as yourself
        $ ./configure --prefix=/usr ;# as yourself
        $ make all doc ;# as yourself
        # make install install-doc ;# as root
@@@ -38,19 -38,6 +38,19 @@@ Issues of note
     has been actively developed since 1997, and people have moved over to
     graphical file managers.
  
 + - You can use git after building but without installing if you
 +   wanted to.  Various git commands need to find other git
 +   commands and scripts to do their work, so you would need to
 +   arrange a few environment variables to tell them that their
 +   friends will be found in your built source area instead of at
 +   their standard installation area.  Something like this works
 +   for me:
 +
 +      GIT_EXEC_PATH=`pwd`
 +      PATH=`pwd`:$PATH
 +      GITPERLLIB=`pwd`/perl/blib/lib:`pwd`/perl/blib/arch/auto/Git
 +      export GIT_EXEC_PATH PATH GITPERLLIB
 +
   - Git is reasonably self-sufficient, but does depend on a few external
     programs and libraries:
  
diff --combined Makefile
index 2ab112bbd877e3b84c40b90731ddc97f618c5d43,b86de761ff20d62578f7e397abaf440a2f576eae..ac42ae32bad42536da717810c77fa38901028e63
+++ b/Makefile
@@@ -1,6 -1,11 +1,6 @@@
  # The default target of this Makefile is...
  all:
  
 -# Define MOZILLA_SHA1 environment variable when running make to make use of
 -# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
 -# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
 -# choice) has very fast version optimized for i586.
 -#
  # Define NO_OPENSSL environment variable if you do not have OpenSSL.
  # This also implies MOZILLA_SHA1.
  #
@@@ -22,7 -27,7 +22,7 @@@
  # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
  # do not support the 'size specifiers' introduced by C99, namely ll, hh,
  # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
- # some c compilers supported these specifiers prior to C99 as an extension.
+ # some C compilers supported these specifiers prior to C99 as an extension.
  #
  # Define NO_STRCASESTR if you don't have strcasestr.
  #
  # Define ARM_SHA1 environment variable when running make to make use of
  # a bundled SHA1 routine optimized for ARM.
  #
 +# Define MOZILLA_SHA1 environment variable when running make to make use of
 +# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
 +# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
 +# choice) has very fast version optimized for i586.
 +#
 +# Define USE_PIC if you need the main git objects to be built with -fPIC
 +# in order to build and link perl/Git.so.  x86-64 seems to need this.
 +#
  # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
  #
  # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
  # Define COLLISION_CHECK below if you believe that SHA1's
  # 1461501637330902918203684832716283019655932542976 hashes do not give you
  # sufficient guarantee that no collisions between objects will ever happen.
 -
 +#
  # Define USE_NSEC below if you want git to care about sub-second file mtimes
  # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
  # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
  # randomly break unless your underlying filesystem supports those sub-second
  # times (my ext3 doesn't).
 -
 +#
  # 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.
  
@@@ -115,8 -112,6 +115,8 @@@ CFLAGS = -g -O2 -Wal
  LDFLAGS =
  ALL_CFLAGS = $(CFLAGS)
  ALL_LDFLAGS = $(LDFLAGS)
 +PERL_CFLAGS =
 +PERL_LDFLAGS =
  STRIP ?= strip
  
  prefix = $(HOME)
@@@ -126,6 -121,16 +126,16 @@@ template_dir = $(prefix)/share/git-core
  GIT_PYTHON_DIR = $(prefix)/share/git-core/python
  # DESTDIR=
  
+ # default configuration for gitweb
+ GITWEB_CONFIG = gitweb_config.perl
+ GITWEB_HOME_LINK_STR = projects
+ GITWEB_SITENAME =
+ GITWEB_PROJECTROOT = /pub/git
+ GITWEB_LIST =
+ GITWEB_HOMETEXT = indextext.html
+ GITWEB_CSS = gitweb.css
+ GITWEB_LOGO = git-logo.png
  export prefix bindir gitexecdir template_dir GIT_PYTHON_DIR
  
  CC = gcc
@@@ -142,11 -147,6 +152,11 @@@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__pow
  
  ### --- END CONFIGURATION SECTION ---
  
 +# Those must not be GNU-specific; they are shared with perl/ which may
 +# be built by a different compiler.
 +BASIC_CFLAGS = $(PERL_CFLAGS)
 +BASIC_LDFLAGS = $(PERL_LDFLAGS)
 +
  SCRIPT_SH = \
        git-bisect.sh git-branch.sh git-checkout.sh \
        git-cherry.sh git-clean.sh git-clone.sh git-commit.sh \
@@@ -183,32 -183,23 +193,23 @@@ SIMPLE_PROGRAMS = 
  
  # ... and all the rest that could be moved out of bindir to gitexecdir
  PROGRAMS = \
-       git-checkout-index$X \
        git-convert-objects$X git-fetch-pack$X git-fsck-objects$X \
        git-hash-object$X git-index-pack$X git-local-fetch$X \
        git-merge-base$X \
-       git-merge-index$X git-mktag$X git-mktree$X git-pack-objects$X git-patch-id$X \
+       git-merge-index$X git-mktag$X git-mktree$X git-patch-id$X \
        git-peek-remote$X git-receive-pack$X \
        git-send-pack$X git-shell$X \
        git-show-index$X git-ssh-fetch$X \
        git-ssh-upload$X git-unpack-file$X \
-       git-unpack-objects$X git-update-server-info$X \
+       git-update-server-info$X \
        git-upload-pack$X git-verify-pack$X \
-       git-symbolic-ref$X \
-       git-name-rev$X git-pack-redundant$X git-var$X \
+       git-pack-redundant$X git-var$X \
        git-describe$X git-merge-tree$X git-blame$X git-imap-send$X
  
- BUILT_INS = git-log$X git-whatchanged$X git-show$X git-update-ref$X \
-       git-count-objects$X git-diff$X git-push$X git-mailsplit$X \
-       git-grep$X git-add$X git-rm$X git-rev-list$X git-stripspace$X \
-       git-check-ref-format$X git-rev-parse$X git-mailinfo$X \
-       git-init-db$X git-tar-tree$X git-upload-tar$X git-format-patch$X \
-       git-ls-files$X git-ls-tree$X git-get-tar-commit-id$X \
-       git-read-tree$X git-commit-tree$X git-write-tree$X \
-       git-apply$X git-show-branch$X git-diff-files$X git-update-index$X \
-       git-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X \
-       git-fmt-merge-msg$X git-prune$X git-mv$X git-prune-packed$X \
-       git-repo-config$X
+ BUILT_INS = \
+       git-format-patch$X git-show$X git-whatchanged$X \
+       git-get-tar-commit-id$X \
+       $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
  
  # what 'all' will build and 'install' will install, in gitexecdir
  ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
@@@ -237,7 -228,7 +238,7 @@@ LIB_H = 
        blob.h cache.h commit.h csum-file.h delta.h \
        diff.h object.h pack.h pkt-line.h quote.h refs.h \
        run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
-       tree-walk.h log-tree.h dir.h path-list.h
+       tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h
  
  DIFF_OBJS = \
        diff.o diff-lib.o diffcore-break.o diffcore-order.o \
@@@ -252,23 -243,53 +253,53 @@@ LIB_OBJS = 
        server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
        tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
        fetch-clone.o revision.o pager.o tree-walk.o xdiff-interface.o \
-       alloc.o merge-file.o path-list.o $(DIFF_OBJS)
+       alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS)
  
  BUILTIN_OBJS = \
-       builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \
-       builtin-grep.o builtin-add.o builtin-rev-list.o builtin-check-ref-format.o \
-       builtin-rm.o builtin-init-db.o builtin-rev-parse.o \
-       builtin-tar-tree.o builtin-upload-tar.o builtin-update-index.o \
-       builtin-ls-files.o builtin-ls-tree.o builtin-write-tree.o \
-       builtin-read-tree.o builtin-commit-tree.o builtin-mailinfo.o \
-       builtin-apply.o builtin-show-branch.o builtin-diff-files.o \
-       builtin-diff-index.o builtin-diff-stages.o builtin-diff-tree.o \
-       builtin-cat-file.o builtin-mailsplit.o builtin-stripspace.o \
-       builtin-update-ref.o builtin-fmt-merge-msg.o builtin-prune.o \
-       builtin-mv.o builtin-prune-packed.o builtin-repo-config.o
+       builtin-add.o \
+       builtin-apply.o \
+       builtin-cat-file.o \
+       builtin-checkout-index.o \
+       builtin-check-ref-format.o \
+       builtin-commit-tree.o \
+       builtin-count-objects.o \
+       builtin-diff.o \
+       builtin-diff-files.o \
+       builtin-diff-index.o \
+       builtin-diff-stages.o \
+       builtin-diff-tree.o \
+       builtin-fmt-merge-msg.o \
+       builtin-grep.o \
+       builtin-init-db.o \
+       builtin-log.o \
+       builtin-ls-files.o \
+       builtin-ls-tree.o \
+       builtin-mailinfo.o \
+       builtin-mailsplit.o \
+       builtin-mv.o \
+       builtin-name-rev.o \
+       builtin-pack-objects.o \
+       builtin-prune.o \
+       builtin-prune-packed.o \
+       builtin-push.o \
+       builtin-read-tree.o \
+       builtin-repo-config.o \
+       builtin-rev-list.o \
+       builtin-rev-parse.o \
+       builtin-rm.o \
+       builtin-show-branch.o \
+       builtin-stripspace.o \
+       builtin-symbolic-ref.o \
+       builtin-tar-tree.o \
+       builtin-unpack-objects.o \
+       builtin-update-index.o \
+       builtin-update-ref.o \
+       builtin-upload-tar.o \
+       builtin-verify-pack.o \
+       builtin-write-tree.o
  
  GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
 -LIBS = $(GITLIBS) -lz
 +EXTLIBS = -lz
  
  #
  # Platform specific tweaks
@@@ -290,14 -311,14 +321,14 @@@ ifeq ($(uname_S),Darwin
        NO_STRLCPY = YesPlease
        ifndef NO_FINK
                ifeq ($(shell test -d /sw/lib && echo y),y)
 -                      ALL_CFLAGS += -I/sw/include
 -                      ALL_LDFLAGS += -L/sw/lib
 +                      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)
 -                      ALL_CFLAGS += -I/opt/local/include
 -                      ALL_LDFLAGS += -L/opt/local/lib
 +                      BASIC_CFLAGS += -I/opt/local/include
 +                      BASIC_LDFLAGS += -L/opt/local/lib
                endif
        endif
  endif
@@@ -306,7 -327,6 +337,6 @@@ ifeq ($(uname_S),SunOS
        NEEDS_NSL = YesPlease
        SHELL_PATH = /bin/bash
        NO_STRCASESTR = YesPlease
-       NO_STRLCPY = YesPlease
        ifeq ($(uname_R),5.8)
                NEEDS_LIBICONV = YesPlease
                NO_UNSETENV = YesPlease
        endif
        INSTALL = ginstall
        TAR = gtar
 -      ALL_CFLAGS += -D__EXTENSIONS__
 +      BASIC_CFLAGS += -D__EXTENSIONS__
  endif
  ifeq ($(uname_O),Cygwin)
        NO_D_TYPE_IN_DIRENT = YesPlease
  endif
  ifeq ($(uname_S),FreeBSD)
        NEEDS_LIBICONV = YesPlease
 -      ALL_CFLAGS += -I/usr/local/include
 -      ALL_LDFLAGS += -L/usr/local/lib
 +      BASIC_CFLAGS += -I/usr/local/include
 +      BASIC_LDFLAGS += -L/usr/local/lib
  endif
  ifeq ($(uname_S),OpenBSD)
        NO_STRCASESTR = YesPlease
        NEEDS_LIBICONV = YesPlease
 -      ALL_CFLAGS += -I/usr/local/include
 -      ALL_LDFLAGS += -L/usr/local/lib
 +      BASIC_CFLAGS += -I/usr/local/include
 +      BASIC_LDFLAGS += -L/usr/local/lib
  endif
  ifeq ($(uname_S),NetBSD)
        ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
                NEEDS_LIBICONV = YesPlease
        endif
 -      ALL_CFLAGS += -I/usr/pkg/include
 -      ALL_LDFLAGS += -L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib
 +      BASIC_CFLAGS += -I/usr/pkg/include
 +      BASIC_LDFLAGS += -L/usr/pkg/lib
 +      ALL_LDFLAGS += -Wl,-rpath,/usr/pkg/lib
  endif
  ifeq ($(uname_S),AIX)
        NO_STRCASESTR=YesPlease
@@@ -365,16 -384,13 +395,16 @@@ ifeq ($(uname_S),IRIX64
        NO_STRLCPY = YesPlease
        NO_SOCKADDR_STORAGE=YesPlease
        SHELL_PATH=/usr/gnu/bin/bash
 -      ALL_CFLAGS += -DPATH_MAX=1024
 +      BASIC_CFLAGS += -DPATH_MAX=1024
        # for now, build 32-bit version
 -      ALL_LDFLAGS += -L/usr/lib32
 +      BASIC_LDFLAGS += -L/usr/lib32
  endif
  ifneq (,$(findstring arm,$(uname_M)))
        ARM_SHA1 = YesPlease
  endif
 +ifeq ($(uname_M),x86_64)
 +      USE_PIC = YesPlease
 +endif
  
  -include config.mak.autogen
  -include config.mak
@@@ -392,7 -408,7 +422,7 @@@ endi
  ifndef NO_CURL
        ifdef CURLDIR
                # This is still problematic -- gcc does not always want -R.
 -              ALL_CFLAGS += -I$(CURLDIR)/include
 +              BASIC_CFLAGS += -I$(CURLDIR)/include
                CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
        else
                CURL_LIBCURL = -lcurl
@@@ -413,13 -429,13 +443,13 @@@ ifndef NO_OPENSS
        OPENSSL_LIBSSL = -lssl
        ifdef OPENSSLDIR
                # Again this may be problematic -- gcc does not always want -R.
 -              ALL_CFLAGS += -I$(OPENSSLDIR)/include
 +              BASIC_CFLAGS += -I$(OPENSSLDIR)/include
                OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
        else
                OPENSSL_LINK =
        endif
  else
 -      ALL_CFLAGS += -DNO_OPENSSL
 +      BASIC_CFLAGS += -DNO_OPENSSL
        MOZILLA_SHA1 = 1
        OPENSSL_LIBSSL =
  endif
@@@ -431,32 -447,32 +461,32 @@@ endi
  ifdef NEEDS_LIBICONV
        ifdef ICONVDIR
                # Again this may be problematic -- gcc does not always want -R.
 -              ALL_CFLAGS += -I$(ICONVDIR)/include
 +              BASIC_CFLAGS += -I$(ICONVDIR)/include
                ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
        else
                ICONV_LINK =
        endif
 -      LIBS += $(ICONV_LINK) -liconv
 +      EXTLIBS += $(ICONV_LINK) -liconv
  endif
  ifdef NEEDS_SOCKET
 -      LIBS += -lsocket
 +      EXTLIBS += -lsocket
        SIMPLE_LIB += -lsocket
  endif
  ifdef NEEDS_NSL
 -      LIBS += -lnsl
 +      EXTLIBS += -lnsl
        SIMPLE_LIB += -lnsl
  endif
  ifdef NO_D_TYPE_IN_DIRENT
 -      ALL_CFLAGS += -DNO_D_TYPE_IN_DIRENT
 +      BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
  endif
  ifdef NO_D_INO_IN_DIRENT
 -      ALL_CFLAGS += -DNO_D_INO_IN_DIRENT
 +      BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
  endif
  ifdef NO_C99_FORMAT
        ALL_CFLAGS += -DNO_C99_FORMAT
  endif
  ifdef NO_SYMLINK_HEAD
 -      ALL_CFLAGS += -DNO_SYMLINK_HEAD
 +      BASIC_CFLAGS += -DNO_SYMLINK_HEAD
  endif
  ifdef NO_STRCASESTR
        COMPAT_CFLAGS += -DNO_STRCASESTR
@@@ -479,13 -495,13 +509,13 @@@ ifdef NO_MMA
        COMPAT_OBJS += compat/mmap.o
  endif
  ifdef NO_IPV6
 -      ALL_CFLAGS += -DNO_IPV6
 +      BASIC_CFLAGS += -DNO_IPV6
  endif
  ifdef NO_SOCKADDR_STORAGE
  ifdef NO_IPV6
 -      ALL_CFLAGS += -Dsockaddr_storage=sockaddr_in
 +      BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
  else
 -      ALL_CFLAGS += -Dsockaddr_storage=sockaddr_in6
 +      BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
  endif
  endif
  ifdef NO_INET_NTOP
  endif
  
  ifdef NO_ICONV
 -      ALL_CFLAGS += -DNO_ICONV
 +      BASIC_CFLAGS += -DNO_ICONV
  endif
  
  ifdef PPC_SHA1
@@@ -509,15 -525,12 +539,15 @@@ ifdef MOZILLA_SHA
        LIB_OBJS += mozilla-sha1/sha1.o
  else
        SHA1_HEADER = <openssl/sha.h>
 -      LIBS += $(LIB_4_CRYPTO)
 +      EXTLIBS += $(LIB_4_CRYPTO)
  endif
  endif
  endif
 +ifdef USE_PIC
 +      ALL_CFLAGS += -fPIC
 +endif
  ifdef NO_ACCURATE_DIFF
 -      ALL_CFLAGS += -DNO_ACCURATE_DIFF
 +      BASIC_CFLAGS += -DNO_ACCURATE_DIFF
  endif
  
  # Shell quote (do not use $(call) to accommodate ancient setups);
@@@ -535,23 -548,14 +565,23 @@@ PERL_PATH_SQ = $(subst ','\'',$(PERL_PA
  PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
  GIT_PYTHON_DIR_SQ = $(subst ','\'',$(GIT_PYTHON_DIR))
  
 -ALL_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)
 +LIBS = $(GITLIBS) $(EXTLIBS)
 +
 +BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)
  LIB_OBJS += $(COMPAT_OBJS)
 +
 +ALL_CFLAGS += $(BASIC_CFLAGS)
 +ALL_LDFLAGS += $(BASIC_LDFLAGS)
 +
  export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
 +
 +
  ### Build rules
  
- all: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk
+ all: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk gitweb/gitweb.cgi
  
 -all:
 +all: perl/Makefile
 +      $(MAKE) -C perl
        $(MAKE) -C templates
  
  strip: $(PROGRAMS) git$X
@@@ -562,7 -566,7 +592,7 @@@ git$X: git.c common-cmds.h $(BUILTIN_OB
                $(ALL_CFLAGS) -o $@ $(filter %.c,$^) \
                $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
  
builtin-help.o: common-cmds.h
+ help.o: common-cmds.h
  
  $(BUILT_INS): git$X
        rm -f $@ && ln git$X $@
@@@ -582,18 -586,9 +612,18 @@@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %
        chmod +x $@+
        mv $@+ $@
  
 -$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
 +$(patsubst %.perl,%,$(SCRIPT_PERL)): perl/Makefile
 +$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
        rm -f $@ $@+
 -      sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
 +      INSTLIBDIR=`$(MAKE) -C perl -s --no-print-directory instlibdir` && \
 +      sed -e '1{' \
 +          -e '        s|#!.*perl|#!$(PERL_PATH_SQ)|' \
 +          -e '        h' \
 +          -e '        s=.*=use lib (split(/:/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
 +          -e '        H' \
 +          -e '        x' \
 +          -e '}' \
 +          -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
            $@.perl >$@+
        chmod +x $@+
@@@ -616,6 -611,23 +646,23 @@@ git-status: git-commi
        cp $< $@+
        mv $@+ $@
  
+ gitweb/gitweb.cgi: gitweb/gitweb.perl
+       rm -f $@ $@+
+       sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
+           -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
+           -e 's|++GIT_BINDIR++|$(bindir)|g' \
+           -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
+           -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
+           -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
+           -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
+           -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
+           -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
+           -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
+           -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
+           $< >$@+
+       chmod +x $@+
+       mv $@+ $@
  git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
        rm -f $@ $@+
        sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
            -e '/@@GITWEB_CGI@@/d' \
            -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
            -e '/@@GITWEB_CSS@@/d' \
-           $@.sh | sed "s|/usr/bin/git|$(bindir)/git|" > $@+
+           $@.sh > $@+
        chmod +x $@+
        mv $@+ $@
  
+ configure: configure.ac
+       rm -f $@ $<+
+       sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
+           $< > $<+
+       autoconf -o $@ $<+
+       rm -f $<+
  # These can record GIT_VERSION
  git$X git.spec \
        $(patsubst %.sh,%,$(SCRIPT_SH)) \
@@@ -695,16 -714,6 +749,16 @@@ $(XDIFF_LIB): $(XDIFF_OBJS
        rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)
  
  
 +PERL_DEFINE = $(BASIC_CFLAGS) -DGIT_VERSION='"$(GIT_VERSION)"'
 +PERL_DEFINE_SQ = $(subst ','\'',$(PERL_DEFINE))
 +PERL_LIBS = $(BASIC_LDFLAGS) $(EXTLIBS)
 +PERL_LIBS_SQ = $(subst ','\'',$(PERL_LIBS))
 +perl/Makefile: perl/Git.pm perl/Makefile.PL GIT-CFLAGS
 +      (cd perl && $(PERL_PATH) Makefile.PL \
 +              PREFIX='$(prefix_SQ)' \
 +              DEFINE='$(PERL_DEFINE_SQ)' \
 +              LIBS='$(PERL_LIBS_SQ)')
 +
  doc:
        $(MAKE) -C Documentation all
  
@@@ -767,7 -776,6 +821,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
        $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
        $(INSTALL) $(PYMODULES) '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
        if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
@@@ -832,14 -840,13 +886,15 @@@ clean
        rm -f $(ALL_PROGRAMS) $(BUILT_INS) git$X
        rm -f *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags
        rm -rf autom4te.cache
-       rm -f config.log config.mak.autogen configure config.status config.cache
+       rm -f configure config.log config.mak.autogen config.mak.append config.status config.cache
        rm -rf $(GIT_TARNAME) .doc-tmp-dir
        rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
        rm -f $(htmldocs).tar.gz $(manpages).tar.gz
+       rm -f gitweb/gitweb.cgi
        $(MAKE) -C Documentation/ clean
 -      $(MAKE) -C templates clean
 +      [ ! -f perl/Makefile ] || $(MAKE) -C perl/ clean || $(MAKE) -C perl/ clean
 +      rm -f perl/ppport.h perl/Makefile.old
 +      $(MAKE) -C templates/ clean
        $(MAKE) -C t/ clean
        rm -f GIT-VERSION-FILE GIT-CFLAGS
  
diff --combined cache.h
index ed26b47852722e1c1df65a71df2a4a6aedacdd55,af7740258d8d1bf5e44d2233c1fe1c35aa62ec77..2b8fafbd637fb6c7510c198ac4257c08d290311d
+++ b/cache.h
@@@ -117,9 -117,6 +117,9 @@@ extern unsigned int active_nr, active_a
  extern struct cache_tree *active_cache_tree;
  extern int cache_errno;
  
 +extern void setup_git(char *new_git_dir, char *new_git_object_dir,
 +                      char *new_git_index_file, char *new_git_graft_file);
 +
  #define GIT_DIR_ENVIRONMENT "GIT_DIR"
  #define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
  #define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
@@@ -178,7 -175,7 +178,7 @@@ struct lock_file 
        struct lock_file *next;
        char filename[PATH_MAX];
  };
- extern int hold_lock_file_for_update(struct lock_file *, const char *path);
+ extern int hold_lock_file_for_update(struct lock_file *, const char *path, int);
  extern int commit_lock_file(struct lock_file *);
  extern void rollback_lock_file(struct lock_file *);
  
@@@ -247,6 -244,8 +247,8 @@@ extern int move_temp_to_file(const cha
  
  extern int has_sha1_pack(const unsigned char *sha1);
  extern int has_sha1_file(const unsigned char *sha1);
+ extern void *map_sha1_file(const unsigned char *sha1, unsigned long *);
+ extern int legacy_loose_object(unsigned char *);
  
  extern int has_pack_file(const unsigned char *sha1);
  extern int has_pack_index(const unsigned char *sha1);
diff --combined sha1_file.c
index 8f279d8d2c7a71b7bc436ced68eab0842bff71e8,842a6f3ae86993ff877150ab92bbab7b4744b4ce..ed52d71a1b01a20e61d736568983cb7a9c0d6b39
@@@ -126,22 -126,16 +126,22 @@@ static void fill_sha1_path(char *pathbu
  char *sha1_file_name(const unsigned char *sha1)
  {
        static char *name, *base;
 +      static const char *last_objdir;
 +      const char *sha1_file_directory = get_object_directory();
  
 -      if (!base) {
 -              const char *sha1_file_directory = get_object_directory();
 +      if (!last_objdir || strcmp(last_objdir, sha1_file_directory)) {
                int len = strlen(sha1_file_directory);
 +              if (base)
 +                      free(base);
                base = xmalloc(len + 60);
                memcpy(base, sha1_file_directory, len);
                memset(base+len, 0, 60);
                base[len] = '/';
                base[len+3] = '/';
                name = base + len + 1;
 +              if (last_objdir)
 +                      free((char *) last_objdir);
 +              last_objdir = strdup(sha1_file_directory);
        }
        fill_sha1_path(name, sha1);
        return base;
@@@ -151,20 -145,14 +151,20 @@@ char *sha1_pack_name(const unsigned cha
  {
        static const char hex[] = "0123456789abcdef";
        static char *name, *base, *buf;
 +      static const char *last_objdir;
 +      const char *sha1_file_directory = get_object_directory();
        int i;
  
 -      if (!base) {
 -              const char *sha1_file_directory = get_object_directory();
 +      if (!last_objdir || strcmp(last_objdir, sha1_file_directory)) {
                int len = strlen(sha1_file_directory);
 +              if (base)
 +                      free(base);
                base = xmalloc(len + 60);
                sprintf(base, "%s/pack/pack-1234567890123456789012345678901234567890.pack", sha1_file_directory);
                name = base + len + 11;
 +              if (last_objdir)
 +                      free((char *) last_objdir);
 +              last_objdir = strdup(sha1_file_directory);
        }
  
        buf = name;
@@@ -182,20 -170,14 +182,20 @@@ char *sha1_pack_index_name(const unsign
  {
        static const char hex[] = "0123456789abcdef";
        static char *name, *base, *buf;
 +      static const char *last_objdir;
 +      const char *sha1_file_directory = get_object_directory();
        int i;
  
 -      if (!base) {
 -              const char *sha1_file_directory = get_object_directory();
 +      if (!last_objdir || strcmp(last_objdir, sha1_file_directory)) {
                int len = strlen(sha1_file_directory);
 +              if (base)
 +                      free(base);
                base = xmalloc(len + 60);
                sprintf(base, "%s/pack/pack-1234567890123456789012345678901234567890.idx", sha1_file_directory);
                name = base + len + 11;
 +              if (last_objdir)
 +                      free((char *) last_objdir);
 +              last_objdir = strdup(sha1_file_directory);
        }
  
        buf = name;
@@@ -608,7 -590,7 +608,7 @@@ static void prepare_packed_git_one(cha
                int namelen = strlen(de->d_name);
                struct packed_git *p;
  
-               if (strcmp(de->d_name + namelen - 4, ".idx"))
+               if (!has_extension(de->d_name, ".idx"))
                        continue;
  
                /* we have .idx.  Is it a file we can map? */
@@@ -664,8 -646,7 +664,7 @@@ int check_sha1_signature(const unsigne
        return memcmp(sha1, real_sha1, 20) ? -1 : 0;
  }
  
- static void *map_sha1_file_internal(const unsigned char *sha1,
-                                   unsigned long *size)
+ void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
  {
        struct stat st;
        void *map;
        return map;
  }
  
+ int legacy_loose_object(unsigned char *map)
+ {
+       unsigned int word;
+       /*
+        * Is it a zlib-compressed buffer? If so, the first byte
+        * must be 0x78 (15-bit window size, deflated), and the
+        * first 16-bit word is evenly divisible by 31
+        */
+       word = (map[0] << 8) + map[1];
+       if (map[0] == 0x78 && !(word % 31))
+               return 1;
+       else
+               return 0;
+ }
  static int unpack_sha1_header(z_stream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz)
  {
        unsigned char c;
-       unsigned int word, bits;
+       unsigned int bits;
        unsigned long size;
        static const char *typename[8] = {
                NULL,   /* OBJ_EXT */
        stream->next_out = buffer;
        stream->avail_out = bufsiz;
  
-       /*
-        * Is it a zlib-compressed buffer? If so, the first byte
-        * must be 0x78 (15-bit window size, deflated), and the
-        * first 16-bit word is evenly divisible by 31
-        */
-       word = (map[0] << 8) + map[1];
-       if (map[0] == 0x78 && !(word % 31)) {
+       if (legacy_loose_object(map)) {
                inflateInit(stream);
                return inflate(stream, 0);
        }
@@@ -1264,7 -1255,7 +1273,7 @@@ int sha1_object_info(const unsigned cha
        z_stream stream;
        char hdr[128];
  
-       map = map_sha1_file_internal(sha1, &mapsize);
+       map = map_sha1_file(sha1, &mapsize);
        if (!map) {
                struct pack_entry e;
  
@@@ -1309,7 -1300,7 +1318,7 @@@ void * read_sha1_file(const unsigned ch
  
        if (find_pack_entry(sha1, &e))
                return read_packed_sha1(sha1, type, size);
-       map = map_sha1_file_internal(sha1, &mapsize);
+       map = map_sha1_file(sha1, &mapsize);
        if (map) {
                buf = unpack_sha1_file(map, mapsize, type, size);
                munmap(map, mapsize);
@@@ -1647,7 -1638,7 +1656,7 @@@ int write_sha1_to_fd(int fd, const unsi
  {
        int retval;
        unsigned long objsize;
-       void *buf = map_sha1_file_internal(sha1, &objsize);
+       void *buf = map_sha1_file(sha1, &objsize);
  
        if (buf) {
                retval = write_buffer(fd, buf, objsize);
diff --combined sha1_name.c
index bbb9f1b6ec51f94a44cac4c9f8eb21f6d0679790,c5a05faeb6b2bac74f4c5e06c5e397dc103bb190..ddabb045a23011d0196ba8e2fa6250a7433d201f
@@@ -12,21 -12,15 +12,21 @@@ static int find_short_object_filename(i
        char hex[40];
        int found = 0;
        static struct alternate_object_database *fakeent;
 +      static const char *last_objdir;
 +      const char *objdir = get_object_directory();
  
 -      if (!fakeent) {
 -              const char *objdir = get_object_directory();
 +      if (!last_objdir || strcmp(last_objdir, objdir)) {
                int objdir_len = strlen(objdir);
                int entlen = objdir_len + 43;
 +              if (fakeent)
 +                      free(fakeent);
                fakeent = xmalloc(sizeof(*fakeent) + entlen);
                memcpy(fakeent->base, objdir, objdir_len);
                fakeent->name = fakeent->base + objdir_len + 1;
                fakeent->name[-1] = '/';
 +              if (last_objdir)
 +                      free((char *) last_objdir);
 +              last_objdir = strdup(objdir);
        }
        fakeent->next = alt_odb_list;
  
@@@ -199,7 -193,7 +199,7 @@@ const char *find_unique_abbrev(const un
  
        is_null = !memcmp(sha1, null_sha1, 20);
        memcpy(hex, sha1_to_hex(sha1), 40);
-       if (len == 40)
+       if (len == 40 || !len)
                return hex;
        while (len < 40) {
                unsigned char sha1_ret[20];