1. 07 3月, 2017 3 次提交
  2. 02 3月, 2017 3 次提交
  3. 20 1月, 2017 1 次提交
  4. 12 1月, 2017 1 次提交
  5. 08 12月, 2016 1 次提交
    • J
      hold_locked_index(): align error handling with hold_lockfile_for_update() · b3e83cc7
      Junio C Hamano 提交于
      Callers of the hold_locked_index() function pass 0 when they want to
      prepare to write a new version of the index file without wishing to
      die or emit an error message when the request fails (e.g. somebody
      else already held the lock), and pass 1 when they want the call to
      die upon failure.
      
      This option is called LOCK_DIE_ON_ERROR by the underlying lockfile
      API, and the hold_locked_index() function translates the paramter to
      LOCK_DIE_ON_ERROR when calling the hold_lock_file_for_update().
      
      Replace these hardcoded '1' with LOCK_DIE_ON_ERROR and stop
      translating.  Callers other than the ones that are replaced with
      this change pass '0' to the function; no behaviour change is
      intended with this patch.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ---
      
      Among the callers of hold_locked_index() that passes 0:
      
       - diff.c::refresh_index_quietly() at the end of "git diff" is an
         opportunistic update; it leaks the lockfile structure but it is
         just before the program exits and nobody should care.
      
       - builtin/describe.c::cmd_describe(),
         builtin/commit.c::cmd_status(),
         sequencer.c::read_and_refresh_cache() are all opportunistic
         updates and they are OK.
      
       - builtin/update-index.c::cmd_update_index() takes a lock upfront
         but we may end up not needing to update the index (i.e. the
         entries may be fully up-to-date), in which case we do not need to
         issue an error upon failure to acquire the lock.  We do diagnose
         and die if we indeed need to update, so it is OK.
      
       - wt-status.c::require_clean_work_tree() IS BUGGY.  It asks
         silence, does not check the returned value.  Compare with
         callsites like cmd_describe() and cmd_status() to notice that it
         is wrong to call update_index_if_able() unconditionally.
      b3e83cc7
  6. 28 10月, 2016 1 次提交
    • J
      git_open(): untangle possible NOATIME and CLOEXEC interactions · 1b8ac5ea
      Junio C Hamano 提交于
      The way we structured the fallback/retry mechanism for opening with
      O_NOATIME and O_CLOEXEC meant that if we failed due to lack of
      support to open the file with O_NOATIME option (i.e. EINVAL), we
      would still try to drop O_CLOEXEC first and retry, and then drop
      O_NOATIME.  A platform on which O_NOATIME is defined in the header
      without support from the kernel wouldn't have a chance to open with
      O_CLOEXEC option due to this code structure.
      
      Arguably, O_CLOEXEC is more important than O_NOATIME, as the latter
      is mostly about performance, while the former can affect correctness.
      
      Instead use O_CLOEXEC to open the file, and then use fcntl(2) to set
      O_NOATIME on the resulting file descriptor.  open(2) itself does not
      cause atime to be updated according to Linus [*1*].
      
      The helper to do the former can be usable in the codepath in
      ce_compare_data() that was recently added to open a file descriptor
      with O_CLOEXEC; use it while we are at it.
      
      *1* <CA+55aFw83E+zOd+z5h-CA-3NhrLjVr-anL6pubrSWttYx3zu8g@mail.gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1b8ac5ea
  7. 26 10月, 2016 1 次提交
    • L
      read-cache: make sure file handles are not inherited by child processes · a0a6cb96
      Lars Schneider 提交于
      This fixes "convert: add filter.<driver>.process option" (edcc8581) on
      Windows.
      
      Consider the case of a file that requires filtering and is present in
      branch A but not in branch B. If A is the current HEAD and we checkout B
      then the following happens:
      
      1. ce_compare_data() opens the file
      2.   index_fd() detects that the file requires to run a clean filter and
           calls index_stream_convert_blob()
      4.     index_stream_convert_blob() calls convert_to_git_filter_fd()
      5.       convert_to_git_filter_fd() calls apply_filter() which creates a
               new long running filter process (in case it is the first file
               of this kind to be filtered)
      6.       The new filter process inherits all file handles. This is the
               default on Linux/OSX and is explicitly defined in the
               `CreateProcessW` call in `mingw.c` on Windows.
      7. ce_compare_data() closes the file
      8. Git unlinks the file as it is not present in B
      
      The unlink operation does not work on Windows because the filter process
      has still an open handle to the file. On Linux/OSX the unlink operation
      succeeds but the file descriptors still leak into the child process.
      
      Fix this problem by opening files in read-cache with the O_CLOEXEC flag
      to ensure that the file descriptor does not remain open in a newly
      spawned process similar to 05d1ed61 ("mingw: ensure temporary file
      handles are not inherited by child processes", 2016-08-22).
      Signed-off-by: NLars Schneider <larsxschneider@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a0a6cb96
  8. 16 9月, 2016 2 次提交
  9. 08 9月, 2016 1 次提交
  10. 13 7月, 2016 1 次提交
    • J
      merge: avoid "safer crlf" during recording of merge results · 1335d76e
      Junio C Hamano 提交于
      When merge_recursive() decides what the correct blob object merge
      result for a path should be, it uses update_file_flags() helper
      function to write it out to a working tree file and then calls
      add_cacheinfo().  The add_cacheinfo() function in turn calls
      make_cache_entry() to create a new cache entry to replace the
      higher-stage entries for the path that represents the conflict.
      
      The make_cache_entry() function calls refresh_cache_entry() to fill
      in the cached stat information.  To mark a cache entry as
      up-to-date, the data is re-read from the file in the working tree,
      and goes through convert_to_git() conversion to be compared with the
      blob object name the new cache entry records.
      
      It is important to note that this happens while the higher-stage
      entries, which are going to be replaced with the new entry, are
      still in the index.  Unfortunately, the convert_to_git() conversion
      has a misguided "safer crlf" mechanism baked in, and looks at the
      existing cache entry for the path to decide how to convert the
      contents in the working tree file.  If our side (i.e. stage#2)
      records a text blob with CRLF in it, even when the system is
      configured to record LF in blobs and convert them to CRLF upon
      checkout (and back to LF upon checkin), the "safer crlf" mechanism
      stops us doing so.
      
      This especially poses a problem during a renormalizing merge, where
      the merge result for the path is computed by first "normalizing" the
      blobs involved in the merge by using convert_to_working_tree()
      followed by convert_to_git() with "safer crlf" disabled.  The merge
      result that is computed correctly and fed to add_cacheinfo() via
      update_file_flags() does _not_ match what refresh_cache_entry() sees
      by converting the working tree file via convert_to_git().
      
      We can work this around by not refreshing the new cache entry in
      make_cache_entry() called by add_cacheinfo().  After add_cacheinfo()
      adds the new entry, we can call refresh_cache_entry() on that,
      knowing that addition of this new cache entry would have removed the
      stale cache entries that had CRLF in stage #2 that were carried over
      before the renormalizing merge started and will not interfere with
      the correct recording of the result.
      
      The test update was taken from a series by Torsten Bögershausen
      that attempted to fix this with a different approach.
      Signed-off-by: NTorsten Bögershausen <tboegi@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      Reviewed-by: NTorsten Bögershausen <tboegi@web.de>
      1335d76e
  11. 08 6月, 2016 1 次提交
    • E
      add: add --chmod=+x / --chmod=-x options · 4e55ed32
      Edward Thomson 提交于
      The executable bit will not be detected (and therefore will not be
      set) for paths in a repository with `core.filemode` set to false,
      though the users may still wish to add files as executable for
      compatibility with other users who _do_ have `core.filemode`
      functionality.  For example, Windows users adding shell scripts may
      wish to add them as executable for compatibility with users on
      non-Windows.
      
      Although this can be done with a plumbing command
      (`git update-index --add --chmod=+x foo`), teaching the `git-add`
      command allows users to set a file executable with a command that
      they're already familiar with.
      Signed-off-by: NEdward Thomson <ethomson@edwardthomson.com>
      Helped-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4e55ed32
  12. 28 1月, 2016 1 次提交
    • C
      config: add core.untrackedCache · 435ec090
      Christian Couder 提交于
      When we know that mtime on directory as given by the environment
      is usable for the purpose of untracked cache, we may want the
      untracked cache to be always used without any mtime test or
      kernel name check being performed.
      
      Also when we know that mtime is not usable for the purpose of
      untracked cache, for example because the repo is shared over a
      network file system, we may want the untracked-cache to be
      automatically removed from the index.
      
      Allow the user to express such preference by setting the
      'core.untrackedCache' configuration variable, which can take
      'keep', 'false', or 'true' and default to 'keep'.
      
      When read_index_from() is called, it now adds or removes the
      untracked cache in the index to respect the value of this
      variable. So it does nothing if the value is `keep` or if the
      variable is unset; it adds the untracked cache if the value is
      `true`; and it removes the cache if the value is `false`.
      
      `git update-index --[no-|force-]untracked-cache` still adds the
      untracked cache to, or removes it, from the index, but this
      shows a warning if it goes against the value of
      core.untrackedCache, because the next time the index is read
      the untracked cache will be added or removed if the
      configuration is set to do so.
      
      Also `--untracked-cache` used to check that the underlying
      operating system and file system change `st_mtime` field of a
      directory if files are added or deleted in that directory. But
      because those tests take a long time, `--untracked-cache` no
      longer performs them. Instead, there is now
      `--test-untracked-cache` to perform the tests. This change
      makes `--untracked-cache` the same as `--force-untracked-cache`.
      
      This last change is backward incompatible and should be
      mentioned in the release notes.
      Helped-by: NDuy Nguyen <pclouds@gmail.com>
      Helped-by: NTorsten Bögershausen <tboegi@web.de>
      Helped-by: NStefan Beller <sbeller@google.com>
      Signed-off-by: NChristian Couder <chriscool@tuxfamily.org>
      Signed-off-by: NÆvar Arnfjörð Bjarmason <avarab@gmail.com>
      
      read-cache: Duy'sfixup
      Signed-off-by: NChristian Couder <chriscool@tuxfamily.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      435ec090
  13. 23 10月, 2015 1 次提交
  14. 22 10月, 2015 1 次提交
  15. 07 9月, 2015 1 次提交
  16. 01 9月, 2015 1 次提交
  17. 11 8月, 2015 2 次提交
  18. 09 6月, 2015 1 次提交
    • N
      read-cache: fix untracked cache invalidation when split-index is used · ffcc9ba7
      Nguyễn Thái Ngọc Duy 提交于
      Before this change, t7063.17 fails. The actual action though happens at
      t7063.16 where the entry "two" is added back to index after being
      removed in the .13. Here we expect a directory invalidate at .16 and
      none at .17 where untracked cache is refreshed. But things do not go as
      expected when GIT_TEST_SPLIT_INDEX is set.
      
      The different behavior that happens at .16 when split index is used: the
      entry "two", when deleted at .13, is simply marked "deleted". When .16
      executes, the entry resurfaces from the version in base index. This
      happens in merge_base_index() where add_index_entry() is called to add
      "two" back from the base index.
      
      This is where the bug comes from. The add_index_entry() is called with
      ADD_CACHE_KEEP_CACHE_TREE flag because this version of "two" is not new,
      it does not break either cache-tree or untracked cache. The code should
      check this flag and not invalidate untracked cache. This causes a second
      invalidation violates test expectation. The fix is obvious.
      Noticed-by: NThomas Gummerer <t.gummerer@gmail.com>
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ffcc9ba7
  19. 29 5月, 2015 1 次提交
    • J
      read-cache.c: drop PROT_WRITE from mmap of index · a1293ef7
      Jeff King 提交于
      Once upon a time, git's in-memory representation of a cache
      entry actually pointed to the mmap'd on-disk data. So in
      520fc241 (Allow writing to the private index file mapping.,
      2005-04-26), we specified PROT_WRITE so that we could tweak
      the entries while we run (in our own MAP_PRIVATE copy-on-write
      version, of course).
      
      Later, 7a51ed66 (Make on-disk index representation separate
      from in-core one, 2008-01-14) stopped doing this; we copy
      the data into our in-core representation, and then drop the
      mmap immediately. We can therefore drop the PROT_WRITE flag.
      It's probably not hurting anything as it is, but it's
      potentially confusing.
      
      Note that we could also mark the mapping as "const" to
      verify that we never write to it. However, we don't
      typically do that for our other maps, as it then requires
      casting to munmap() it.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a1293ef7
  20. 24 3月, 2015 2 次提交
    • S
      read-cache: fix memleak · 915e44c6
      Stefan Beller 提交于
      `ce` is allocated in make_cache_entry and should be freed if it is not
      used any more. refresh_cache_entry as a wrapper around refresh_cache_ent
      will either return
      
       - the `ce` given as the parameter, when it was up-to-date;
       - a new updated cache entry which is allocated to new memory; or
       - a NULL when refreshing failed.
      
      In the latter two cases, the original cache-entry `ce` is not used
      and needs to be freed.  The rule can be expressed as "if the return
      value from refresh is different from the original ce, ce is no
      longer used."
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NStefan Beller <sbeller@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      915e44c6
    • J
      add_to_index(): free unused cache-entry · 067178ed
      Junio C Hamano 提交于
      We allocate a cache-entry pretty early in the function and then
      decide either not to do anything when we are pretending to add, or
      add it and then get an error (another possibility is obviously to
      succeed).
      
      When pretending or failing to add, we forgot to free the
      cache-entry.
      
      Noticed during a discussion on Stefan's patch to change the coding
      style without fixing the issue ;-)
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      067178ed
  21. 23 3月, 2015 1 次提交
  22. 21 3月, 2015 1 次提交
    • T
      read-cache: fix reading of split index · 03f15a79
      Thomas Gummerer 提交于
      The split index extension uses ewah bitmaps to mark index entries as
      deleted, instead of removing them from the index directly.  This can
      result in an on-disk index, in which entries of stage #0 and higher
      stages appear, which are removed later when the index bases are merged.
      
      15999d0b read_index_from(): catch out of order entries when reading an
      index file introduces a check which checks if the entries are in order
      after each index entry is read in do_read_index.  This check may however
      fail when a split index is read.
      
      Fix this by moving checking the index after we know there is no split
      index or after the split index bases are successfully merged instead.
      Signed-off-by: NThomas Gummerer <t.gummerer@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      03f15a79
  23. 13 3月, 2015 6 次提交
  24. 18 2月, 2015 1 次提交
  25. 18 12月, 2014 3 次提交
    • J
      read-cache: optionally disallow NTFS .git variants · 2b4c6efc
      Johannes Schindelin 提交于
      The point of disallowing ".git" in the index is that we
      would never want to accidentally overwrite files in the
      repository directory. But this means we need to respect the
      filesystem's idea of when two paths are equal. The prior
      commit added a helper to make such a comparison for NTFS
      and FAT32; let's use it in verify_path().
      
      We make this check optional for two reasons:
      
        1. It restricts the set of allowable filenames, which is
           unnecessary for people who are not on NTFS nor FAT32.
           In practice this probably doesn't matter, though, as
           the restricted names are rather obscure and almost
           certainly would never come up in practice.
      
        2. It has a minor performance penalty for every path we
           insert into the index.
      
      This patch ties the check to the core.protectNTFS config
      option. Though this is expected to be most useful on Windows,
      we allow it to be set everywhere, as NTFS may be mounted on
      other platforms. The variable does default to on for Windows,
      though.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2b4c6efc
    • J
      read-cache: optionally disallow HFS+ .git variants · a42643aa
      Jeff King 提交于
      The point of disallowing ".git" in the index is that we
      would never want to accidentally overwrite files in the
      repository directory. But this means we need to respect the
      filesystem's idea of when two paths are equal. The prior
      commit added a helper to make such a comparison for HFS+;
      let's use it in verify_path.
      
      We make this check optional for two reasons:
      
        1. It restricts the set of allowable filenames, which is
           unnecessary for people who are not on HFS+. In practice
           this probably doesn't matter, though, as the restricted
           names are rather obscure and almost certainly would
           never come up in practice.
      
        2. It has a minor performance penalty for every path we
           insert into the index.
      
      This patch ties the check to the core.protectHFS config
      option. Though this is expected to be most useful on OS X,
      we allow it to be set everywhere, as HFS+ may be mounted on
      other platforms. The variable does default to on for OS X,
      though.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a42643aa
    • J
      verify_dotfile(): reject .git case-insensitively · cc2fc7c2
      Jeff King 提交于
      We do not allow ".git" to enter into the index as a path
      component, because checking out the result to the working
      tree may causes confusion for subsequent git commands.
      However, on case-insensitive file systems, ".Git" or ".GIT"
      is the same. We should catch and prevent those, too.
      
      Note that technically we could allow this for repos on
      case-sensitive filesystems. But there's not much point. It's
      unlikely that anybody cares, and it creates a repository
      that is unexpectedly non-portable to other systems.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cc2fc7c2
  26. 02 10月, 2014 1 次提交