1. 16 12月, 2012 1 次提交
    • J
      silence some -Wuninitialized false positives · a469a101
      Jeff King 提交于
      There are a few error functions that simply wrap error() and
      provide a standardized message text. Like error(), they
      always return -1; knowing that can help the compiler silence
      some false positive -Wuninitialized warnings.
      
      One strategy would be to just declare these as inline in the
      header file so that the compiler can see that they always
      return -1. However, gcc does not always inline them (e.g.,
      it will not inline opterror, even with -O3), which renders
      our change pointless.
      
      Instead, let's follow the same route we did with error() in
      the last patch, and define a macro that makes the constant
      return value obvious to the compiler.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a469a101
  2. 24 10月, 2012 1 次提交
    • J
      git-config: fix regexp memory leaks on error conditions · 97ed50f9
      Jeff King 提交于
      The get_value function has a goto label for cleaning up on
      errors, but it only cleans up half of what the function
      might allocate. Let's also clean up the key and regexp
      variables there.
      
      Note that we need to take special care when compiling the
      regex fails to clean it up ourselves, since it is in a
      half-constructed state (we would want to free it, but not
      regfree it).
      
      Similarly, we fix git_config_parse_key to return NULL when
      it fails, not a pointer to some already-freed memory.
      Signed-off-by: NJeff King <peff@peff.net>
      97ed50f9
  3. 02 10月, 2012 1 次提交
    • B
      Remove the hard coded length limit on variable names in config files · 0971e992
      Ben Walton 提交于
      Previously while reading the variable names in config files, there
      was a 256 character limit with at most 128 of those characters being
      used by the section header portion of the variable name.  This
      limitation was only enforced while reading the config files.  It was
      possible to write a config file that was not subsequently readable.
      
      Instead of enforcing this limitation for both reading and writing,
      remove it entirely by changing the var member of the config_file
      struct to a strbuf instead of a fixed length buffer.  Update all of
      the parsing functions in config.c to use the strbuf instead of the
      static buffer.
      
      The parsing functions that returned the base length of the variable
      name now return simply 0 for success and -1 for failure.  The base
      length information is obtained through the strbuf's len member.
      
      We now send the buf member of the strbuf to external callback
      functions to preserve the external api.  None of the external
      callers rely on the old size limitation for sizing their own buffers
      so removing the limit should have no externally visible effect.
      Signed-off-by: NBen Walton <bdwalton@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0971e992
  4. 22 8月, 2012 1 次提交
    • J
      config: warn on inaccessible files · ba8bd830
      Jeff King 提交于
      Before reading a config file, we check "!access(path, R_OK)"
      to make sure that the file exists and is readable. If it's
      not, then we silently ignore it.
      
      For the case of ENOENT, this is fine, as the presence of the
      file is optional. For other cases, though, it may indicate a
      configuration error (e.g., not having permissions to read
      the file). Let's print a warning in these cases to let the
      user know.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ba8bd830
  5. 17 7月, 2012 1 次提交
  6. 09 7月, 2012 1 次提交
    • T
      git on Mac OS and precomposed unicode · 76759c7d
      Torsten Bögershausen 提交于
      Mac OS X mangles file names containing unicode on file systems HFS+,
      VFAT or SAMBA.  When a file using unicode code points outside ASCII
      is created on a HFS+ drive, the file name is converted into
      decomposed unicode and written to disk. No conversion is done if
      the file name is already decomposed unicode.
      
      Calling open("\xc3\x84", ...) with a precomposed "Ä" yields the same
      result as open("\x41\xcc\x88",...) with a decomposed "Ä".
      
      As a consequence, readdir() returns the file names in decomposed
      unicode, even if the user expects precomposed unicode.  Unlike on
      HFS+, Mac OS X stores files on a VFAT drive (e.g. an USB drive) in
      precomposed unicode, but readdir() still returns file names in
      decomposed unicode.  When a git repository is stored on a network
      share using SAMBA, file names are send over the wire and written to
      disk on the remote system in precomposed unicode, but Mac OS X
      readdir() returns decomposed unicode to be compatible with its
      behaviour on HFS+ and VFAT.
      
      The unicode decomposition causes many problems:
      
      - The names "git add" and other commands get from the end user may
        often be precomposed form (the decomposed form is not easily input
        from the keyboard), but when the commands read from the filesystem
        to see what it is going to update the index with already is on the
        filesystem, readdir() will give decomposed form, which is different.
      
      - Similarly "git log", "git mv" and all other commands that need to
        compare pathnames found on the command line (often but not always
        precomposed form; a command line input resulting from globbing may
        be in decomposed) with pathnames found in the tree objects (should
        be precomposed form to be compatible with other systems and for
        consistency in general).
      
      - The same for names stored in the index, which should be
        precomposed, that may need to be compared with the names read from
        readdir().
      
      NFS mounted from Linux is fully transparent and does not suffer from
      the above.
      
      As Mac OS X treats precomposed and decomposed file names as equal,
      we can
      
       - wrap readdir() on Mac OS X to return the precomposed form, and
      
       - normalize decomposed form given from the command line also to the
         precomposed form,
      
      to ensure that all pathnames used in Git are always in the
      precomposed form.  This behaviour can be requested by setting
      "core.precomposedunicode" configuration variable to true.
      
      The code in compat/precomposed_utf8.c implements basically 4 new
      functions: precomposed_utf8_opendir(), precomposed_utf8_readdir(),
      precomposed_utf8_closedir() and precompose_argv().  The first three
      are to wrap opendir(3), readdir(3), and closedir(3) functions.
      
      The argv[] conversion allows to use the TAB filename completion done
      by the shell on command line.  It tolerates other tools which use
      readdir() to feed decomposed file names into git.
      
      When creating a new git repository with "git init" or "git clone",
      "core.precomposedunicode" will be set "false".
      
      The user needs to activate this feature manually.  She typically
      sets core.precomposedunicode to "true" on HFS and VFAT, or file
      systems mounted via SAMBA.
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NTorsten Bögershausen <tboegi@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      76759c7d
  7. 26 6月, 2012 1 次提交
  8. 23 5月, 2012 1 次提交
  9. 30 4月, 2012 1 次提交
  10. 26 4月, 2012 1 次提交
  11. 25 4月, 2012 1 次提交
    • M
      push: introduce new push.default mode "simple" · b55e6775
      Matthieu Moy 提交于
      When calling "git push" without argument, we want to allow Git to do
      something simple to explain and safe. push.default=matching is unsafe
      when used to push to shared repositories, and hard to explain to
      beginners in some contexts. It is debatable whether 'upstream' or
      'current' is the safest or the easiest to explain, so introduce a new
      mode called 'simple' that is the intersection of them: push to the
      upstream branch, but only if it has the same name remotely. If not, give
      an error that suggests the right command to push explicitely to
      'upstream' or 'current'.
      
      A question is whether to allow pushing when no upstream is configured. An
      argument in favor of allowing the push is that it makes the new mode work
      in more cases. On the other hand, refusing to push when no upstream is
      configured encourages the user to set the upstream, which will be
      beneficial on the next pull. Lacking better argument, we chose to deny
      the push, because it will be easier to change in the future if someone
      shows us wrong.
      Original-patch-by: NJeff King <peff@peff.net>
      Signed-off-by: NMatthieu Moy <Matthieu.Moy@imag.fr>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b55e6775
  12. 13 3月, 2012 1 次提交
  13. 17 2月, 2012 5 次提交
    • J
      config: add include directive · 9b25a0b5
      Jeff King 提交于
      It can be useful to split your ~/.gitconfig across multiple
      files. For example, you might have a "main" file which is
      used on many machines, but a small set of per-machine
      tweaks. Or you may want to make some of your config public
      (e.g., clever aliases) while keeping other data back (e.g.,
      your name or other identifying information). Or you may want
      to include a number of config options in some subset of your
      repos without copying and pasting (e.g., you want to
      reference them from the .git/config of participating repos).
      
      This patch introduces an include directive for config files.
      It looks like:
      
        [include]
          path = /path/to/file
      
      This is syntactically backwards-compatible with existing git
      config parsers (i.e., they will see it as another config
      entry and ignore it unless you are looking up include.path).
      
      The implementation provides a "git_config_include" callback
      which wraps regular config callbacks. Callers can pass it to
      git_config_from_file, and it will transparently follow any
      include directives, passing all of the discovered options to
      the real callback.
      
      Include directives are turned on automatically for "regular"
      git config parsing. This includes calls to git_config, as
      well as calls to the "git config" program that do not
      specify a single file (e.g., using "-f", "--global", etc).
      They are not turned on in other cases, including:
      
        1. Parsing of other config-like files, like .gitmodules.
           There isn't a real need, and I'd rather be conservative
           and avoid unnecessary incompatibility or confusion.
      
        2. Reading single files via "git config". This is for two
           reasons:
      
             a. backwards compatibility with scripts looking at
                config-like files.
      
             b. inspection of a specific file probably means you
      	  care about just what's in that file, not a general
                lookup for "do we have this value anywhere at
      	  all". If that is not the case, the caller can
      	  always specify "--includes".
      
        3. Writing files via "git config"; we want to treat
           include.* variables as literal items to be copied (or
           modified), and not expand them. So "git config
           --unset-all foo.bar" would operate _only_ on
           .git/config, not any of its included files (just as it
           also does not operate on ~/.gitconfig).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9b25a0b5
    • J
      config: eliminate config_exclusive_filename · 4a7bb5ba
      Jeff King 提交于
      This is a magic global variable that was intended as an
      override to the usual git-config lookup process. Once upon a
      time, you could specify GIT_CONFIG to any git program, and
      it would look only at that file. This turned out to be
      confusing and cause a lot of bugs for little gain. As a
      result, dc871831 (Only use GIT_CONFIG in "git config", not
      other programs, 2008-06-30) took this away for all callers
      except git-config.
      
      Since git-config no longer uses it either, the variable can
      just go away. As the diff shows, nobody was setting to
      anything except NULL, so we can just replace any sites where
      it was read with NULL.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4a7bb5ba
    • J
      config: provide a version of git_config with more options · c9b5e2a5
      Jeff King 提交于
      Callers may want to provide a specific version of a file in which to look
      for config. Right now this can be done by setting the magic global
      config_exclusive_filename variable.  By providing a version of git_config
      that takes a filename, we can take a step towards making this magic global
      go away.
      
      Furthermore, by providing a more "advanced" interface, we now have a a
      natural place to add new options for callers like git-config, which care
      about tweaking the specifics of config lookup, without disturbing the
      large number of "simple" users (i.e., every other part of git).
      
      The astute reader of this patch may notice that the logic for handling
      config_exclusive_filename was taken out of git_config_early, but added
      into git_config. This means that git_config_early will no longer respect
      config_exclusive_filename.  That's OK, because the only other caller of
      git_config_early is check_repository_format_gently, but the only function
      which sets config_exclusive_filename is cmd_config, which does not call
      check_repository_format_gently (and if it did, it would have been a bug,
      anyway, as we would be checking the repository format in the wrong file).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c9b5e2a5
    • J
      config: teach git_config_rename_section a file argument · 42bd39b5
      Jeff King 提交于
      The other config-writing functions (git_config_set and
      git_config_set_multivar) each have an -"in_file" version to
      write a specific file. Let's add one for rename_section,
      with the eventual goal of moving away from the magic
      config_exclusive_filename global.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      42bd39b5
    • J
      config: teach git_config_set_multivar_in_file a default path · 0a5f5759
      Jeff King 提交于
      The git_config_set_multivar_in_file function takes a
      filename argument to specify the file into which the values
      should be written. Currently, this value must be non-NULL.
      Callers which want to write to the default location must use
      the regular, non-"in_file" version, which will either write
      to config_exclusive_filename, or to the repo config if the
      exclusive filename is NULL.
      
      Let's migrate the "default to using repo config" logic into
      the "in_file" form. That will let callers get the same
      default-if-NULL behavior as one gets with
      config_exclusive_filename, but without having to use the
      global variable.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0a5f5759
  14. 02 12月, 2011 1 次提交
  15. 21 11月, 2011 1 次提交
    • R
      config.c: Fix a static buffer overwrite bug by avoiding mkpath() · 05bab3ea
      Ramsay Jones 提交于
      On cygwin, test number 21 of t3200-branch.sh (git branch -m q q2
      without config should succeed) fails. The failure involves the
      functions from path.c which parcel out internal static buffers
      from the git_path() and mkpath() functions.
      
      In particular, the rename_ref() function calls safe_create_leading\
      _directories() with a filename returned by git_path("logs/%s", ref).
      safe_create_leading_directories(), in turn, calls stat() on each
      element of the path it is given. On cygwin, this leads to a call
      to git_config() for each component of the path, since this test
      explicitly removes the config file. git_config() calls mkpath(), so
      on the fourth component of the path, the original buffer passed
      into the function is overwritten with the config filename.
      
      Note that this bug is specific to cygwin and it's schizophrenic
      stat() functions (see commits adbc0b6b, 7faee6b8 and 79748439). The
      lack of a config file and a path with at least four elements is
      also important to trigger the bug.
      
      In order to fix the problem, we replace the call to mkpath() with
      a call to mksnpath() and provide our own buffer.
      Signed-off-by: NRamsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      05bab3ea
  16. 06 11月, 2011 1 次提交
    • N
      Support sizes >=2G in various config options accepting 'g' sizes. · ebaa1bd4
      Nick Alcock 提交于
      The config options core.packedGitWindowSize, core.packedGitLimit,
      core.deltaBaseCacheLimit, core.bigFileThreshold, pack.windowMemory and
      pack.packSizeLimit all claim to support suffixes up to and including
      'g'.  This implies that they should accept sizes >=2G on 64-bit
      systems: certainly, specifying a size of 3g should not silently be
      translated to zero or transformed into a large negative value due to
      integer overflow.  However, due to use of git_config_int() rather than
      git_config_ulong(), that is exactly what happens:
      
      % git config core.bigFileThreshold 2g
      % git gc --aggressive # with extra debugging code to print out
                            # core.bigfilethreshold after parsing
      bigfilethreshold: -2147483648
      [...]
      
      This is probably irrelevant for core.deltaBaseCacheLimit, but is
      problematic for the other values.  (It is particularly problematic for
      core.packedGitLimit, which can't even be set to its default value in
      the config file due to this bug.)
      
      This fixes things for 32-bit platforms as well.  They get the usual bad
      config error if an overlarge value is specified, e.g.:
      
      fatal: bad config value for 'core.bigfilethreshold' in /home/nix/.gitconfig
      
      This is detected in all cases, even if the 32-bit platform has no size
      larger than 'long'.  For signed integral configuration values, we also
      detect the case where the value is too large for the signed type but
      not the unsigned type.
      Signed-off-by: NNick Alcock <nix@esperi.org.uk>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ebaa1bd4
  17. 07 10月, 2011 1 次提交
    • J
      attr: read core.attributesfile from git_default_core_config · 64589a03
      Junio C Hamano 提交于
      This code calls git_config from a helper function to parse the config entry
      it is interested in.  Calling git_config in this way may cause a problem if
      the helper function can be called after a previous call to git_config by
      another function since the second call to git_config may reset some
      variable to the value in the config file which was previously overridden.
      
      The above is not a problem in this case since the function passed to
      git_config only parses one config entry and the variable it sets is not
      assigned outside of the parsing function.  But a programmer who desires
      all of the standard config options to be parsed may be tempted to modify
      git_attr_config() so that it falls back to git_default_config() and then it
      _would_ be vulnerable to the above described behavior.
      
      So, move the call to git_config up into the top-level cmd_* function and
      move the responsibility for parsing core.attributesfile into the main
      config file parser.
      
      Which is only the logical thing to do ;-)
      Signed-off-by: NBrandon Casey <drafnel@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      64589a03
  18. 05 8月, 2011 1 次提交
  19. 20 7月, 2011 1 次提交
  20. 07 7月, 2011 1 次提交
    • J
      core: log offset pack data accesses happened · 5f44324d
      Junio C Hamano 提交于
      In a workload other than "git log" (without pathspec nor any option that
      causes us to inspect trees and blobs), the recency pack order is said to
      cause the access jump around quite a bit. Add a hook to allow us observe
      how bad it is.
      
      "git config core.logpackaccess /var/tmp/pal.txt" will give you the log
      in the specified file.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5f44324d
  21. 23 6月, 2011 5 次提交
  22. 17 6月, 2011 1 次提交
    • R
      config.c: Make git_config() work correctly when called recursively · 924aaf3e
      Ramsay Jones 提交于
      On Cygwin, this fixes a test failure in t3301-notes.sh (test 98,
      "git notes copy --for-rewrite (disabled)").
      
      The test failure is caused by a recursive call to git_config() which
      has the effect of skipping to the end-of-file while processing the
      "notes.rewriteref" config variable. Thus, any config variables that
      appear after "notes.rewriteref" are simply ignored by git_config().
      Also, we note that the original FILE handle is leaked as a result
      of the recursive call.
      
      The recursive call to git_config() is due to the "schizophrenic stat"
      functions on cygwin, where one of two different implementations of
      the l/stat functions is selected lazily, depending on some config
      variables.
      
      In this case, the init_copy_notes_for_rewrite() function calls
      git_config() with the notes_rewrite_config() callback function.
      This callback, while processing the "notes.rewriteref" variable,
      in turn calls string_list_add_refs_by_glob() to process the
      associated ref value. This eventually leads to a call to the
      get_ref_dir() function, which in turn calls stat(). On cygwin,
      the stat() macro leads to an indirect call to cygwin_stat_stub()
      which, via init_stat(), then calls git_config() in order to
      determine which l/stat implementation to bind to.
      
      In order to solve this problem, we modify git_config() so that the
      global state variables used by the config reading code is packaged
      up and managed on a local state stack.
      Signed-off-by: NRamsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      924aaf3e
  23. 01 6月, 2011 1 次提交
  24. 25 5月, 2011 3 次提交
  25. 18 5月, 2011 1 次提交
  26. 10 5月, 2011 1 次提交
    • J
      convert: rename the "eol" global variable to "core_eol" · ec70f52f
      Junio C Hamano 提交于
      Yes, it is clear that "eol" wants to mean some sort of end-of-line thing,
      but as the name of a global variable, it is way too short to describe what
      kind of end-of-line thing it wants to represent. Besides, there are many
      codepaths that want to use their own local "char *eol" variable to point
      at the end of the current line they are processing.
      
      This global variable holds what we read from core.eol configuration
      variable. Name it as such.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ec70f52f
  27. 12 4月, 2011 1 次提交
  28. 06 4月, 2011 1 次提交
  29. 21 3月, 2011 1 次提交
  30. 17 3月, 2011 1 次提交
    • J
      standardize brace placement in struct definitions · 9cba13ca
      Jonathan Nieder 提交于
      In a struct definitions, unlike functions, the prevailing style is for
      the opening brace to go on the same line as the struct name, like so:
      
       struct foo {
      	int bar;
      	char *baz;
       };
      
      Indeed, grepping for 'struct [a-z_]* {$' yields about 5 times as many
      matches as 'struct [a-z_]*$'.
      
      Linus sayeth:
      
       Heretic people all over the world have claimed that this inconsistency
       is ...  well ...  inconsistent, but all right-thinking people know that
       (a) K&R are _right_ and (b) K&R are right.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9cba13ca