1. 04 10月, 2016 2 次提交
    • J
      abbrev: prepare for new world order · 7b5b7721
      Junio C Hamano 提交于
      The code that sets custom abbreviation length, in response to
      command line argument, often does something like this:
      
      	if (skip_prefix(arg, "--abbrev=", &arg))
      		abbrev = atoi(arg);
      	else if (!strcmp("--abbrev", &arg))
      		abbrev = DEFAULT_ABBREV;
      	/* make the value sane */
      	if (abbrev < 0 || 40 < abbrev)
      		abbrev = ... some sane value ...
      
      However, it is pointless to sanity-check and tweak the value
      obtained from DEFAULT_ABBREV.  We are going to allow it to be
      initially set to -1 to signal that the default abbreviation length
      must be auto sized upon the first request to abbreviate, based on
      the number of objects in the repository, and when that happens,
      rejecting or tweaking a negative value to a "saner" one will
      negatively interfere with the auto sizing.  The codepaths for
      
          git rev-parse --short <object>
          git diff --raw --abbrev
      
      do exactly that; allow them to pass possibly negative abbrevs
      intact, that will come from DEFAULT_ABBREV in the future.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7b5b7721
    • J
      abbrev: add FALLBACK_DEFAULT_ABBREV to prepare for auto sizing · 65acfeac
      Junio C Hamano 提交于
      We'll be introducing a new way to decide the default abbreviation
      length by initialising DEFAULT_ABBREV to -1 to signal the first call
      to "find unique abbreviation" codepath to compute a reasonable value
      based on the number of objects we have to avoid collisions.
      
      We have long relied on DEFAULT_ABBREV being a positive concrete
      value that is used as the abbreviation length when no extra
      configuration or command line option has overridden it.  Some
      codepaths wants to use such a positive concrete default value
      even before making their first request to actually trigger the
      computation for the auto sized default.
      
      Introduce FALLBACK_DEFAULT_ABBREV and use it to the code that
      attempts to align the report from "git fetch".  For now, this
      macro is also used to initialize the default_abbrev variable,
      but the auto-sizing code will use -1 and then use the value of
      FALLBACK_DEFAULT_ABBREV as the starting point of auto-sizing.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      65acfeac
  2. 28 9月, 2016 1 次提交
    • J
      get_short_sha1: make default disambiguation configurable · 5b33cb1f
      Jeff King 提交于
      When we find ambiguous short sha1s, we may get a
      disambiguation rule from our caller's context. But if we
      don't, we fall back to treating all sha1s the same, even
      though most projects will tend to refer only to commits by
      their short sha1s.
      
      This patch introduces a configuration option that lets the
      user pick a different fallback (e.g., only commits). It's
      possible that we may want to make this the default, but it's
      a good idea to start as a config option for two reasons:
      
        1. It lets people experiment with this and see if it's a
           good idea (i.e., the "tend to" above is an assumption;
           we don't really know if this will break some obscure
           cases).
      
        2. Even if we do flip the default, it gives people an
           escape hatch if it causes problems (you can sometimes
           override it by asking for "1234^{tree}", but not all
           combinations are possible).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5b33cb1f
  3. 27 9月, 2016 10 次提交
    • J
      get_short_sha1: list ambiguous objects on error · 1ffa26c4
      Jeff King 提交于
      When the user gives us an ambiguous short sha1, we print an
      error and refuse to resolve it. In some cases, the next step
      is for them to feed us more characters (e.g., if they were
      retyping or cut-and-pasting from a full sha1). But in other
      cases, that might be all they have. For example, an old
      commit message may have used a 7-character hex that was
      unique at the time, but is now ambiguous.  Git doesn't
      provide any information about the ambiguous objects it
      found, so it's hard for the user to find out which one they
      probably meant.
      
      This patch teaches get_short_sha1() to list the sha1s of the
      objects it found, along with a few bits of information that
      may help the user decide which one they meant. Here's what
      it looks like on git.git:
      
        $ git rev-parse b2e1
        error: short SHA1 b2e1 is ambiguous
        hint: The candidates are:
        hint:   b2e1196 tag v2.8.0-rc1
        hint:   b2e11d1 tree
        hint:   b2e16327 commit 2007-11-14 - Merge branch 'bs/maint-commit-options'
        hint:   b2e1759 blob
        hint:   b2e18954 blob
        hint:   b2e1895c blob
        fatal: ambiguous argument 'b2e1': unknown revision or path not in the working tree.
        Use '--' to separate paths from revisions, like this:
        'git <command> [<revision>...] -- [<file>...]'
      
      We show the tagname for tags, and the date and subject for
      commits. For trees and blobs, in theory we could dig in the
      history to find the paths at which they were present. But
      that's very expensive (on the order of 30s for the kernel),
      and it's not likely to be all that helpful. Most short
      references are to commits, so the useful information is
      typically going to be that the object in question _isn't_ a
      commit. So it's silly to spend a lot of CPU preemptively
      digging up the path; the user can do it themselves if they
      really need to.
      
      And of course it's somewhat ironic that we abbreviate the
      sha1s in the disambiguation hint. But full sha1s would cause
      annoying line wrapping for the commit lines, and presumably
      the user is going to just re-issue their command immediately
      with the corrected sha1.
      
      We also restrict the list to those that match any
      disambiguation hint. E.g.:
      
        $ git rev-parse b2e1:foo
        error: short SHA1 b2e1 is ambiguous
        hint: The candidates are:
        hint:   b2e1196 tag v2.8.0-rc1
        hint:   b2e11d1 tree
        hint:   b2e16327 commit 2007-11-14 - Merge branch 'bs/maint-commit-options'
        fatal: Invalid object name 'b2e1'.
      
      does not bother reporting the blobs, because they cannot
      work as a treeish.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1ffa26c4
    • J
      for_each_abbrev: drop duplicate objects · fad6b9e5
      Jeff King 提交于
      If an object appears multiple times in the object database
      (e.g., in both loose and packed form, or in two separate
      packs), the disambiguation machinery may see it more than
      once. The get_short_sha1() function handles this already,
      but for_each_abbrev() blindly fires the callback for each
      instance it finds.
      
      We can fix this by collecting the output in a sha1 array and
      de-duplicating it.  As a bonus, the sort done for the
      de-duplication means that our output will be stable,
      regardless of the order in which the objects are found.
      
      Note that the old code normalized the callback's output to
      0/1 to store in the 1-bit ds->ambiguous flag (which both
      halted the iteration and was returned from the
      for_each_abbrev function). Now that we are using sha1_array,
      we can return the real value. In practice, it doesn't matter
      as the sole caller only ever returns 0.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fad6b9e5
    • J
      sha1_array: let callbacks interrupt iteration · 16ddcd40
      Jeff King 提交于
      The callbacks for iterating a sha1_array must have a void
      return.  This is unlike our usual for_each semantics, where
      a callback may interrupt iteration and have its value
      propagated. Let's switch it to the usual form, which will
      enable its use in more places (e.g., where we are replacing
      an existing iteration with a different data structure).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      16ddcd40
    • J
      get_short_sha1: mark ambiguity error for translation · 0c99171a
      Jeff King 提交于
      This is a human-readable message, and there's no reason it
      should not be translated. While we're at it, let's drop the
      period from the end, which is not our usual style.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0c99171a
    • J
      get_short_sha1: NUL-terminate hex prefix · 59e4e34f
      Jeff King 提交于
      We store the hex prefix in a 40-byte buffer with the prefix
      itself followed by 40-minus-len "x" characters. These x's
      serve no purpose, and the lack of NUL termination makes the
      prefix string annoying to use. Let's just terminate it.
      
      Note that this is in contrast to the binary prefix, which
      _must_ be zero-padded, because we look at the whole thing
      during a binary search to find the first potential match in
      each pack index. The loose-object hex search cannot use the
      same trick because it has to do a linear walk through the
      unsorted results of readdir() (and even if it could, you'd
      want zeroes instead of x's).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      59e4e34f
    • J
      get_short_sha1: refactor init of disambiguation code · 0016043b
      Jeff King 提交于
      The disambiguation machinery has two callers: get_short_sha1
      and for_each_abbrev. Both need to repeat much of the same
      setup: declaring buffers, sanity-checking lengths, preparing
      the prefixes, etc.  Let's pull that into a single init
      function so we can avoid repeating ourselves.
      
      Pulling the buffers into the "struct disambiguate_state"
      isn't strictly necessary, but it does make things simpler
      for the callers, who no longer have to worry about sizing
      them correctly (i.e., it's an implicit requirement that
      the caller provide 20- and 40-byte buffers).
      
      And while we're touching this code, we can convert any
      magic-number sizes to the more modern GIT_SHA1_* constants.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0016043b
    • J
      get_short_sha1: parse tags when looking for treeish · 5d5def2a
      Jeff King 提交于
      The treeish disambiguation function tries to peel tags, but
      it does so by calling:
      
        deref_tag(lookup_object(sha1), ...);
      
      This will only work if we have previously looked at the tag
      and created a "struct tag" for it. Since parsing revision
      arguments typically happens before anything else, this is
      usually not the case, and we would fail to peel the tag (we
      are lucky that deref_tag() gracefully handles the NULL and
      does not segfault).
      
      Instead, we can use parse_object(). Note that this is the
      same fix done by 94d75d1e (get_short_sha1(): correctly
      disambiguate type-limited abbreviation, 2013-07-01), but
      that commit fixed only the committish disambiguator, and
      left the bug in the treeish one.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5d5def2a
    • J
      get_sha1: propagate flags to child functions · 8a10fea4
      Jeff King 提交于
      The get_sha1() function is actually implementation by many
      sub-functions, but we do not always pass our flags around to
      all of those functions. As a result, we may forget that our
      caller asked us to resolve with GET_SHA1_QUIETLY and output
      messages. The two triggerable cases are:
      
        1. Resolving treeish:path will resolve the "treeish"
           portion using GET_SHA1_TREEISH, dropping all other
           flags.
      
        2. The peel_onion() function did not take flags at all
           but recurses to get_sha1_1(), which does.
      
      The solution for both is to bitwise-OR their new flags with
      the existing ones (after dropping any mutually exclusive
      disambiguation flags).
      
      This bug can trigger with "git rev-parse --quiet", which
      asks for quiet resolution. But it can also happen in a more
      vanilla code path when we do a follow-up ONLY_TO_DIE
      invocation of get_sha1(), and that's what the tests check.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8a10fea4
    • J
      get_sha1: avoid repeating ourselves via ONLY_TO_DIE · 7243ffdd
      Jeff King 提交于
      When the revision code cannot parse an argument like
      "HEAD:foo", it will call maybe_die_on_misspelt_object_name(),
      which re-runs get_sha1() with an extra ONLY_TO_DIE flag. We
      then spend more effort to generate a better error message.
      
      Unfortunately, a side effect is that our second call may
      repeat the same error messages from the original get_sha1()
      call. You can see this with:
      
        $ git show 0017
        error: short SHA1 0017 is ambiguous.
        error: short SHA1 0017 is ambiguous.
        fatal: ambiguous argument '0017': unknown revision or path not in the working tree.
        Use '--' to separate paths from revisions, like this:
        'git <command> [<revision>...] -- [<file>...]'
      
      where the second "error:" line comes from the ONLY_TO_DIE
      call.
      
      To fix this, we can make ONLY_TO_DIE imply QUIETLY. This is
      a little odd, because the whole point of ONLY_TO_DIE is to
      output error messages. But what we want to do is tell the
      rest of the get_sha1() code (particularly get_sha1_1()) that
      the _regular_ messages should be quiet, but the only-to-die
      ones should not.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7243ffdd
    • J
      get_sha1: detect buggy calls with multiple disambiguators · 259942f5
      Jeff King 提交于
      The get_sha1() family of functions takes a flags field, but
      some of the flags are mutually exclusive. In particular, we
      can only handle one disambiguating function, and the flags
      quietly override each other. Let's instead detect these as
      programming bugs.
      
      Technically some of the flags are supersets of the others,
      so treating COMMITTISH|TREEISH as just COMMITTISH is not
      wrong, but it's a good sign the caller is confused. And
      certainly asking for BLOB|TREE does not work.
      
      We can do the check easily with some bit-twiddling, and as a
      bonus, the bit-mask of disambiguators will come in handy in
      a future patch.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      259942f5
  4. 22 9月, 2016 21 次提交
    • J
      Fourth batch for 2.11 · 6fe1b140
      Junio C Hamano 提交于
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6fe1b140
    • J
      Merge branch 'jk/reduce-gc-aggressive-depth' · 0952ca8a
      Junio C Hamano 提交于
      "git gc --aggressive" used to limit the delta-chain length to 250,
      which is way too deep for gaining additional space savings and is
      detrimental for runtime performance.  The limit has been reduced to
      50.
      
      * jk/reduce-gc-aggressive-depth:
        gc: default aggressive depth to 50
      0952ca8a
    • J
      Merge branch 'jk/rebase-i-drop-ident-check' · ae1ae600
      Junio C Hamano 提交于
      Even when "git pull --rebase=preserve" (and the underlying "git
      rebase --preserve") can complete without creating any new commit
      (i.e. fast-forwards), it still insisted on having a usable ident
      information (read: user.email is set correctly), which was less
      than nice.  As the underlying commands used inside "git rebase"
      would fail with a more meaningful error message and advice text
      when the bogus ident matters, this extra check was removed.
      
      * jk/rebase-i-drop-ident-check:
        rebase-interactive: drop early check for valid ident
      ae1ae600
    • J
      Merge branch 'va/i18n' · 1fe6f5fb
      Junio C Hamano 提交于
      More i18n.
      
      * va/i18n:
        i18n: update-index: mark warnings for translation
        i18n: show-branch: mark plural strings for translation
        i18n: show-branch: mark error messages for translation
        i18n: receive-pack: mark messages for translation
        notes: spell first word of error messages in lowercase
        i18n: notes: mark error messages for translation
        i18n: merge-recursive: mark verbose message for translation
        i18n: merge-recursive: mark error messages for translation
        i18n: config: mark error message for translation
        i18n: branch: mark option description for translation
        i18n: blame: mark error messages for translation
      1fe6f5fb
    • J
      Merge branch 'jt/format-patch-base-info-above-sig' · e8f871a9
      Junio C Hamano 提交于
      "git format-patch --base=..." feature that was recently added
      showed the base commit information after "-- " e-mail signature
      line, which turned out to be inconvenient.  The base information
      has been moved above the signature line.
      
      * jt/format-patch-base-info-above-sig:
        format-patch: show base info before email signature
      e8f871a9
    • J
      Merge branch 'ks/perf-build-with-autoconf' · 0c5ff916
      Junio C Hamano 提交于
      Performance tests done via "t/perf" did not use the same set of
      build configuration if the user relied on autoconf generated
      configuration.
      
      * ks/perf-build-with-autoconf:
        t/perf/run: copy config.mak.autogen & friends to build area
      0c5ff916
    • J
      Merge branch 'mr/vcs-svn-printf-ulong' · ac5ce66a
      Junio C Hamano 提交于
      Code cleanup.
      
      * mr/vcs-svn-printf-ulong:
        vcs-svn/fast_export: fix timestamp fmt specifiers
      ac5ce66a
    • J
      Merge branch 'rs/xdiff-merge-overlapping-hunks-for-W-context' · 4ed38637
      Junio C Hamano 提交于
      "git diff -W" output needs to extend the context backward to
      include the header line of the current function and also forward to
      include the body of the entire current function up to the header
      line of the next one.  This process may have to merge to adjacent
      hunks, but the code forgot to do so in some cases.
      
      * rs/xdiff-merge-overlapping-hunks-for-W-context:
        xdiff: fix merging of hunks with -W context and -u context
      4ed38637
    • J
      Merge branch 'rs/unpack-trees-reduce-file-scope-global' · e9c6d3dc
      Junio C Hamano 提交于
      Code cleanup.
      
      * rs/unpack-trees-reduce-file-scope-global:
        unpack-trees: pass checkout state explicitly to check_updates()
      e9c6d3dc
    • J
      Merge branch 'rs/strbuf-remove-fix' · 3ba0bbb9
      Junio C Hamano 提交于
      Code cleanup.
      
      * rs/strbuf-remove-fix:
        strbuf: use valid pointer in strbuf_remove()
      3ba0bbb9
    • J
      Merge branch 'rs/pack-sort-with-llist-mergesort' · ee198369
      Junio C Hamano 提交于
      Code cleanup.
      
      * rs/pack-sort-with-llist-mergesort:
        sha1_file: use llist_mergesort() for sorting packs
      ee198369
    • J
      Merge branch 'rs/checkout-some-states-are-const' · 48e1f8ed
      Junio C Hamano 提交于
      Code cleanup.
      
      * rs/checkout-some-states-are-const:
        checkout: constify parameters of checkout_stage() and checkout_merged()
      48e1f8ed
    • J
      Merge branch 'jk/setup-sequence-update' · d845d727
      Junio C Hamano 提交于
      There were numerous corner cases in which the configuration files
      are read and used or not read at all depending on the directory a
      Git command was run, leading to inconsistent behaviour.  The code
      to set-up repository access at the beginning of a Git process has
      been updated to fix them.
      
      * jk/setup-sequence-update:
        t1007: factor out repeated setup
        init: reset cached config when entering new repo
        init: expand comments explaining config trickery
        config: only read .git/config from configured repos
        test-config: setup git directory
        t1302: use "git -C"
        pager: handle early config
        pager: use callbacks instead of configset
        pager: make pager_program a file-local static
        pager: stop loading git_default_config()
        pager: remove obsolete comment
        diff: always try to set up the repository
        diff: handle --no-index prefixes consistently
        diff: skip implicit no-index check when given --no-index
        patch-id: use RUN_SETUP_GENTLY
        hash-object: always try to set up the git repository
      d845d727
    • J
      Merge branch 'ew/http-do-not-forget-to-call-curl-multi-remove-handle' · ac8ddd7b
      Junio C Hamano 提交于
      The http transport (with curl-multi option, which is the default
      these days) failed to remove curl-easy handle from a curlm session,
      which led to unnecessary API failures.
      
      * ew/http-do-not-forget-to-call-curl-multi-remove-handle:
        http: always remove curl easy from curlm session on release
        http: consolidate #ifdefs for curl_multi_remove_handle
        http: warn on curl_multi_add_handle failures
      ac8ddd7b
    • J
      Merge branch 'bw/pathspec-remove-unused-extern-decl' · 570b4494
      Junio C Hamano 提交于
      Code cleanup.
      
      * bw/pathspec-remove-unused-extern-decl:
        pathspec: remove unnecessary function prototypes
      570b4494
    • J
      Merge branch 'ks/pack-objects-bitmap' · 7f109ef5
      Junio C Hamano 提交于
      Some codepaths in "git pack-objects" were not ready to use an
      existing pack bitmap; now they are and as the result they have
      become faster.
      
      * ks/pack-objects-bitmap:
        pack-objects: use reachability bitmap index when generating non-stdout pack
        pack-objects: respect --local/--honor-pack-keep/--incremental when bitmap is in use
      7f109ef5
    • J
      Merge branch 'jk/patch-ids-no-merges' · f0a84de2
      Junio C Hamano 提交于
      "git log --cherry-pick" used to include merge commits as candidates
      to be matched up with other commits, resulting a lot of wasted time.
      The patch-id generation logic has been updated to ignore merges to
      avoid the wastage.
      
      * jk/patch-ids-no-merges:
        patch-ids: refuse to compute patch-id for merge commit
        patch-ids: turn off rename detection
      f0a84de2
    • J
      Merge branch 'jk/delta-base-cache' · 13307145
      Junio C Hamano 提交于
      Recently we updated the code to manage the in-core cache that holds
      objects that have recently been used to reconstitute other objects
      that are stored as deltas against them, but the update used an
      incorrect API function to manage the list of these objects.  This
      has been fixed.
      
      * jk/delta-base-cache:
        add_delta_base_cache: use list_for_each_safe
      13307145
    • J
      Merge branch 'et/add-chmod-x' · a9817aae
      Junio C Hamano 提交于
      "git add --chmod=+x" added recently lacked documentation, which has
      been corrected.
      
      * et/add-chmod-x:
        add: document the chmod option
      a9817aae
    • J
      Merge branch 'js/cat-file-filters' · 7889ed25
      Junio C Hamano 提交于
      Even though "git hash-objects", which is a tool to take an
      on-filesystem data stream and put it into the Git object store,
      allowed to perform the "outside-world-to-Git" conversions (e.g.
      end-of-line conversions and application of the clean-filter), and
      it had the feature on by default from very early days, its reverse
      operation "git cat-file", which takes an object from the Git object
      store and externalize for the consumption by the outside world,
      lacked an equivalent mechanism to run the "Git-to-outside-world"
      conversion.  The command learned the "--filters" option to do so.
      
      * js/cat-file-filters:
        cat-file: support --textconv/--filters in batch mode
        cat-file --textconv/--filters: allow specifying the path separately
        cat-file: introduce the --filters option
        cat-file: fix a grammo in the man page
      7889ed25
    • J
      Merge branch 'jt/accept-capability-advertisement-when-fetching-from-void' · 07d87243
      Junio C Hamano 提交于
      JGit can show a fake ref "capabilities^{}" to "git fetch" when it
      does not advertise any refs, but "git fetch" was not prepared to
      see such an advertisement.  When the other side disconnects without
      giving any ref advertisement, we used to say "there may not be a
      repository at that URL", but we may have seen other advertisement
      like "shallow" and ".have" in which case we definitely know that a
      repository is there.  The code to detect this case has also been
      updated.
      
      * jt/accept-capability-advertisement-when-fetching-from-void:
        connect: advertized capability is not a ref
        connect: tighten check for unexpected early hang up
        tests: move test_lazy_prereq JGIT to test-lib.sh
      07d87243
  5. 20 9月, 2016 6 次提交