fast-import: leakfix for 'ls' of dirty trees

When the chosen directory has changed since it was last written to
pack, "tree_content_get" makes a deep copy of its content to scribble
on while computing the tree name, which we forgot to free.

This leak has been present since the 'ls' command was introduced in
v1.7.5-rc0~3^2~33 (fast-import: add 'ls' command, 2010-12-02).

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
fast-import: don't allow 'ls' of path with empty components

As the fast-import manual explains:

	The value of <path> must be in canonical form. That is it must
	not:
	. contain an empty directory component (e.g. foo//bar is invalid),
	. end with a directory separator (e.g. foo/ is invalid),
	. start with a directory separator (e.g. /foo is invalid),

Unfortunately the "ls" command accepts these invalid syntaxes and
responds by declaring that the indicated path is missing.  This is too
subtle and causes importers to silently misbehave; better to error out
so the operator knows what's happening.

The C, R, and M commands already error out for such paths.

Reported-by: Andrew Sayers <andrew-git@pileofstuff.org>
Analysis-by: David Barr <davidbarr@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
ident.c: add split_ident_line() to parse formatted ident line

The commit formatting logic format_person_part() in pretty.c
implements the logic to split an author/committer ident line into
its parts, intermixed with logic to compute its output using these
piece it computes.

Separate the former out to a helper function split_ident_line() so
that other codepath can use the same logic, and rewrite the function
using the helper function.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
t7503: does pre-commit-hook learn authorship?

When "--author" option is used to lie the authorship to "git commit"
command, hooks should learn the author name and email just like when
GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL environment variables are used
to lie the authorship.  Test this.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit: pass author/committer info to hooks

When lying the author name via GIT_AUTHOR_NAME environment variable
to "git commit", the hooks run by the command saw it and could act
on the name that will be recorded in the final commit. When the user
uses the "--author" option from the command line, the command should
give the same information to the hook, and back when "git command"
was a scripted Porcelain, it did set the environment variable and
hooks can learn the author name from it.

However, when the command was reimplemented in C, the rewritten code
was not very faithful to the original, and hooks stopped getting the
authorship information given with "--author".  Fix this by exporting
the necessary environment variables.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge https://github.com/git-l10n/git-po

Updates to localized messages for zn_CN and sv locales.

via Jiang Xin
* https://github.com/git-l10n/git-po:
  l10n: Improve zh_CN translation for msg "not something we can merge"
  l10n: Improve zh_CN trans for msg that cannot fast-forward
  l10n: Update zh_CN translation for 1.7.10-rc0
  Update Swedish translation (732t0f0u).
  po/sv.po: add Swedish translation
  l10n: Update git.pot (1 new message)
  l10n: Update zh_CN translation for 1.7.9.2
  l10n: Improve commit msg for zh_CN translation
  l10n: Improve zh_CN translation for msg that make empty commit when amend.
  l10n: Improve zh_CN translation for empty cherry-pick msg.
  l10n: Improve zh_CN translation for msg about branch deletion deny
  l10n: Improve zh_CN translation for lines insertion and deletion.
config: report errors at the EOL with correct line number

A section in a config file with a missing "]" reports the next line
as bad, same goes to a value with a missing end quote.

This happens because the error is not detected until the end of the
line, when line number is already increased. Fix this by decreasing
line number by one for these cases.

Signed-off-by: Martin Stenberg <martin@gnutiken.se>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
i18n: fix auto detection of gettext scheme for shell scripts

A new code added by ad17ea7 (add a Makefile switch to avoid gettext
translation in shell scripts, 2012-01-23) tried to optionally force
a gettext scheme to "fallthrough", but ended up forcing it to everybody.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-am: error out when seeing -b/--binary

The --binary option to git-apply has been a no-op since 2b6eef9 (Make
apply --binary a no-op., 2006-09-06) and was deprecated in cb3a160
(git-am: ignore --binary option, 2008-08-09).

We could remove it outright, but let's be nice to people who still
have scripts saying 'git am -b' (if they exist) and tell them the
reason for the sudden failure.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'jc/am-3-nonstandard-popt' into maint

The code to synthesize the fake ancestor tree used by 3-way merge
fallback in "git am" was not prepared to read a patch created with
a non-standard -p<num> value.

* jc/am-3-nonstandard-popt:
  test: "am -3" can accept non-standard -p<num>
  am -3: allow nonstandard -p<num> option
Merge branch 'jn/maint-do-not-match-with-unsanitized-searchtext' into maint

"gitweb" did use quotemeta() to prepare search string when asked to
do a fixed-string project search, but did not use it by mistake and
used the user-supplied string instead.

By Jakub Narebski
* jn/maint-do-not-match-with-unsanitized-searchtext:
  gitweb: Fix fixed string (non-regexp) project search
Merge branch 'jc/maint-diff-patch-header' into maint

"git diff-index" and its friends at the plumbing level showed the
"diff --git" header and nothing else for a path whose cached stat
info is dirty without actual difference when asked to produce a
patch. This was a longstanding bug that we could have fixed long
time ago.

By Junio C Hamano
* jc/maint-diff-patch-header:
  diff -p: squelch "diff --git" header for stat-dirty paths
  t4011: illustrate "diff-index -p" on stat-dirty paths
  t4011: modernise style
Merge branch 'tr/maint-bundle-boundary' into maint

"git bundle" did not record boundary commits correctly when there
are many of them.

By Thomas Rast
* tr/maint-bundle-boundary:
  bundle: keep around names passed to add_pending_object()
  t5510: ensure we stay in the toplevel test dir
  t5510: refactor bundle->pack conversion
Git 1.7.9.4

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Sync with 1.7.9.4
Merge branch 'az/verify-tag-use-gpg-config'

"git tag -s" honored "gpg.program" configuration variable since
1.7.9, but "git tag -v" and "git verify-tag" didn't.

By Alex Zepeda
* az/verify-tag-use-gpg-config:
  verify-tag: Parse GPG configuration options.
Update draft release notes to 1.7.10 before -rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'master' into next

By Thynson (7) and others
via Junio C Hamano (8) and Jiang Xin (1)
* master:
  Update draft release notes to 1.7.10 before -rc1
  Git 1.7.9.4
  git-am: error out when seeing -b/--binary
  l10n: Improve zh_CN translation for msg "not something we can merge"
  l10n: Improve zh_CN trans for msg that cannot fast-forward
  l10n: Update zh_CN translation for 1.7.10-rc0
  Update Swedish translation (732t0f0u).
  po/sv.po: add Swedish translation
  l10n: Update git.pot (1 new message)
  l10n: Update zh_CN translation for 1.7.9.2
  l10n: Improve commit msg for zh_CN translation
  l10n: Improve zh_CN translation for msg that make empty commit when amend.
  l10n: Improve zh_CN translation for empty cherry-pick msg.
  l10n: Improve zh_CN translation for msg about branch deletion deny
  l10n: Improve zh_CN translation for lines insertion and deletion.
Merge branch 'ph/rerere-doc' into next

* ph/rerere-doc:
  rerere: Document 'rerere remaining'
Merge branch 'jc/maint-undefined-i18n-observation-test' into next

It was unclear what a test in t0204 wanted to check; it turns out
that it was only to observe an undefined behaviour of the system,
and did not anticipate one kind of reasonable error behaviour.

We may want merge this before 1.7.10 to help Mac OS X builders.

* jc/maint-undefined-i18n-observation-test:
  t0204: clarify the "observe undefined behaviour" test