receive-pack::hmac_sha1(): copy the entire SHA-1 hash out

clang gives the following warning:

builtin/receive-pack.c:327:35: error: sizeof on array function
parameter will return size of 'unsigned char *' instead of 'unsigned
char [20]' [-Werror,-Wsizeof-array-argument]
        git_SHA1_Update(&ctx, out, sizeof(out));
                                         ^
builtin/receive-pack.c:292:37: note: declared here
static void hmac_sha1(unsigned char out[20],
                                   ^
Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_to_hex: split out "hex-format n bytes" helper and use it

The original sha1_to_hex() becomes the only one caller of
bin_to_hex() helper; no functional or performance change intended.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
receive-pack: truncate hmac early and convert only necessary bytes

Instead of copying out 20-bytes of HMAC, format it into 40-bytes of
hex and then chomping it to 20-bytes output when generating a nonce,
copy out only HMAC_TRUNCATE (=10) bytes, convert it to text using
the new bin_to_hex() helper to do the same.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'pr/use-default-sigpipe-setting' into jch

We used to get confused when a process called us with SIGPIPE
ignored; we do want to die with SIGPIPE when the output is not
read by default, and do ignore the signal when appropriate.

* pr/use-default-sigpipe-setting:
  mingw.h: add dummy functions for sigset_t operations
  unblock and unignore SIGPIPE
Merge branch 'sb/merge-recursive-copy-paste-fix' into jch

"git merge-recursive" had a small bug that could have made it
mishandle "one side deleted, the other side did not touch it" in a
rare corner case, where the other side actually did touch to cause
the blob object names to be different but both blobs before and
after the change normalize to the same (e.g. correcting mistake to
check in a blob with CRLF line endings by replacing it with another
blob that records the same contents with LF line endings).

* sb/merge-recursive-copy-paste-fix:
  merge-recursive: remove stale commented debugging code
  merge-recursive: fix copy-paste mistake
Merge branch 'jc/push-cert' into jch

Allow "git push" request to be signed, so that it can be verified and
audited, using the GPG signature of the person who pushed, that the
tips of branches at a public repository really point the commits
the pusher wanted to, without having to "trust" the server.

* jc/push-cert: (24 commits)
  receive-pack::hmac_sha1(): copy the entire SHA-1 hash out
  signed push: allow stale nonce in stateless mode
  signed push: teach smart-HTTP to pass "git push --signed" around
  signed push: fortify against replay attacks
  signed push: add "pushee" header to push certificate
  signed push: remove duplicated protocol info
  send-pack: send feature request on push-cert packet
  receive-pack: GPG-validate push certificates
  push: the beginning of "git push --signed"
  pack-protocol doc: typofix for PKT-LINE
  gpg-interface: move parse_signature() to where it should be
  gpg-interface: move parse_gpg_output() to where it should be
  send-pack: clarify that cmds_sent is a boolean
  send-pack: refactor inspecting and resetting status and sending commands
  send-pack: rename "new_refs" to "need_pack_data"
  receive-pack: factor out capability string generation
  send-pack: factor out capability string generation
  send-pack: always send capabilities
  send-pack: refactor decision to send update per ref
  send-pack: move REF_STATUS_REJECT_NODELETE logic a bit higher
  ...
Merge branch 'jt/itimer-autoconf' into jch

Split the early part of jt/timer-settime topic out into a topic.

* jt/itimer-autoconf:
  autoconf: check for setitimer()
  autoconf: check for struct itimerval
  git-compat-util.h: add missing semicolon after struct itimerval
Merge branch 'nd/archive-pathspec' into jch

"git archive" learned to filter what gets archived with pathspec.

* nd/archive-pathspec:
  archive: support filtering paths with glob
Merge branch 'jc/test-lazy-prereq' into jch

Test-script clean-up.

* jc/test-lazy-prereq:
  tests: drop GIT_*_TIMING_TESTS environment variable support
### match next
Merge branch 'sp/stream-clean-filter' into jch

* sp/stream-clean-filter:
  sha1_file: don't convert off_t to size_t too early to avoid potential die()
  convert: stream from fd to required clean filter to reduce used address space
  copy_fd(): do not close the input file descriptor
  mmap_limit: introduce GIT_MMAP_LIMIT to allow testing expected mmap size
  memory_limit: use git_env_ulong() to parse GIT_ALLOC_LIMIT
  config.c: add git_env_ulong() to parse environment variable
  convert: drop arguments other than 'path' from would_convert_to_git()

# Conflicts:
# 	wrapper.c
Merge branch 'tr/remerge-diff' into jch

"log -p" output learns a new way to let users inspect a merge
commit by showing the differences between the automerged result
with conflicts the person who recorded the merge would have seen
and the final conflict resolution that was recorded in the merge.

* tr/remerge-diff:
  log --remerge-diff: show what the conflict resolution changed
  name-hash: allow dir hashing even when !ignore_case
  merge-recursive: allow storing conflict hunks in index
  merge_diff_mode: fold all merge diff variants into an enum
  combine-diff: do not pass revs->dense_combined_merges redundantly
  merge-recursive: -Xindex-only to leave worktree unchanged
  merge-recursive: internal flag to avoid touching the worktree
  merge-recursive: remove dead conditional in update_stages()

# Conflicts:
# 	merge-recursive.c
Merge branch 'da/include-compat-util-first-in-c' into jch

* da/include-compat-util-first-in-c:
  SQUASH???
  check-headers: add header usage checks for .c files
  Makefile: add check-headers target
  cleanups: ensure that git-compat-util.h is included first
Merge branch 'so/rebase-doc-fork-point' into jch

* so/rebase-doc-fork-point:
  Documentation/git-rebase.txt: document when --fork-point is auto-enabled
Merge branch 'sk/tag-contains-wo-recursion' into jch

* sk/tag-contains-wo-recursion:
  t7004: give the test a bit more stack space
Merge branch 'jc/push-cert-hmac-optim' into jch

* jc/push-cert-hmac-optim:
  receive-pack: truncate hmac early and convert only necessary bytes
  sha1_to_hex: split out "hex-format n bytes" helper and use it
Merge branch 'cc/interpret-trailers' into pu

A new filter to programatically edit the tail end of the commit log
messages.

Discussion on the topic with Michael Tsirkin who wants to utilize
this machinery is going on.  Finally a real functionality review
that is very much welcomed ;-).

* cc/interpret-trailers:
  Documentation: add documentation for 'git interpret-trailers'
  trailer: add tests for commands in config file
  trailer: execute command from 'trailer.<name>.command'
  trailer: add tests for "git interpret-trailers"
  trailer: add interpret-trailers command
  trailer: put all the processing together and print
  trailer: parse trailers from file or stdin
  trailer: process command line trailer arguments
  trailer: read and process config information
  trailer: process trailers from input message and arguments
  trailer: add data structures and basic functions
Merge branch 'mh/lockfile' into pu

Rerolled, reviews in progress; it seems that we will see another reroll?

* mh/lockfile: (35 commits)
  get_locked_file_path(): new function
  lockfile.c: rename static functions
  lockfile: rename LOCK_NODEREF to LOCK_NO_DEREF
  commit_locked_index(): extract a function commit_lock_file_to()
  trim_last_path_component(): replace last_path_elm()
  resolve_symlink(): take a strbuf parameter
  resolve_symlink(): use a strbuf for internal scratch space
  struct lock_file: change the filename member into a strbuf
  commit_lock_file(): use a strbuf to manage temporary space
  try_merge_strategy(): use a statically-allocated lock_file object
  try_merge_strategy(): remove redundant lock_file allocation
  struct lock_file: declare some fields volatile
  lockfile: avoid transitory invalid states
  git_config_set_multivar_in_file(): avoid call to rollback_lock_file()
  dump_marks(): remove a redundant call to rollback_lock_file()
  api-lockfile: document edge cases
  commit_lock_file(): rollback lock file on failure to rename
  commit_lock_file(): if close fails, roll back
  commit_lock_file(): die() if called for unlocked lockfile object
  commit_lock_file(): inline temporary variable
  ...

# Conflicts:
# 	lockfile.c
# 	refs.c
Merge branch 'nd/multiple-work-trees' into pu

A replacement for contrib/workdir/git-new-workdir that does not
rely on symbolic links and make sharing of objects and refs safer
by making the borrowee and borrowers aware of each other.

Rerolled, reviews in progress; it seems that we will see another reroll?

* nd/multiple-work-trees: (32 commits)
  t2025: add a test to make sure grafts is working from a linked checkout
  checkout: don't require a work tree when checking out into a new one
  git_path(): keep "info/sparse-checkout" per work-tree
  count-objects: report unused files in $GIT_DIR/worktrees/...
  gc: support prune --worktrees
  gc: factor out gc.pruneexpire parsing code
  gc: style change -- no SP before closing parenthesis
  checkout: clean up half-prepared directories in --to mode
  checkout: reject if the branch is already checked out elsewhere
  prune: strategies for linked checkouts
  checkout: support checking out into a new working directory
  use new wrapper write_file() for simple file writing
  wrapper.c: wrapper to open a file, fprintf then close
  setup.c: support multi-checkout repo setup
  setup.c: detect $GIT_COMMON_DIR check_repository_format_gently()
  setup.c: convert check_repository_format_gently to use strbuf
  setup.c: detect $GIT_COMMON_DIR in is_git_directory()
  setup.c: convert is_git_directory() to use strbuf
  git-stash: avoid hardcoding $GIT_DIR/logs/....
  *.sh: avoid hardcoding $GIT_DIR/hooks/...
  ...

# Conflicts:
# 	builtin/gc.c
# 	builtin/receive-pack.c
# 	refs.c
# 	refs.h
# 	trace.c
# 	wrapper.c
Merge branch 'hv/submodule-config' into pu

Kicked back to 'pu' per request ($gmane/255610).

* hv/submodule-config:
  do not die on error of parsing fetchrecursesubmodules option
  use new config API for worktree configurations of submodules
  extract functions for submodule config set and lookup
  implement submodule config cache for lookup of submodule names