Merge branch 'js/read-tree' into js/c-merge-recursive
authorJunio C Hamano <junkio@cox.net>
Mon, 31 Jul 2006 06:42:10 +0000 (23:42 -0700)
committerJunio C Hamano <junkio@cox.net>
Mon, 31 Jul 2006 06:42:10 +0000 (23:42 -0700)
* js/read-tree: (107 commits)
read-tree: move merge functions to the library
read-trees: refactor the unpack_trees() part
tar-tree: illustrate an obscure feature better
git.c: allow alias expansion without a git directory
setup_git_directory_gently: do not barf when GIT_DIR is given.
Build on Debian GNU/kFreeBSD
Call setup_git_directory() much earlier
Call setup_git_directory() early
Display an error from update-ref if target ref name is invalid.
Fix http-fetch
t4103: fix binary patch application test.
git-apply -R: binary patches are irreversible for now.
Teach git-apply about '-R'
Makefile: ssh-pull.o depends on ssh-fetch.c
log and diff family: honor config even from subdirectories
git-reset: detect update-ref error and report it.
lost-found: use fsck-objects --full
Teach git-http-fetch the --stdin switch
Teach git-local-fetch the --stdin switch
Make pull() support fetching multiple targets at once
...

1  2 
Makefile
cache.h
git-merge.sh
git-rebase.sh
read-cache.c
diff --combined Makefile
index 12ffd45ca9cd9eb70092b4c4637bdd7b616e5372,b2332761babbf75f42dac2994cb371cfd01a9685..b7a095f0dd06791bf95194fbc27922abf1a91a1d
+++ b/Makefile
@@@ -37,6 -37,18 +37,18 @@@ all
  # tests.  These tests take up a significant amount of the total test time
  # but are not needed unless you plan to talk to SVN repos.
  #
+ # Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
+ # installed in /sw, but don't want GIT to link against any libraries
+ # installed there.  If defined you may specify your own (or Fink's)
+ # include directories and library directories by defining CFLAGS
+ # and LDFLAGS appropriately.
+ #
+ # Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
+ # have DarwinPorts installed in /opt/local, but don't want GIT to
+ # link against any libraries installed there.  If defined you may
+ # specify your own (or DarwinPort's) include directories and
+ # library directories by defining CFLAGS and LDFLAGS appropriately.
+ #
  # Define PPC_SHA1 environment variable when running make to make use of
  # a bundled SHA1 routine optimized for PowerPC.
  #
@@@ -104,6 -116,8 +116,8 @@@ template_dir = $(prefix)/share/git-core
  GIT_PYTHON_DIR = $(prefix)/share/git-core/python
  # DESTDIR=
  
+ export prefix bindir gitexecdir template_dir GIT_PYTHON_DIR
  CC = gcc
  AR = ar
  TAR = tar
@@@ -137,7 -151,7 +151,7 @@@ SCRIPT_PERL = 
        git-archimport.perl git-cvsimport.perl git-relink.perl \
        git-shortlog.perl git-rerere.perl \
        git-annotate.perl git-cvsserver.perl \
-       git-svnimport.perl git-mv.perl git-cvsexportcommit.perl \
+       git-svnimport.perl git-cvsexportcommit.perl \
        git-send-email.perl git-svn.perl
  
  SCRIPT_PYTHON = \
@@@ -167,8 -181,7 +181,8 @@@ PROGRAMS = 
        git-upload-pack$X git-verify-pack$X \
        git-symbolic-ref$X \
        git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X \
 -      git-describe$X git-merge-tree$X git-blame$X git-imap-send$X
 +      git-describe$X git-merge-tree$X git-blame$X git-imap-send$X \
 +      git-merge-recur$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-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-fmt-merge-msg$X git-prune$X git-mv$X
  
  # what 'all' will build and 'install' will install, in gitexecdir
  ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
@@@ -208,7 -221,7 +222,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
+       tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h
  
  DIFF_OBJS = \
        diff.o diff-lib.o diffcore-break.o diffcore-order.o \
@@@ -223,7 -236,7 +237,7 @@@ 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 $(DIFF_OBJS)
+       alloc.o merge-file.o path-list.o unpack-trees.o $(DIFF_OBJS)
  
  BUILTIN_OBJS = \
        builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.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-update-ref.o builtin-fmt-merge-msg.o builtin-prune.o \
+       builtin-mv.o
  
  GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
  LIBS = $(GITLIBS) -lz
  ifeq ($(uname_S),Linux)
        NO_STRLCPY = YesPlease
  endif
+ ifeq ($(uname_S),GNU/kFreeBSD)
+       NO_STRLCPY = YesPlease
+ endif
  ifeq ($(uname_S),Darwin)
        NEEDS_SSL_WITH_CRYPTO = YesPlease
        NEEDS_LIBICONV = YesPlease
        NO_STRLCPY = YesPlease
-       ## fink
-       ifeq ($(shell test -d /sw/lib && echo y),y)
-               ALL_CFLAGS += -I/sw/include
-               ALL_LDFLAGS += -L/sw/lib
+       ifndef NO_FINK
+               ifeq ($(shell test -d /sw/lib && echo y),y)
+                       ALL_CFLAGS += -I/sw/include
+                       ALL_LDFLAGS += -L/sw/lib
+               endif
        endif
-       ## darwinports
-       ifeq ($(shell test -d /opt/local/lib && echo y),y)
-               ALL_CFLAGS += -I/opt/local/include
-               ALL_LDFLAGS += -L/opt/local/lib
+       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
+               endif
        endif
  endif
  ifeq ($(uname_S),SunOS)
@@@ -337,6 -356,7 +357,7 @@@ ifneq (,$(findstring arm,$(uname_M))
        ARM_SHA1 = YesPlease
  endif
  
+ -include config.mak.autogen
  -include config.mak
  
  ifdef WITH_OWN_SUBPROCESS_PY
@@@ -562,7 -582,7 +583,7 @@@ git-instaweb: git-instaweb.sh gitweb/gi
            -e '/@@GITWEB_CGI@@/d' \
            -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
            -e '/@@GITWEB_CSS@@/d' \
-           $@.sh > $@+
+           $@.sh | sed "s|/usr/bin/git|$(bindir)/git|" > $@+
        chmod +x $@+
        mv $@+ $@
  
@@@ -599,6 -619,8 +620,8 @@@ $(SIMPLE_PROGRAMS) : git-%$X : %.
        $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
                $(LIB_FILE) $(SIMPLE_LIB)
  
+ ssh-pull.o: ssh-fetch.c
+ ssh-push.o: ssh-upload.c
  git-local-fetch$X: fetch.o
  git-ssh-fetch$X: rsh.o fetch.o
  git-ssh-upload$X: rsh.o
@@@ -616,11 -638,6 +639,11 @@@ git-http-push$X: revision.o http.o http
        $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
                $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
  
 +merge-recursive.o path-list.o: path-list.h
 +git-merge-recur$X: merge-recursive.o path-list.o $(GITLIBS)
 +      $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 +              $(LIBS)
 +
  $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
  $(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
  $(DIFF_OBJS): diffcore.h
@@@ -745,8 -762,8 +768,8 @@@ dist-doc
        rm -fr .doc-tmp-dir
        mkdir .doc-tmp-dir .doc-tmp-dir/man1 .doc-tmp-dir/man7
        $(MAKE) -C Documentation DESTDIR=./ \
-               man1=../.doc-tmp-dir/man1 \
-               man7=../.doc-tmp-dir/man7 \
+               man1dir=../.doc-tmp-dir/man1 \
+               man7dir=../.doc-tmp-dir/man7 \
                install
        cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
        gzip -n -9 -f $(manpages).tar
@@@ -759,6 -776,8 +782,8 @@@ clean
                $(LIB_FILE) $(XDIFF_LIB)
        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 -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
diff --combined cache.h
index 8cc0ccbd0fa81eb72161b77e82f5fda201fdbdd9,c575b8a9962d4eec64e91b1b0df38e60b20df288..7c69b30637406a17fd6ccadcfa58a2a809fba0bb
+++ b/cache.h
@@@ -145,7 -145,6 +145,7 @@@ extern void verify_non_filename(const c
  extern int read_cache(void);
  extern int read_cache_from(const char *path);
  extern int write_cache(int newfd, struct cache_entry **cache, int entries);
 +extern int discard_cache(void);
  extern int verify_path(const char *path);
  extern int cache_name_pos(const char *name, int namelen);
  #define ADD_CACHE_OK_TO_ADD 1         /* Ok to add */
@@@ -155,6 -154,7 +155,7 @@@ extern int add_cache_entry(struct cache
  extern struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really);
  extern int remove_cache_entry_at(int pos);
  extern int remove_file_from_cache(const char *path);
+ extern int add_file_to_index(const char *path, int verbose);
  extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
  extern int ce_match_stat(struct cache_entry *ce, struct stat *st, int);
  extern int ce_modified(struct cache_entry *ce, struct stat *st, int);
@@@ -180,6 -180,7 +181,7 @@@ extern int commit_lock_file(struct lock
  extern void rollback_lock_file(struct lock_file *);
  
  /* Environment bits from configuration mechanism */
+ extern int use_legacy_headers;
  extern int trust_executable_bit;
  extern int assume_unchanged;
  extern int prefer_symlink_refs;
diff --combined git-merge.sh
index 9b681159dcd5e1e22886d101306e496528cb60a4,a9cfafb1dfba6e85834a33caf6b3c69910594bf6..d049e164318a416941334b15699d52f87b00387f
@@@ -9,20 -9,15 +9,20 @@@ USAGE='[-n] [--no-commit] [--squash] [-
  LF='
  '
  
 -all_strategies='recursive octopus resolve stupid ours'
 -default_twohead_strategies='recursive'
 +all_strategies='recursive recur octopus resolve stupid ours'
 +case "${GIT_USE_RECUR_FOR_RECURSIVE}" in
 +'')
 +      default_twohead_strategies=recursive ;;
 +?*)
 +      default_twohead_strategies=recur ;;
 +esac
  default_octopus_strategies='octopus'
  no_trivial_merge_strategies='ours'
  use_strategies=
  
  index_merge=t
  if test "@@NO_PYTHON@@"; then
 -      all_strategies='resolve octopus stupid ours'
 +      all_strategies='recur resolve octopus stupid ours'
        default_twohead_strategies='resolve'
  fi
  
@@@ -63,7 -58,13 +63,13 @@@ squash_message () 
  }
  
  finish () {
-       test '' = "$2" || echo "$2"
+       if test '' = "$2"
+       then
+               rlogm="$rloga"
+       else
+               echo "$2"
+               rlogm="$rloga: $2"
+       fi
        case "$squash" in
        t)
                echo "Squash commit -- not updating HEAD"
@@@ -75,7 -76,7 +81,7 @@@
                        echo "No merge message -- not updating HEAD"
                        ;;
                *)
-                       git-update-ref HEAD "$1" "$head" || exit 1
+                       git-update-ref -m "$rlogm" HEAD "$1" "$head" || exit 1
                        ;;
                esac
                ;;
@@@ -93,6 -94,7 +99,7 @@@
        esac
  }
  
+ rloga=
  while case "$#" in 0) break ;; esac
  do
        case "$1" in
                        strategy="$2"
                        shift ;;
                esac
 +              case "$strategy,${GIT_USE_RECUR_FOR_RECURSIVE}" in
 +              recursive,?*)
 +                      strategy=recur ;;
 +              esac
                case " $all_strategies " in
                *" $strategy "*)
                        use_strategies="$use_strategies$strategy " ;;
                        die "available strategies are: $all_strategies" ;;
                esac
                ;;
+       --reflog-action=*)
+               rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'`
+               ;;
        -*)     usage ;;
        *)      break ;;
        esac
@@@ -140,6 -141,7 +150,7 @@@ shif
  
  # All the rest are remote heads
  test "$#" = 0 && usage ;# we need at least one remote head.
+ test "$rloga" = '' && rloga="merge: $@"
  
  remoteheads=
  for remote
@@@ -325,7 -327,7 +336,7 @@@ if test '' != "$result_tree
  then
      parents=$(git-show-branch --independent "$head" "$@" | sed -e 's/^/-p /')
      result_commit=$(echo "$merge_msg" | git-commit-tree $result_tree $parents) || exit
-     finish "$result_commit" "Merge $result_commit, made by $wt_strategy."
+     finish "$result_commit" "Merge made by $wt_strategy."
      dropsave
      exit 0
  fi
diff --combined git-rebase.sh
index 8c5da7219e760cd7e57b523eb626629727b1d44b,29028dd5fc0669cd2d7d3b956bfdd2583cc785b7..cb1a9ce12c932f532003ee78c965ee7f839bd207
@@@ -35,13 -35,7 +35,13 @@@ If you would prefer to skip this patch
  To restore the original branch and stop rebasing run \"git rebase --abort\".
  "
  unset newbase
 -strategy=recursive
 +case "${GIT_USE_RECUR_FOR_RECURSIVE}" in
 +'')
 +      strategy=recursive ;;
 +?*)
 +      strategy=recur ;;
 +esac
 +
  do_merge=
  dotest=$GIT_DIR/.dotest-merge
  prec=4
@@@ -137,7 -131,8 +137,8 @@@ d
                        finish_rb_merge
                        exit
                fi
-               git am --resolved --3way --resolvemsg="$RESOLVEMSG"
+               git am --resolved --3way --resolvemsg="$RESOLVEMSG" \
+                       --reflog-action=rebase
                exit
                ;;
        --skip)
                        finish_rb_merge
                        exit
                fi
-               git am -3 --skip --resolvemsg="$RESOLVEMSG"
+               git am -3 --skip --resolvemsg="$RESOLVEMSG" \
+                       --reflog-action=rebase
                exit
                ;;
        --abort)
        shift
  done
  
 +case "$strategy,${GIT_USE_RECUR_FOR_RECURSIVE}" in
 +recursive,?*)
 +      strategy=recur ;;
 +esac
 +
  # Make sure we do not have .dotest
  if test -z "$do_merge"
  then
@@@ -299,7 -290,8 +301,8 @@@ f
  if test -z "$do_merge"
  then
        git-format-patch -k --stdout --full-index "$upstream"..ORIG_HEAD |
-       git am --binary -3 -k --resolvemsg="$RESOLVEMSG"
+       git am --binary -3 -k --resolvemsg="$RESOLVEMSG" \
+               --reflog-action=rebase
        exit $?
  fi
  
diff --combined read-cache.c
index 9c0a9fc2a1d8cba09e6f695883bf74b40243e99c,c0b031367bf0d33e535cdfc183da2276577c8011..c375e912a957114fa3473383c6318de185c8aa79
@@@ -319,6 -319,45 +319,45 @@@ int remove_file_from_cache(const char *
        return 0;
  }
  
+ int add_file_to_index(const char *path, int verbose)
+ {
+       int size, namelen;
+       struct stat st;
+       struct cache_entry *ce;
+       if (lstat(path, &st))
+               die("%s: unable to stat (%s)", path, strerror(errno));
+       if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode))
+               die("%s: can only add regular files or symbolic links", path);
+       namelen = strlen(path);
+       size = cache_entry_size(namelen);
+       ce = xcalloc(1, size);
+       memcpy(ce->name, path, namelen);
+       ce->ce_flags = htons(namelen);
+       fill_stat_cache_info(ce, &st);
+       ce->ce_mode = create_ce_mode(st.st_mode);
+       if (!trust_executable_bit) {
+               /* If there is an existing entry, pick the mode bits
+                * from it.
+                */
+               int pos = cache_name_pos(path, namelen);
+               if (pos >= 0)
+                       ce->ce_mode = active_cache[pos]->ce_mode;
+       }
+       if (index_path(ce->sha1, path, &st, 1))
+               die("unable to index file %s", path);
+       if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD))
+               die("unable to add %s to index",path);
+       if (verbose)
+               printf("add '%s'\n", path);
+       cache_tree_invalidate_path(active_cache_tree, path);
+       return 0;
+ }
  int ce_same_name(struct cache_entry *a, struct cache_entry *b)
  {
        int len = ce_namelen(a);
@@@ -797,23 -836,6 +836,23 @@@ unmap
        die("index file corrupt");
  }
  
 +int discard_cache()
 +{
 +      int ret;
 +
 +      if (cache_mmap == NULL)
 +              return 0;
 +      ret = munmap(cache_mmap, cache_mmap_size);
 +      cache_mmap = NULL;
 +      cache_mmap_size = 0;
 +      active_nr = active_cache_changed = 0;
 +      index_file_timestamp = 0;
 +      cache_tree_free(&active_cache_tree);
 +
 +      /* no need to throw away allocated active_cache */
 +      return ret;
 +}
 +
  #define WRITE_BUFFER_SIZE 8192
  static unsigned char write_buffer[WRITE_BUFFER_SIZE];
  static unsigned long write_buffer_len;