sequencer.c: check for lock failure and bail early in fast_forward_to

Change fast_forward_to() to check if locking the ref failed, print a
nice error message and bail out early.

The old code did not check if ref_lock was NULL and relied on the
fact that the write_ref_sha1() would safely detect this condition
and set the return variable ret to indicate an error.

While that is safe, it makes the code harder to read for two reasons:

 * Inconsistency.  Almost all other places we do check the lock for
   NULL explicitly, so the naive reader is confused "why don't we
   check here?"

 * And relying on write_ref_sha1() to detect and return an error for
   when a previous lock_any_ref_for_update() failed feels obfuscated.

This change should not change any functionality or logic aside from
adding an extra error message when this condition is triggered
(write_ref_sha1() returns an error silently for this condition).

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit.c: check for lock error and return early

Move the check for the lock failure to happen immediately after
lock_any_ref_for_update().  Previously the lock and the
check-if-lock-failed was separated by a handful of string
manipulation statements.

Moving the check to occur immediately after the failed lock makes
the code slightly easier to read and makes it follow the pattern of

 try-to-take-a-lock();
 if (check-if-lock-failed) {
    error();
 }

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'rs/ref-update-check-errors-early' into jch

* rs/ref-update-check-errors-early:
  commit.c: check for lock error and return early
  sequencer.c: check for lock failure and bail early in fast_forward_to
Merge branch 'po/everyday-doc' into pu

This may make the said command to emit something, but the source is
not meant to be formatted into a manual pages to begin with, and
also its contents are a bit stale.  It may be a good first step in
the right direction, but needs more work to at least get the
mark-up right before public consumption.

Will hold.

* po/everyday-doc:
  Make 'git help everyday' work

# Conflicts:
# 	Documentation/Makefile
Merge branch 'jl/submodule-recursive-checkout' into pu

An RFCv2 exists ($gmane/241455) with sizable review comments.

* jl/submodule-recursive-checkout:
  Teach checkout to recursively checkout submodules
  submodule: teach unpack_trees() to update submodules
  submodule: teach unpack_trees() to repopulate submodules
  submodule: teach unpack_trees() to remove submodule contents
  submodule: prepare for recursive checkout of submodules
Merge branch 'rb/merge-prepare-commit-msg-hook' into pu

Expose more merge states (e.g. $GIT_DIR/MERGE_MODE) to hooks that
run during "git merge".  The log message stresses too much on one
hook, prepare-commit-msg, but it would equally apply to other hooks
like post-merge, I think.

* rb/merge-prepare-commit-msg-hook:
  merge: drop unused arg from abort_commit method signature
  merge: make prepare_to_commit responsible for write_merge_state
  t7505: ensure cleanup after hook blocks merge
  t7505: add missing &&

# Conflicts:
# 	builtin/merge.c
# 	t/t7505-prepare-commit-msg-hook.sh
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:
# 	builtin/log.c
# 	log-tree.c
# 	pretty.c
Merge branch 'jc/show-branch' into pu

* jc/show-branch:
  show-branch: use commit slab to represent bitflags of arbitrary width
  show-branch.c: remove "all_mask"
  show-branch.c: abstract out "flags" operation
  show-branch.c: lift all_mask/all_revs to a global static
  show-branch.c: update comment style
Merge branch 'tr/merge-recursive-index-only' into pu

Will hold.

* tr/merge-recursive-index-only:
  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()
Merge branch 'tg/perf-lib-test-perf-cleanup' into pu

Add test_perf_cleanup shell function to the perf suite, that allows
the script writers to define a test with a clean-up action.

Will hold.

* tg/perf-lib-test-perf-cleanup:
  perf-lib: add test_perf_cleanup target
  perf-lib: split starting the test from the execution
Merge branch 'bc/blame-crlf-test' into pu

I have a feeling that a fix for this should be fairly isolated and
trivial (it should be just the matter of paying attention to the
crlf settings when synthesizing the fake commit)---perhaps somebody
can squash in a fix to this?

* bc/blame-crlf-test:
  blame: add a failing test for a CRLF issue.
Merge branch 'jh/submodule-tests' into pu

* jh/submodule-tests:
  t7410: 210 tests for various 'git submodule update' scenarios
Merge branch 'jl/gitk-show-added-submodule-changes' into pu

Tentatively queued what I expect to receive via Paul Mackerras.

* jl/gitk-show-added-submodule-changes:
  gitk: show staged submodules regardless of ignore config
  l10n: Init Vietnamese translation
Merge branch 'jl/git-gui-show-added-submodule-changes' into pu

Tentatively queued what I expect to receive via Pat Thoyts.

* jl/git-gui-show-added-submodule-changes:
  git-gui: show staged submodules regardless of ignore config
### broken or came too late for the day's cycle
Merge branch 'jk/makefile' into pu

Simplify the Makefile rules and macros that exist primarily for
quoting purposes, and make it easier to robustly express the
dependency rules.

* jk/makefile:
  FIXUP
  move LESS/LV pager environment to Makefile
  Makefile: teach scripts to include make variables
  FIXUP
  Makefile: auto-build C strings from make variables
  Makefile: drop *_SQ variables
  FIXUP
  Makefile: add c-quote helper function
  Makefile: introduce sq function for shell-quoting
  Makefile: always create files via make-var
  Makefile: store GIT-* sentinel files in MAKE/
  Makefile: prefer printf to echo for GIT-*
  Makefile: use tempfile/mv strategy for GIT-*
  Makefile: introduce make-var helper function
  Makefile: fix git-instaweb dependency on gitweb
  Makefile: drop USE_GETTEXT_SCHEME from GIT-CFLAGS

# Conflicts:
# 	Makefile
Merge branch 'jc/graph-post-root-gap' into pu

This was primarily a RFH ($gmane/239580).

* jc/graph-post-root-gap:
  WIP: document what we want at the end
  graph: remove unused code a bit
  graph: stuff the current commit into graph->columns[]
Merge branch 'fc/publish-vs-upstream' into pu

Add branch@{publish}; it seems that this is somewhat different from
Ram and Peff started working on.  There are still many discussion
messages going back and forth but not updates to the patches.

Seems to have some interactions to break t5516 when merged to 'pu'.

* fc/publish-vs-upstream:
  sha1_name: add support for @{publish} marks
  sha1_name: simplify track finding
  sha1_name: cleanup interpret_branch_name()
  branch: display publish branch
  push: add --set-publish option
  branch: add --set-publish-to option
  Add concept of 'publish' branch
  t5516 (fetch-push): fix test restoration