1. 13 9月, 2011 1 次提交
    • J
      fetch: avoid quadratic loop checking for updated submodules · 6859de45
      Jeff King 提交于
      Recent versions of git can be slow to fetch repositories with a
      large number of refs (or when they already have a large
      number of refs). For example, GitHub makes pull-requests
      available as refs, which can lead to a large number of
      available refs. This slowness goes away when submodule
      recursion is turned off:
      
        $ git ls-remote git://github.com/rails/rails.git | wc -l
        3034
      
        [this takes ~10 seconds of CPU time to complete]
        git fetch --recurse-submodules=no \
          git://github.com/rails/rails.git "refs/*:refs/*"
      
        [this still isn't done after 10 _minutes_ of pegging the CPU]
        git fetch \
          git://github.com/rails/rails.git "refs/*:refs/*"
      
      You can produce a quicker and simpler test case like this:
      
        doit() {
          head=`git rev-parse HEAD`
          for i in `seq 1 $1`; do
            echo $head refs/heads/ref$i
          done >.git/packed-refs
          echo "==> $1"
          rm -rf dest
          git init -q --bare dest &&
            (cd dest && time git.compile fetch -q .. refs/*:refs/*)
        }
      
        rm -rf repo
        git init -q repo && cd repo &&
        >file && git add file && git commit -q -m one
      
        doit 100
        doit 200
        doit 400
        doit 800
        doit 1600
        doit 3200
      
      Which yields timings like:
      
        # refs  seconds of CPU
           100            0.06
           200            0.24
           400            0.95
           800            3.39
          1600           13.66
          3200           54.09
      
      Notice that although the number of refs doubles in each
      trial, the CPU time spent quadruples.
      
      The problem is that the submodule recursion code works
      something like:
      
        - for each ref we fetch
          - for each commit in git rev-list $new_sha1 --not --all
            - add modified submodules to list
        - fetch any newly referenced submodules
      
      But that means if we fetch N refs, we start N revision
      walks. Worse, because we use "--all", the number of refs we
      must process that constitute "--all" keeps growing, too. And
      you end up doing O(N^2) ref resolutions.
      
      Instead, this patch structures the code like this:
      
        - for each sha1 we already have
          - add $old_sha1 to list $old
        - for each ref we fetch
          - add $new_sha1 to list $new
        - for each commit in git rev-list $new --not $old
          - add modified submodules to list
        - fetch any newly referenced submodules
      
      This yields timings like:
      
        # refs  seconds of CPU
        100               0.00
        200               0.04
        400               0.04
        800               0.10
        1600              0.21
        3200              0.39
      
      Note that the amount of effort doubles as the number of refs
      doubles. Similarly, the fetch of rails.git takes about as
      much time as it does with --recurse-submodules=no.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6859de45
  2. 15 5月, 2011 1 次提交
    • J
      Submodules: Don't parse .gitmodules when it contains, merge conflicts · d4e98b58
      Jens Lehmann 提交于
      Commands like "git status", "git diff" and "git fetch" would fail when the
      .gitmodules file contained merge conflicts because the config parser would
      call die() when hitting the conflict markers:
      
          "fatal: bad config file line <n> in <path>/.gitmodules"
      
      While this behavior was on the safe side, it is really unhelpful to the
      user to have commands like status and diff fail, as these are needed to
      find out what's going on. And the error message is only mildly helpful,
      as it points to the right file but doesn't mention that it is unmerged.
      Users of git gui were not shown any conflicts at all when this happened.
      
      Improve the situation by checking if the index records .gitmodules as
      unmerged. When that is the case we can't make any assumptions about the
      configuration to be found there after the merge conflict is resolved by
      the user, so assume that all recursion is disabled unless .git/config or
      the global config say otherwise.
      
      As soon as the merge conflict is resolved and the .gitmodules file has
      been staged subsequent commands again honor any configuration done there.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d4e98b58
  3. 23 3月, 2011 1 次提交
    • S
      Fix sparse warnings · c2e86add
      Stephen Boyd 提交于
      Fix warnings from 'make check'.
      
       - These files don't include 'builtin.h' causing sparse to complain that
         cmd_* isn't declared:
      
         builtin/clone.c:364, builtin/fetch-pack.c:797,
         builtin/fmt-merge-msg.c:34, builtin/hash-object.c:78,
         builtin/merge-index.c:69, builtin/merge-recursive.c:22
         builtin/merge-tree.c:341, builtin/mktag.c:156, builtin/notes.c:426
         builtin/notes.c:822, builtin/pack-redundant.c:596,
         builtin/pack-refs.c:10, builtin/patch-id.c:60, builtin/patch-id.c:149,
         builtin/remote.c:1512, builtin/remote-ext.c:240,
         builtin/remote-fd.c:53, builtin/reset.c:236, builtin/send-pack.c:384,
         builtin/unpack-file.c:25, builtin/var.c:75
      
       - These files have symbols which should be marked static since they're
         only file scope:
      
         submodule.c:12, diff.c:631, replace_object.c:92, submodule.c:13,
         submodule.c:14, trace.c:78, transport.c:195, transport-helper.c:79,
         unpack-trees.c:19, url.c:3, url.c:18, url.c:104, url.c:117, url.c:123,
         url.c:129, url.c:136, thread-utils.c:21, thread-utils.c:48
      
       - These files redeclare symbols to be different types:
      
         builtin/index-pack.c:210, parse-options.c:564, parse-options.c:571,
         usage.c:49, usage.c:58, usage.c:63, usage.c:72
      
       - These files use a literal integer 0 when they really should use a NULL
         pointer:
      
         daemon.c:663, fast-import.c:2942, imap-send.c:1072, notes-merge.c:362
      
      While we're in the area, clean up some unused #includes in builtin files
      (mostly exec_cmd.h).
      Signed-off-by: NStephen Boyd <bebarino@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c2e86add
  4. 17 3月, 2011 1 次提交
    • J
      diff --submodule: split into bite-sized pieces · 808a95dc
      Jonathan Nieder 提交于
      Introduce two functions:
      
       - prepare_submodule_summary prepares the revision walker
         to list changes in a submodule.  That is, it:
      
         * finds merge bases between the commits pointed to this
           path from before ("left") and after ("right") the change;
         * checks whether this is a fast-forward or fast-backward;
         * prepares a revision walk to list commits in the symmetric
           difference between the commits at each endpoint.
      
         It returns nonzero on error.
      
       - print_submodule_summary runs the revision walk and saves
         the result to a strbuf in --left-right format.
      
      The goal is just readability.  No functional change intended.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Acked-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      808a95dc
  5. 10 3月, 2011 5 次提交
    • J
      fetch/pull: Don't recurse into a submodule when commits are already present · c16c3e40
      Jens Lehmann 提交于
      When looking for submodules where new commits have been recorded in the
      superproject ignore those cases where the submodules commits are already
      present locally. This can happen e.g. when the submodule has been rewound
      to an earlier state. Then there is no need to fetch the submodule again
      as the commit recorded in the newly fetched superproject commit has
      already been fetched earlier into the submodule.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c16c3e40
    • J
      Submodules: Add 'on-demand' value for the 'fetchRecurseSubmodule' option · bf42b384
      Jens Lehmann 提交于
      Now the behavior of fetch and pull can be configured to the recently added
      'on-demand' mode separately for each submodule too.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bf42b384
    • J
      config: teach the fetch.recurseSubmodules option the 'on-demand' value · 1fb25502
      Jens Lehmann 提交于
      To enable the user to change the default behavior of "git fetch" and "git
      pull" regarding submodule recursion add the new "on-demand" value which
      has just been added to the "--recurse-submodules" command line option.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1fb25502
    • J
      fetch/pull: Add the 'on-demand' value to the --recurse-submodules option · 8f0700dd
      Jens Lehmann 提交于
      Until now the --recurse-submodules option could only be used to either
      fetch all populated submodules recursively or to disable recursion
      completely. As fetch and pull now by default just fetch those submodules
      for which new commits have been fetched in the superproject, a command
      line option to enforce that behavior is needed to be able to override
      configuration settings.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8f0700dd
    • J
      fetch/pull: recurse into submodules when necessary · 88a21979
      Jens Lehmann 提交于
      To be able to access all commits of populated submodules referenced by the
      superproject it is sufficient to only then let "git fetch" recurse into a
      submodule when the new commits fetched in the superproject record new
      commits for it. Having these commits present is extremely useful when
      using the "--submodule" option to "git diff" (which is what "git gui" and
      "gitk" do since 1.6.6), as all submodule commits needed for creating a
      descriptive output can be accessed. Also merging submodule commits (added
      in 1.7.3) depends on the submodule commits in question being present to
      work. Last but not least this enables disconnected operation when using
      submodules, as all commits necessary for a successful "git submodule
      update -N" will have been fetched automatically. So we choose this mode as
      the default for fetch and pull.
      
      Before a new or changed ref from upstream is updated in update_local_ref()
      "git rev-list <new-sha1> --not --branches --remotes" is used to determine
      all newly fetched commits. These are then walked and diffed against their
      parent(s) to see if a submodule has been changed. If that is the case, its
      path is stored to be fetched after the superproject fetch is completed.
      
      Using the "--recurse-submodules" or the "--no-recurse-submodules" option
      disables the examination of the fetched refs because the result will be
      ignored anyway.
      
      There is currently no infrastructure for storing deleted and new
      submodules in the .git directory of the superproject. That's why fetch and
      pull for now only fetch submodules that are already checked out and are
      not renamed.
      
      In t7403 the "--no-recurse-submodules" argument had to be added to "git
      pull" to avoid failure because of the moved upstream submodule repo.
      
      Thanks-to: Jonathan Nieder <jrnieder@gmail.com>
      Thanks-to: Heiko Voigt <hvoigt@hvoigt.net>
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      88a21979
  6. 10 12月, 2010 1 次提交
  7. 13 11月, 2010 3 次提交
    • J
      Submodules: Add the "fetchRecurseSubmodules" config option · c1a3c364
      Jens Lehmann 提交于
      The new boolean "fetchRecurseSubmodules" config option controls the
      behavior for "git fetch" and "git pull". It specifies if these commands
      should recurse into submodules and fetch new commits there too and can be
      set separately for each submodule.
      
      In the .gitmodules file "submodule.<name>.fetchRecurseSubmodules" entries
      are read before looking for them in .git/config. Thus settings found in
      .git/config will override those from .gitmodules, thereby allowing the
      user to ignore settings given by the remote side while also letting
      upstream set reasonable defaults for those users who don't have special
      needs.
      
      This configuration can be overridden by the command line option
      "--[no-]recurse-submodules" of "git fetch" and "git pull".
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c1a3c364
    • J
      Add the 'fetch.recurseSubmodules' config setting · be254a0e
      Jens Lehmann 提交于
      This new boolean option can be used to override the default for "git
      fetch" and "git pull", which is to not recurse into populated submodules
      and fetch all new commits there too.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      be254a0e
    • J
      fetch/pull: Add the --recurse-submodules option · 7dce19d3
      Jens Lehmann 提交于
      Until now you had to call "git submodule update" (without -N|--no-fetch
      option) or something like "git submodule foreach git fetch" to fetch
      new commits in populated submodules from their remote.
      
      This could lead to "(commits not present)" messages in the output of
      "git diff --submodule" (which is used by "git gui" and "gitk") after
      fetching or pulling new commits in the superproject and is an obstacle for
      implementing recursive checkout of submodules. Also "git submodule
      update" cannot fetch changes when disconnected, so it was very easy to
      forget to fetch the submodule changes before disconnecting only to
      discover later that they are needed.
      
      This patch adds the "--recurse-submodules" option to recursively fetch
      each populated submodule from the url configured in the .git/config of the
      submodule at the end of each "git fetch" or during "git pull" in the
      superproject. The submodule paths are taken from the index.
      
      The hidden option "--submodule-prefix" is added to "git fetch" to be able
      to print out the full paths of nested submodules.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7dce19d3
  8. 10 8月, 2010 3 次提交
    • J
      Add the 'diff.ignoreSubmodules' config setting · be4f2b40
      Johannes Schindelin 提交于
      When you have a lot of submodules checked out, the time penalty to check
      for dirty submodules can easily imply a multiplication of the total time
      by the factor 20. This makes the difference between almost instantaneous
      (< 2 seconds) and unbearably slow (> 50 seconds) here, since the disk
      caches are constantly overloaded.
      
      To this end, the submodule.*.ignore config option was introduced, but it
      is per-submodule.
      
      This commit introduces a global config setting to set a default
      (porcelain) value for the --ignore-submodules option, keeping the
      default at 'none'. It can be overridden by the submodule.*.ignore
      setting and by the --ignore-submodules option.
      
      Incidentally, this commit fixes an issue with the overriding logic:
      multiple --ignore-submodules options would not clear the previously
      set flags.
      
      While at it, fix a typo in the documentation for submodule.*.ignore.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      be4f2b40
    • J
      Submodules: Use "ignore" settings from .gitmodules too for diff and status · 302ad7a9
      Jens Lehmann 提交于
      The .gitmodules file is parsed for "submodule.<name>.ignore" entries
      before looking for them in .git/config. Thus settings found in .git/config
      will override those from .gitmodules, thereby allowing the local developer
      to ignore settings given by the remote side while also letting upstream
      set defaults for those users who don't have special needs.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      302ad7a9
    • J
      Submodules: Add the new "ignore" config option for diff and status · aee9c7d6
      Jens Lehmann 提交于
      The new "ignore" config option controls the default behavior for "git
      status" and the diff family. It specifies under what circumstances they
      consider submodules as modified and can be set separately for each
      submodule.
      
      The command line option "--ignore-submodules=" has been extended to accept
      the new parameter "none" for both status and diff.
      
      Users that chose submodules to get rid of long work tree scanning times
      might want to set the "dirty" option for those submodules. This brings
      back the pre 1.7.0 behavior, where submodule work trees were never
      scanned for modifications. By using "--ignore-submodules=none" on the
      command line the status and diff commands can be told to do a full scan.
      
      This option can be set to the following values (which have the same name
      and meaning as for the "--ignore-submodules" option of status and diff):
      
      "all": All changes to the submodule will be ignored.
      
      "dirty": Only differences of the commit recorded in the superproject and
      	the submodules HEAD will be considered modifications, all changes
      	to the work tree of the submodule will be ignored. When using this
      	value, the submodule will not be scanned for work tree changes at
      	all, leading to a performance benefit on large submodules.
      
      "untracked": Only untracked files in the submodules work tree are ignored,
      	a changed HEAD and/or modified files in the submodule will mark it
      	as modified.
      
      "none" (which is the default): Either untracked or modified files in a
      	submodules work tree or a difference between the subdmodules HEAD
      	and the commit recorded in the superproject will make it show up
      	as changed. This value is added as a new parameter for the
      	"--ignore-submodules" option of the diff family and "git status"
      	so the user can override the settings in the configuration.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      aee9c7d6
  9. 08 7月, 2010 1 次提交
    • H
      Implement automatic fast-forward merge for submodules · 68d03e4a
      Heiko Voigt 提交于
      This implements a simple merge strategy for submodule hashes. We check
      whether one side of the merge candidates is already contained in the
      other and then merge automatically.
      
      If both sides contain changes we search for a merge in the submodule.
      In case a single one exists we check that out and suggest it as the
      merge resolution. A list of candidates is returned when we find multiple
      merges that contain both sides of the changes.
      
      This is useful for a workflow in which the developers can publish topic
      branches in submodules and a separate maintainer merges them. In case
      the developers always wait until their branch gets merged before tracking
      them in the superproject all merges of branches that contain submodule
      changes will be resolved automatically. If developers choose to track
      their feature branch the maintainer might get a conflict but git will
      search the submodule for a merge and suggest it/them as a resolution.
      Signed-off-by: NHeiko Voigt <hvoigt@hvoigt.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      68d03e4a
  10. 26 6月, 2010 1 次提交
    • J
      Add the option "--ignore-submodules" to "git status" · 46a958b3
      Jens Lehmann 提交于
      In some use cases it is not desirable that "git status" considers
      submodules that only contain untracked content as dirty. This may happen
      e.g. when the submodule is not under the developers control and not all
      build generated files have been added to .gitignore by the upstream
      developers. Using the "untracked" parameter for the "--ignore-submodules"
      option disables checking for untracked content and lets git diff report
      them as changed only when they have new commits or modified content.
      
      Sometimes it is not wanted to have submodules show up as changed when they
      just contain changes to their work tree (this was the behavior before
      1.7.0). An example for that are scripts which just want to check for
      submodule commits while ignoring any changes to the work tree. Also users
      having large submodules known not to change might want to use this option,
      as the - sometimes substantial - time it takes to scan the submodule work
      tree(s) is saved when using the "dirty" parameter.
      
      And if you want to ignore any changes to submodules, you can now do that
      by using this option without parameters or with "all" (when the config
      option status.submodulesummary is set, using "all" will also suppress the
      output of the submodule summary).
      
      A new function handle_ignore_submodules_arg() is introduced to parse this
      option new to "git status" in a single location, as "git diff" already
      knew it.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      46a958b3
  11. 11 4月, 2010 1 次提交
    • J
      Teach diff --submodule and status to handle .git files in submodules · eee49b6c
      Jens Lehmann 提交于
      The simple test for an existing .git directory gives an incorrect result
      if .git is a file that records "gitdir: overthere". So for submodules that
      use a .git file, "git status" and the diff family - when the "--submodule"
      option is given - did assume the submodule was not populated at all when
      a .git file was used, thus generating wrong output or no output at all.
      
      This is fixed by using read_gitfile_gently() to get the correct location
      of the .git directory. While at it, is_submodule_modified() was cleaned up
      to use the "dir" member of "struct child_process" instead of setting the
      GIT_WORK_TREE and GIT_DIR environment variables.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      eee49b6c
  12. 14 3月, 2010 1 次提交
  13. 05 3月, 2010 1 次提交
    • J
      git diff --submodule: Show detailed dirty status of submodules · c7e1a736
      Jens Lehmann 提交于
      When encountering a dirty submodule while doing "git diff --submodule"
      print an extra line for new untracked content and another for modified
      but already tracked content. And if the HEAD of the submodule is equal
      to the ref diffed against in the superproject, drop the output which
      would just show the same SHA1s and no commit message headlines.
      
      To achieve that, the dirty_submodule bitfield is expanded to two bits.
      The output of "git status" inside the submodule is parsed to set the
      according bits.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c7e1a736
  14. 25 2月, 2010 1 次提交
  15. 01 2月, 2010 1 次提交
  16. 31 1月, 2010 1 次提交
  17. 25 1月, 2010 1 次提交
  18. 17 1月, 2010 1 次提交
  19. 12 1月, 2010 1 次提交
  20. 21 11月, 2009 1 次提交
  21. 20 10月, 2009 1 次提交