submodule: teach rm to remove submodules unless they contain a git directory

Currently using "git rm" on a submodule - populated or not - fails with
this error:

	fatal: git rm: '<submodule path>': Is a directory

This made sense in the past as there was no way to remove a submodule
without possibly removing unpushed parts of the submodule's history
contained in its .git directory too, so erroring out here protected the
user from possible loss of data.

But submodules cloned with a recent git version do not contain the .git
directory anymore, they use a gitfile to point to their git directory
which is safely stored inside the superproject's .git directory. The work
tree of these submodules can safely be removed without losing history, so
let's teach git to do so.

Using rm on an unpopulated submodule now removes the empty directory from
the work tree and the gitlink from the index. If the submodule's directory
is missing from the work tree, it will still be removed from the index.

Using rm on a populated submodule using a gitfile will apply the usual
checks for work tree modification adapted to submodules (unless forced).
For a submodule that means that the HEAD is the same as recorded in the
index, no tracked files are modified and no untracked files that aren't
ignored are present in the submodules work tree (ignored files are deemed
expendable and won't stop a submodule's work tree from being removed).
That logic has to be applied in all nested submodules too.

Using rm on a submodule which has its .git directory inside the work trees
top level directory will just error out like it did before to protect the
repository, even when forced. In the future git could either provide a
message informing the user to convert the submodule to use a gitfile or
even attempt to do the conversion itself, but that is not part of this
change.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff: diff.context configuration gives default to -U

Introduce a configuration variable diff.context that tells
Porcelain commands to use a non-default number of context
lines instead of 3 (the default).  With this variable, users
do not have to keep repeating "git log -U8" from the command
line; instead, it becomes sufficient to say "git config
diff.context 8" just once.

Signed-off-by: Jeff Muizelaar <jmuizelaar@mozilla.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'tu/gc-auto-quiet' into next

"gc --auto" notified the user that auto-packing has triggered even
under the "--quiet" option.

* tu/gc-auto-quiet:
  silence git gc --auto --quiet output
Merge branch 'jl/submodule-rm' into next

"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.

* jl/submodule-rm:
  submodule: teach rm to remove submodules unless they contain a git directory
Merge branch 'jm/diff-context-config' into next

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

* jm/diff-context-config:
  diff: diff.context configuration gives default to -U
Merge branch 'lt/mailinfo-handle-attachment-more-sanely' into next

A patch attached as application/octet-stream (e.g. not text/*) were
mishandled, not correctly honoring Content-Transfer-Encoding
(e.g. base64).

* lt/mailinfo-handle-attachment-more-sanely:
  mailinfo: don't require "text" mime type for attachments
Merge branch 'nd/grep-reflog' into next

Teach the commands from the "log" family the "--grep-reflog" option
to limit output by string that appears in the reflog entry when the
"--walk-reflogs" option is in effect.

* nd/grep-reflog:
  revision: make --grep search in notes too if shown
  log --grep-reflog: reject the option without -g
  revision: add --grep-reflog to filter commits by reflog messages
  grep: prepare for new header field filter
Sync with 1.8.0-rc0
t4055: avoid use of sed 'a' command

The 'a', 'i' and 'c' commands take a literal text to be added
followed by backslash, but then in the source we cannot indent
the literal text which makes it ugly.

We need to also remember to double the backslash inside double
quotes.

Avoid these issues altogether by having an extra line in a template
file and generate test vectors by deleting the line or replacing the
line and not using the 'a' command.

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

* master:
  Start preparing for 1.7.12.3
  l10n: Fix to Swedish translation
  Documentation: mention `push.default` in git-push.txt
  RelNotes/1.8.0: various typo and style fixes
Merge branch 'jm/diff-context-config' into next

Brown paper bag fix.

* jm/diff-context-config:
  t4055: avoid use of sed 'a' command
t1450: the order the objects are checked is undefined

When a tag T points at an object X that is of a type that is
different from what the tag records as, fsck should report it as an
error.

However, depending on the order X and T are checked individually,
the actual error message can be different.  If X is checked first,
fsck remembers X's type and then when it checks T, it notices that T
records X as a wrong type (i.e. the complaint is about a broken tag
T).  If T is checked first, on the other hand, fsck remembers that we
need to verify X is of the type tag records, and when it later
checks X, it notices that X is of a wrong type (i.e. the complaint
is about a broken object X).

The important thing is that fsck notices such an error and diagnoses
the issue on object X, but the test was expecting that we happen to
check objects in the order to make us detect issues with tag T, not
with object X.  Remove this unwarranted assumption.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'jc/maint-t1450-fsck-order-fix' into next

The fsck test assumed too much on what kind of error it will
detect. The only important thing is the inconsistency is detected
as an error.

* jc/maint-t1450-fsck-order-fix:
  t1450: the order the objects are checked is undefined
Merge branch 'master' into next

* master:
  Update draft release notes to 1.8.0
Merge branch 'jk/blame-tree' into HEAD

* jk/blame-tree:
  d74f87710e79db48f1ea64e3837ebcdd49306586
Merge branch 'jk/builtin-attr' into HEAD

* jk/builtin-attr:
  40defefd895d6181bc03019c25c12a4da2123810
Merge branch 'jk/bundle-fetch' into HEAD

* jk/bundle-fetch:
  964c6cec1d2d1a0cabad903690a50e6e65645fcd
  26c141815005f4cab3061bd4b969d181dd78cffb
  7a22d64d56477d813539bb2cb6b70f186f2b563b
  a67d3b47f384eb151284ac34bb28d8105f2a6ba9
  e3ff6e882a835633b0978ea5dcdb1bf691b00f7e
  414c69155c3df4631bcb86c86b9dba45033d2bb6
  2d13b160e50fc53a1de7c386f73b3f2776d5e0db
  1e4982bd25d9c2f42a2ebf6919384774b833a437
  765c09446fc89e8ec0fe888ecbcbb6e7b37eed59
  424544756a86ab4728ebb8da8e1349ae809978b7
  b50ba906a625ceb0fe98e9c54c1ea34e11f27e2f
  1c5b834b708d86791ecc178124173bc7d2a26169
  fa0f99f1809bb52eb992c983143e6ff816006bf4
  db85de6a5f26447aacc08ceaadf0b1d0dace24c6
Merge branch 'jk/cache-patch-id' into HEAD

* jk/cache-patch-id:
  05ce7b8d4f8281adc02b24f1502c120ed64d469b
  7799442d1271e5c1574f623d64e70dd3694026c0
  9980d591e8159c7eb50dc4a5b5734d4e19ad2682
  d52362ad826a698d22120e9f3a5b1c1f3ef24358
  9dfe9e2a3a37ef93517303e5ddc7fba5b9e39ba0
  b2dbc838aaaac9f3236acff9045da5686dfabe03
  f805e277cb838e16aeb810d7cbd11bb3e96770a8
  71ad9d64efd2544e020ec67191037951ba7f14a0
Merge branch 'jk/cache-renames' into HEAD

* jk/cache-renames:
  3ad805c513b15105e4f1915ee0d4141e3afa7493
  261f3c197c912ae7eae1265c1e162057eca02c9f

Conflicts:
	Makefile
	metadata-cache.c
	metadata-cache.h
Merge branch 'jk/child-cleanup' into HEAD

* jk/child-cleanup:
  0b291191a63a0e158c6bd34470ef30093b87c819