# git clone questions relating to cpio

14 messages from 2007-10-01 to 2007-10-03. Participants: Reece Dunn, Johan Herland, Johannes Schindelin, Junio C Hamano, Johannes Sixt, Chris Larson, Miklos Vajna, Shawn O. Pearce.
Thread: https://gitlist.dev/t/10109

## Reece Dunn, 2007-10-01 19:28

Subject: git clone questions relating to cpio
Message-ID: <3f4fd2640710011228w61ce34b5ve47ea529eed384fd@mail.gmail.com>
URL: https://gitlist.dev/e/3f4fd2640710011228w61ce34b5ve47ea529eed384fd%40mail.gmail.com

```
Hi,

I am running a Linux From Scratch 6.2 system that does not have cpio
installed on it. This means that I can't clone a local repository
unless I install cpio. Is it possible to use a fallback method if cpio
is not present, as there is no NO_CPIO option on make like there is
for OpenSSH, cURL and expat?

Also, I have an external USB hardrive that is mounted onto the virtual
filesystem. Will clones from the USB harddrive (or a USB flash drive
that is mounted) result in a copy being performed, not a hardlink?

Ideally, the hard linking for local clones should be optional. What if
I want to move a repository because, for example, I have imported a
CVS repository and now want to push it to a new bare repository?

- Reece

```

## Johan Herland, 2007-10-01 21:42

Subject: Re: git clone questions relating to cpio
Message-ID: <200710012342.37352.johan@herland.net>
URL: https://gitlist.dev/e/200710012342.37352.johan%40herland.net
In-Reply-To: <3f4fd2640710011228w61ce34b5ve47ea529eed384fd@mail.gmail.com>

```
On Monday 01 October 2007, Reece Dunn wrote:
> Hi,
> 
> I am running a Linux From Scratch 6.2 system that does not have cpio
> installed on it. This means that I can't clone a local repository
> unless I install cpio. Is it possible to use a fallback method if cpio
> is not present, as there is no NO_CPIO option on make like there is
> for OpenSSH, cURL and expat?

Using "file://" when specifying the source repo will force git-clone to use 
the git protocol, instead of doing a copy/hardlink.

I.e. change "git clone foo bar" to "git clone file://foo bar" in order to 
prevent git-clone from calling cpio.

However, grepping for cpio in the git source tree reveals a couple of uses 
in git-merge, so you might bump into problems there...

> Also, I have an external USB hardrive that is mounted onto the virtual
> filesystem. Will clones from the USB harddrive (or a USB flash drive
> that is mounted) result in a copy being performed, not a hardlink?

Hardlinks are impossible across filesystems. If you're cloning to a 
different filesystem git will _have_ to make a full copy.

> Ideally, the hard linking for local clones should be optional.

<quote src="git-clone(1)">
--local, -l

  When the repository to clone from is on a local machine, this flag 
bypasses normal "git aware" transport mechanism and clones the repository 
by making a copy of HEAD and everything under objects and refs directories. 
The files under .git/objects/ directory are hardlinked to save space when 
possible. This is now the default when the source repository is specified 
with /path/to/repo syntax, so it essentially is a no-op option. To force 
copying instead of hardlinking (which may be desirable if you are trying to 
make a back-up of your repository), but still avoid the usual "git aware" 
transport mechanism, --no-hardlinks can be used.

--no-hardlinks

  Optimize the cloning process from a repository on a local filesystem by 
copying files under .git/objects directory.
</quote>

And as I said above, you can use "file://" to force the "git aware" 
transport mechanism, which bypasses the whole local copy/hardlink issue 
entirely.

> What if I want to move a repository because, for example, I have imported
> a CVS repository and now want to push it to a new bare repository?

Even if you were to use hardlinks, cloning a repo followed by deleting the 
original will be safe (as long as you don't supply '--shared' to 
git-clone). That's the beauty of hardlinks.

I also think it's fairly safe to just 'mv' the whole repository to its new 
location.


Have fun! :)

...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

```

## Johannes Schindelin, 2007-10-01 23:23

Subject: Re: git clone questions relating to cpio
Message-ID: <Pine.LNX.4.64.0710020022470.28395@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0710020022470.28395%40racer.site
In-Reply-To: <3f4fd2640710011228w61ce34b5ve47ea529eed384fd@mail.gmail.com>

```
Hi,

On Mon, 1 Oct 2007, Reece Dunn wrote:

> I am running a Linux From Scratch 6.2 system that does not have cpio
> installed on it. This means that I can't clone a local repository
> unless I install cpio.

You might be interested in the workaround Hannes did in mingw.git; he made 
a wrapper script called 'cpio' using 'tar'.

Ciao,
Dscho

```

## Junio C Hamano, 2007-10-01 23:32

Subject: Re: git clone questions relating to cpio
Message-ID: <7vwsu6pg0v.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vwsu6pg0v.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <Pine.LNX.4.64.0710020022470.28395@racer.site>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> On Mon, 1 Oct 2007, Reece Dunn wrote:
>
>> I am running a Linux From Scratch 6.2 system that does not have cpio
>> installed on it. This means that I can't clone a local repository
>> unless I install cpio.
>
> You might be interested in the workaround Hannes did in mingw.git; he made 
> a wrapper script called 'cpio' using 'tar'.

I think that may be good enough as workaround, but I do not
think you would get the space saving from hardlinks that way.

```

## Johannes Sixt, 2007-10-02 06:11

Subject: Re: git clone questions relating to cpio
Message-ID: <4701E10C.7050405@viscovery.net>
URL: https://gitlist.dev/e/4701E10C.7050405%40viscovery.net
In-Reply-To: <7vwsu6pg0v.fsf@gitster.siamese.dyndns.org>

```
Junio C Hamano schrieb:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
>> On Mon, 1 Oct 2007, Reece Dunn wrote:
>>
>>> I am running a Linux From Scratch 6.2 system that does not have cpio
>>> installed on it. This means that I can't clone a local repository
>>> unless I install cpio.
>> You might be interested in the workaround Hannes did in mingw.git; he made 
>> a wrapper script called 'cpio' using 'tar'.
> 
> I think that may be good enough as workaround, but I do not
> think you would get the space saving from hardlinks that way.

FWIW, I'm thinking about changing the cpio -p (passthrough) part to use
'cp -l --parents --target-directory=...' instead of tar; this gives us hard 
links, even on NTFS. But it needs GNU's cp, of course.

-- Hannes

```

## Junio C Hamano, 2007-10-02 06:23

Subject: Re: git clone questions relating to cpio
Message-ID: <7vy7emm3v9.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vy7emm3v9.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <4701E10C.7050405@viscovery.net>

```
Johannes Sixt <j.sixt@viscovery.net> writes:

> FWIW, I'm thinking about changing the cpio -p (passthrough) part to use
> 'cp -l --parents --target-directory=...' instead of tar; this gives us
> hard links, even on NTFS. But it needs GNU's cp, of course.

Yeah, that's the reason it is not appropriate than cpio, even if
we forget about Windows.

```

## Reece Dunn, 2007-10-02 21:09

Subject: Re: git clone questions relating to cpio
Message-ID: <3f4fd2640710021409q104a4204r522391912d5b5c8c@mail.gmail.com>
URL: https://gitlist.dev/e/3f4fd2640710021409q104a4204r522391912d5b5c8c%40mail.gmail.com
In-Reply-To: <200710012342.37352.johan@herland.net>

```
On 01/10/2007, Johan Herland <johan@herland.net> wrote:
> On Monday 01 October 2007, Reece Dunn wrote:
> > Hi,
> >
> > I am running a Linux From Scratch 6.2 system that does not have cpio
> > installed on it. This means that I can't clone a local repository
> > unless I install cpio. Is it possible to use a fallback method if cpio
> > is not present, as there is no NO_CPIO option on make like there is
> > for OpenSSH, cURL and expat?
>
> Using "file://" when specifying the source repo will force git-clone to use
> the git protocol, instead of doing a copy/hardlink.
>
> I.e. change "git clone foo bar" to "git clone file://foo bar" in order to
> prevent git-clone from calling cpio.

Thanks for the tip.

> However, grepping for cpio in the git source tree reveals a couple of uses
> in git-merge, so you might bump into problems there...

Looks like I'll need to install cpio, then (also allowing me to take
advantage of the fast local clones via hardlinks).

Do you know if cpio is listed anywhere in required dependencies?

> > Also, I have an external USB hardrive that is mounted onto the virtual
> > filesystem. Will clones from the USB harddrive (or a USB flash drive
> > that is mounted) result in a copy being performed, not a hardlink?
>
> Hardlinks are impossible across filesystems. If you're cloning to a
> different filesystem git will _have_ to make a full copy.

Exactly. I was asking this to clarify cpio (and therefore git)
behaviour in this situation.

> > Ideally, the hard linking for local clones should be optional.
>
> <quote src="git-clone(1)">...</quote>

Indeed, they are. Thanks for the info.

> And as I said above, you can use "file://" to force the "git aware"
> transport mechanism, which bypasses the whole local copy/hardlink issue
> entirely.

Sure.

> > What if I want to move a repository because, for example, I have imported
> > a CVS repository and now want to push it to a new bare repository?
>
> Even if you were to use hardlinks, cloning a repo followed by deleting the
> original will be safe (as long as you don't supply '--shared' to
> git-clone). That's the beauty of hardlinks.

That is good to know.

> I also think it's fairly safe to just 'mv' the whole repository to its new
> location.

This also works, as long as you are not moving between a bare and
standard repository.

> Have fun! :)

Will do :)

Thanks,
- Reece

```

## Johan Herland, 2007-10-02 23:42

Subject: [PATCH] Mention 'cpio' dependency in INSTALL
Message-ID: <200710030142.30062.johan@herland.net>
URL: https://gitlist.dev/e/200710030142.30062.johan%40herland.net
In-Reply-To: <3f4fd2640710021409q104a4204r522391912d5b5c8c@mail.gmail.com>

```
Signed-off-by: Johan Herland <johan@herland.net>
---

On Tuesday 02 October 2007, Reece Dunn wrote:
> Do you know if cpio is listed anywhere in required dependencies?

Doing the following in the git repo:
$ grep -r cpio *
git-clone.sh:           find objects -depth -print | cpio -pumd$l "$GIT_DIR/" || exit 1
git-merge.sh:   cpio -0 -o >"$GIT_DIR/MERGE_SAVE"
git-merge.sh:           cpio -iuv <"$GIT_DIR/MERGE_SAVE"

reveals that cpio is not mentioned anywhere in the documentation,
nor in the requirements section of the INSTALL file.


Have fun!

...Johan


 INSTALL |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/INSTALL b/INSTALL
index 289b046..f1eb404 100644
--- a/INSTALL
+++ b/INSTALL
@@ -79,6 +79,9 @@ Issues of note:
 	- "perl" and POSIX-compliant shells are needed to use most of
 	  the barebone Porcelainish scripts.
 
+	- "cpio" is used by git-merge for saving and restoring the index,
+	  and by git-clone when doing a local (possibly hardlinked) clone.
+
  - Some platform specific issues are dealt with Makefile rules,
    but depending on your specific installation, you may not
    have all the libraries/tools needed, or you may have
-- 
1.5.3.3.1144.gf10f2

```

## Junio C Hamano, 2007-10-03 00:14

Subject: Re: [PATCH] Mention 'cpio' dependency in INSTALL
Message-ID: <7v1wcdjbq6.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v1wcdjbq6.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <200710030142.30062.johan@herland.net>

```
Johan Herland <johan@herland.net> writes:

> reveals that cpio is not mentioned anywhere in the documentation,
> nor in the requirements section of the INSTALL file.

Thanks.

We use many other tools that are typically found in bog-standard
UNIX environments, like sed, echo, cat, sort, etc. and we do not
list them in the INSTALL file (nor we would want to).  cpio used
to be in the "bog standard" category but perhaps Linux distros
do not install it by default, so it is worth listing it there.

Are there other commands we rely on that may not be universally
installed?  I myself consider "cut" to be in the category, but
other than that I do not think of anything offhand.

```

## Chris Larson, 2007-10-03 06:09

Subject: Re: [PATCH] Mention 'cpio' dependency in INSTALL
Message-ID: <b6ebd0a50710022309n774afe5bpa995de6d8e4568ec@mail.gmail.com>
URL: https://gitlist.dev/e/b6ebd0a50710022309n774afe5bpa995de6d8e4568ec%40mail.gmail.com
In-Reply-To: <7v1wcdjbq6.fsf@gitster.siamese.dyndns.org>

```
On 10/2/07, Junio C Hamano <gitster@pobox.com> wrote:
> Johan Herland <johan@herland.net> writes:
>
> > reveals that cpio is not mentioned anywhere in the documentation,
> > nor in the requirements section of the INSTALL file.
>
> Thanks.
>
> We use many other tools that are typically found in bog-standard
> UNIX environments, like sed, echo, cat, sort, etc. and we do not
> list them in the INSTALL file (nor we would want to).  cpio used
> to be in the "bog standard" category but perhaps Linux distros
> do not install it by default, so it is worth listing it there.
>
> Are there other commands we rely on that may not be universally
> installed?  I myself consider "cut" to be in the category, but
> other than that I do not think of anything offhand.

I'd think it might be a good idea to list any utilities used that
aren't in, say, the Single Unix Specification, for example.
-- 
Chris Larson - clarson at kergoth dot com
Software Engineer - MontaVista - clarson at mvista dot com
Core Developer/Architect - TSLib, BitBake, OpenEmbedded, OpenZaurus

```

## Miklos Vajna, 2007-10-03 07:40

Subject: Re: [PATCH] Mention 'cpio' dependency in INSTALL
Message-ID: <20071003074007.GA15339@genesis.frugalware.org>
URL: https://gitlist.dev/e/20071003074007.GA15339%40genesis.frugalware.org
In-Reply-To: <7v1wcdjbq6.fsf@gitster.siamese.dyndns.org>

```
On Tue, Oct 02, 2007 at 05:14:25PM -0700, Junio C Hamano <gitster@pobox.com> wrote:
> Are there other commands we rely on that may not be universally
> installed?  I myself consider "cut" to be in the category, but
> other than that I do not think of anything offhand.

when using git in a chroot, i obviously had coreutils/sed/grep installed
and the only "extra" package i needed (besides the curl an openssl libs)
was cpio

- VMiklos

```

## Johan Herland, 2007-10-03 08:27

Subject: [PATCH v2] INSTALL: Update section on external dependencies
Message-ID: <200710031027.48999.johan@herland.net>
URL: https://gitlist.dev/e/200710031027.48999.johan%40herland.net
In-Reply-To: <20071003074007.GA15339@genesis.frugalware.org>

```
Includes:
- Mention dependency on "core" utilities, including coreutils, sed, cut, grep
- Mention dependency on cpio
- Fix up some whitespace and linebreaking issues

Signed-off-by: Johan Herland <johan@herland.net>
---

On Wednesday 03 October 2007, Miklos Vajna wrote:
> On Tue, Oct 02, 2007 at 05:14:25PM -0700, Junio C Hamano <gitster@pobox.com> wrote:
> > Are there other commands we rely on that may not be universally
> > installed?  I myself consider "cut" to be in the category, but
> > other than that I do not think of anything offhand.
> 
> when using git in a chroot, i obviously had coreutils/sed/grep installed
> and the only "extra" package i needed (besides the curl an openssl libs)
> was cpio

Ok, here's a more complete patch.

...Johan


 INSTALL |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/INSTALL b/INSTALL
index 289b046..244470f 100644
--- a/INSTALL
+++ b/INSTALL
@@ -54,6 +54,8 @@ Issues of note:
  - Git is reasonably self-sufficient, but does depend on a few external
    programs and libraries:
 
+	- Common "core" utilities including coreutils, sed, cut, and grep.
+
 	- "zlib", the compression library. Git won't build without it.
 
 	- "openssl".  Unless you specify otherwise, you'll get the SHA1
@@ -63,22 +65,24 @@ Issues of note:
 	  that come with git (git includes the one from Mozilla, and has
 	  its own PowerPC and ARM optimized ones too - see the Makefile).
 
-	- "libcurl" and "curl" executable.  git-http-fetch and
-	  git-fetch use them.  If you do not use http
-	  transfer, you are probably OK if you do not have
-	  them.
+	- "libcurl" and "curl" executable.  git-http-fetch and git-fetch
+	  use them.  If you do not use http transfer, you are probably OK
+	  if you do not have them.
 
 	- expat library; git-http-push uses it for remote lock
 	  management over DAV.  Similar to "curl" above, this is optional.
 
-        - "wish", the Tcl/Tk windowing shell is used in gitk to show the
-          history graphically, and in git-gui.
+	- "wish", the Tcl/Tk windowing shell is used in gitk to show the
+	  history graphically, and in git-gui.
 
-	- "ssh" is used to push and pull over the net
+	- "ssh" is used to push and pull over the net.
 
 	- "perl" and POSIX-compliant shells are needed to use most of
 	  the barebone Porcelainish scripts.
 
+	- "cpio" is used by git-merge for saving and restoring the index,
+	  and by git-clone when doing a local (possibly hardlinked) clone.
+
  - Some platform specific issues are dealt with Makefile rules,
    but depending on your specific installation, you may not
    have all the libraries/tools needed, or you may have
-- 
1.5.3.3.1144.gf10f2

```

## Johannes Schindelin, 2007-10-03 15:56

Subject: Re: [PATCH v2] INSTALL: Update section on external dependencies
Message-ID: <Pine.LNX.4.64.0710031655590.28395@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0710031655590.28395%40racer.site
In-Reply-To: <200710031027.48999.johan@herland.net>

```
Hi,

On Wed, 3 Oct 2007, Johan Herland wrote:

> Includes:
> - Mention dependency on "core" utilities, including coreutils, sed, cut, grep

Maybe mention libc, too?  Oh, and that you need a computer? ;-)

> - Fix up some whitespace and linebreaking issues

The commit message could use some of that, too... ;-)

Ciao,
Dscho

```

## Shawn O. Pearce, 2007-10-03 16:05

Subject: Re: [PATCH v2] INSTALL: Update section on external dependencies
Message-ID: <20071003160546.GJ2137@spearce.org>
URL: https://gitlist.dev/e/20071003160546.GJ2137%40spearce.org
In-Reply-To: <Pine.LNX.4.64.0710031655590.28395@racer.site>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> On Wed, 3 Oct 2007, Johan Herland wrote:
> 
> > Includes:
> > - Mention dependency on "core" utilities, including coreutils, sed, cut, grep
> 
> Maybe mention libc, too?  Oh, and that you need a computer? ;-)

Don't forget that the computer must be plugged in and have
electricity as well.  I see users all too often wonder why everything
they type is black, on a black background...
 
-- 
Shawn.

```
