Merge branch 'js/shallow'
authorJunio C Hamano <junkio@cox.net>
Thu, 28 Dec 2006 09:25:43 +0000 (01:25 -0800)
committerJunio C Hamano <junkio@cox.net>
Thu, 28 Dec 2006 09:25:43 +0000 (01:25 -0800)
* js/shallow:
fetch-pack: Do not fetch tags for shallow clones.
get_shallow_commits: Avoid memory leak if a commit has been reached already.
git-fetch: Reset shallow_depth before auto-following tags.
upload-pack: Check for NOT_SHALLOW flag before sending a shallow to the client.
fetch-pack: Properly remove the shallow file when it becomes empty.
shallow clone: unparse and reparse an unshallowed commit
Why didn't we mark want_obj as ~UNINTERESTING in the old code?
Why does it mean we do not have to register shallow if we have one?
We should make sure that the protocol is still extensible.
add tests for shallow stuff
Shallow clone: do not ignore shallowness when following tags
allow deepening of a shallow repository
allow cloning a repository "shallowly"
support fetching into a shallow repository
upload-pack: no longer call rev-list

1  2 
Makefile
git-fetch.sh
diff --combined Makefile
index 775ffaac27d7382df9db84d226603854295045d6,c21b91bfab2e8665be728593c64352137c857fd4..544385f3e38727ab59b531978d63aaf5ee119712
+++ b/Makefile
@@@ -157,7 -157,7 +157,7 @@@ BASIC_LDFLAGS 
  SCRIPT_SH = \
        git-bisect.sh git-checkout.sh \
        git-clean.sh git-clone.sh git-commit.sh \
 -      git-fetch.sh \
 +      git-fetch.sh git-gc.sh \
        git-ls-remote.sh \
        git-merge-one-file.sh git-parse-remote.sh \
        git-pull.sh git-rebase.sh \
@@@ -250,8 -250,7 +250,7 @@@ LIB_OBJS = 
        revision.o pager.o tree-walk.o xdiff-interface.o \
        write_or_die.o trace.o list-objects.o grep.o \
        alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \
-       color.o wt-status.o archive-zip.o archive-tar.o \
-       utf8.o
+       color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o
  
  BUILTIN_OBJS = \
        builtin-add.o \
@@@ -360,8 -359,8 +359,8 @@@ ifeq ($(uname_O),Cygwin
        NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
        # There are conflicting reports about this.
        # On some boxes NO_MMAP is needed, and not so elsewhere.
 -      # Try uncommenting this if you see things break -- YMMV.
 -      NO_MMAP = YesPlease
 +      # Try commenting this out if you suspect MMAP is more efficient
 +      NO_MMAP = YesPlease
        NO_IPV6 = YesPlease
        X = .exe
  endif
diff --combined git-fetch.sh
index 7fb47f69fb89156770919c70b7ac7e6fa75e92e5,5f316053fb9ad146546ed0718cc98b772c48b07f..8bd11f8b60c0ffec8a67f59bc7e12e1f63adfc91
@@@ -4,8 -4,6 +4,8 @@@
  USAGE='<fetch-options> <repository> <refspec>...'
  SUBDIRECTORY_OK=Yes
  . git-sh-setup
 +set_reflog_action "fetch $*"
 +
  TOP=$(git-rev-parse --show-cdup)
  if test ! -z "$TOP"
  then
@@@ -19,6 -17,7 +19,6 @@@ LF=
  '
  IFS="$LF"
  
 -rloga=fetch
  no_tags=
  tags=
  append=
@@@ -28,6 -27,7 +28,7 @@@ update_head_ok
  exec=
  upload_pack=
  keep=
+ shallow_depth=
  while case "$#" in 0) break ;; esac
  do
        case "$1" in
        -k|--k|--ke|--kee|--keep)
                keep='-k -k'
                ;;
 -      --reflog-action=*)
 -              rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'`
 -              ;;
+       --depth=*)
+               shallow_depth="--depth=`expr "z$1" : 'z-[^=]*=\(.*\)'`"
+               ;;
+       --depth)
+               shift
+               shallow_depth="--depth=$1"
+               ;;
        -*)
                usage
                ;;
@@@ -84,6 -94,9 +92,6 @@@ refs
  rref=
  rsync_slurped_objects=
  
 -rloga="$rloga $remote_nick"
 -test "$remote_nick" = "$remote" || rloga="$rloga $remote"
 -
  if test "" = "$append"
  then
        : >"$GIT_DIR/FETCH_HEAD"
@@@ -167,12 -180,12 +175,12 @@@ update_local_ref () 
                else
                        echo >&2 "* $1: updating with $3"
                        echo >&2 "  $label_: $newshort_"
 -                      git-update-ref -m "$rloga: updating tag" "$1" "$2"
 +                      git-update-ref -m "$GIT_REFLOG_ACTION: updating tag" "$1" "$2"
                fi
        else
                echo >&2 "* $1: storing $3"
                echo >&2 "  $label_: $newshort_"
 -              git-update-ref -m "$rloga: storing tag" "$1" "$2"
 +              git-update-ref -m "$GIT_REFLOG_ACTION: storing tag" "$1" "$2"
        fi
        ;;
  
            *,$local)
                echo >&2 "* $1: fast forward to $3"
                echo >&2 "  old..new: $oldshort_..$newshort_"
 -              git-update-ref -m "$rloga: fast-forward" "$1" "$2" "$local"
 +              git-update-ref -m "$GIT_REFLOG_ACTION: fast-forward" "$1" "$2" "$local"
                ;;
            *)
                false
                *,t,*)
                        echo >&2 "* $1: forcing update to non-fast forward $3"
                        echo >&2 "  old...new: $oldshort_...$newshort_"
 -                      git-update-ref -m "$rloga: forced-update" "$1" "$2" "$local"
 +                      git-update-ref -m "$GIT_REFLOG_ACTION: forced-update" "$1" "$2" "$local"
                        ;;
                *)
                        echo >&2 "* $1: not updating to non-fast forward $3"
        else
            echo >&2 "* $1: storing $3"
            echo >&2 "  $label_: $newshort_"
 -          git-update-ref -m "$rloga: storing head" "$1" "$2"
 +          git-update-ref -m "$GIT_REFLOG_ACTION: storing head" "$1" "$2"
        fi
        ;;
      esac
@@@ -300,6 -313,8 +308,8 @@@ fetch_main () 
        # There are transports that can fetch only one head at a time...
        case "$remote" in
        http://* | https://* | ftp://*)
+         test -n "$shallow_depth" &&
+               die "shallow clone with http not supported"
          proto=`expr "$remote" : '\([^:]*\):'`
          if [ -n "$GIT_SSL_NO_VERIFY" ]; then
              curl_extra_args="-k"
          git-http-fetch -v -a "$head" "$remote/" || exit
          ;;
        rsync://*)
+         test -n "$shallow_depth" &&
+               die "shallow clone with rsync not supported"
          TMP_HEAD="$GIT_DIR/TMP_HEAD"
          rsync -L -q "$remote/$remote_name" "$TMP_HEAD" || exit 1
          head=$(git-rev-parse --verify TMP_HEAD)
        pack_lockfile=
        IFS="   $LF"
        (
-         git-fetch-pack --thin $exec $keep "$remote" $rref || echo failed "$remote"
+         git-fetch-pack --thin $exec $keep $shallow_depth "$remote" $rref || echo failed "$remote"
        ) |
        while read sha1 remote_name
        do
@@@ -446,6 -463,8 +458,8 @@@ case "$no_tags$tags" i
        case "$taglist" in
        '') ;;
        ?*)
+               # do not deepen a shallow tree when following tags
+               shallow_depth=
                fetch_main "$taglist" || exit ;;
        esac
  esac
@@@ -460,7 -479,7 +474,7 @@@ case "$orig_head" i
        if test "$curr_head" != "$orig_head"
        then
            git-update-ref \
 -                      -m "$rloga: Undoing incorrectly fetched HEAD." \
 +                      -m "$GIT_REFLOG_ACTION: Undoing incorrectly fetched HEAD." \
                        HEAD "$orig_head"
                die "Cannot fetch into the current branch."
        fi