1. 25 2月, 2014 4 次提交
  2. 11 2月, 2014 1 次提交
  3. 06 2月, 2014 1 次提交
  4. 15 1月, 2014 1 次提交
  5. 07 1月, 2014 2 次提交
    • M
      safe_create_leading_directories(): add new error value SCLD_VANISHED · 18d37e86
      Michael Haggerty 提交于
      Add a new possible error result that can be returned by
      safe_create_leading_directories() and
      safe_create_leading_directories_const(): SCLD_VANISHED.  This value
      indicates that a file or directory on the path existed at one point
      (either it already existed or the function created it), but then it
      disappeared.  This probably indicates that another process deleted the
      directory while we were working.  If SCLD_VANISHED is returned, the
      caller might want to retry the function call, as there is a chance
      that a new attempt will succeed.
      
      Why doesn't safe_create_leading_directories() do the retrying
      internally?  Because an empty directory isn't really ever safe until
      it holds a file.  So even if safe_create_leading_directories() were
      absolutely sure that the directory existed before it returned, there
      would be no guarantee that the directory still existed when the caller
      tried to write something in it.
      Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      18d37e86
    • M
      safe_create_leading_directories(): introduce enum for return values · 0be0521b
      Michael Haggerty 提交于
      Instead of returning magic integer values (which a couple of callers
      go to the trouble of distinguishing), return values from an enum.  Add
      a docstring.
      Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0be0521b
  6. 27 12月, 2013 1 次提交
    • J
      sha1_object_info_extended: provide delta base sha1s · 5d642e75
      Jeff King 提交于
      A caller of sha1_object_info_extended technically has enough
      information to determine the base sha1 from the results of
      the call. It knows the pack, offset, and delta type of the
      object, which is sufficient to find the base.
      
      However, the functions to do so are not publicly available,
      and the code itself is intimate enough with the pack details
      that it should be abstracted away. We could add a public
      helper to allow callers to query the delta base separately,
      but it is simpler and slightly more efficient to optionally
      grab it along with the rest of the object_info data.
      
      For cases where the object is not stored as a delta, we
      write the null sha1 into the query field. A careful caller
      could check "oi.whence == OI_PACKED && oi.u.packed.is_delta"
      before looking at the base sha1, but using the null sha1
      provides a simple alternative (and gives a better sanity
      check for a non-careful caller than simply returning random
      bytes).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5d642e75
  7. 13 12月, 2013 3 次提交
  8. 11 12月, 2013 2 次提交
    • N
      add GIT_SHALLOW_FILE to propagate --shallow-file to subprocesses · 069c0532
      Nguyễn Thái Ngọc Duy 提交于
      This may be needed when a hook is run after a new shallow pack is
      received, but .git/shallow is not settled yet. A temporary shallow
      file to plug all loose ends should be used instead. GIT_SHALLOW_FILE
      is overriden by --shallow-file.
      
      --shallow-file does not work in this case because the hook may spawn
      many git subprocesses and the launch commands do not have
      --shallow-file as it's a recent addition.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      069c0532
    • N
      shallow.c: the 8 steps to select new commits for .git/shallow · 58babfff
      Nguyễn Thái Ngọc Duy 提交于
      Suppose a fetch or push is requested between two shallow repositories
      (with no history deepening or shortening). A pack that contains
      necessary objects is transferred over together with .git/shallow of
      the sender. The receiver has to determine whether it needs to update
      .git/shallow if new refs needs new shallow comits.
      
      The rule here is avoid updating .git/shallow by default. But we don't
      want to waste the received pack. If the pack contains two refs, one
      needs new shallow commits installed in .git/shallow and one does not,
      we keep the latter and reject/warn about the former.
      
      Even if .git/shallow update is allowed, we only add shallow commits
      strictly necessary for the former ref (remember the sender can send
      more shallow commits than necessary) and pay attention not to
      accidentally cut the receiver history short (no history shortening is
      asked for)
      
      So the steps to figure out what ref need what new shallow commits are:
      
      1. Split the sender shallow commit list into "ours" and "theirs" list
         by has_sha1_file. Those that exist in current repo in "ours", the
         remaining in "theirs".
      
      2. Check the receiver .git/shallow, remove from "ours" the ones that
         also exist in .git/shallow.
      
      3. Fetch the new pack. Either install or unpack it.
      
      4. Do has_sha1_file on "theirs" list again. Drop the ones that fail
         has_sha1_file. Obviously the new pack does not need them.
      
      5. If the pack is kept, remove from "ours" the ones that do not exist
         in the new pack.
      
      6. Walk the new refs to answer the question "what shallow commits,
         both ours and theirs, are required in .git/shallow in order to add
         this ref?". Shallow commits not associated to any refs are removed
         from their respective list.
      
      7. (*) Check reachability (from the current refs) of all remaining
         commits in "ours". Those reachable are removed. We do not want to
         cut any part of our (reachable) history. We only check up
         commits. True reachability test is done by
         check_everything_connected() at the end as usual.
      
      8. Combine the final "ours" and "theirs" and add them all to
         .git/shallow. Install new refs. The case where some hook rejects
         some refs on a push is explained in more detail in the push
         patches.
      
      Of these steps, #6 and #7 are expensive. Both require walking through
      some commits, or in the worst case all commits. And we rather avoid
      them in at least common case, where the transferred pack does not
      contain any shallow commits that the sender advertises. Let's look at
      each scenario:
      
      1) the sender has longer history than the receiver
      
         All shallow commits from the sender will be put into "theirs" list
         at step 1 because none of them exists in current repo. In the
         common case, "theirs" becomes empty at step 4 and exit early.
      
      2) the sender has shorter history than the receiver
      
         All shallow commits from the sender are likely in "ours" list at
         step 1. In the common case, if the new pack is kept, we could empty
         "ours" and exit early at step 5.
      
         If the pack is not kept, we hit the expensive step 6 then exit
         after "ours" is emptied. There'll be only a handful of objects to
         walk in fast-forward case. If it's forced update, we may need to
         walk to the bottom.
      
      3) the sender has same .git/shallow as the receiver
      
         This is similar to case 2 except that "ours" should be emptied at
         step 2 and exit early.
      
      A fetch after "clone --depth=X" is case 1. A fetch after "clone" (from
      a shallow repo) is case 3. Luckily they're cheap for the common case.
      
      A push from "clone --depth=X" falls into case 2, which is expensive.
      Some more work may be done at the sender/client side to avoid more
      work on the server side: if the transferred pack does not contain any
      shallow commits, send-pack should not send any shallow commits to the
      receive-pack, effectively turning it into a normal push and avoid all
      steps.
      
      This patch implements all steps except #3, already handled by
      fetch-pack and receive-pack, #6 and #7, which has their own patch due
      to their size.
      
      (*) in previous versions step 7 was put before step 3. I reorder it so
          that the common case that keeps the pack does not need to walk
          commits at all. In future if we implement faster commit
          reachability check (maybe with the help of pack bitmaps or commit
          cache), step 7 could become cheap and be moved up before 6 again.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      58babfff
  9. 19 11月, 2013 4 次提交
  10. 28 10月, 2013 1 次提交
  11. 25 10月, 2013 2 次提交
  12. 14 10月, 2013 1 次提交
    • J
      Use simpler relative_path when set_git_dir · 41894ae3
      Jiang Xin 提交于
      Using a relative_path as git_dir first appears in v1.5.6-1-g044bbbcb.
      It will make git_dir shorter only if git_dir is inside work_tree,
      and this will increase performance. But my last refactor effort on
      relative_path function (commit v1.8.3-rc2-12-ge02ca72f) changed that.
      Always use relative_path as git_dir may bring troubles like
      $gmane/234434.
      
      Because new relative_path is a combination of original relative_path
      from path.c and original path_relative from quote.c, so in order to
      restore the origin implementation, save the original relative_path
      as remove_leading_path, and call it in setup.c.
      Suggested-by: NKarsten Blees <karsten.blees@gmail.com>
      Signed-off-by: NJiang Xin <worldhello.net@gmail.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      41894ae3
  13. 21 9月, 2013 1 次提交
    • J
      format-patch: print in-body "From" only when needed · 662cc30c
      Jeff King 提交于
      Commit a9080475 taught format-patch the "--from" option,
      which places the author ident into an in-body from header,
      and uses the committer ident in the rfc822 from header.  The
      documentation claims that it will omit the in-body header
      when it is the same as the rfc822 header, but the code never
      implemented that behavior.
      
      This patch completes the feature by comparing the two idents
      and doing nothing when they are the same (this is the same
      as simply omitting the in-body header, as the two are by
      definition indistinguishable in this case). This makes it
      reasonable to turn on "--from" all the time (if it matches
      your particular workflow), rather than only using it when
      exporting other people's patches.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      662cc30c
  14. 18 9月, 2013 2 次提交
    • J
      connect.c: make parse_feature_value() static · 5d54cffc
      Junio C Hamano 提交于
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5d54cffc
    • E
      name-hash: refactor polymorphic index_name_exists() · db5360f3
      Eric Sunshine 提交于
      Depending upon the absence or presence of a trailing '/' on the incoming
      pathname, index_name_exists() checks either if a file is present in the
      index or if a directory is represented within the index. Each caller
      explicitly chooses the mode of operation by adding or removing a
      trailing '/' before invoking index_name_exists().
      
      Since these two modes of operations are disjoint and have no code in
      common (one searches index_state.name_hash; the other dir_hash), they
      can be represented more naturally as distinct functions: one to search
      for a file, and one for a directory.
      
      Splitting index searching into two functions relieves callers of the
      artificial burden of having to add or remove a slash to select the mode
      of operation; instead they just call the desired function. A subsequent
      patch will take advantage of this benefit in order to eliminate the
      requirement that the incoming pathname for a directory search must have
      a trailing slash.
      
      (In order to avoid disturbing in-flight topics, index_name_exists() is
      retained as a thin wrapper dispatching either to index_dir_exists() or
      index_file_exists().)
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      db5360f3
  15. 10 9月, 2013 1 次提交
    • J
      git-config: always treat --int as 64-bit internally · 00160242
      Jeff King 提交于
      When you run "git config --int", the maximum size of integer
      you get depends on how git was compiled, and what it
      considers to be an "int".
      
      This is almost useful, because your scripts calling "git
      config" will behave similarly to git internally. But relying
      on this is dubious; you have to actually know how git treats
      each value internally (e.g., int versus unsigned long),
      which is not documented and is subject to change. And even
      if you know it is "unsigned long", we do not have a
      git-config option to match that behavior.
      
      Furthermore, you may simply be asking git to store a value
      on your behalf (e.g., configuration for a hook). In that
      case, the relevant range check has nothing at all to do with
      git, but rather with whatever scripting tools you are using
      (and git has no way of knowing what the appropriate range is
      there).
      
      Not only is the range check useless, but it is actively
      harmful, as there is no way at all for scripts to look
      at config variables with large values. For instance, one
      cannot reliably get the value of pack.packSizeLimit via
      git-config. On an LP64 system, git happily uses a 64-bit
      "unsigned long" internally to represent the value, but the
      script cannot read any value over 2G.
      
      Ideally, the "--int" option would simply represent an
      arbitrarily large integer. For practical purposes, however,
      a 64-bit integer is large enough, and is much easier to
      implement (and if somebody overflows it, we will still
      notice the problem, and not simply return garbage).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      00160242
  16. 04 9月, 2013 1 次提交
  17. 21 8月, 2013 1 次提交
  18. 30 7月, 2013 1 次提交
  19. 18 7月, 2013 1 次提交
  20. 16 7月, 2013 8 次提交
  21. 13 7月, 2013 1 次提交
    • J
      sha1_object_info_extended: make type calculation optional · 5b086407
      Jeff King 提交于
      Each caller of sha1_object_info_extended sets up an
      object_info struct to tell the function which elements of
      the object it wants to get. Until now, getting the type of
      the object has always been required (and it is returned via
      the return type rather than a pointer in object_info).
      
      This can involve actually opening a loose object file to
      determine its type, or following delta chains to determine a
      packed file's base type. These effects produce a measurable
      slow-down when doing a "cat-file --batch-check" that does
      not include %(objecttype).
      
      This patch adds a "typep" query to struct object_info, so
      that it can be optionally queried just like size and
      disk_size. As a result, the return type of the function is
      no longer the object type, but rather 0/-1 for success/error.
      
      As there are only three callers total, we just fix up each
      caller rather than keep a compatibility wrapper:
      
        1. The simpler sha1_object_info wrapper continues to
           always ask for and return the type field.
      
        2. The istream_source function wants to know the type, and
           so always asks for it.
      
        3. The cat-file batch code asks for the type only when
           %(objecttype) is part of the format string.
      
      On linux.git, the best-of-five for running:
      
        $ git rev-list --objects --all >objects
        $ time git cat-file --batch-check='%(objectsize:disk)'
      
      on a fully packed repository goes from:
      
        real    0m8.680s
        user    0m8.160s
        sys     0m0.512s
      
      to:
      
        real    0m7.205s
        user    0m6.580s
        sys     0m0.608s
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5b086407