1. 06 6月, 2015 1 次提交
  2. 13 2月, 2015 1 次提交
  3. 02 12月, 2014 1 次提交
  4. 16 10月, 2014 2 次提交
  5. 29 8月, 2014 1 次提交
    • S
      memory_limit: use git_env_ulong() to parse GIT_ALLOC_LIMIT · 9927d962
      Steffen Prohaska 提交于
      GIT_ALLOC_LIMIT limits xmalloc()'s size, which is of type size_t.
      Better use git_env_ulong() to parse the environment variable, so
      that the postfixes 'k', 'm', and 'g' can be used; and use size_t to
      store the limit for consistency.  The change to size_t has no direct
      practical impact, because the environment variable is only meant to
      be used for our own tests, and we use it to test small sizes.
      
      The cast of size in the call to die() is changed to uintmax_t to
      match the format string PRIuMAX.
      Signed-off-by: NSteffen Prohaska <prohaska@zib.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9927d962
  6. 27 8月, 2014 1 次提交
  7. 19 8月, 2014 1 次提交
  8. 11 4月, 2014 2 次提交
    • Y
      read-cache.c: verify index file before we opportunistically update it · 426ddeea
      Yiannis Marangos 提交于
      Before we proceed to opportunistically update the index (often done
      by an otherwise read-only operation like "git status" and "git diff"
      that internally refreshes the index), we must verify that the
      current index file is the same as the one that we read earlier
      before we took the lock on it, in order to avoid a possible race.
      
      In the example below git-status does "opportunistic update" and
      git-rebase updates the index, but the race can happen in general.
      
        1. process A calls git-rebase (or does anything that uses the index)
      
        2. process A applies 1st commit
      
        3. process B calls git-status (or does anything that updates the index)
      
        4. process B reads index
      
        5. process A applies 2nd commit
      
        6. process B takes the lock, then overwrites process A's changes.
      
        7. process A applies 3rd commit
      
      As an end result the 3rd commit will have a revert of the 2nd commit.
      When process B takes the lock, it needs to make sure that the index
      hasn't changed since step 4.
      Signed-off-by: NYiannis Marangos <yiannis.marangos@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      426ddeea
    • Y
      wrapper.c: add xpread() similar to xread() · 9aa91af0
      Yiannis Marangos 提交于
      It is a common mistake to call read(2)/pread(2) and forget to
      anticipate that they may return error with EAGAIN/EINTR when the
      system call is interrupted.
      
      We have xread() helper to relieve callers of read(2) from having to
      worry about it; add xpread() helper to do the same for pread(2).
      
      Update the caller in the builtin/index-pack.c and the mmap emulation
      in compat/.
      Signed-off-by: NYiannis Marangos <yiannis.marangos@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9aa91af0
  9. 13 11月, 2013 1 次提交
  10. 15 10月, 2013 1 次提交
  11. 21 8月, 2013 1 次提交
    • S
      xread, xwrite: limit size of IO to 8MB · 0b6806b9
      Steffen Prohaska 提交于
      Checking out 2GB or more through an external filter (see test) fails
      on Mac OS X 10.8.4 (12E55) for a 64-bit executable with:
      
          error: read from external filter cat failed
          error: cannot feed the input to external filter cat
          error: cat died of signal 13
          error: external filter cat failed 141
          error: external filter cat failed
      
      The reason is that read() immediately returns with EINVAL when asked
      to read more than 2GB.  According to POSIX [1], if the value of
      nbyte passed to read() is greater than SSIZE_MAX, the result is
      implementation-defined.  The write function has the same restriction
      [2].  Since OS X still supports running 32-bit executables, the
      32-bit limit (SSIZE_MAX = INT_MAX = 2GB - 1) seems to be also
      imposed on 64-bit executables under certain conditions.  For write,
      the problem has been addressed earlier [6c642a].
      
      Address the problem for read() and write() differently, by limiting
      size of IO chunks unconditionally on all platforms in xread() and
      xwrite().  Large chunks only cause problems, like causing latencies
      when killing the process, even if OS X was not buggy.  Doing IO in
      reasonably sized smaller chunks should have no negative impact on
      performance.
      
      The compat wrapper clipped_write() introduced earlier [6c642a] is
      not needed anymore.  It will be reverted in a separate commit.  The
      new test catches read and write problems.
      
      Note that 'git add' exits with 0 even if it prints filtering errors
      to stderr.  The test, therefore, checks stderr.  'git add' should
      probably be changed (sometime in another commit) to exit with
      nonzero if filtering fails.  The test could then be changed to use
      test_must_fail.
      
      Thanks to the following people for suggestions and testing:
      
          Johannes Sixt <j6t@kdbg.org>
          John Keeping <john@keeping.me.uk>
          Jonathan Nieder <jrnieder@gmail.com>
          Kyle J. McKay <mackyle@gmail.com>
          Linus Torvalds <torvalds@linux-foundation.org>
          Torsten Bögershausen <tboegi@web.de>
      
      [1] http://pubs.opengroup.org/onlinepubs/009695399/functions/read.html
      [2] http://pubs.opengroup.org/onlinepubs/009695399/functions/write.html
      
      [6c642a] commit 6c642a87
          compate/clipped-write.c: large write(2) fails on Mac OS X/XNU
      Signed-off-by: NSteffen Prohaska <prohaska@zib.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0b6806b9
  12. 13 7月, 2013 1 次提交
  13. 15 4月, 2013 1 次提交
    • J
      config: allow inaccessible configuration under $HOME · 4698c8fe
      Jonathan Nieder 提交于
      The changes v1.7.12.1~2^2~4 (config: warn on inaccessible files,
      2012-08-21) and v1.8.1.1~22^2~2 (config: treat user and xdg config
      permission problems as errors, 2012-10-13) were intended to prevent
      important configuration (think "[transfer] fsckobjects") from being
      ignored when the configuration is unintentionally unreadable (for
      example with EIO on a flaky filesystem, or with ENOMEM due to a DoS
      attack).  Usually ~/.gitconfig and ~/.config/git are readable by the
      current user, and if they aren't then it would be easy to fix those
      permissions, so the damage from adding this check should have been
      minimal.
      
      Unfortunately the access() check often trips when git is being run as
      a server.  A daemon (such as inetd or git-daemon) starts as "root",
      creates a listening socket, and then drops privileges, meaning that
      when git commands are invoked they cannot access $HOME and die with
      
       fatal: unable to access '/root/.config/git/config': Permission denied
      
      Any patch to fix this would have one of three problems:
      
        1. We annoy sysadmins who need to take an extra step to handle HOME
           when dropping privileges (the current behavior, or any other
           proposal that they have to opt into).
      
        2. We annoy sysadmins who want to set HOME when dropping privileges,
           either by making what they want to do impossible, or making them
           set an extra variable or option to accomplish what used to work
           (e.g., a patch to git-daemon to set HOME when --user is passed).
      
        3. We loosen the check, so some cases which might be noteworthy are
           not caught.
      
      This patch is of type (3).
      
      Treat user and xdg configuration that are inaccessible due to
      permissions (EACCES) as though no user configuration was provided at
      all.
      
      An alternative method would be to check if $HOME is readable, but that
      would not help in cases where the user who dropped privileges had a
      globally readable HOME with only .config or .gitconfig being private.
      
      This does not change the behavior when /etc/gitconfig or .git/config
      is unreadable (since those are more serious configuration errors),
      nor when ~/.gitconfig or ~/.config/git is unreadable due to problems
      other than permissions.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Improved-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4698c8fe
  14. 19 12月, 2012 1 次提交
    • J
      xmkstemp(): avoid showing truncated template more carefully · f7be59b4
      Junio C Hamano 提交于
      Some implementations of xmkstemp() leaves the given in/out buffer
      truncated when they return with failure.
      
      6cf6bb3e (Improve error messages when temporary file creation fails,
      2010-12-18) attempted to show the real filename we tried to create
      (but failed), and if that is not available due to such truncation,
      to show the original template that was given by the caller.
      
      But it failed to take into account that the given template could
      have "directory/" in front, in which case the truncation point may
      not be template[0] but somewhere else.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f7be59b4
  15. 14 10月, 2012 2 次提交
    • J
      config: treat user and xdg config permission problems as errors · 96b9e0e3
      Jonathan Nieder 提交于
      Git reads multiple configuration files: settings come first from the
      system config file (typically /etc/gitconfig), then the xdg config
      file (typically ~/.config/git/config), then the user's dotfile
      (~/.gitconfig), then the repository configuration (.git/config).
      
      Git has always used access(2) to decide whether to use each file; as
      an unfortunate side effect, that means that if one of these files is
      unreadable (e.g., EPERM or EIO), git skips it.  So if I use
      ~/.gitconfig to override some settings but make a mistake and give it
      the wrong permissions then I am subject to the settings the sysadmin
      chose for /etc/gitconfig.
      
      Better to error out and ask the user to correct the problem.
      
      This only affects the user and xdg config files, since the user
      presumably has enough access to fix their permissions.  If the system
      config file is unreadable, the best we can do is to warn about it so
      the user knows to notify someone and get on with work in the meantime.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      96b9e0e3
    • J
      config, gitignore: failure to access with ENOTDIR is ok · e5c52c98
      Jonathan Nieder 提交于
      The access_or_warn() function is used to check for optional
      configuration files like .gitconfig and .gitignore and warn when they
      are not accessible due to a configuration issue (e.g., bad
      permissions).  It is not supposed to complain when a file is simply
      missing.
      
      Noticed on a system where ~/.config/git was a file --- when the new
      XDG_CONFIG_HOME support looks for ~/.config/git/config it should
      ignore ~/.config/git instead of printing irritating warnings:
      
       $ git status -s
       warning: unable to access '/home/jrn/.config/git/config': Not a directory
       warning: unable to access '/home/jrn/.config/git/config': Not a directory
       warning: unable to access '/home/jrn/.config/git/config': Not a directory
       warning: unable to access '/home/jrn/.config/git/config': Not a directory
      
      Compare v1.7.12.1~2^2 (attr:failure to open a .gitattributes file
      is OK with ENOTDIR, 2012-09-13).
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e5c52c98
  16. 22 8月, 2012 2 次提交
    • J
      warn_on_inaccessible(): a helper to warn on inaccessible paths · 55b38a48
      Junio C Hamano 提交于
      The previous series introduced warnings to multiple places, but it
      could become tiring to see the warning on the same path over and
      over again during a single run of Git.  Making just one function
      responsible for issuing this warning, we could later choose to keep
      track of which paths we issued a warning (it would involve a hash
      table of paths after running them through real_path() or something)
      in order to reduce noise.
      
      Right now we do not know if the noise reduction is necessary, but it
      still would be a good code reduction/sharing anyway.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      55b38a48
    • 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
  17. 23 5月, 2012 1 次提交
    • J
      ident: report passwd errors with a more friendly message · 2f705875
      Jeff King 提交于
      When getpwuid fails, we give a cute but cryptic message.
      While it makes sense if you know that getpwuid or identity
      functions are being called, this code is triggered behind
      the scenes by quite a few git commands these days (e.g.,
      receive-pack on a remote server might use it for a reflog;
      the current message is hard to distinguish from an
      authentication error).  Let's switch to something that gives
      a little more context.
      
      While we're at it, we can factor out all of the
      cut-and-pastes of the "you don't exist" message into a
      wrapper function. Rather than provide xgetpwuid, let's make
      it even more specific to just getting the passwd entry for
      the current uid. That's the only way we use getpwuid anyway,
      and it lets us make an even more specific error message.
      
      The current message also fails to mention errno. While the
      usual cause for getpwuid failing is that the user does not
      exist, mentioning errno makes it easier to diagnose these
      problems.  Note that POSIX specifies that errno remain
      untouched if the passwd entry does not exist (but will be
      set on actual errors), whereas some systems will return
      ENOENT or similar for a missing entry. We handle both cases
      in our wrapper.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2f705875
  18. 08 3月, 2012 1 次提交
  19. 27 5月, 2011 1 次提交
    • J
      read_in_full: always report errors · 56d7c27a
      Jeff King 提交于
      The read_in_full function repeatedly calls read() to fill a
      buffer. If the first read() returns an error, we notify the
      caller by returning the error. However, if we read some data
      and then get an error on a subsequent read, we simply return
      the amount of data that we did read, and the caller is
      unaware of the error.
      
      This makes the tradeoff that seeing the partial data is more
      important than the fact that an error occurred. In practice,
      this is generally not the case; we care more if an error
      occurred, and should throw away any partial data.
      
      I audited the current callers. In most cases, this will make
      no difference at all, as they do:
      
        if (read_in_full(fd, buf, size) != size)
      	  error("short read");
      
      However, it will help in a few cases:
      
        1. In sha1_file.c:index_stream, we would fail to notice
           errors in the incoming stream.
      
        2. When reading symbolic refs in resolve_ref, we would
           fail to notice errors and potentially use a truncated
           ref name.
      
        3. In various places, we will get much better error
           messages. For example, callers of safe_read would
           erroneously print "the remote end hung up unexpectedly"
           instead of showing the read error.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      56d7c27a
  20. 18 3月, 2011 1 次提交
  21. 11 2月, 2011 1 次提交
  22. 22 12月, 2010 2 次提交
  23. 11 11月, 2010 5 次提交
  24. 21 8月, 2010 1 次提交
  25. 09 5月, 2010 1 次提交
  26. 29 3月, 2010 3 次提交
  27. 25 3月, 2010 1 次提交
  28. 23 2月, 2010 2 次提交
    • M
      Use git_mkstemp_mode and xmkstemp_mode in odb_mkstemp, not chmod later. · f80c7ae8
      Matthieu Moy 提交于
      We used to create 0600 files, and then use chmod to set the group and
      other permission bits to the umask. This usually has the same effect
      as a normal file creation with a umask.
      
      But in the presence of ACLs, the group permission plays the role of
      the ACL mask: the "g" bits of newly created files are chosen according
      to default ACL mask of the directory, not according to the umask, and
      doing a chmod() on these "g" bits affect the ACL's mask instead of
      actual group permission.
      
      In other words, creating files with 0600 and then doing a chmod to the
      umask creates files which are unreadable by users allowed in the
      default ACL. To create the files without breaking ACLs, we let the
      umask do it's job at the file's creation time, and get rid of the
      later chmod.
      Signed-off-by: NMatthieu Moy <Matthieu.Moy@imag.fr>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f80c7ae8
    • M
      git_mkstemp_mode, xmkstemp_mode: variants of gitmkstemps with mode argument. · b862b61c
      Matthieu Moy 提交于
      gitmkstemps emulates the behavior of mkstemps, which is usually used
      to create files in a shared directory like /tmp/, hence, it creates
      files with permission 0600.
      
      Add git_mkstemps_mode() that allows us to specify the desired mode, and
      make git_mkstemps() a wrapper that always uses 0600 to call it. Later we
      will use git_mkstemps_mode() when creating pack files.
      Signed-off-by: NMatthieu Moy <Matthieu.Moy@imag.fr>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b862b61c