Merge branch 'np/types' into jc/fetch
authorJunio C Hamano <junkio@cox.net>
Tue, 27 Feb 2007 10:27:26 +0000 (02:27 -0800)
committerJunio C Hamano <junkio@cox.net>
Tue, 27 Feb 2007 10:27:26 +0000 (02:27 -0800)
* np/types: (253 commits)
get rid of lookup_object_type()
convert object type handling from a string to a number
formalize typename(), and add its reverse type_from_string()
sha1_file.c: don't ignore an error condition in sha1_loose_object_info()
sha1_file.c: cleanup "offset" usage
sha1_file.c: cleanup hdr usage
git-apply: do not fix whitespaces on context lines.
diff --cc: integer overflow given a 2GB-or-larger file
mailinfo: do not get confused with logical lines that are too long.
Documentation: link in 1.5.0.2 material to the top documentation page.
Documentation: document remote.<name>.tagopt
GIT 1.5.0.2
git-remote: support remotes with a dot in the name
Documentation: describe "-f/-t/-m" options to "git-remote add"
diff --cc: fix display of symlink conflicts during a merge.
merge-recursive: fix longstanding bug in merging symlinks
merge-index: fix longstanding bug in merging symlinks
diff --cached: give more sensible error message when HEAD is yet to be created.
Update tests to use test-chmtime
Add test-chmtime: a utility to change mtime on files
...

1  2 
Makefile
builtin.h
git-fetch.sh
git.c
diff --combined Makefile
index 181ad942796b2d77ba01fd9da84de218285d0484,8a42be9babb04a2a9f6eb0fba24a5fc8b5fe59a1..9f20f842215364744809b03ab5bfa9506931e94a
+++ b/Makefile
@@@ -28,6 -28,10 +28,10 @@@ all:
  #
  # Define NO_STRLCPY if you don't have strlcpy.
  #
+ # Define NO_STRTOUMAX if you don't have strtoumax in the C library.
+ # If your compiler also does not support long long or does not have
+ # strtoull, define NO_STRTOULL.
+ #
  # Define NO_SETENV if you don't have setenv in the C library.
  #
  # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
@@@ -124,6 -128,7 +128,7 @@@ prefix = $(HOME
  bindir = $(prefix)/bin
  gitexecdir = $(bindir)
  template_dir = $(prefix)/share/git-core/templates/
+ ETC_GITCONFIG = $(prefix)/etc/gitconfig
  # DESTDIR=
  
  # default configuration for gitweb
@@@ -172,7 -177,7 +177,7 @@@ SCRIPT_SH = 
        git-merge-one-file.sh git-parse-remote.sh \
        git-pull.sh git-rebase.sh \
        git-repack.sh git-request-pull.sh git-reset.sh \
-       git-resolve.sh git-revert.sh git-sh-setup.sh \
+       git-revert.sh git-sh-setup.sh \
        git-tag.sh git-verify-tag.sh \
        git-applymbox.sh git-applypatch.sh git-am.sh \
        git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
@@@ -262,7 -267,8 +267,8 @@@ 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 shallow.o utf8.o
+       color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \
+       convert.o
  
  BUILTIN_OBJS = \
        builtin-add.o \
        builtin-diff.o \
        builtin-diff-files.o \
        builtin-diff-index.o \
-       builtin-diff-stages.o \
        builtin-diff-tree.o \
 +      builtin-fetch--tool.o \
        builtin-fmt-merge-msg.o \
        builtin-for-each-ref.o \
        builtin-fsck.o \
        builtin-ls-tree.o \
        builtin-mailinfo.o \
        builtin-mailsplit.o \
+       builtin-merge-base.o \
        builtin-merge-file.o \
        builtin-mv.o \
        builtin-name-rev.o \
@@@ -354,11 -359,13 +360,13 @@@ ifeq ($(uname_S),SunOS
                NO_UNSETENV = YesPlease
                NO_SETENV = YesPlease
                NO_C99_FORMAT = YesPlease
+               NO_STRTOUMAX = YesPlease
        endif
        ifeq ($(uname_R),5.9)
                NO_UNSETENV = YesPlease
                NO_SETENV = YesPlease
                NO_C99_FORMAT = YesPlease
+               NO_STRTOUMAX = YesPlease
        endif
        INSTALL = ginstall
        TAR = gtar
@@@ -518,6 -525,13 +526,13 @@@ ifdef NO_STRLCP
        COMPAT_CFLAGS += -DNO_STRLCPY
        COMPAT_OBJS += compat/strlcpy.o
  endif
+ ifdef NO_STRTOUMAX
+       COMPAT_CFLAGS += -DNO_STRTOUMAX
+       COMPAT_OBJS += compat/strtoumax.o
+ endif
+ ifdef NO_STRTOULL
+       COMPAT_CFLAGS += -DNO_STRTOULL
+ endif
  ifdef NO_SETENV
        COMPAT_CFLAGS += -DNO_SETENV
        COMPAT_OBJS += compat/setenv.o
@@@ -585,6 -599,7 +600,7 @@@ endi
  # Shell quote (do not use $(call) to accommodate ancient setups);
  
  SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
+ ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
  
  DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
  bindir_SQ = $(subst ','\'',$(bindir))
@@@ -597,7 -612,8 +613,8 @@@ PERL_PATH_SQ = $(subst ','\'',$(PERL_PA
  
  LIBS = $(GITLIBS) $(EXTLIBS)
  
- BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)
+ BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
+       -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' $(COMPAT_CFLAGS)
  LIB_OBJS += $(COMPAT_OBJS)
  
  ALL_CFLAGS += $(BASIC_CFLAGS)
@@@ -813,7 -829,7 +830,7 @@@ GIT-CFLAGS: .FORCE-GIT-CFLAG
  
  export NO_SVN_TESTS
  
- test: all
+ test: all test-chmtime$X
        $(MAKE) -C t/ all
  
  test-date$X: test-date.c date.o ctype.o
@@@ -828,6 -844,9 +845,9 @@@ test-dump-cache-tree$X: dump-cache-tree
  test-sha1$X: test-sha1.o $(GITLIBS)
        $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
  
+ test-chmtime$X: test-chmtime.c
+       $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $<
  check-sha1:: test-sha1$X
        ./test-sha1.sh
  
@@@ -883,7 -902,8 +903,8 @@@ dist: git.spec git-archiv
        $(TAR) rf $(GIT_TARNAME).tar \
                $(GIT_TARNAME)/git.spec \
                $(GIT_TARNAME)/version \
-               $(GIT_TARNAME)/git-gui/version
+               $(GIT_TARNAME)/git-gui/version \
+               $(GIT_TARNAME)/git-gui/credits
        @rm -rf $(GIT_TARNAME)
        gzip -f -9 $(GIT_TARNAME).tar
  
@@@ -940,11 -960,14 +961,14 @@@ check-docs:
                case "$$v" in \
                git-merge-octopus | git-merge-ours | git-merge-recursive | \
                git-merge-resolve | git-merge-stupid | \
+               git-add--interactive | git-fsck-objects | git-init-db | \
+               git-repo-config | \
                git-ssh-pull | git-ssh-push ) continue ;; \
                esac ; \
                test -f "Documentation/$$v.txt" || \
                echo "no doc: $$v"; \
-               grep -q "^gitlink:$$v\[[0-9]\]::" Documentation/git.txt || \
+               sed -e '1,/^__DATA__/d' Documentation/cmd-list.perl | \
+               grep -q "^$$v[  ]" || \
                case "$$v" in \
                git) ;; \
                *) echo "no link: $$v";; \
diff --combined builtin.h
index 3cad4028d2da4092bc9f7b2526e025b482d57fdf,57e8741ff0569a349a48e386fae2664fe474a546..9a25b79f87ee1b1b6944ecd2030126c1aff88539
+++ b/builtin.h
@@@ -29,9 -29,7 +29,8 @@@ extern int cmd_describe(int argc, cons
  extern int cmd_diff_files(int argc, const char **argv, const char *prefix);
  extern int cmd_diff_index(int argc, const char **argv, const char *prefix);
  extern int cmd_diff(int argc, const char **argv, const char *prefix);
- extern int cmd_diff_stages(int argc, const char **argv, const char *prefix);
  extern int cmd_diff_tree(int argc, const char **argv, const char *prefix);
 +extern int cmd_fetch__tool(int argc, const char **argv, const char *prefix);
  extern int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix);
  extern int cmd_for_each_ref(int argc, const char **argv, const char *prefix);
  extern int cmd_format_patch(int argc, const char **argv, const char *prefix);
@@@ -46,6 -44,7 +45,7 @@@ extern int cmd_ls_files(int argc, cons
  extern int cmd_ls_tree(int argc, const char **argv, const char *prefix);
  extern int cmd_mailinfo(int argc, const char **argv, const char *prefix);
  extern int cmd_mailsplit(int argc, const char **argv, const char *prefix);
+ extern int cmd_merge_base(int argc, const char **argv, const char *prefix);
  extern int cmd_merge_file(int argc, const char **argv, const char *prefix);
  extern int cmd_mv(int argc, const char **argv, const char *prefix);
  extern int cmd_name_rev(int argc, const char **argv, const char *prefix);
diff --combined git-fetch.sh
index f875e0f99ee2138bdbbd617fb8572699b36dff3c,d230995f6e3033456b670fa60b8a392dbc8dd08f..f438ac1ef2351e902980e5a896d84b693589d430
@@@ -107,19 -107,133 +107,19 @@@ ls_remote_result=$(git ls-remote $exec 
        die "Cannot get the repository state from $remote"
  
  append_fetch_head () {
 -    head_="$1"
 -    remote_="$2"
 -    remote_name_="$3"
 -    remote_nick_="$4"
 -    local_name_="$5"
 -    case "$6" in
 -    t) not_for_merge_='not-for-merge' ;;
 -    '') not_for_merge_= ;;
 -    esac
 -
 -    # remote-nick is the URL given on the command line (or a shorthand)
 -    # remote-name is the $GIT_DIR relative refs/ path we computed
 -    # for this refspec.
 -
 -    # the $note_ variable will be fed to git-fmt-merge-msg for further
 -    # processing.
 -    case "$remote_name_" in
 -    HEAD)
 -      note_= ;;
 -    refs/heads/*)
 -      note_="$(expr "$remote_name_" : 'refs/heads/\(.*\)')"
 -      note_="branch '$note_' of " ;;
 -    refs/tags/*)
 -      note_="$(expr "$remote_name_" : 'refs/tags/\(.*\)')"
 -      note_="tag '$note_' of " ;;
 -    refs/remotes/*)
 -      note_="$(expr "$remote_name_" : 'refs/remotes/\(.*\)')"
 -      note_="remote branch '$note_' of " ;;
 -    *)
 -      note_="$remote_name of " ;;
 -    esac
 -    remote_1_=$(expr "z$remote_" : 'z\(.*\)\.git/*$') &&
 -      remote_="$remote_1_"
 -    note_="$note_$remote_"
 -
 -    # 2.6.11-tree tag would not be happy to be fed to resolve.
 -    if git-cat-file commit "$head_" >/dev/null 2>&1
 -    then
 -      headc_=$(git-rev-parse --verify "$head_^0") || exit
 -      echo "$headc_   $not_for_merge_ $note_" >>"$GIT_DIR/FETCH_HEAD"
 -    else
 -      echo "$head_    not-for-merge   $note_" >>"$GIT_DIR/FETCH_HEAD"
 -    fi
 -
 -    update_local_ref "$local_name_" "$head_" "$note_"
 +      flags=
 +      test -n "$verbose" && flags="$flags -v"
 +      test -n "$force" && flags="$flags -f"
 +      GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION" \
 +              git-fetch--tool $flags append-fetch-head "$@"
  }
  
  update_local_ref () {
 -    # If we are storing the head locally make sure that it is
 -    # a fast forward (aka "reverse push").
 -
 -    label_=$(git-cat-file -t $2)
 -    newshort_=$(git-rev-parse --short $2)
 -    if test -z "$1" ; then
 -      [ "$verbose" ] && echo >&2 "* fetched $3"
 -      [ "$verbose" ] && echo >&2 "  $label_: $newshort_"
 -      return 0
 -    fi
 -    oldshort_=$(git show-ref --hash --abbrev "$1" 2>/dev/null)
 -
 -    case "$1" in
 -    refs/tags/*)
 -      # Tags need not be pointing at commits so there
 -      # is no way to guarantee "fast-forward" anyway.
 -      if test -n "$oldshort_"
 -      then
 -              if now_=$(git show-ref --hash "$1") && test "$now_" = "$2"
 -              then
 -                      [ "$verbose" ] && echo >&2 "* $1: same as $3"
 -                      [ "$verbose" ] && echo >&2 "  $label_: $newshort_" ||:
 -              else
 -                      echo >&2 "* $1: updating with $3"
 -                      echo >&2 "  $label_: $newshort_"
 -                      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 "$GIT_REFLOG_ACTION: storing tag" "$1" "$2"
 -      fi
 -      ;;
 -
 -    refs/heads/* | refs/remotes/*)
 -      # $1 is the ref being updated.
 -      # $2 is the new value for the ref.
 -      local=$(git-rev-parse --verify "$1^0" 2>/dev/null)
 -      if test "$local"
 -      then
 -          # Require fast-forward.
 -          mb=$(git-merge-base "$local" "$2") &&
 -          case "$2,$mb" in
 -          $local,*)
 -              if test -n "$verbose"
 -              then
 -                      echo >&2 "* $1: same as $3"
 -                      echo >&2 "  $label_: $newshort_"
 -              fi
 -              ;;
 -          *,$local)
 -              echo >&2 "* $1: fast forward to $3"
 -              echo >&2 "  old..new: $oldshort_..$newshort_"
 -              git-update-ref -m "$GIT_REFLOG_ACTION: fast-forward" "$1" "$2" "$local"
 -              ;;
 -          *)
 -              false
 -              ;;
 -          esac || {
 -              case ",$force,$single_force," in
 -              *,t,*)
 -                      echo >&2 "* $1: forcing update to non-fast forward $3"
 -                      echo >&2 "  old...new: $oldshort_...$newshort_"
 -                      git-update-ref -m "$GIT_REFLOG_ACTION: forced-update" "$1" "$2" "$local"
 -                      ;;
 -              *)
 -                      echo >&2 "* $1: not updating to non-fast forward $3"
 -                      echo >&2 "  old...new: $oldshort_...$newshort_"
 -                      exit 1
 -                      ;;
 -              esac
 -          }
 -      else
 -          echo >&2 "* $1: storing $3"
 -          echo >&2 "  $label_: $newshort_"
 -          git-update-ref -m "$GIT_REFLOG_ACTION: storing head" "$1" "$2"
 -      fi
 -      ;;
 -    esac
 +      flags=
 +      test -n "$verbose" && flags="$flags -v"
 +      test -n "$force" && flags="$flags -f"
 +      GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION" \
 +              git-fetch--tool $flags update-local-ref "$@"
  }
  
  # updating the current HEAD with git-fetch in a bare
@@@ -129,6 -243,15 +129,15 @@@ the
        orig_head=$(git-rev-parse --verify HEAD 2>/dev/null)
  fi
  
+ # Allow --notags from remote.$1.tagopt
+ case "$tags$no_tags" in
+ '')
+       case "$(git-config --get "remote.$1.tagopt")" in
+       --no-tags)
+               no_tags=t ;;
+       esac
+ esac
  # If --tags (and later --heads or --all) is specified, then we are
  # not talking about defaults stored in Pull: line of remotes or
  # branches file, and just fetch those and refspecs explicitly given.
@@@ -154,30 -277,7 +163,30 @@@ the
        fi
  fi
  
 -fetch_main () {
 +fetch_native () {
 +
 +  eval=$(echo "$1" | git-fetch--tool parse-reflist "-")
 +  eval "$eval"
 +
 +    ( : subshell because we muck with IFS
 +      IFS="   $LF"
 +      (
 +        git-fetch-pack --thin $exec $keep $shallow_depth "$remote" $rref ||
 +        echo failed "$remote"
 +      ) |
 +      (
 +      flags=
 +      test -n "$verbose" && flags="$flags -v"
 +      test -n "$force" && flags="$flags -f"
 +      GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION" \
 +              git-fetch--tool $flags native-store \
 +                      "$remote" "$remote_nick" "$refs"
 +      )
 +    ) || exit
 +
 +}
 +
 +fetch_dumb () {
    reflist="$1"
    refs=
    rref=
              rsync_slurped_objects=t
          }
          ;;
 -      *)
 -        # We will do git native transport with just one call later.
 -        continue ;;
        esac
  
        append_fetch_head "$head" "$remote" \
  
    done
  
 -  case "$remote" in
 -  http://* | https://* | ftp://* | rsync://* )
 -      ;; # we are already done.
 -  *)
 -    ( : subshell because we muck with IFS
 -      IFS="   $LF"
 -      (
 -        git-fetch-pack --thin $exec $keep $shallow_depth "$remote" $rref ||
 -        echo failed "$remote"
 -      ) |
 -      (
 -      trap '
 -              if test -n "$keepfile" && test -f "$keepfile"
 -              then
 -                      rm -f "$keepfile"
 -              fi
 -      ' 0
 -
 -        keepfile=
 -      while read sha1 remote_name
 -      do
 -        case "$sha1" in
 -        failed)
 -                echo >&2 "Fetch failure: $remote"
 -                exit 1 ;;
 -        # special line coming from index-pack with the pack name
 -        pack)
 -                continue ;;
 -        keep)
 -                keepfile="$GIT_OBJECT_DIRECTORY/pack/pack-$remote_name.keep"
 -                continue ;;
 -        esac
 -        found=
 -        single_force=
 -        for ref in $refs
 -        do
 -            case "$ref" in
 -            +$remote_name:*)
 -                single_force=t
 -                not_for_merge=
 -                found="$ref"
 -                break ;;
 -            .+$remote_name:*)
 -                single_force=t
 -                not_for_merge=t
 -                found="$ref"
 -                break ;;
 -            .$remote_name:*)
 -                not_for_merge=t
 -                found="$ref"
 -                break ;;
 -            $remote_name:*)
 -                not_for_merge=
 -                found="$ref"
 -                break ;;
 -            esac
 -        done
 -        local_name=$(expr "z$found" : 'z[^:]*:\(.*\)')
 -        append_fetch_head "$sha1" "$remote" \
 -                "$remote_name" "$remote_nick" "$local_name" \
 -                "$not_for_merge" || exit
 -        done
 -      )
 -    ) || exit ;;
 -  esac
 +}
  
 +fetch_main () {
 +      case "$remote" in
 +      http://* | https://* | ftp://* | rsync://* )
 +              fetch_dumb "$@"
 +              ;;
 +      *)
 +              fetch_native "$@"
 +              ;;
 +      esac
  }
  
  fetch_main "$reflist" || exit
diff --combined git.c
index a167b1e42e942cb420c0cf6ab3ae370780a8b517,83f3d90ee35418976baea4f032c13aed0ec9e664..2361b5fbbc4729c728159a7f2d79408a0ec1e8d6
--- 1/git.c
--- 2/git.c
+++ b/git.c
@@@ -48,7 -48,7 +48,7 @@@ static int handle_options(const char**
                /*
                 * Check remaining flags.
                 */
-               if (!strncmp(cmd, "--exec-path", 11)) {
+               if (!prefixcmp(cmd, "--exec-path")) {
                        cmd += 11;
                        if (*cmd == '=')
                                git_set_exec_path(cmd + 1);
@@@ -66,7 -66,7 +66,7 @@@
                        setenv(GIT_DIR_ENVIRONMENT, (*argv)[1], 1);
                        (*argv)++;
                        (*argc)--;
-               } else if (!strncmp(cmd, "--git-dir=", 10)) {
+               } else if (!prefixcmp(cmd, "--git-dir=")) {
                        setenv(GIT_DIR_ENVIRONMENT, cmd + 10, 1);
                } else if (!strcmp(cmd, "--bare")) {
                        static char git_dir[PATH_MAX+1];
@@@ -88,7 -88,7 +88,7 @@@ static char *alias_string
  
  static int git_alias_config(const char *var, const char *value)
  {
-       if (!strncmp(var, "alias.", 6) && !strcmp(var + 6, alias_command)) {
+       if (!prefixcmp(var, "alias.") && !strcmp(var + 6, alias_command)) {
                alias_string = xstrdup(value);
        }
        return 0;
@@@ -240,16 -240,14 +240,15 @@@ static void handle_internal_command(in
                { "diff", cmd_diff, RUN_SETUP | USE_PAGER },
                { "diff-files", cmd_diff_files, RUN_SETUP },
                { "diff-index", cmd_diff_index, RUN_SETUP },
-               { "diff-stages", cmd_diff_stages, RUN_SETUP },
                { "diff-tree", cmd_diff_tree, RUN_SETUP },
 +              { "fetch--tool", cmd_fetch__tool, RUN_SETUP },
                { "fmt-merge-msg", cmd_fmt_merge_msg, RUN_SETUP },
                { "for-each-ref", cmd_for_each_ref, RUN_SETUP },
                { "format-patch", cmd_format_patch, RUN_SETUP },
                { "fsck", cmd_fsck, RUN_SETUP },
                { "fsck-objects", cmd_fsck, RUN_SETUP },
                { "get-tar-commit-id", cmd_get_tar_commit_id },
-               { "grep", cmd_grep, RUN_SETUP },
+               { "grep", cmd_grep, RUN_SETUP | USE_PAGER },
                { "help", cmd_help },
                { "init", cmd_init_db },
                { "init-db", cmd_init_db },
                { "ls-tree", cmd_ls_tree, RUN_SETUP },
                { "mailinfo", cmd_mailinfo },
                { "mailsplit", cmd_mailsplit },
+               { "merge-base", cmd_merge_base, RUN_SETUP },
                { "merge-file", cmd_merge_file },
                { "mv", cmd_mv, RUN_SETUP | NOT_BARE },
                { "name-rev", cmd_name_rev, RUN_SETUP },
@@@ -349,7 -348,7 +349,7 @@@ int main(int argc, const char **argv, c
         * So we just directly call the internal command handler, and
         * die if that one cannot handle it.
         */
-       if (!strncmp(cmd, "git-", 4)) {
+       if (!prefixcmp(cmd, "git-")) {
                cmd += 4;
                argv[0] = cmd;
                handle_internal_command(argc, argv, envp);
        argc--;
        handle_options(&argv, &argc);
        if (argc > 0) {
-               if (!strncmp(argv[0], "--", 2))
+               if (!prefixcmp(argv[0], "--"))
                        argv[0] += 2;
        } else {
                /* Default command: "help" */