1. 20 8月, 2017 1 次提交
    • J
      progress: simplify "delayed" progress API · 8aade107
      Junio C Hamano 提交于
      We used to expose the full power of the delayed progress API to the
      callers, so that they can specify, not just the message to show and
      expected total amount of work that is used to compute the percentage
      of work performed so far, the percent-threshold parameter P and the
      delay-seconds parameter N.  The progress meter starts to show at N
      seconds into the operation only if we have not yet completed P per-cent
      of the total work.
      
      Most callers used either (0%, 2s) or (50%, 1s) as (P, N), but there
      are oddballs that chose more random-looking values like 95%.
      
      For a smoother workload, (50%, 1s) would allow us to start showing
      the progress meter earlier than (0%, 2s), while keeping the chance
      of not showing progress meter for long running operation the same as
      the latter.  For a task that would take 2s or more to complete, it
      is likely that less than half of it would complete within the first
      second, if the workload is smooth.  But for a spiky workload whose
      earlier part is easier, such a setting is likely to fail to show the
      progress meter entirely and (0%, 2s) is more appropriate.
      
      But that is merely a theory.  Realistically, it is of dubious value
      to ask each codepath to carefully consider smoothness of their
      workload and specify their own setting by passing two extra
      parameters.  Let's simplify the API by dropping both parameters and
      have everybody use (0%, 2s).
      
      Oh, by the way, the percent-threshold parameter and the structure
      member were consistently misspelled, which also is now fixed ;-)
      Helped-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8aade107
  2. 15 8月, 2017 1 次提交
  3. 04 8月, 2017 2 次提交
    • B
      unpack-trees: improve loading of .gitmodules · 33028713
      Brandon Williams 提交于
      When recursing submodules 'check_updates()' needs to have strict control
      over the submodule-config subsystem to ensure that the gitmodules file
      has been read before checking cache entries which are marked for
      removal as well ensuring the proper gitmodules file is read before
      updating cache entries.
      
      Because of this let's not rely on callers of 'check_updates()' to read
      the gitmodules file before calling 'check_updates()' and handle the
      reading explicitly.
      Signed-off-by: NBrandon Williams <bmwill@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      33028713
    • B
      unpack-trees: don't respect submodule.update · 7463e2ec
      Brandon Williams 提交于
      The 'submodule.update' config was historically used and respected by the
      'submodule update' command because update handled a variety of different
      ways it updated a submodule.  As we begin teaching other commands about
      submodules it makes more sense for the different settings of
      'submodule.update' to be handled by the individual commands themselves
      (checkout, rebase, merge, etc) so it shouldn't be respected by the
      native checkout command.
      
      Also remove the overlaying of the repository's config (via using
      'submodule_config()') from the commands which use the unpack-trees
      logic (checkout, read-tree, reset).
      Signed-off-by: NBrandon Williams <bmwill@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7463e2ec
  4. 03 8月, 2017 1 次提交
  5. 01 7月, 2017 1 次提交
    • L
      convert: add "status=delayed" to filter process protocol · 2841e8f8
      Lars Schneider 提交于
      Some `clean` / `smudge` filters may require a significant amount of
      time to process a single blob (e.g. the Git LFS smudge filter might
      perform network requests). During this process the Git checkout
      operation is blocked and Git needs to wait until the filter is done to
      continue with the checkout.
      
      Teach the filter process protocol, introduced in edcc8581 ("convert: add
      filter.<driver>.process option", 2016-10-16), to accept the status
      "delayed" as response to a filter request. Upon this response Git
      continues with the checkout operation. After the checkout operation Git
      calls "finish_delayed_checkout" which queries the filter for remaining
      blobs. If the filter is still working on the completion, then the filter
      is expected to block. If the filter has completed all remaining blobs
      then an empty response is expected.
      
      Git has a multiple code paths that checkout a blob. Support delayed
      checkouts only in `clone` (in unpack-trees.c) and `checkout` operations
      for now. The optimization is most effective in these code paths as all
      files of the tree are processed.
      Signed-off-by: NLars Schneider <larsxschneider@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2841e8f8
  6. 16 6月, 2017 1 次提交
  7. 20 5月, 2017 1 次提交
  8. 06 5月, 2017 4 次提交
  9. 19 4月, 2017 1 次提交
  10. 15 4月, 2017 1 次提交
    • J
      unpack-trees: avoid duplicate ODB lookups during checkout · d12a8cf0
      Jeff Hostetler 提交于
      Teach traverse_trees_recursive() to not do redundant ODB
      lookups when both directories refer to the same OID.
      
      In operations such as read-tree and checkout, there will
      likely be many peer directories that have the same OID when
      the differences between the commits are relatively small.
      In these cases we can avoid hitting the ODB multiple times
      for the same OID.
      
      This patch handles n=2 and n=3 cases and simply copies the
      data rather than repeating the fill_tree_descriptor().
      
      ================
      On the Windows repo (500K trees, 3.1M files, 450MB index),
      this reduced the overall time by 0.75 seconds when cycling
      between 2 commits with a single file difference.
      
      (avg) before: 22.699
      (avg) after:  21.955
      ===============
      
      ================
      On Linux using p0006-read-tree-checkout.sh with linux.git:
      
      Test                                                          HEAD^              HEAD
      -------------------------------------------------------------------------------------------------------
      0006.2: read-tree br_base br_ballast (57994)                  0.24(0.20+0.03)    0.24(0.22+0.01) +0.0%
      0006.3: switch between br_base br_ballast (57994)             10.58(6.23+2.86)   10.67(5.94+2.87) +0.9%
      0006.4: switch between br_ballast br_ballast_plus_1 (57994)   0.60(0.44+0.17)    0.57(0.44+0.14) -5.0%
      0006.5: switch between aliases (57994)                        0.59(0.48+0.13)    0.57(0.44+0.15) -3.4%
      ================
      Signed-off-by: NJeff Hostetler <jeffhost@microsoft.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d12a8cf0
  11. 30 3月, 2017 1 次提交
  12. 17 3月, 2017 2 次提交
  13. 26 1月, 2017 1 次提交
    • S
      unpack-trees: support super-prefix option · 3d415425
      Stefan Beller 提交于
      In the future we want to support working tree operations within submodules,
      e.g. "git checkout --recurse-submodules", which will update the submodule
      to the commit as recorded in its superproject. In the submodule the
      unpack-tree operation is carried out as usual, but the reporting to the
      user needs to prefix any path with the superproject. The mechanism for
      this is the super-prefix. (see 74866d75, git: make super-prefix option)
      
      Add support for the super-prefix option for commands that unpack trees
      by wrapping any path output in unpacking trees in the newly introduced
      super_prefixed function. This new function prefixes any path with the
      super-prefix if there is one.  Assuming the submodule case doesn't happen
      in the majority of the cases, we'd want to have a fast behavior for no
      super prefix, i.e. no reallocation/copying, but just returning path.
      
      Another aspect of introducing the `super_prefixed` function is to consider
      who owns the memory and if this is the right place where the path gets
      modified. As the super prefix ought to change the output behavior only and
      not the actual unpack tree part, it is fine to be that late in the line.
      As we get passed in 'const char *path', we cannot change the path itself,
      which means in case of a super prefix we have to copy over the path.
      We need two static buffers in that function as the error messages
      contain at most two paths.
      
      For testing purposes enable it in read-tree, which has no output
      of paths other than an unpack-trees.c. These are all converted in
      this patch.
      Signed-off-by: NStefan Beller <sbeller@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3d415425
  14. 11 1月, 2017 3 次提交
  15. 06 12月, 2016 1 次提交
  16. 23 9月, 2016 1 次提交
  17. 14 9月, 2016 1 次提交
  18. 09 9月, 2016 1 次提交
  19. 08 9月, 2016 1 次提交
  20. 27 6月, 2016 1 次提交
  21. 13 5月, 2016 1 次提交
  22. 10 5月, 2016 1 次提交
  23. 26 4月, 2016 1 次提交
  24. 13 4月, 2016 1 次提交
  25. 23 1月, 2016 1 次提交
  26. 06 1月, 2016 1 次提交
    • D
      do_compare_entry: use already-computed path · d9c2bd56
      David Turner 提交于
      In traverse_trees, we generate the complete traverse path for a
      traverse_info.  Later, in do_compare_entry, we used to go do a bunch
      of work to compare the traverse_info to a cache_entry's name without
      computing that path.  But since we already have that path, we don't
      need to do all that work.  Instead, we can just put the generated
      path into the traverse_info, and do the comparison more directly.
      
      We copy the path because prune_traversal might mutate `base`. This
      doesn't happen in any codepaths where do_compare_entry is called,
      but it's better to be safe.
      
      This makes git checkout much faster -- about 25% on Twitter's
      monorepo.  Deeper directory trees are likely to benefit more than
      shallower ones.
      Signed-off-by: NDavid Turner <dturner@twopensource.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d9c2bd56
  27. 26 9月, 2015 1 次提交
  28. 04 9月, 2015 1 次提交
    • J
      verify_absent: allow filenames longer than PATH_MAX · f514ef97
      Jeff King 提交于
      When unpack-trees wants to know whether a path will
      overwrite anything in the working tree, we use lstat() to
      see if there is anything there. But if we are going to write
      "foo/bar", we can't just lstat("foo/bar"); we need to look
      for leading prefixes (e.g., "foo"). So we use the lstat cache
      to find the length of the leading prefix, and copy the
      filename up to that length into a temporary buffer (since
      the original name is const, we cannot just stick a NUL in
      it).
      
      The copy we make goes into a PATH_MAX-sized buffer, which
      will overflow if the prefix is longer than PATH_MAX. How
      this happens is a little tricky, since in theory PATH_MAX is
      the biggest path we will have read from the filesystem. But
      this can happen if:
      
        - the compiled-in PATH_MAX does not accurately reflect
          what the filesystem is capable of
      
        - the leading prefix is not _quite_ what is on disk; it
          contains the next element from the name we are checking.
          So if we want to write "aaa/bbb/ccc/ddd" and "aaa/bbb"
          exists, the prefix of interest is "aaa/bbb/ccc". If
          "aaa/bbb" approaches PATH_MAX, then "ccc" can overflow
          it.
      
      So this can be triggered, but it's hard to do. In
      particular, you cannot just "git clone" a bogus repo. The
      verify_absent checks happen before unpack-trees writes
      anything to the filesystem, so there are never any leading
      prefixes during the initial checkout, and the bug doesn't
      trigger. And by definition, these files are larger than
      PATH_MAX, so writing them will fail, and clone will
      complain (though it may write a partial path, which will
      cause a subsequent "git checkout" to hit the bug).
      
      We can fix it by creating the temporary path on the heap.
      The extra malloc overhead is not important, as we are
      already making at least one stat() call (and probably more
      for the prefix discovery).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f514ef97
  29. 11 8月, 2015 1 次提交
    • J
      prefer git_pathdup to git_path in some possibly-dangerous cases · fcd12db6
      Jeff King 提交于
      Because git_path uses a static buffer that is shared with
      calls to git_path, mkpath, etc, it can be dangerous to
      assign the result to a variable or pass it to a non-trivial
      function. The value may change unexpectedly due to other
      calls.
      
      None of the cases changed here has a known bug, but they're
      worth converting away from git_path because:
      
        1. It's easy to use git_pathdup in these cases.
      
        2. They use constructs (like assignment) that make it
           hard to tell whether they're safe or not.
      
      The extra malloc overhead should be trivial, as an
      allocation should be an order of magnitude cheaper than a
      system call (which we are clearly about to make, since we
      are constructing a filename). The real cost is that we must
      remember to free the result.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fcd12db6
  30. 29 7月, 2015 1 次提交
  31. 22 7月, 2015 1 次提交
    • D
      unpack-trees: don't update files with CE_WT_REMOVE set · 7d782416
      David Turner 提交于
      Don't update files in the worktree from cache entries which are
      flagged with CE_WT_REMOVE.
      
      When a user does a sparse checkout, git removes files that are
      marked with CE_WT_REMOVE (because they are out-of-scope for the
      sparse checkout). If those files are also marked CE_UPDATE (for
      instance, because they differ in the branch that is being checked
      out and the outgoing branch), git would previously recreate them.
      This patch prevents them from being recreated.
      
      These erroneously-created files would also interfere with merges,
      causing pre-merge revisions of out-of-scope files to appear in the
      worktree.
      
      apply_sparse_checkout() is the function where all "action"
      manipulation (add, delete, update files..) for sparse checkout
      occurs; it should not ask to delete and update both at the same
      time.
      Signed-off-by: NAnatole Shaw <git-devel@omni.poc.net>
      Signed-off-by: NDavid Turner <dturner@twopensource.com>
      Helped-by: NDuy Nguyen <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7d782416
  32. 13 3月, 2015 1 次提交
    • N
      untracked cache: invalidate at index addition or removal · e931371a
      Nguyễn Thái Ngọc Duy 提交于
      Ideally we should implement untracked_cache_remove_from_index() and
      untracked_cache_add_to_index() so that they update untracked cache
      right away instead of invalidating it and wait for read_directory()
      next time to deal with it. But that may need some more work in
      unpack-trees.c. So stay simple as the first step.
      
      The new call in add_index_entry_with_check() may look strange because
      new calls usually stay close to cache_tree_invalidate_path(). We do it
      a bit later than c_t_i_p() in this function because if it's about
      replacing the entry with the same name, we don't care (but cache-tree
      does).
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e931371a
  33. 18 12月, 2014 1 次提交