Merge branch 'js/etc-config'
authorJunio C Hamano <junkio@cox.net>
Sat, 24 Feb 2007 09:43:28 +0000 (01:43 -0800)
committerJunio C Hamano <junkio@cox.net>
Sat, 24 Feb 2007 09:43:28 +0000 (01:43 -0800)
* js/etc-config:
Make tests independent of global config files
config: read system-wide defaults from /etc/gitconfig

1  2 
Documentation/config.txt
Makefile
config.c
diff --combined Documentation/config.txt
index 70f548464a5f0b841da4cef5acc8c3c65bce1de7,1dd90d804623e8d6c88caf11059801aadf6d26f3..6309d89b4bb9e6cefd868fb87dd78dfd3dd32d24
@@@ -5,7 -5,8 +5,8 @@@ The git configuration file contains a n
  the git command's behavior. `.git/config` file for each repository
  is used to store the information for that repository, and
  `$HOME/.gitconfig` is used to store per user information to give
- fallback values for `.git/config` file.
+ fallback values for `.git/config` file. The file `/etc/gitconfig`
+ can be used to store system-wide defaults.
  
  They can be used by both the git plumbing
  and the porcelains. The variables are divided into sections, where
@@@ -142,18 -143,6 +143,18 @@@ core.preferSymlinkRefs:
        This is sometimes needed to work with old scripts that
        expect HEAD to be a symbolic link.
  
 +core.bare::
 +      If true this repository is assumed to be 'bare' and has no
 +      working directory associated with it.  If this is the case a
 +      number of commands that require a working directory will be
 +      disabled, such as gitlink:git-add[1] or gitlink:git-merge[1].
 ++
 +This setting is automatically guessed by gitlink:git-clone[1] or
 +gitlink:git-init[1] when the repository was created.  By default a
 +repository that ends in "/.git" is assumed to be not bare (bare =
 +false), while all other repositories are assumed to be bare (bare
 += true).
 +
  core.logAllRefUpdates::
        Updates to a ref <ref> is logged to the file
        "$GIT_DIR/logs/<ref>", by appending the new and old
@@@ -192,17 -181,10 +193,17 @@@ core.compression:
        slowest.
  
  core.legacyheaders::
 -      A boolean which enables the legacy object header format in case
 -      you want to interoperate with old clients accessing the object
 -      database directly (where the "http://" and "rsync://" protocols
 -      count as direct access).
 +      A boolean which
 +      changes the format of loose objects so that they are more
 +      efficient to pack and to send out of the repository over git
 +      native protocol, since v1.4.2.  However, loose objects
 +      written in the new format cannot be read by git older than
 +      that version; people fetching from your repository using
 +      older versions of git over dumb transports (e.g. http)
 +      will also be affected.
 ++
 +To let git use the new loose object format, you have to
 +set core.legacyheaders to false.
  
  core.packedGitWindowSize::
        Number of bytes of a pack file to map into memory in a
@@@ -470,10 -452,6 +471,10 @@@ remote.<name>.push:
        The default set of "refspec" for gitlink:git-push[1]. See
        gitlink:git-push[1].
  
 +remote.<name>.skipDefaultUpdate::
 +      If true, this remote will be skipped by default when updating
 +      using the remote subcommand of gitlink:git-remote[1].
 +
  remote.<name>.receivepack::
        The default program to execute on the remote side when pushing.  See
        option \--exec of gitlink:git-push[1].
@@@ -482,10 -460,6 +483,10 @@@ remote.<name>.uploadpack:
        The default program to execute on the remote side when fetching.  See
        option \--exec of gitlink:git-fetch-pack[1].
  
 +remotes.<group>::
 +      The list of remotes which are fetched by "git remote update
 +      <group>".  See gitlink:git-remote[1].
 +
  repack.usedeltabaseoffset::
        Allow gitlink:git-repack[1] to create packs that uses
        delta-base offset.  Defaults to false.
diff --combined Makefile
index fbe05f938ebbd713171234eaa6d956b23fba5e1d,203aac4517b3ac0311e0e6444caf64a5fa2b67df..e51b448c78827dfc9563cda309a67281b29b873b
+++ b/Makefile
@@@ -28,10 -28,6 +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.
@@@ -128,6 -124,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
@@@ -176,7 -173,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 \
@@@ -266,8 -263,7 +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-fmt-merge-msg.o \
        builtin-for-each-ref.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 \
@@@ -358,13 -354,11 +359,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
@@@ -524,13 -518,6 +525,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
@@@ -598,6 -585,7 +599,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))
@@@ -610,7 -598,8 +612,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)
@@@ -896,8 -885,7 +899,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
  
@@@ -954,14 -942,11 +957,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 config.c
index 8b6cf1aaa55a510bffa1d0b8a143e23a6883d45c,b0c0948cc825f783ee5187aa5ff60838bd4a2759..0ff413b804afc1ec042ed5190ae4f9055a17ea87
+++ b/config.c
@@@ -310,14 -310,12 +310,14 @@@ int git_default_config(const char *var
        }
  
        if (!strcmp(var, "core.packedgitwindowsize")) {
 -              int pgsz = getpagesize();
 +              int pgsz_x2 = getpagesize() * 2;
                packed_git_window_size = git_config_int(var, value);
 -              packed_git_window_size /= pgsz;
 -              if (packed_git_window_size < 2)
 -                      packed_git_window_size = 2;
 -              packed_git_window_size *= pgsz;
 +
 +              /* This value must be multiple of (pagesize * 2) */
 +              packed_git_window_size /= pgsz_x2;
 +              if (packed_git_window_size < 1)
 +                      packed_git_window_size = 1;
 +              packed_git_window_size *= pgsz_x2;
                return 0;
        }
  
                return 0;
        }
  
 +      if (!strcmp(var, "core.autocrlf")) {
 +              if (value && !strcasecmp(value, "input")) {
 +                      auto_crlf = -1;
 +                      return 0;
 +              }
 +              auto_crlf = git_config_bool(var, value);
 +              return 0;
 +      }
 +
        if (!strcmp(var, "user.name")) {
                strlcpy(git_default_name, value, sizeof(git_default_name));
                return 0;
@@@ -394,6 -383,8 +394,8 @@@ int git_config(config_fn_t fn
         * config file otherwise. */
        filename = getenv(CONFIG_ENVIRONMENT);
        if (!filename) {
+               if (!access(ETC_GITCONFIG, R_OK))
+                       ret += git_config_from_file(fn, ETC_GITCONFIG);
                home = getenv("HOME");
                filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
                if (!filename)