1. 11 10月, 2016 10 次提交
    • J
      fill_sha1_file: write into a strbuf · f7b7774f
      Jeff King 提交于
      It's currently the responsibility of the caller to give
      fill_sha1_file() enough bytes to write into, leading them to
      manually compute the required lengths. Instead, let's just
      write into a strbuf so that it's impossible to get this
      wrong.
      
      The alt_odb caller already has a strbuf, so this makes
      things strictly simpler. The other caller, sha1_file_name(),
      uses a static PATH_MAX buffer and dies when it would
      overflow. We can convert this to a static strbuf, which
      means our allocation cost is amortized (and as a bonus, we
      no longer have to worry about PATH_MAX being too short for
      normal use).
      
      This does introduce some small overhead in fill_sha1_file(),
      as each strbuf_addchar() will check whether it needs to
      grow. However, between the optimization in fec501da
      (strbuf_addch: avoid calling strbuf_grow, 2015-04-16) and
      the fact that this is not generally called in a tight loop
      (after all, the next step is typically to access the file!)
      this probably doesn't matter. And even if it did, the right
      place to micro-optimize is inside fill_sha1_file(), by
      calling a single strbuf_grow() there.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f7b7774f
    • J
      alternates: store scratch buffer as strbuf · 38dbe5f0
      Jeff King 提交于
      We pre-size the scratch buffer to hold a loose object
      filename of the form "xx/yyyy...", which leads to allocation
      code that is hard to verify. We have to use some magic
      numbers during the initial allocation, and then writers must
      blindly assume that the buffer is big enough. Using a strbuf
      makes it more clear that we cannot overflow.
      
      Unfortunately, we do still need some magic numbers to grow
      our strbuf before calling fill_sha1_path(), but the strbuf
      growth is much closer to the point of use. This makes it
      easier to see that it's correct, and opens the possibility
      of pushing it even further down if fill_sha1_path() learns
      to work on strbufs.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      38dbe5f0
    • J
      fill_sha1_file: write "boring" characters · afbba2f0
      Jeff King 提交于
      This function forms a sha1 as "xx/yyyy...", but skips over
      the slot for the slash rather than writing it, leaving it to
      the caller to do so. It also does not bother to put in a
      trailing NUL, even though every caller would want it (we're
      forming a path which by definition is not a directory, so
      the only thing to do with it is feed it to a system call).
      
      Let's make the lives of our callers easier by just writing
      out the internal "/" and the NUL.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      afbba2f0
    • J
      alternates: use a separate scratch space · 597f9134
      Jeff King 提交于
      The alternate_object_database struct uses a single buffer
      both for storing the path to the alternate, and as a scratch
      buffer for forming object names. This is efficient (since
      otherwise we'd end up storing the path twice), but it makes
      life hard for callers who just want to know the path to the
      alternate. They have to remember to stop reading after
      "alt->name - alt->base" bytes, and to subtract one for the
      trailing '/'.
      
      It would be much simpler if they could simply access a
      NUL-terminated path string. We could encapsulate this in a
      function which puts a NUL in the scratch buffer and returns
      the string, but that opens up questions about the lifetime
      of the result. The first time another caller uses the
      alternate, the scratch buffer may get other data tacked onto
      it.
      
      Let's instead just store the root path separately from the
      scratch buffer. There aren't enough alternates being stored
      for the duplicated data to matter for performance, and this
      keeps things simple and safe for the callers.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      597f9134
    • J
      alternates: encapsulate alt->base munging · 29ec6af2
      Jeff King 提交于
      The alternate_object_database struct holds a path to the
      alternate objects, but we also use that buffer as scratch
      space for forming loose object filenames. Let's pull that
      logic into a helper function so that we can more easily
      modify it.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      29ec6af2
    • J
      alternates: provide helper for allocating alternate · 7f0fa2c0
      Jeff King 提交于
      Allocating a struct alternate_object_database is tricky, as
      we must over-allocate the buffer to provide scratch space,
      and then put in particular '/' and NUL markers.
      
      Let's encapsulate this in a function so that the complexity
      doesn't leak into callers (and so that we can modify it
      later).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7f0fa2c0
    • J
      alternates: provide helper for adding to alternates list · a5b34d21
      Jeff King 提交于
      The submodule code wants to temporarily add an alternate
      object store to our in-memory alt_odb list, but does it
      manually. Let's provide a helper so it can reuse the code in
      link_alt_odb_entry().
      
      While we're adding our new add_to_alternates_memory(), let's
      document add_to_alternates_file(), as the two are related.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a5b34d21
    • J
      link_alt_odb_entry: refactor string handling · 4ea82473
      Jeff King 提交于
      The string handling in link_alt_odb_entry() is mostly an
      artifact of the original version, which took the path as a
      ptr/len combo, and did not have a NUL-terminated string
      until we created one in the alternate_object_database
      struct.  But since 5bdf0a84 (sha1_file: normalize alt_odb
      path before comparing and storing, 2011-09-07), the first
      thing we do is put the path into a strbuf, which gives us
      some easy opportunities for cleanup.
      
      In particular:
      
        - we call strlen(pathbuf.buf), which is silly; we can look
          at pathbuf.len.
      
        - even though we have a strbuf, we don't maintain its
          "len" field when chomping extra slashes from the
          end, and instead keep a separate "pfxlen" variable. We
          can fix this and then drop "pfxlen" entirely.
      
        - we don't check whether the path is usable until after we
          allocate the new struct, making extra cleanup work for
          ourselves. Since we have a NUL-terminated string, we can
          bump the "is it usable" checks higher in the function.
          While we're at it, we can move that logic to its own
          helper, which makes the flow of link_alt_odb_entry()
          easier to follow.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4ea82473
    • J
      link_alt_odb_entry: handle normalize_path errors · 670c359d
      Jeff King 提交于
      When we add a new alternate to the list, we try to normalize
      out any redundant "..", etc. However, we do not look at the
      return value of normalize_path_copy(), and will happily
      continue with a path that could not be normalized. Worse,
      the normalizing process is done in-place, so we are left
      with whatever half-finished working state the normalizing
      function was in.
      
      Fortunately, this cannot cause us to read past the end of
      our buffer, as that working state will always leave the
      NUL from the original path in place. And we do tend to
      notice problems when we check is_directory() on the path.
      But you can see the nonsense that we feed to is_directory
      with an entry like:
      
        this/../../is/../../way/../../too/../../deep/../../to/../../resolve
      
      in your objects/info/alternates, which yields:
      
        error: object directory
        /to/e/deep/too/way//ects/this/../../is/../../way/../../too/../../deep/../../to/../../resolve
        does not exist; check .git/objects/info/alternates.
      
      We can easily fix this just by checking the return value.
      But that makes it hard to generate a good error message,
      since we're normalizing in-place and our input value has
      been overwritten by cruft.
      
      Instead, let's provide a strbuf helper that does an in-place
      normalize, but restores the original contents on error. This
      uses a second buffer under the hood, which is slightly less
      efficient, but this is not a performance-critical code path.
      
      The strbuf helper can also properly set the "len" parameter
      of the strbuf before returning. Just doing:
      
        normalize_path_copy(buf.buf, buf.buf);
      
      will shorten the string, but leave buf.len at the original
      length. That may be confusing to later code which uses the
      strbuf.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      670c359d
    • J
      t5613: clarify "too deep" recursion tests · f0f86fa9
      Jeff King 提交于
      These tests are just trying to show that we allow recursion
      up to a certain depth, but not past it. But the counting is
      a bit non-intuitive, and rather than test at the edge of the
      breakage, we test "OK" cases in the middle of the chain.
      Let's explain what's going on, and explicitly test the
      switch between "OK" and "too deep".
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f0f86fa9
  2. 04 10月, 2016 22 次提交
    • J
      t5613: do not chdir in main process · 8f2ed267
      Jeff King 提交于
      Our usual style when working with subdirectories is to chdir
      inside a subshell or to use "git -C", which means we do not
      have to constantly return to the main test directory. Let's
      convert this old test, which does not follow that style.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8f2ed267
    • J
      t5613: whitespace/style cleanups · 128a348d
      Jeff King 提交于
      Our normal test style these days puts the opening quote of
      the body on the description line, and indents the body with
      a single tab. This ancient test did not follow this.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      128a348d
    • J
      t5613: use test_must_fail · 195eb465
      Jeff King 提交于
      Besides being our normal style, this correctly checks for an
      error exit() versus signal death.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      195eb465
    • J
      t5613: drop test_valid_repo function · b28a88f2
      Jeff King 提交于
      This function makes sure that "git fsck" does not report any
      errors. But "--full" has been the default since f29cd393
      (fsck: default to "git fsck --full", 2009-10-20), and we can
      use the exit code (instead of counting the lines) since
      e2b4f635 (fsck: exit with non-zero status upon errors,
      2007-03-05).
      
      So we can just use "git fsck", which is shorter and more
      flexible (e.g., we can use "git -C").
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b28a88f2
    • J
      t5613: drop reachable_via function · 32d8b422
      Jeff King 提交于
      This function was never used since its inception in dd05ea17
      (test case for transitive info/alternates, 2006-05-07).
      Which is just as well, since it mutates the repo state in a
      way that would invalidate further tests, without cleaning up
      after itself. Let's get rid of it so that nobody is tempted
      to use it.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      32d8b422
    • J
      Sync with 2.10.1 · 0cf36115
      Junio C Hamano 提交于
      * maint:
        Git 2.10.1
      0cf36115
    • J
      Seventh batch for 2.11 · 30d687df
      Junio C Hamano 提交于
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      30d687df
    • J
      Merge branch 'pb/rev-list-reverse-with-count' · 8f0e5439
      Junio C Hamano 提交于
      Doc update to clarify what "log -3 --reverse" does.
      
      * pb/rev-list-reverse-with-count:
        rev-list-options: clarify the usage of --reverse
      8f0e5439
    • J
      Merge branch 'dt/tree-fsck' · 4e34e20c
      Junio C Hamano 提交于
      The codepath in "git fsck" to detect malformed tree objects has
      been updated not to die but keep going after detecting them.
      
      * dt/tree-fsck:
        fsck: handle bad trees like other errors
        tree-walk: be more specific about corrupt tree errors
      4e34e20c
    • J
      Merge branch 'kd/mailinfo-quoted-string' · fe252ef8
      Junio C Hamano 提交于
      An author name, that spelled a backslash-quoted double quote in the
      human readable part "My \"double quoted\" name", was not unquoted
      correctly while applying a patch from a piece of e-mail.
      
      * kd/mailinfo-quoted-string:
        mailinfo: unescape quoted-pair in header fields
        t5100-mailinfo: replace common path prefix with variable
      fe252ef8
    • J
      Merge branch 'mh/diff-indent-heuristic' · e704c618
      Junio C Hamano 提交于
      Clean-up for a recently graduated topic.
      
      * mh/diff-indent-heuristic:
        xdiff: rename "struct group" to "struct xdlgroup"
      e704c618
    • J
      Merge branch 'dt/mailinfo' · 883ac022
      Junio C Hamano 提交于
      * dt/mailinfo:
        add David Turner's Two Sigma address
      883ac022
    • J
      Merge branch 'va/git-gui-i18n' · cb3debdc
      Junio C Hamano 提交于
      "git gui" l10n to Portuguese.
      
      * va/git-gui-i18n:
        git-gui: l10n: add Portuguese translation
        git-gui i18n: mark strings for translation
      cb3debdc
    • J
      Merge branch 'rs/git-gui-use-modern-git-merge-syntax' · 5a2c86fb
      Junio C Hamano 提交于
      The original command line syntax for "git merge", which was "git
      merge <msg> HEAD <parent>...", has been deprecated for quite some
      time, and "git gui" was the last in-tree user of the syntax.  This
      is finally fixed, so that we can move forward with the deprecation.
      
      * rs/git-gui-use-modern-git-merge-syntax:
        git-gui: stop using deprecated merge syntax
      5a2c86fb
    • J
      Merge branch 'jc/verify-loose-object-header' · 71a57ab3
      Junio C Hamano 提交于
      Codepaths that read from an on-disk loose object were too loose in
      validating what they are reading is a proper object file and
      sometimes read past the data they read from the disk, which has
      been corrected.  H/t to Gustavo Grieco for reporting.
      
      * jc/verify-loose-object-header:
        unpack_sha1_header(): detect malformed object header
        streaming: make sure to notice corrupt object
      71a57ab3
    • J
      Merge branch 'nd/init-core-worktree-in-multi-worktree-world' · 53eb85e6
      Junio C Hamano 提交于
      "git init" tried to record core.worktree in the repository's
      'config' file when GIT_WORK_TREE environment variable was set and
      it was different from where GIT_DIR appears as ".git" at its top,
      but the logic was faulty when .git is a "gitdir:" file that points
      at the real place, causing trouble in working trees that are
      managed by "git worktree".  This has been corrected.
      
      * nd/init-core-worktree-in-multi-worktree-world:
        init: kill git_link variable
        init: do not set unnecessary core.worktree
        init: kill set_git_dir_init()
        init: call set_git_dir_init() from within init_db()
        init: correct re-initialization from a linked worktree
      53eb85e6
    • J
      Merge branch 'ik/gitweb-force-highlight' · 34740849
      Junio C Hamano 提交于
      "gitweb" can spawn "highlight" to show blob contents with
      (programming) language-specific syntax highlighting, but only
      when the language is known.  "highlight" can however be told
      to make the guess itself by giving it "--force" option, which
      has been enabled.
      
      * ik/gitweb-force-highlight:
        gitweb: use highlight's shebang detection
        gitweb: remove unused guess_file_syntax() parameter
      34740849
    • J
      Merge branch 'rs/copy-array' · b1f0a856
      Junio C Hamano 提交于
      Code cleanup.
      
      * rs/copy-array:
        use COPY_ARRAY
        add COPY_ARRAY
      b1f0a856
    • J
      Git 2.10.1 · 6406bdc0
      Junio C Hamano 提交于
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6406bdc0
    • J
      Merge branch 'jk/ident-ai-canonname-could-be-null' into maint · 11738ddf
      Junio C Hamano 提交于
      In the codepath that comes up with the hostname to be used in an
      e-mail when the user didn't tell us, we looked at ai_canonname
      field in struct addrinfo without making sure it is not NULL first.
      
      * jk/ident-ai-canonname-could-be-null:
        ident: handle NULL ai_canonname
      11738ddf
    • J
      Merge branch 'jk/doc-cvs-update' into maint · 3d0049ea
      Junio C Hamano 提交于
      Documentation around tools to import from CVS was fairly outdated.
      
      * jk/doc-cvs-update:
        docs/cvs-migration: mention cvsimport caveats
        docs/cvs-migration: update link to cvsps homepage
        docs/cvsimport: prefer cvs-fast-export to parsecvs
      3d0049ea
    • J
      Merge branch 'jk/pack-tag-of-tag' into maint · f4315eed
      Junio C Hamano 提交于
      "git pack-objects --include-tag" was taught that when we know that
      we are sending an object C, we want a tag B that directly points at
      C but also a tag A that points at the tag B.  We used to miss the
      intermediate tag B in some cases.
      
      * jk/pack-tag-of-tag:
        pack-objects: walk tag chains for --include-tag
        t5305: simplify packname handling
        t5305: use "git -C"
        t5305: drop "dry-run" of unpack-objects
        t5305: move cleanup into test block
      f4315eed
  3. 30 9月, 2016 8 次提交
    • J
      Sync with maint · 3ef7618e
      Junio C Hamano 提交于
      * maint:
        Prepare for 2.10.1
      3ef7618e
    • J
      Sixth batch for 2.11 · 641b158a
      Junio C Hamano 提交于
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      641b158a
    • J
      Merge branch 'jc/worktree-config' · ed0006aa
      Junio C Hamano 提交于
      "git worktree", even though it used the default_abbrev setting that
      ought to be affected by core.abbrev configuration variable, ignored
      the variable setting.  The command has been taught to read the
      default set of configuration variables to correct this.
      
      * jc/worktree-config:
        worktree: honor configuration variables
      ed0006aa
    • J
      Merge branch 'jk/ident-ai-canonname-could-be-null' · fff948fe
      Junio C Hamano 提交于
      In the codepath that comes up with the hostname to be used in an
      e-mail when the user didn't tell us, we looked at ai_canonname
      field in struct addrinfo without making sure it is not NULL first.
      
      * jk/ident-ai-canonname-could-be-null:
        ident: handle NULL ai_canonname
      fff948fe
    • J
      Merge branch 'jt/fetch-pack-in-vain-count-with-stateless' · 938c2a63
      Junio C Hamano 提交于
      When "git fetch" tries to find where the history of the repository
      it runs in has diverged from what the other side has, it has a
      mechanism to avoid digging too deep into irrelevant side branches.
      This however did not work well over the "smart-http" transport due
      to a design bug, which has been fixed.
      
      * jt/fetch-pack-in-vain-count-with-stateless:
        fetch-pack: do not reset in_vain on non-novel acks
      938c2a63
    • J
      Merge branch 'jk/verify-packfile-gently' · 5c2c2d4a
      Junio C Hamano 提交于
      A low-level function verify_packfile() was meant to show errors
      that were detected without dying itself, but under some conditions
      it didn't and died instead, which has been fixed.
      
      * jk/verify-packfile-gently:
        verify_packfile: check pack validity before accessing data
      5c2c2d4a
    • J
      Merge branch 'jt/mailinfo-fold-in-body-headers' · 4cff50b3
      Junio C Hamano 提交于
      When "git format-patch --stdout" output is placed as an in-body
      header and it uses the RFC2822 header folding, "git am" failed to
      put the header line back into a single logical line.  The
      underlying "git mailinfo" was taught to handle this properly.
      
      * jt/mailinfo-fold-in-body-headers:
        mailinfo: handle in-body header continuations
        mailinfo: make is_scissors_line take plain char *
        mailinfo: separate in-body header processing
      4cff50b3
    • J
      Prepare for 2.10.1 · 92d42666
      Junio C Hamano 提交于
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      92d42666