pack-objects: no crc check when the cached version is used

Current code makes pack-objects always do check_pack_crc() in
unpack_entry() even if right after that we find out there's a cached
version and pack access is not needed. Swap two code blocks, search
for cached version first, then check crc.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'nd/fetch-into-shallow' into jch

When there is no sufficient overlap between old and new history
during a fetch into a shallow repository, we unnecessarily sent
objects the sending side knows the receiving end has.

* nd/fetch-into-shallow:
  Add testcase for needless objects during a shallow fetch
  list-objects: mark more commits as edges in mark_edges_uninteresting
  list-objects: reduce one argument in mark_edges_uninteresting
  upload-pack: delegate rev walking in shallow fetch to pack-objects
  shallow: add setup_temporary_shallow()
  shallow: only add shallow graft points to new shallow file
  move setup_alternate_shallow and write_shallow_commits to shallow.c

# Conflicts:
# 	fetch-pack.c
Merge branch 'jk/duplicate-objects-in-packs' into jch

A packfile that stores the same object more than once is broken and
will be rejected.

* jk/duplicate-objects-in-packs:
  t5308: check that index-pack --strict detects duplicate objects
  test index-pack on packs with recoverable delta cycles
  add tests for indexing packs with delta cycles
  sha1-lookup: handle duplicate keys with GIT_USE_LOOKUP
  test-sha1: add a binary output mode
Merge branch 'ap/commit-author-mailmap' into jch

"git commit --author=$name", when $name is not in the canonical
"A. U. Thor <au.thor@example.xz>" format, looks for a matching name
from existing history, but did not consult mailmap to grab the
preferred author name.

* ap/commit-author-mailmap:
  commit: search author pattern against mailmap
Merge branch 'kk/tests-with-no-perl' into jch

Some tests were not skipped under NO_PERL build.

* kk/tests-with-no-perl:
  reset test: modernize style
  t/t7106-reset-unborn-branch.sh: Add PERL prerequisite
  add -i test: use skip_all instead of repeated PERL prerequisite
  Make test "using invalid commit with -C" more strict
Merge branch 'jk/write-broken-index-with-nul-sha1' into jch

Earlier we started rejecting an attempt to add 0{40} object name to
the index and to tree objects, but it sometimes is necessary to
allow so to be able to use tools like filter-branch to correct such
broken tree objects.

* jk/write-broken-index-with-nul-sha1:
  write_index: optionally allow broken null sha1s
Merge branch 'tb/precompose-autodetect-fix' into jch

On MacOS X, we detected if the filesystem needs the "pre-composed
unicode strings" workaround, but did not automatically enable it.
Now we do.

* tb/precompose-autodetect-fix:
  Set core.precomposeunicode to true on e.g. HFS+
Merge branch 'jx/clean-interactive' into jch

Finishing touches to update the document to adjust to a new option
"git clean" learned recently.

* jx/clean-interactive:
  documentation: clarify notes for clean.requireForce
Merge branch 'jk/free-tree-buffer' into jch

* jk/free-tree-buffer:
  clear parsed flag when we free tree buffers
Merge branch 'jk/has-sha1-file-retry-packed' into jch

When an object is not found after checking the packfiles and then
loose object directory, read_sha1_file() re-checks the packfiles to
prevent racing with a concurrent repacker; teach the same logic to
has_sha1_file().

* jk/has-sha1-file-retry-packed:
  has_sha1_file: re-check pack directory before giving up
Merge branch 'fc/trivial' into jch

* fc/trivial:
  pull: use $curr_branch_short more
  add: trivial style cleanup
  reset: trivial style cleanup
  branch: trivial style fix
  reset: trivial refactoring

# Conflicts:
# 	builtin/reset.c
Merge branch 'fc/fast-export' into jch

Code simpification.

* fc/fast-export:
  fast-export: refactor get_tags_and_duplicates()
  fast-export: make extra_refs global
Merge branch 'fc/rev-parse-test-updates' into jch

Modernize tests.

* fc/rev-parse-test-updates:
  rev-parse test: use standard test functions for setup
  rev-parse test: use test_cmp instead of "test" builtin
  rev-parse test: use test_must_fail, not "if <command>; then false; fi"
  rev-parse test: modernize quoting and whitespace
Merge branch 'fc/t3200-fixes' into jch

* fc/t3200-fixes:
  t: branch: fix broken && chains
  t: branch: fix typo
  t: branch: trivial style fix
Merge branch 'jk/pager-bypass-cat-for-default-pager' into jch

If a build-time fallback is set to "cat" instead of "less", we
should apply the same "no subprocess or pipe" optimization as we
apply to user-supplied GIT_PAGER=cat.

* jk/pager-bypass-cat-for-default-pager:
  pager: turn on "cat" optimization for DEFAULT_PAGER
Merge branch 'nd/git-dir-pointing-at-gitfile' into jch

We made sure that we notice the user-supplied GIT_DIR is actually a
gitfile, but failed to do so when the default ".git" is a gitfile.

* nd/git-dir-pointing-at-gitfile:
  Make setup_git_env() resolve .git file when $GIT_DIR is not specified
Merge branch 'ab/gitweb-author-initials' into jch

* ab/gitweb-author-initials:
  gitweb: Fix the author initials in blame for non-ASCII names
Merge branch 'ta/user-manual' into jch

Update the user's manual to more recent versions of Git.

* ta/user-manual:
  "git prune" is safe
  Remove irrelevant reference from "Tying it all together"
  Remove unnecessary historical note from "Object storage format"
  Improve section "Merging multiple trees"
  Improve section "Manipulating branches"
  Simplify "How to make a commit"
  Fix some typos and improve wording
  Use "git merge" instead of "git pull ."
  Use current output for "git repack"
  Use current "detached HEAD" message
  Call it "Git User Manual" and remove reference to very old Git version
Merge branch 'dw/diff-no-index-doc' into jch

When the user types "git diff" outside a working tree, thinking he
is inside one, the current error message that is a single-liner
"usage: git diff --no-index <path> <path>" may not be sufficient to
make him realize the mistake. Add "Not a git repository" to the
error message when we fell into the "--no-index" mode without an
explicit command line option to instruct us to do so.

* dw/diff-no-index-doc:
  diff --no-index: describe in a separate paragraph
  diff --no-index: clarify operation when not inside a repository
Merge branch 'rh/ishes-doc' into jch

We liberally use "committish" and "commit-ish" (and "treeish" and
"tree-ish"); as these are non-words, let's unify these terms to
their dashed form.  More importantly, clarify the documentation on
object peeling using these terms.

* rh/ishes-doc:
  glossary: fix and clarify the definition of 'ref'
  revisions.txt: fix and clarify <rev>^{<type>}
  glossary: more precise definition of tree-ish (a.k.a. treeish)
  use 'commit-ish' instead of 'committish'
  use 'tree-ish' instead of 'treeish'
  glossary: define commit-ish (a.k.a. committish)
  glossary: mention 'treeish' as an alternative to 'tree-ish'