git-remote-mediawiki: don't compute the diff when getting commit message
git-remote-mediawiki: don't "use encoding 'utf8';"

The use of this statement is generally discouraged, and is too intrusive
for us: it forces the HTTP requests made by the API to contain only valid
UTF-8 characters. This would break the upload of binary files.
git-remote-mediawiki: send "File:" attachments to a remote wiki

The current version of the git-remote-mediawiki supports only import and
export of plain wiki pages. This patch adds the functionality to export
file attachments (i.e. the content of the File: MediaWiki namespace),
which are also exposed by MediaWiki API.

This requires a recent version of MediaWiki::API (Version 0.37 works.
Version 0.34 doesn't).

Signed-off-by: Pavel Volek <Pavel.Volek@ensimag.imag.fr>
Signed-off-by: NGUYEN Kim Thuat <Kim-Thuat.Nguyen@ensimag.imag.fr>
Signed-off-by: ROUCHER IGLESIAS Javier <roucherj@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-remote-mediawiki: split get_mw_pages into smaller functions
git-remote-mediawiki: import "File:" attachments

Add the symmetrical feature to the "File:" export support in the previous
patch. Download files from the wiki as needed, and feed them into the
fast-import stream. Import both the file itself, and the corresponding
description page.

Signed-off-by: Pavel Volek <Pavel.Volek@ensimag.imag.fr>
Signed-off-by: NGUYEN Kim Thuat <Kim-Thuat.Nguyen@ensimag.imag.fr>
Signed-off-by: ROUCHER IGLESIAS Javier <roucherj@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-checkout: disallow --detach on unborn branch

abe199808c (git checkout -b: allow switching out of an unborn branch)
introduced a bug demonstrated by

  git checkout --orphan foo
  git checkout --detach
  git symbolic-ref HEAD

which gives 'refs/heads/(null)'.

This happens because we strbuf_addf(&branch_ref, "refs/heads/%s",
opts->new_branch) when opts->new_branch can be NULL for --detach.

Catch and forbid this case, adding a test to t2017 to catch it in
future.

Signed-off-by: Chris Webb <chris@arachsys.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
rebase: don't source git-sh-setup twice

The git-sh-setup script is already sourced in git-rebase.sh before
calling into git-rebase--(am|interactive|merge).sh. There are no other
callers of these scripts. It is therefore unnecessary to source
git-sh-setup again in them.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
rebase --root: print usage on too many args

Just like

  git rebase --onto newbase upstream branch error

displays the usage message, so should clearly

  git rebase --onto newbase --root branch error

, but it doesn't. Instead, it ignores both "branch" and "error" and
rebases the current HEAD. This is because we try to match the number
of remainging arguments "$#", which fails to match "1" argument and
matches the "*" that really should have been a "0".

Make sure we display usage information when too many arguments are
given. Also fail-fast in case of similar bugs in the future by
matching on exactly 0 arguments and failing on unknown numbers.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
am --rebasing: get patch body from commit, not from mailbox

Rebasing a commit that contains a diff in the commit message results
in a failure with output such as

  First, rewinding head to replay your work on top of it...
  Applying: My cool patch.
  fatal: sha1 information is lacking or useless
  (app/controllers/settings_controller.rb).
  Repository lacks necessary blobs to fall back on 3-way merge.
  Cannot fall back to three-way merge.
  Patch failed at 0001 My cool patch.

The reason is that 'git rebase' without -p/-i/-m internally calls 'git
format-patch' and pipes the output to 'git am --rebasing', which has
no way of knowing what is a real patch and what is a commit message
that contains a patch.

Make 'git am' while in --rebasing mode get the patch body from the
commit object instead of extracting it from the mailbox.

Patch by Junio, test case and commit log message by Martin.

Reported-by: anikey <arty.anikey@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
am: don't call mailinfo if $rebasing

Since 5e835ca (rebase: do not munge commit log message, 2008-04-16),
'git am --rebasing' no longer gets the commit log message from the
patch, but reads it from the commit identified by the "From " header
line. From 43c2325 (am: use get_author_ident_from_commit instead of
mailinfo when rebasing, 2010-06-16), it also gets the author name,
email and date from the commit. Now that the final part of the patch
-- the patch body itself -- is also read from the commit, there is no
longer a need to call 'git mailinfo' to extract any of these parts
while --rebasing.

Sugested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
index-pack: Disable threading on cygwin

The Cygwin implementation of pread() is not thread-safe since, just
like the emulation provided by compat/pread.c, it uses a sequence of
seek-read-seek calls. In order to avoid failues due to thread-safety
issues, commit b038a61 disables threading when NO_PREAD is defined.
(ie when using the emulation code in compat/pread.c).

We introduce a new build variable, NO_THREAD_SAFE_PREAD, which allows
use to disable the threaded index-pack code on cygwin, in addition to
the above NO_PREAD case.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'mm/push-default-switch-warning' into jch

Will merge to 'next'.

Hopefully we can have a solidly tested series early in 1.7.12 or
1.7.13 at the latest.

# By Matthieu Moy
* mm/push-default-switch-warning:
  push: start warning upcoming default change for push.default
Merge branch 'th/diff-no-index-fixes' into jch

"git diff --no-index" did not correctly handle relative paths and
did not correctly give exit codes when run under "--quiet" option.

Will merge to 'next'.

# By Jeff King (1) and Tim Henigan (1)
* th/diff-no-index-fixes:
  diff-no-index: exit(1) if 'diff --quiet <repo file> <external file>' finds changes
  diff: handle relative paths in no-index
Merge branch 'nd/clone-single-fix' into jch

"git clone --single-branch" to clone a single branch did not limit
the cloning to the specified branch.

Will merge to 'next'.

# By Nguyễn Thái Ngọc Duy
* nd/clone-single-fix:
  clone: fix ref selection in --single-branch --branch=xxx
Merge branch 'js/fast-export-paths-with-spaces' into jch

"git fast-export" produced an input stream for fast-import without
properly quoting pathnames when they contain SPs in them.

# By Jay Soffian
* js/fast-export-paths-with-spaces:
  fast-export: quote paths with spaces
Merge branch 'mm/config-xdg' into jch

Teach git to read various information from $XDG_CONFIG_HOME/git/ to allow
the user to avoid cluttering $HOME.

# By Huynh Khoi Nguyen Nguyen
* mm/config-xdg:
  config: write to $XDG_CONFIG_HOME/git/config file when appropriate
  Let core.attributesfile default to $XDG_CONFIG_HOME/git/attributes
  Let core.excludesfile default to $XDG_CONFIG_HOME/git/ignore
  config: read (but not write) from $XDG_CONFIG_HOME/git/config file
Merge branch 'mm/credential-plumbing' into jch

Expose the credential API to scripted Porcelain writers.

# By Matthieu Moy (2) and Javier Roucher Iglesias (1)
* mm/credential-plumbing:
  git-remote-mediawiki: add credential support
  git credential fill: output the whole 'struct credential'
  add 'git credential' plumbing command
Merge branch 'mm/mediawiki-file-attachments' into jch

"mediawiki" remote helper (in contrib/) learned to handle file
attachments.

# By Matthieu Moy (3) and others
* mm/mediawiki-file-attachments:
  git-remote-mediawiki: import "File:" attachments
  git-remote-mediawiki: split get_mw_pages into smaller functions
  git-remote-mediawiki: send "File:" attachments to a remote wiki
  git-remote-mediawiki: don't "use encoding 'utf8';"
  git-remote-mediawiki: don't compute the diff when getting commit message
Merge branch 'rj/platform-pread-may-be-thread-unsafe' into jch

On Cygwin, the platform pread(3) is not thread safe, just like our
own compat/ emulation, and cannot be used in the index-pack program.

* rj/platform-pread-may-be-thread-unsafe:
  index-pack: Disable threading on cygwin
Merge branch 'jc/apply-3way' into jch

"git apply" learns to wiggle the base version and perform three-way merge
when a patch does not exactly apply to the version you have.

Waiting for comments.

* jc/apply-3way:
  apply --3way: tests
  apply: document --3way option
  apply: allow rerere() upon --3way results
  apply: register conflicted stages to the index
  apply: --3way with add/add conflict
  apply: move verify_index_match() higher
  apply: plug the three-way merge logic in
  apply: fall back on three-way merge
  apply: accept -3/--3way command line option
  apply: move "already exists" logic to check_to_create()
  apply: move check_to_create_blob() closer to its sole caller
  apply: further split load_preimage()
  apply: refactor "previous patch" logic
  apply: split load_preimage() helper function out
  apply: factor out checkout_target() helper function
  apply: refactor read_file_or_gitlink()
  apply: clear_image() clears things a bit more
  apply: a bit more comments on PATH_TO_BE_DELETED
  apply: fix an incomplete comment in check_patch()

Conflicts:
	builtin/apply.c