git-remote-testpy: fix path hashing on Python 3

When this change was originally made (0846b0c - git-remote-testpy:
hash bytes explicitly , I didn't realise that the "hex" encoding we
chose is a "bytes to bytes" encoding so it just fails with an error
on Python 3 in the same way as the original code.

It is not possible to provide a single code path that works on
Python 2 and Python 3 since Python 2.x will attempt to decode the
string before encoding it, which fails for strings that are not
valid in the default encoding.  Python 3.1 introduced the
"surrogateescape" error handler which handles this correctly and
permits a bytes -> unicode -> bytes round-trip to be lossless.

At this point Python 3.0 is unsupported so we don't go out of our
way to try to support it.

Helped-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch: reject -D/-d without branch name

Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch: give a more helpful message on redundant arguments

While at there, do not stop user from editing a branch description
when the unrelated HEAD is detached.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch: mark more strings for translation

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mergetools: Simplify how we handle "vim" and "defaults"

Remove the exceptions for "vim" and "defaults" in the mergetool library
so that every filename in mergetools/ matches 1:1 with the name of a
valid built-in tool.

Define the trivial fallback definition of shell functions in-line in
git-mergetool-lib script, instead of dot-sourcing them from another
file.  The result is much easier to follow.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mergetool--lib: simplify command expressions

Use $(command "$arg") instead of "$(command "$arg")" when it is the
right hand side of a variable assignment, as var="$(command "$arg")"
is harder to read.

Make the expression in get_merge_tool_cmd() even simpler by avoiding
"echo" completely.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mergetool--lib: improve the help text in guess_merge_tool()

This code path is only activated when the user does not have a valid
configured tool.  Add a message to guide new users towards configuring a
default tool.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mergetool--lib: add functions for finding available tools

Refactor show_tool_help() so that the tool-finding logic is broken out
into separate functions.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
doc: generate a list of valid merge tools

Use the new filter_tools() function to build lists of all
the built-in tools supported by difftool and mergetool.
This frees us from needing to update the documentation
whenever a new tool is added.

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

Cleans up mergetool/difftool combo.

The top one needs to be squashed into the second one before merging
it to 'next'.

* jk/mergetool:
  mergetools: Simplify how we handle "vim" and "defaults"
  mergetool--lib: don't call "exit" in setup_tool
  mergetool--lib: Improve show_tool_help() output
  mergetools/vim: Remove redundant diff command
  git-difftool: use git-mergetool--lib for "--tool-help"
  git-mergetool: don't hardcode 'mergetool' in show_tool_help
  git-mergetool: remove redundant assignment
  git-mergetool: move show_tool_help to mergetool--lib
Merge branch 'da/mergetool-docs' into jch

* da/mergetool-docs:
  doc: generate a list of valid merge tools
  mergetool--lib: add functions for finding available tools
  mergetool--lib: improve the help text in guess_merge_tool()
  mergetool--lib: simplify command expressions
Merge branch 'jk/remote-helpers-in-python-3' into jch

Prepare remote-helper test written in Python to be run with Python3.

Michael Haggerty points out that the top one does not fix what it
tries to fix.
$gmane/214675

* jk/remote-helpers-in-python-3:
  git-remote-testpy: fix path hashing on Python 3
Merge branch 'jk/gc-auto-after-fetch' into pu

This is to resolve merge conflicts early for the same topic to
recent codebase.

Will merge to 'next'.

* jk/gc-auto-after-fetch:
  fetch-pack: avoid repeatedly re-scanning pack directory
  fetch: run gc --auto after fetching
Merge branch 'jk/read-commit-buffer-data-after-free' into pu

Clarify the ownership rule for commit->buffer field, which some
callers incorrectly accessed without making sure the data is
available there.

* jk/read-commit-buffer-data-after-free:
  logmsg_reencode: lazily load missing commit buffers
  logmsg_reencode: never return NULL
  commit: drop useless xstrdup of commit message
Merge branch 'ss/mergetools-tortoise' into pu

Update mergetools to work better with newer merge helper tortoise ships.

Will merge to 'next'.

* ss/mergetools-tortoise:
  mergetools: allow passing pathnames with SP in them to TortoiseGitMerge
  mergetools: support TortoiseGitMerge
Merge branch 'bc/git-p4-for-python-2.4' into pu

With small updates to remove dependency on newer features of
Python, keep git-p4 usable with older Python.

* bc/git-p4-for-python-2.4:
  git-p4.py: support Python 2.4
  git-p4.py: support Python 2.5

Conflicts:
	INSTALL
Merge branch 'pw/git-p4-on-cygwin' into pu

* pw/git-p4-on-cygwin: (21 commits)
  git p4: introduce gitConfigBool
  git p4: avoid shell when calling git config
  git p4: avoid shell when invoking git config --get-all
  git p4: avoid shell when invoking git rev-list
  git p4: avoid shell when mapping users
  git p4: disable read-only attribute before deleting
  git p4 test: use test_chmod for cygwin
  git p4: cygwin p4 client does not mark read-only
  git p4 test: avoid wildcard * in windows
  git p4 test: use LineEnd unix in windows tests too
  git p4 test: newline handling
  git p4: scrub crlf for utf16 files on windows
  git p4: remove unreachable windows \r\n conversion code
  git p4 test: translate windows paths for cygwin
  git p4 test: start p4d inside its db dir
  git p4 test: use client_view in t9806
  git p4 test: avoid loop in client_view
  git p4 test: use client_view to build the initial client
  git p4: generate better error message for bad depot path
  git p4: remove unused imports
  ...
Merge branch 'nd/branch-error-cases' into pu

* nd/branch-error-cases:
  branch: mark more strings for translation
  branch: give a more helpful message on redundant arguments
  branch: reject -D/-d without branch name
Merge branch 'dg/subtree-fixes' into pu

contrib/subtree updates; there are a few more from T. Zheng that
were posted separately, with an overlap.

Expecting a reroll.

* dg/subtree-fixes:
  contrib/subtree: mkdir the manual directory if needed
  contrib/subtree: honor $(DESTDIR)
  contrib/subtree: fix synopsis and command help
  contrib/subtree: better error handling for "add"
  contrib/subtree: add --unannotate option
  contrib/subtree: use %B for split Subject/Body
  t7900: remove test number comments
Merge branch 'mb/gitweb-highlight-link-target' into pu

Expecting a reroll.
$gmane/211935

* mb/gitweb-highlight-link-target:
  Highlight the link target line in Gitweb using CSS