Add better ".git" detection and use

This way, packagers can set GIT_DIR appropriately if they'd prefer to not have ".git" inside their working directory.

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
devicemapper: Fix tests on fedora

If /dev/loop-control exists on the system running the test then
ioctlLoopCtlGetFree() will be called, but if not it won't.  It does
not exist in the standard docker build environment, so the tests
currently require this to not be called. This makes it instead
optional, allowing the tests to run on e.g. Fedora.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Ensure docker cp stream is closes properly
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
tell the reader that they need git and make for this tutorial

Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@fosiki.com> (github: SvenDowideit)
Avoid extra mount/unmount during build

CmdRun() calls first run() and then wait() to wait for it to exit,
then it runs commit(). The run command will mount the container and
the container exiting will unmount it. Then the commit will
immediately mount it again to do a diff.

This seems minor, but this is actually problematic, as the Get/Put
pair will create a spurious mount/unmount cycle that is not needed and
slows things down. Additionally it will create a supurious
devicemapper activate/deactivate cycle that causes races with udev as
seen in https://github.com/dotcloud/docker/issues/4036.

To ensure that we only unmount once we split up run() into create()
and run() and reference the mount until after the commit().

With this change docker build on devicemapper is now race-free, and
slightly faster.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Merge pull request #3947 from maxamillion/maxamillion/add_redhat_sysvinit

Add sysvinit/sysconfig files for redhat family of distros (RHEL/CentOS/SL/etc.)
Merge pull request #4090 from SvenDowideit/add-install-make-git-to-devenv

tell the reader that they need git and make for this tutorial
(resubmit) Add notes about OS/X and remote daemons

Docker-DCO-1.1-Signed-off-by: Charles Merriam <charles.merriam@gmail.com> (github: merriam)
Minor error in example code (resubmit #4109)

Docker-DCO-1.1-Signed-off-by: Charles Merriam <charles.merriam@gmail.com> (github: merriam)
Merge pull request #4112 from merriam/patch-3

(resubmit #4110) Add notes about OS/X and remote daemons
Merge pull request #4111 from merriam/patch-4

Minor error in example code (resubmit #4109)
Merge pull request #4073 from crosbymichael/fix-docker-cp-close

Ensure docker cp stream is closed properly
Merge pull request #4056 from alexlarsson/fix-devmapper-test

devicemapper: Fix tests on fedora
Merge pull request #4043 from tianon/hack-git-detection-and-use

Add better ".git" detection and use
Merge pull request #4096 from alexlarsson/fix-devmapper-race-2

Avoid extra mount/unmount during build
remove unneeded sysctl changes in sysvinit-redhat init script

Docker-DCO-1.1-Signed-off-by: Adam Miller <admiller@redhat.com> (github: maxamillion)