1. 03 9月, 2014 1 次提交
  2. 11 8月, 2014 1 次提交
  3. 18 7月, 2014 1 次提交
  4. 24 6月, 2014 1 次提交
    • J
      builtin/clone.c: detect a clone starting at a tag correctly · 60a5f5fc
      Junio C Hamano 提交于
      31b808a0 (clone --single: limit the fetch refspec to fetched branch,
      2012-09-20) tried to see if the given "branch" to follow is actually
      a tag at the remote repository by checking with "refs/tags/" but it
      incorrectly used strstr(3); it is actively wrong to treat a "branch"
      "refs/heads/refs/tags/foo" and use the logic for the "refs/tags/"
      ref hierarchy.  What the code really wanted to do is to see if it
      starts with "refs/tags/".
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      60a5f5fc
  5. 21 6月, 2014 1 次提交
    • J
      refactor skip_prefix to return a boolean · cf4fff57
      Jeff King 提交于
      The skip_prefix() function returns a pointer to the content
      past the prefix, or NULL if the prefix was not found. While
      this is nice and simple, in practice it makes it hard to use
      for two reasons:
      
        1. When you want to conditionally skip or keep the string
           as-is, you have to introduce a temporary variable.
           For example:
      
             tmp = skip_prefix(buf, "foo");
             if (tmp)
      	       buf = tmp;
      
        2. It is verbose to check the outcome in a conditional, as
           you need extra parentheses to silence compiler
           warnings. For example:
      
             if ((cp = skip_prefix(buf, "foo"))
      	       /* do something with cp */
      
      Both of these make it harder to use for long if-chains, and
      we tend to use starts_with() instead. However, the first line
      of "do something" is often to then skip forward in buf past
      the prefix, either using a magic constant or with an extra
      strlen(3) (which is generally computed at compile time, but
      means we are repeating ourselves).
      
      This patch refactors skip_prefix() to return a simple boolean,
      and to provide the pointer value as an out-parameter. If the
      prefix is not found, the out-parameter is untouched. This
      lets you write:
      
        if (skip_prefix(arg, "foo ", &arg))
      	  do_foo(arg);
        else if (skip_prefix(arg, "bar ", &arg))
      	  do_bar(arg);
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cf4fff57
  6. 14 6月, 2014 1 次提交
  7. 08 4月, 2014 1 次提交
  8. 19 3月, 2014 1 次提交
  9. 11 12月, 2013 3 次提交
    • N
      clone: use git protocol for cloning shallow repo locally · 0d7d285f
      Nguyễn Thái Ngọc Duy 提交于
      clone_local() does not handle $SRC/shallow. It could be made so, but
      it's simpler to use fetch-pack/upload-pack instead.
      
      This used to be caught by the check in upload-pack, which is triggered
      by transport_get_remote_refs(), even in local clone case. The check is
      now gone and check_everything_connected() should catch the result
      incomplete repo. But check_everything_connected() will soon be skipped
      in local clone case, opening a door to corrupt repo. This patch should
      close that door.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0d7d285f
    • N
      clone: support remote shallow repository · beea4152
      Nguyễn Thái Ngọc Duy 提交于
      Cloning from a shallow repository does not follow the "8 steps for new
      .git/shallow" because if it does we need to get through step 6 for all
      refs. That means commit walking down to the bottom.
      
      Instead the rule to create .git/shallow is simpler and, more
      importantly, cheap: if a shallow commit is found in the pack, it's
      probably used (i.e. reachable from some refs), so we add it. Others
      are dropped.
      
      One may notice this method seems flawed by the word "probably". A
      shallow commit may not be reachable from any refs at all if it's
      attached to an object island (a group of objects that are not
      reachable by any refs).
      
      If that object island is not complete, a new fetch request may send
      more objects to connect it to some ref. At that time, because we
      incorrectly installed the shallow commit in this island, the user will
      not see anything after that commit (fsck is still ok). This is not
      desired.
      
      Given that object islands are rare (C Git never sends such islands for
      security reasons) and do not really harm the repository integrity, a
      tradeoff is made to surprise the user occasionally but work faster
      everyday.
      
      A new option --strict could be added later that follows exactly the 8
      steps. "git prune" can also learn to remove dangling objects _and_ the
      shallow commits that are attached to them from .git/shallow.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      beea4152
    • N
      clone: prevent --reference to a shallow repository · 606e435a
      Nguyễn Thái Ngọc Duy 提交于
      If we borrow objects from another repository, we should also pay
      attention to their $GIT_DIR/shallow (and even info/grafts). But
      current alternates code does not.
      
      Reject alternate repos that are shallow because we do not do it
      right. In future the alternate code may be updated to check
      $GIT_DIR/shallow properly so that this restriction could be lifted.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      606e435a
  10. 07 12月, 2013 1 次提交
  11. 06 12月, 2013 1 次提交
    • C
      replace {pre,suf}fixcmp() with {starts,ends}_with() · 59556548
      Christian Couder 提交于
      Leaving only the function definitions and declarations so that any
      new topic in flight can still make use of the old functions, replace
      existing uses of the prefixcmp() and suffixcmp() with new API
      functions.
      
      The change can be recreated by mechanically applying this:
      
          $ git grep -l -e prefixcmp -e suffixcmp -- \*.c |
            grep -v strbuf\\.c |
            xargs perl -pi -e '
              s|!prefixcmp\(|starts_with\(|g;
              s|prefixcmp\(|!starts_with\(|g;
              s|!suffixcmp\(|ends_with\(|g;
              s|suffixcmp\(|!ends_with\(|g;
            '
      
      on the result of preparatory changes in this series.
      Signed-off-by: NChristian Couder <chriscool@tuxfamily.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      59556548
  12. 15 10月, 2013 1 次提交
  13. 25 9月, 2013 1 次提交
  14. 19 9月, 2013 3 次提交
    • J
      clone: always set transport options · 643f918d
      Jeff King 提交于
      A clone will always create a transport struct, whether we
      are cloning locally or using an actual protocol. In the
      local case, we only use the transport to get the list of
      refs, and then transfer the objects out-of-band.
      
      However, there are many options that we do not bother
      setting up in the local case. For the most part, these are
      noops, because they only affect the object-fetching stage
      (e.g., the --depth option).  However, some options do have a
      visible impact. For example, giving the path to upload-pack
      via "-u" does not currently work for a local clone, even
      though we need upload-pack to get the ref list.
      
      We can just drop the conditional entirely and set these
      options for both local and non-local clones. Rather than
      keep track of which options impact the object versus the ref
      fetching stage, we can simply let the noops be noops (and
      the cost of setting the options in the first place is not
      high).
      
      The one exception is that we also check that the transport
      provides both a "get_refs_list" and a "fetch" method. We
      will now be checking the former for both cases (which is
      good, since a transport that cannot fetch refs would not
      work for a local clone), and we tweak the conditional to
      check for a "fetch" only when we are non-local.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      643f918d
    • J
      clone: treat "checking connectivity" like other progress · 2856cbf0
      Jeff King 提交于
      When stderr does not point to a tty, we typically suppress
      "we are now in this phase" progress reporting (e.g., we ask
      the server not to send us "counting objects" and the like).
      
      The new "checking connectivity" message is in the same vein,
      and should be suppressed. Since clone relies on the
      transport code to make the decision, we can simply sneak a
      peek at the "progress" field of the transport struct. That
      properly takes into account both the verbosity and progress
      options we were given, as well as the result of isatty().
      
      Note that we do not set up that progress flag for a local
      clone, as we do not fetch using the transport at all. That's
      acceptable here, though, because we also do not perform a
      connectivity check in that case.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2856cbf0
    • J
      clone: send diagnostic messages to stderr · 68b939b2
      Jeff King 提交于
      Putting messages like "Cloning into.." and "done" on stdout
      is un-Unix and uselessly clutters the stdout channel. Send
      them to stderr.
      
      We have to tweak two tests to accommodate this:
      
        1. t5601 checks for doubled output due to forking, and
           doesn't actually care where the output goes; adjust it
           to check stderr.
      
        2. t5702 is trying to test whether progress output was
           sent to stderr, but naively does so by checking
           whether stderr produced any output. Instead, have it
           look for "%", a token found in progress output but not
           elsewhere (and which lets us avoid hard-coding the
           progress text in the test).
      
      This should not regress any scripts that try to parse the
      current output, as the output is already internationalized
      and therefore unstable.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      68b939b2
  15. 06 8月, 2013 2 次提交
  16. 08 7月, 2013 1 次提交
    • J
      clone: drop connectivity check for local clones · 125a05fd
      Jeff King 提交于
      Commit 0433ad12 (clone: run check_everything_connected,
      2013-03-25) added the same connectivity check to clone that
      we use for fetching. The intent was to provide enough safety
      checks that "git clone git://..." could be counted on to
      detect bit errors and other repo corruption, and not
      silently propagate them to the clone.
      
      For local clones, this turns out to be a bad idea, for two
      reasons:
      
        1. Local clones use hard linking (or even shared object
           stores), and so complete far more quickly. The time
           spent on the connectivity check is therefore
           proportionally much more painful.
      
        2. Local clones do not actually meet our safety guarantee
           anyway. The connectivity check makes sure we have all
           of the objects we claim to, but it does not check for
           bit errors. We will notice bit errors in commits and
           trees, but we do not load blob objects at all. Whereas
           over the pack transport, we actually recompute the sha1
           of each object in the incoming packfile; bit errors
           change the sha1 of the object, which is then caught by
           the connectivity check.
      
      This patch drops the connectivity check in the local case.
      Note that we have to revert the changes from 0433ad12 to
      t5710, as we no longer notice the corruption during clone.
      
      We could go a step further and provide a "verify even local
      clones" option, but it is probably not worthwhile. You can
      already spell that as "cd foo.git && git fsck && git clone ."
      or as "git clone --no-local foo.git".
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      125a05fd
  17. 04 7月, 2013 1 次提交
  18. 21 6月, 2013 1 次提交
  19. 28 5月, 2013 1 次提交
    • N
      clone: open a shortcut for connectivity check · c6807a40
      Nguyễn Thái Ngọc Duy 提交于
      In order to make sure the cloned repository is good, we run "rev-list
      --objects --not --all $new_refs" on the repository. This is expensive
      on large repositories. This patch attempts to mitigate the impact in
      this special case.
      
      In the "good" clone case, we only have one pack. If all of the
      following are met, we can be sure that all objects reachable from the
      new refs exist, which is the intention of running "rev-list ...":
      
       - all refs point to an object in the pack
       - there are no dangling pointers in any object in the pack
       - no objects in the pack point to objects outside the pack
      
      The second and third checks can be done with the help of index-pack as
      a slight variation of --strict check (which introduces a new condition
      for the shortcut: pack transfer must be used and the number of objects
      large enough to call index-pack). The first is checked in
      check_everything_connected after we get an "ok" from index-pack.
      
      "index-pack + new checks" is still faster than the current "index-pack
      + rev-list", which is the whole point of this patch. If any of the
      conditions fail, we fall back to the good old but expensive "rev-list
      ..". In that case it's even more expensive because we have to pay for
      the new checks in index-pack. But that should only happen when the
      other side is either buggy or malicious.
      
      Cloning linux-2.6 over file://
      
              before         after
      real    3m25.693s      2m53.050s
      user    5m2.037s       4m42.396s
      sys     0m13.750s      0m16.574s
      
      A more realistic test with ssh:// over wireless
      
              before         after
      real    11m26.629s     10m4.213s
      user    5m43.196s      5m19.444s
      sys     0m35.812s      0m37.630s
      
      This shortcut is not applied to shallow clones, partly because shallow
      clones should have no more objects than a usual fetch and the cost of
      rev-list is acceptable, partly to avoid dealing with corner cases when
      grafting is involved.
      
      This shortcut does not apply to unpack-objects code path either
      because the number of objects must be small in order to trigger that
      code path.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c6807a40
  20. 12 5月, 2013 1 次提交
  21. 07 5月, 2013 1 次提交
  22. 02 5月, 2013 1 次提交
  23. 29 4月, 2013 1 次提交
  24. 10 4月, 2013 1 次提交
  25. 09 4月, 2013 1 次提交
    • A
      clone: Fix error message for reference repository · 0658569e
      Aaron Schrab 提交于
      Do not report that an argument to clone's --reference option is not a
      local directory.  Nothing checks for the existence or type of the path
      as supplied by the user; checks are only done for particular contents of
      the supposed directory, so we have no way to know the status of the
      supplied path.  Telling the user that a directory doesn't exist when
      that isn't actually known may lead him or her on the wrong path to
      finding the problem.
      
      Instead just state that the entered path is not a local repository which
      is really all that is known about it.  It could be more helpful to state
      the actual paths which were checked, but I believe that giving a good
      description of that would be too verbose for a simple error message and
      would be too dependent on implementation details.
      Signed-off-by: NAaron Schrab <aaron@schrab.com>
      Reviewed-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0658569e
  26. 30 3月, 2013 1 次提交
    • J
      clone: leave repo in place after checkout errors · d3b34622
      Jeff King 提交于
      If we manage to clone a remote repository but run into an
      error in the checkout, it is probably sane to leave the repo
      directory in place. That lets the user examine the situation
      without spending time to re-clone from the remote (which may
      be a lengthy process).
      
      Rather than try to convert each die() from the checkout code
      path into an error(), we simply set a flag that tells the
      "remove_junk" atexit function to print a helpful message and
      leave the repo in place.
      
      Note that the test added in this patch actually passes
      without the code change. The reason is that the cleanup code
      is buggy; we chdir into the working tree for the checkout,
      but still may use relative paths to remove the directories
      (which means if you cloned into "foo", we would accidentally
      remove "foo" from the working tree!).  There's no point in
      fixing it now, since this patch means we will never try to
      remove anything after the chdir, anyway.
      
      [jc: replaced the message with a more succinct version from
      Jonathan]
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d3b34622
  27. 28 3月, 2013 2 次提交
    • J
      clone: run check_everything_connected · 0433ad12
      Jeff King 提交于
      When we fetch from a remote, we do a revision walk to make
      sure that what we received is connected to our existing
      history. We do not do the same check for clone, which should
      be able to check that we received an intact history graph.
      
      The upside of this patch is that it will make clone more
      resilient against propagating repository corruption. The
      downside is that we will now traverse "rev-list --objects
      --all" down to the roots, which may take some time (it is
      especially noticeable for a "--local --bare" clone).
      
      Note that we need to adjust t5710, which tries to make such
      a bogus clone. Rather than checking after the fact that our
      clone is bogus, we can simplify it to just make sure "git
      clone" reports failure.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0433ad12
    • J
      clone: die on errors from unpack_trees · 0aac7bb2
      Jeff King 提交于
      When clone is populating the working tree, it ignores the
      return status from unpack_trees; this means we may report a
      successful clone, even when the checkout fails.
      
      When checkout fails, we may want to leave the $GIT_DIR in
      place, as it might be possible to recover the data through
      further use of "git checkout" (e.g., if the checkout failed
      due to a transient error, disk full, etc). However, we
      already die on a number of other checkout-related errors, so
      this patch follows that pattern.
      
      In addition to marking a now-passing test, we need to adjust
      t5710, which blindly assumed it could make bogus clones of
      very deep alternates hierarchies. By using "--bare", we can
      avoid it actually touching any objects.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0aac7bb2
  28. 12 1月, 2013 1 次提交
    • J
      clone: do not export and unexport GIT_CONFIG · 3f4f4cc0
      Junio C Hamano 提交于
      Earlier, dc871831 (use GIT_CONFIG only in "git config", not other
      programs, 2008-06-30) made sure that the environment variable is
      never used outside "git config", but "git clone", after creating a
      directory for the new repository and until the init_db() function
      populates its .git/ directory, exported the variable for no good
      reason.  No hook will run from init_db() and more importantly no
      hook can run until init_db() finishes creation of the new
      repository, so it cannot be used by any invocation of "git config"
      by definition.
      
      Stop doing the useless export/unexport.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3f4f4cc0
  29. 11 1月, 2013 1 次提交
    • N
      clone: forbid --bare --separate-git-dir <dir> · 95b63f1e
      Nguyễn Thái Ngọc Duy 提交于
      The --separate-git-dir option was introduced to make it simple to put
      the git directory somewhere outside the worktree, for example when
      cloning a repository for use as a submodule.
      
      It was not intended for use when creating a bare repository. In that
      case there is no worktree and it is more natural to directly clone the
      repository and create a .git file as separate steps:
      
              git clone --bare /path/to/repo.git bar.git
              printf 'gitdir: bar.git\n' >foo.git
      
      Forbid the combination, making the command easier to explain.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      95b63f1e
  30. 06 1月, 2013 1 次提交
    • J
      clone: support atomic operation with --separate-git-dir · 9be1980b
      Jens Lehmann 提交于
      Since b57fb80a (init, clone: support --separate-git-dir for .git file)
      git clone supports the --separate-git-dir option to create the git dir
      outside the work tree. But when that option is used, the git dir won't be
      deleted in case the clone fails like it would be without this option. This
      makes clone lose its atomicity as in case of a failure a partly set up git
      dir is left behind. A real world example where this leads to problems is
      when "git submodule update" fails to clone a submodule and later calls to
      "git submodule update" stumble over the partially set up git dir and try
      to revive the submodule from there, which then fails with a not very user
      friendly error message.
      
      Fix that by updating the junk_git_dir variable (used to remember if and
      what git dir should be removed in case of failure) to the new value given
      with the --seperate-git-dir option. Also add a test for this to t5600 (and
      while at it fix the former last test to not cd into a directory to test
      for its existence but use "test -d" instead).
      Reported-by: NManlio Perillo <manlio.perillo@gmail.com>
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9be1980b
  31. 21 9月, 2012 1 次提交
    • R
      clone --single: limit the fetch refspec to fetched branch · 31b808a0
      Ralf Thielow 提交于
      After running "git clone --single", the resulting repository has the
      usual default "+refs/heads/*:refs/remotes/origin/*" wildcard fetch
      refspec installed, which means that a subsequent "git fetch" will
      end up grabbing all the other branches.
      
      Update the fetch refspec to cover only the singly cloned ref instead
      to correct this.
      
      That means:
      If "--single" is used without "--branch" or "--mirror", the
      fetch refspec covers the branch on which remote's HEAD points to.
      If "--single" is used with "--branch", it'll cover only the branch
      specified in the "--branch" option.
      If "--single" is combined with "--mirror", then it'll cover all
      refs of the cloned repository.
      If "--single" is used with "--branch" that specifies a tag, then
      it'll cover only the ref for this tag.
      Signed-off-by: NRalf Thielow <ralf.thielow@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      31b808a0
  32. 05 9月, 2012 1 次提交
  33. 21 8月, 2012 1 次提交
  34. 10 7月, 2012 1 次提交