builtin/notes: fix premature failure when trying to add the empty blob

This fixes a small buglet when trying to explicitly add the empty blob
as a note object using the -c or -C option to git notes add/append.
Instead of failing with a nonsensical error message indicating that the
empty blob does not exist, we should rather behave as if an empty notes
message was given (e.g. using -m "" or -F /dev/null).

The next patch contains a test that verifies the fixed behavior.

Found-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t3312-notes-empty: test that 'git notes' removes empty notes by default

Add test cases documenting the current behavior when trying to
add/append/edit empty notes. This is in preparation for adding
--allow-empty; to allow empty notes to be stored.

Improved-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
notes: add --allow-empty, to allow storing empty notes

Although the "git notes" man page advertises that we support binary-safe
notes addition (using the -C option), we currently do not support adding
the empty note (i.e. using the empty blob to annotate an object). Instead,
an empty note is always treated as an intent to remove the note
altogether.

Introduce the --allow-empty option to the add/append/edit subcommands,
to explicitly allow an empty note to be stored into the notes tree.

Also update the documentation, and add test cases for the new option.

Reported-by: James H. Fisher <jhf@trifork.com>
Improved-by: Kyle J. McKay <mackyle@gmail.com>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'jc/clone-borrow' into jch

Allow "git clone --reference" to be used more safely.

* jc/clone-borrow:
  clone: --dissociate option to mark that reference is only temporary
Merge branch 'jc/checkout-local-track-report' into jch

The report from "git checkout" on a branch that builds on another
local branch by setting its branch.*.merge to branch name (not a
full refname) incorrectly said that the upstream is gone.

* jc/checkout-local-track-report:
  checkout: report upstream correctly even with loosely defined branch.*.merge
Merge branch 'jc/diff-b-m' into jch

Fix long-standing bug in "diff -B -M" output.

* jc/diff-b-m:
  diff -B -M: fix output for "copy and then rewrite" case
Merge branch 'jc/strbuf-add-lines-avoid-sp-ht-sequence' into jch

The commented output used to blindly add a SP before the payload
line, resulting in "# \t<indented text>\n" when the payload began
with a HT.  Instead, produce "#\t<indented text>\n".

* jc/strbuf-add-lines-avoid-sp-ht-sequence:
  strbuf_add_commented_lines(): avoid SP-HT sequence in commented lines
Merge branch 'jc/conflict-hint' into jch

Unlike all the other hints given in the commit log editor, the list
of conflicted paths were appended at the end without commented out.

* jc/conflict-hint:
  merge & sequencer: turn "Conflicts:" hint into a comment
  builtin/commit.c: extract ignore_non_trailer() helper function
  merge & sequencer: unify codepaths that write "Conflicts:" hint
  builtin/merge.c: drop a parameter that is never used
Merge branch 'jk/cache-tree-protect-from-broken-libgit2' into jch

* jk/cache-tree-protect-from-broken-libgit2:
  cache-tree: avoid infinite loop on zero-entry tree
Merge branch 'rs/use-child-process-init-more' into jch

* rs/use-child-process-init-more:
  bundle: split out ref writing from bundle_create
  bundle: split out a helper function to compute and write prerequisites
  bundle: split out a helper function to create pack data
  use child_process_init() to initialize struct child_process variables
Merge branch 'jk/fetch-reflog-df-conflict' into jch

Corner-case bugfixes for "git fetch" around reflog handling.

* jk/fetch-reflog-df-conflict:
  ignore stale directories when checking reflog existence
  fetch: load all default config at startup
Merge branch 'js/diff-highlight-avoid-sigpipe' into jch

* js/diff-highlight-avoid-sigpipe:
  diff-highlight: exit when a pipe is broken
Merge branch 'tm/line-log-first-parent' into jch

* tm/line-log-first-parent:
  line-log: fix crash when --first-parent is used
Merge branch 'nd/gitignore-trailing-whitespace' into jch

* nd/gitignore-trailing-whitespace:
  gitignore.txt: fix spelling of "backslash"
### match next
Merge branch 'nd/lockfile-absolute' into jch

The lockfile API can get confused which file to clean up when the
process moved the $cwd after creating a lockfile.

* nd/lockfile-absolute:
  lockfile.c: store absolute path
Merge branch 'jc/merge-bases' into jch

* jc/merge-bases:
  get_merge_bases(): always clean-up object flags
  bisect: clean flags after checking merge bases
Merge branch 'rs/ref-transaction-reflog' into jch

Reviews and comments?

* rs/ref-transaction-reflog:
  refs.c: allow deleting refs with a broken sha1
  refs.c: remove lock_any_ref_for_update
  refs.c: make unlock_ref/close_ref/commit_ref static
  refs.c: rename log_ref_setup to create_reflog
  reflog.c: use a reflog transaction when writing during expire
  refs.c: allow multiple reflog updates during a single transaction
  refs.c: only write reflog update if msg is non-NULL
  refs.c: add a flag to allow reflog updates to truncate the log
  refs.c: add a transaction function to append a reflog entry
  copy.c: make copy_fd preserve meaningful errno
  refs.c: add a function to append a reflog entry to a fd
  refs.c: add a new update_type field to ref_update
  refs.c: rename the transaction functions
  refs.c: make ref_transaction_delete a wrapper for ref_transaction_update
  refs.c make ref_transaction_create a wrapper to ref_transaction_update
Merge branch 'ms/submodule-update-config-doc' into jch

* ms/submodule-update-config-doc:
  submodule: clarify documentation for update subcommand
Merge branch 'jc/push-cert-hmac-optim' into pu

This is "we could do this if we wanted to", not "we measured and it
improves performance critical codepath".

* 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