strbuf_branchname(): do not double-expand @{-1}~22

If you were on 'frotz' branch before you checked out your current
branch, "git merge @{-1}~22" means the same as "git merge frotz~22".

The strbuf_branchname() function, when interpret_branch_name() gives
up resolving "@{-1}~22" fully, returns "frotz" and tells the caller
that it only resolved "@{-1}" part of the input, mistakes this as a
total failure, and appends the whole thing to the result, yielding
"frotz@{-1}~22", which does not make any sense.

Inspect the return value from interpret_branch_name() a bit more
carefully.  When it errored out without consuming anything, we will
get -1 and we should return the whole thing.  Otherwise, we should
append the remainder (i.e. "~22" in the earlier example) to the
partially resolved name (i.e. "frotz").

The test suite adds enough number of checkout to make @{-12} in the
last test in t0100 that tried to check "we haven't flipped branches
that many times" error case; raise the number to a hundred.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h: eliminate SHA-1 deprecation warnings on Mac OS X

Mac OS X 10.8 Mountain Lion prints warnings when building git:

	warning: 'SHA1_Init' is deprecated
	(declared at /usr/include/openssl/sha.h:121)

Silence the warnings by using the CommonCrytpo SHA-1
functions for SHA1_Init(), SHA1_Update(), and SHA1_Final().

Add a NO_COMMON_DIGEST_FOR_OPENSSL option to the Makefile to allow
users to opt out of using this library.  When defined, Git will
use OpenSSL instead.

COMMON_DIGEST_FOR_OPENSSL is defined to enable the OpenSSL
compatibility macros in CommonDigest.h.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
imap-send: eliminate HMAC deprecation warnings on Mac OS X

Mac OS X 10.8 Mountain Lion warns that HMAC_Init() and friends
are deprecated.  Detect the COMMON_DIGEST_FOR_OPENSSL definition
and use CommonCrypto's HMAC functions to eliminate the warnings.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'da/darwin' into jch

* da/darwin:
  imap-send: eliminate HMAC deprecation warnings on Mac OS X
  cache.h: eliminate SHA-1 deprecation warnings on Mac OS X
  Makefile: fix default regex settings on Darwin
Merge branch 'kb/ancestry-path-threedots' into jch

* kb/ancestry-path-threedots:
  t6019: demonstrate --ancestry-path A...B breakage
Merge branch 'kb/full-history-compute-treesame-carefully-2' into jch

Major update to a very core part of the system to improve culling
of irrelevant parents while traversing a mergy history.

Will not be a 1.8.3 material, but is an important topic.

* kb/full-history-compute-treesame-carefully-2:
  revision.c: treat A...B merge bases as if manually specified
  revision.c: discount side branches when computing TREESAME
  simplify-merges: drop merge from irrelevant side branch
  simplify-merges: never remove all TREESAME parents
  t6012: update test for tweaked full-history traversal
  revision.c: Make --full-history consider more merges
  rev-list-options.txt: correct TREESAME for P
  t6111: allow checking the parents as well
  t6111: new TREESAME test set
  t6019: test file dropped in -s ours merge
  decorate.c: compact table when growing
Merge branch 'mk/combine-diff-context-horizon-fix' into jch

"git diff -c -p" was not showing a deleted line from a hunk when
another hunk immediately begins where the earlier one ends.

* mk/combine-diff-context-horizon-fix:
  combine-diff.c: Fix output when changes are exactly 3 lines apart

# Conflicts:
# 	t/t4038-diff-combined.sh
Merge branch 'mm/color-auto-default' into jch

Flip the default for color.ui to 'auto', which is what many
tutorials recommend new users to do.

* mm/color-auto-default:
  make color.ui default to 'auto'
  config: refactor management of color.ui's default value
Merge branch 'jc/strbuf-branchname-fix' into jch

"git merge @{-1}~22" was rewritten to "git merge frotz@{1}~22"
incorrectly when your previous branch was "frotz" (it should be
rewritten to "git merge frotz~22" instead).

* jc/strbuf-branchname-fix:
  strbuf_branchname(): do not double-expand @{-1}~22
Merge branch 'fc/at-head' into jch

Instead of typing four capital letters "HEAD", you can say "@"
instead.

* fc/at-head:
  sha1_name: compare variable with constant, not constant with variable
  Add new @ shortcut for HEAD
  sha1_name: refactor reinterpret()
  sha1_name: check @{-N} errors sooner
  sha1_name: reorganize get_sha1_basic()
  sha1_name: don't waste cycles in the @-parsing loop
  sha1_name: remove unnecessary braces
  sha1_name: remove no-op
  tests: at-combinations: @{N} versus HEAD@{N}
  tests: at-combinations: increase coverage
  tests: at-combinations: improve nonsense()
  tests: at-combinations: check ref names directly
  tests: at-combinations: simplify setup
Merge branch 'jc/push-2.0-default-to-simple' into jch

The early bits to adjust the tests have been merged to 'master'.

* jc/push-2.0-default-to-simple:
  push: switch default from "matching" to "simple"

# Conflicts:
# 	Documentation/config.txt
# 	Documentation/git-push.txt
# 	builtin/push.c
Merge branch 'jn/add-2.0-u-A-sans-pathspec' into jch

* jn/add-2.0-u-A-sans-pathspec:
  git add: -u/-A now affects the entire working tree
Merge branch 'jc/add-2.0-ignore-removal' into jch

Updated endgame for "git add <pathspec>" that defaults to "--all"
aka "--no-ignore-removal".

* jc/add-2.0-ignore-removal:
  git add <pathspec>... defaults to "-A"

# Conflicts:
# 	builtin/add.c
Merge branch 'jc/core-checkstat-2.0' into jch

The bottom one is a fix for a breakage of a new feature in 1.8.2
but it is not all that urgent.

* jc/core-checkstat-2.0:
  core.statinfo: remove as promised in Git 2.0
Merge branch 'jh/shorten-refname' into pu

When remotes/origin/HEAD is not a symbolic ref, "rev-parse
--abbrev-ref remotes/origin/HEAD" ought to show "origin", not
"origin/HEAD", which is fixed with this series (if it is a symbolic
ref that points at remotes/origin/something, then it should show
"origin/something" and it already does).

I think this is being rerolled using strbuf_expand().

* jh/shorten-refname:
  t1514: refname shortening is done after dereferencing symbolic refs
  shorten_unambiguous_ref(): Fix shortening refs/remotes/origin/HEAD to origin
  t1514: Demonstrate failure to correctly shorten "refs/remotes/origin/HEAD"
  t1514: Add tests of shortening refnames in strict/loose mode
Merge branch 'nd/warn-ambiguous-object-name' into pu

"git cmd <name>", when <name> happens to be a 40-hex string,
directly uses the 40-hex string as an object name, even if a ref
"refs/<some hierarchy>/<name>" exists.  This disambiguation order
is unlikely to change, but we should warn about the ambiguity just
like we warn when more than one refs/ hierachies share the same
name.

The message needs to be fixed up, as this is not "refname is
ambiguous".

* nd/warn-ambiguous-object-name:
  get_sha1: improve ambiguity warning regarding SHA-1 and ref names
Merge branch 'jk/gitweb-utf8' into pu

Various fixes to gitweb.

* jk/gitweb-utf8:
  gitweb: Fix broken blob action parameters on blob/commitdiff pages
  gitweb: Don't append ';js=(0|1)' to external links
  gitweb: Make feed title valid utf8
  gitweb: Fix utf8 encoding for blob_plain, blobdiff_plain, commitdiff_plain, and patch
Merge branch 'jc/format-patch' into pu

A new option to send a single patch to the standard output to be
appended at the bottom of a message.  I personally have no need for
this, but it was easy enough to cobble together.  Tests, docs and
stripping out more MIMEy stuff are left as exercises to interested
parties.

* jc/format-patch:
  format-patch: --inline-single
  format-patch: rename "no_inline" field

# Conflicts:
# 	pretty.c
Merge branch 'jk/commit-info-slab' into pu

Technology demonstration to show a way we could use unbound number
of flag bits on commit objects.

* jk/commit-info-slab:
  commit-slab: introduce a macro to define a slab for new type
  commit-slab: avoid large realloc
  commit: allow associating auxiliary info on-demand
Merge branch 'mg/more-textconv' into pu

Looked reasonable, I think.  Comments?

* mg/more-textconv:
  grep: honor --textconv for the case rev:path
  grep: allow to use textconv filters
  t7008: demonstrate behavior of grep with textconv
  cat-file: do not die on --textconv without textconv filters
  show: honor --textconv for blobs
  diff_opt: track whether flags have been set explicitly
  t4030: demonstrate behavior of show with textconv