format-patch: do not wrap non-rfc2047 headers too early

Do not wrap the second and later lines of an ASCII header substantially
before the 78 character limit.

Signed-off-by: Jan H. Schönherr <schnhrr@cs.tu-berlin.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
format-patch: do not wrap rfc2047 encoded headers too late

Encoded characters add more than one character at once to an encoded
header. Include all characters that are about to be added in the length
calculation for wrapping.

Additionally, RFC 2047 imposes a maximum line length of 76 characters
if that line contains an rfc2047 encoded word.

Signed-off-by: Jan H. Schönherr <schnhrr@cs.tu-berlin.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
format-patch: introduce helper function last_line_length()

Currently, an open-coded loop to calculate the length of the last
line of a string buffer is used in multiple places.

Move that code into a function of its own.

Signed-off-by: Jan H. Schönherr <schnhrr@cs.tu-berlin.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
format-patch: fix rfc2047 address encoding with respect to rfc822 specials

According to RFC 2047 and RFC 822, rfc2047 encoded words and and rfc822
quoted strings do not mix.

Be more strict about rfc2047 encoded words in addresses, so that it is a
bit more conform to RFC 2047.

(Especially, my own name gets correctly decoded as Jan H. Schönherr
(without quotes) and not as "Jan H. Schönherr" (with quotes).)

Signed-off-by: Jan H. Schönherr <schnhrr@cs.tu-berlin.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
format-patch: tests: check rfc822+rfc2047 in to+cc headers

Do some checks for RFC 822 and RFC 2047 support in To:
and Cc: headers and fix ambiguous old checks.

Signed-off-by: Jan H. Schönherr <schnhrr@cs.tu-berlin.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitignore: make pattern parsing code a separate function

This function can later be reused by attr.c. Also turn to_exclude
field into a flag.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
attr: more matching optimizations from .gitignore

.gitattributes and .gitignore share the same pattern syntax but has
separate matching implementation. Over the years, ignore's
implementation accumulates more optimizations while attr's stays the
same.

This patch adds those optimizations to attr. Basically it tries to
avoid fnmatch as much as possible in favor of strncmp.

A few notes from this work is put in the documentation:

* "!pattern" syntax is forbidden in .gitattributes.  As an attribute
  can be unset (i.e. set to a special value "false") or made back to
  unspecified (i.e. not even set to "false"), "!pattern attr" is unclear
  which one it means.

* we support attaching attributes to directories, but git-core
  internally does not currently make use of attributes on
  directories.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'jm/diff-context-config' into jch

Teaches a new configuration variable to "git diff" Porcelain and
its friends.

Will defer to the next cycle.

* jm/diff-context-config:
  t4055: avoid use of sed 'a' command
  diff: diff.context configuration gives default to -U
Merge branch 'jl/submodule-rm' into jch

"git rm submodule" cannot blindly remove a submodule directory as
its working tree may have local changes, and worse yet, it may even
have its repository embedded in it.  Teach it some special cases
where it is safe to remove a submodule, specifically, when there is
no local changes in the submodule working tree, and its repository
is not embedded in its working tree but is elsewhere and uses the
gitfile mechanism to point at it.

Will defer to the next cycle.

* jl/submodule-rm:
  submodule: teach rm to remove submodules unless they contain a git directory
Merge branch 'rc/maint-complete-git-p4' into jch

Comment from Pete will need to be addressed in a follow-up patch.

* rc/maint-complete-git-p4:
  Teach git-completion about git p4
Merge branch 'fa/remote-svn' into jch

A GSoC project.

* fa/remote-svn:
  Add a test script for remote-svn
  remote-svn: add marks-file regeneration
  Add a svnrdump-simulator replaying a dump file for testing
  remote-svn: add incremental import
  remote-svn: Activate import/export-marks for fast-import
  Create a note for every imported commit containing svn metadata
  vcs-svn: add fast_export_note to create notes
  Allow reading svn dumps from files via file:// urls
  remote-svn, vcs-svn: Enable fetching to private refs
  When debug==1, start fast-import with "--stats" instead of "--quiet"
  Add documentation for the 'bidi-import' capability of remote-helpers
  Connect fast-import to the remote-helper via pipe, adding 'bidi-import' capability
  Add argv_array_detach and argv_array_free_detached
  Add svndump_init_fd to allow reading dumps from arbitrary FDs
  Add git-remote-testsvn to Makefile
  Implement a remote helper for svn in C
Merge branch 'jl/submodule-add-by-name' into jch

If you remove a submodule, in order to keep the repository so that
"git checkout" to an older commit in the superproject history can
resurrect the submodule, the real repository will stay in $GIT_DIR
of the superproject.  A later "git submodule add $path" to add a
different submodule at the same path will fail.  Diagnose this case
a bit better, and if the user really wants to add an unrelated
submodule at the same path, give the "--name" option to give it a
place in $GIT_DIR of the superproject that does not conflict with
the original submodule.

* jl/submodule-add-by-name:
  submodule add: Fail when .git/modules/<name> already exists unless forced
  Teach "git submodule add" the --name option
Merge branch 'bw/config-lift-variable-name-length-limit' into jch

The configuration parser had an unnecessary hardcoded limit on
variable names that was not checked consistently. Lift the limit.

* bw/config-lift-variable-name-length-limit:
  Remove the hard coded length limit on variable names in config files
Merge branch 'jk/peel-ref' into jch

Speeds up "git upload-pack" (what is invoked by "git fetch" on the
other side of the connection) by reducing the cost to advertise the
branches and tags that are available in the repository.

* jk/peel-ref:
  upload-pack: use peel_ref for ref advertisements
  peel_ref: check object type before loading
  peel_ref: do not return a null sha1
  peel_ref: use faster deref_tag_noverify
Merge branch 'jc/doc-long-options' into jch

The end-user facing documentation claimed to be an "exhaustive"
list of features of parse-options command line parser, but it
didn't mention anything about abbreviating long option names to
their unique prefixes. Mention it, warn against relying too much on
it (as uniqueness may disappear in future versions of Git), and
drop the claim to be exhaustive.

* jc/doc-long-options:
  gitcli: parse-options lets you omit tail of long options
Merge branch 'nd/attr-match-optim' into jch

Trivial and obvious optimization for finding attributes that match
a given path.

* nd/attr-match-optim:
  attr: avoid searching for basename on every match
  attr: avoid strlen() on every match
Merge branch 'nd/doc-ignore' into jch

Documentation updates for excluding path whose name begin with # or !.

* nd/doc-ignore:
  gitignore.txt: suggestions how to get literal # or ! at the beginning
Merge branch 'rr/git-uri-doc' into jch

* rr/git-uri-doc:
  Git url doc: mark ftp/ftps as read-only and deprecate them
Merge branch 'bw/cp-a-is-gnuism' into jch

* bw/cp-a-is-gnuism:
  tests: "cp -a" is a GNUism
Merge branch 'jk/no-more-pre-exec-callback' into jch

(Originally merged to 'next' on 2012-07-23)

Will defer to the next cycle.

* jk/no-more-pre-exec-callback:
  pager: drop "wait for output to run less" hack