apply: a bit more comments on PATH_TO_BE_DELETED

The code is littered with to_be_deleted() whose purpose is not so clear.
Describe where it matters.  Also remove an extra space before "#define"
that snuck in by mistake at 7fac0ee (builtin-apply: keep information about
files to be deleted, 2009-04-11).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
apply: refactor "previous patch" logic

The code to grab the result of application of a previous patch in the
input was mixed with error message generation for a case where a later
patch tries to modify contents of a path that has been removed.

The same code is duplicated elsewhere in the code.  Introduce a helper
to clarify what is going on.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
WIP: the message is bogus in apply:::check_patch()

This check is not really about type-change (for which it would be
sufficient to check only was_deleted()) but is also about a swap
rename.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
xdiff: signed right shift for 32-bit case of XDL_FAST_HASH

In the 32-bit branch of count_masked_bytes(), the compiler uses a
logical right shift on mask, because it is unsigned.  We want it to
be an arithmetic right shift, however (keeping negative numbers
negative instead of shifting the sign bit as well).

There is no way to specify it in C, but we can at least cast mask to
signed long.  This will make the compiler use an arithmetic right shift
on certain implementations, but that's OK because we only turn on
XDL_FAST_HASH in the Makefile for known-good architectures, and at
least gcc 4.6.3 and clang 3.0 do what we want on the most interesting
one (x86).

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'bp/diff-no-index-strbuf-fix' into jch

By Bobby Powers
* bp/diff-no-index-strbuf-fix:
  diff --no-index: don't leak buffers in queue_diff
  diff --no-index: reset temporary buffer lengths on directory iteration
Merge branch 'hv/submodule-alt-odb' into jch

By Heiko Voigt
* hv/submodule-alt-odb:
  teach add_submodule_odb() to look for alternates
Merge branch 'js/rebase-i-p-test-fix' into jch

By Johannes Sixt
* js/rebase-i-p-test-fix:
  Fix t3411.3 to actually rebase something
Merge branch 'js/rev-parse-doc-fix' into jch

By Jon Seymour
* js/rev-parse-doc-fix:
  rev-parse doc: --git-dir does not always show a relative path
Merge branch 'rs/archive-tree-in-tip-simplify' into jch

By René Scharfe
* rs/archive-tree-in-tip-simplify:
  archive-tar: keep const in checksum calculation
  archive: simplify refname handling
Merge branch 'nl/http-proxy-more' into pu

I queued only the later two patches from this series, even though they do
not make much sense without the first one that seems to need a bit more
work, so that we won't forget.

By Jeff King (1) and Nelson Benitez Leon (1)
* nl/http-proxy-more:
  http: rename HTTP_REAUTH to HTTP_AUTH_RETRY
  http: Avoid limit of retrying request only twice
Merge branch 'mm/push-default-switch-warning' into pu

Will squash the two, but this has to wait for a few release cycles.

By Junio C Hamano (1) and Matthieu Moy (1)
* mm/push-default-switch-warning:
  t5541: warning message is given even with --quiet
  push: start warning upcoming default change for push.default
Merge branch 'jc/split-blob' into pu

Not ready.

I finished the streaming checkout codepath, but as explained in
127b177 (bulk-checkin: support chunked-object encoding, 2011-11-30),
these are still early steps of a long and painful journey. At least
pack-objects and fsck need to learn the new encoding for the series
to be usable locally, and then index-pack/unpack-objects needs to
learn it to be used remotely.

Given that I heard a lot of noise that people want large files, and
that I was asked by somebody at GitTogether'11 privately for an
advice on how to pay developers (not me) to help adding necessary
support, I am somewhat dissapointed that the original patch series
that was sent almost two months ago still remains here without much
comments and updates from the developer community. I even made the
interface to the logic that decides where to split chunks easily
replaceable, and I deliberately made the logic in the original patch
extremely stupid to entice others, especially the "bup" fanboys, to
come up with a better logic, thinking that giving people an easy
target to shoot for, they may be encouraged to help out. The plan is
not working :-(.

* jc/split-blob:
  chunked-object: streaming checkout
  chunked-object: fallback checkout codepaths
  bulk-checkin: support chunked-object encoding
  bulk-checkin: allow the same data to be multiply hashed
  new representation types in the packstream
  packfile: use varint functions

Conflicts:
	t/t1050-large.sh
Merge branch 'jc/run-hook-env-1' into pu

Not urgent.

Updates run_hook() API to be much less specific to "commit".  It would
only be useful if people start doing more interesting things with hooks.

* jc/run-hook-env-1:
  run_hook(): enhance the interface to pass arbitrary environment
Merge branch 'jc/maint-push-refs-all' into pu

Allows pushing and fetching refs/stash.
Not ready.
There still seem to be other bugs hiding (e.g. try pushing twice).

* jc/maint-push-refs-all:
  get_fetch_map(): tighten checks on dest refs
  fetch/push: allow refs/*:refs/*
Merge branch 'sg/bash-prompt' into pu

This is only the "correction" bits taken from the beginning of a larger
series that is to be rerolled.

By SZEDER Gábor
* sg/bash-prompt:
  completion: respect $GIT_DIR
  completion: use __gitdir() in _git_log()
  tests: add tests for the bash prompt functions in the completion script
  tests: move code to run tests under bash into a helper library
Merge branch 'jc/apply-3way' into pu

"git apply" learns to wiggle the base version and perform three-way merge
when a patch does not exactly apply to the version you have.

It turns out that it is very unpleasant to deal with add/add conflict,
but it is needed for "apply --3way" to replace the use of the three-step
"apply --build-fake-ancestor", "apply --index" then slow "merge-recursive"
pipeline in "am -3".

* jc/apply-3way:
  WIP: the message is bogus in apply:::check_patch()
  apply: refactor "previous patch" logic
  apply: a bit more comments on PATH_TO_BE_DELETED
  apply: document --3way option
  apply: allow rerere() upon --3way results
  apply: register conflicted stages to the index
  apply: plug the three-way merge logic in
  apply: fall back on three-way merge
  apply: accept -3/--3way command line option
  apply: split load_preimage() helper function out
  apply: refactor read_file_or_gitlink()
  apply: clear_image() clears things a bit more

Conflicts:
	builtin/apply.c
Merge branch 'rs/dir-strbuf-read-recursive-fix' into pu

By René Scharfe
* rs/dir-strbuf-read-recursive-fix:
  dir: simplify fill_directory()
  dir: respect string length argument of read_directory_recursive()
Merge branch 'rs/xdiff-fast-hash-fix' into pu

By René Scharfe
* rs/xdiff-fast-hash-fix:
  xdiff: signed right shift for 32-bit case of XDL_FAST_HASH
pack-objects, streaming: turn "xx >= big_file_threshold" to ".. > .."

This is because all other places do "xx > big_file_threshold"

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-objects: refactor write_object() into helper functions

The function first decides if we want to copy data taken from existing
pack verbatim or we want to encode the data ourselves for the packfile
we are creating and then carries out the decision.  Separate the latter
phase into two helper functions, one for the case the data is reused,
the other for the case the data is produced anew.

A little twist is that it can later turn out that we cannot reuse the
data after we initially decide to do so; in such a case, the "reuse"
helper makes a call to "generate" helper.  It is easier to follow than
the current fallback code that uses "goto" inside a single large
function.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>