Clear fd after closing to avoid double-close error

In send_pack(), clear the fd passed to pack_objects() by setting
it to -1, since pack_objects() closes the fd (via a call to
run_command()).  Likewise, in get_pack(), clear the fd passed to
run_command().

Not doing so risks having git_transport_push(), caller of
send_pack(), closing the fd again, possibly incorrectly closing
some other open file; or similarly with fetch_refs_from_pack(),
indirect caller of get_pack().

Signed-off-by: Jens Lindström <jl@opera.com>
Acked-by: Jeff King <peff@peff.net>
Acked-by: Duy Nguyen <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote-hg: unquote C-style paths when exporting

git-fast-import documentation says that paths can be C-style quoted.
Unfortunately, the current remote-hg helper doesn't unquote quoted
path and pass them as-is to Mercurial when the commit is created.

This results in the following situation:

 - clone a mercurial repository with git
 - add a file with space in a directory: `>dir/foo\ bar`
 - commit that new file, and push the change to mercurial
 - the mercurial repository now has a new directory named '"dir',
   which contains a file named 'foo bar"'

Use Python str.decode('string-escape') to unquote the string if it
starts and ends with ".  It has been tested with quotes, spaces, and
utf-8 encoded file-names.

Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'jx/relative-path-regression-fix' into jch

* jx/relative-path-regression-fix:
  Use simpler relative_path when set_git_dir
  relative_path should honor dos-drive-prefix
  test: use unambigous leading path (/foo) for MSYS
Merge branch 'jc/revision-range-unpeel' into jch

"git rev-list --objects ^v1.0^ v1.0" gave v1.0 tag itself in the
output, but "git rev-list --objects v1.0^..v1.0" did not.

* jc/revision-range-unpeel:
  revision: do not peel tags used in range notation
Merge branch 'ew/keepalive' into jch

* ew/keepalive:
  http: use curl's tcp keepalive if available
  http: enable keepalive on TCP sockets
Merge branch 'jk/remote-literal-string-leakfix' into jch

* jk/remote-literal-string-leakfix:
  remote: do not copy "origin" string literal
Merge branch 'jk/split-broken-ident' into jch

Make the fall-back parsing of commit objects with broken author or
committer lines more robust to pick up the timestamps.

* jk/split-broken-ident:
  split_ident: parse timestamp from end of line
Merge branch 'sg/prompt-svn-remote-fix' into jch

Bash portability fix.

* sg/prompt-svn-remote-fix:
  bash prompt: don't use '+=' operator in show upstream code path
Merge branch 'ak/submodule-foreach-quoting' into jch

A behavior change, but a worthwhile one: "git submodule foreach"
was treating its arguments as part of a single command to be
concatenated and passed to a shell, making writing buggy
scripts too easy.

This patch preserves the old "just pass it to the shell" behavior
when a single argument is passed to 'git submodule foreach' and
moves to a new "skip the shell and use the arguments passed
unmolested" behavior when more than one argument is passed.

The old behavior (always concatenating and passing to the shell)
was similar to the 'ssh' command, while the new behavior (switching
on the number of arguments) is what 'xterm -e' does.

May need more thought to make sure this change is advertised well
so that scripts that used multiple arguments but added their own
extra layer of quoting are not broken.

* ak/submodule-foreach-quoting:
  submodule foreach: skip eval for more than one argument
Merge branch 'jk/http-auth-redirects' (early part) into jch

* 'jk/http-auth-redirects' (early part):
  http: refactor options to http_get_*
  http_request: factor out curlinfo_strbuf
  http_get_file: style fixes
Merge branch 'jc/upload-pack-send-symref' into jch

One long-standing flaw in the pack transfer protocol used by "git
clone" was that there was no way to tell the other end which branch
"HEAD" points at, and the receiving end needed to guess.  A new
capability has been defined in the pack protocol to convey this
information so that cloning from a repository with more than one
branches pointing at the same commit where the HEAD is at now
reliably sets the initial branch in the resulting repository.

* jc/upload-pack-send-symref:
  t5570: Update for clone-progress-to-stderr branch
  t5570: Update for symref capability
  clone: test the new HEAD detection logic
  connect: annotate refs with their symref information in get_remote_head()
  connect.c: make parse_feature_value() static
  upload-pack: send non-HEAD symbolic refs
  upload-pack: send symbolic ref information as capability
  upload-pack.c: do not pass confusing cb_data to mark_our_ref()
  t5505: fix "set-head --auto with ambiguous HEAD" test
Merge branch 'sb/repack-in-c' into jch

* sb/repack-in-c:
  Reword repack documentation to no longer state it's a script
### match next
Merge branch 'jl/submodule-mv' into jch

Moving a regular file in a repository with a .gitmodules file was
producing a warning 'Could not find section in .gitmodules where
path=<filename>'.

* jl/submodule-mv:
  mv: Fix spurious warning when moving a file in presence of submodules
Merge branch 'jk/http-auth-redirects' into jch

Handle the case where http transport gets redirected during the
authorization request better.

* jk/http-auth-redirects:
  remote-curl: rewrite base url from info/refs redirects
  remote-curl: store url as a strbuf
  remote-curl: make refs_url a strbuf
  http: update base URLs when we see redirects
  http: provide effective url to callers
  http: hoist credential request out of handle_curl_result

# Conflicts:
# 	http.c
# 	remote-curl.c
Merge branch 'sg/t3600-nul-sha1-fix' into jch

* sg/t3600-nul-sha1-fix:
  t3600: fix broken "choking git rm" test
Merge branch 'mm/checkout-auto-track-fix' into jch

"git checkout topic", when there is not yet a local "topic" branch
but there is a unique remote-tracking branch for a remote "topic"
branch, pretended as if "git checkout -t -b topic remote/$r/topic"
(for that unique remote $r) was run. This hack however was not
implemented for "git checkout topic --".

* mm/checkout-auto-track-fix:
  checkout: proper error message on 'git checkout foo bar --'
  checkout: allow dwim for branch creation for "git checkout $branch --"
Merge branch 'hn/log-graph-color-octopus' into jch

* hn/log-graph-color-octopus:
  graph: fix coloring around octopus merges
Merge branch 'nd/gc-lock-against-each-other' into jch

* nd/gc-lock-against-each-other:
  gc: remove gc.pid file at end of execution
###