Subject: Re: confused about preserved permissions

From: René Scharfe <[email-masked]>
Date: Tue, 21 Aug 2007 20:01:01 +0200

Mike Hommey schrieb:
> On Mon, Aug 20, 2007 at 06:44:11PM +0200, martin f krafft <[email-masked]> wrote:
>> Why does git bother saving a mode when later it never seems to use
>> it again?
> 
> Same applies to git-archive, which generates files with mode 666 and
> directories with 777, while it could follow the modes in the
> repository... or at least, that's what the manpage claims, but facts
> seem to be quite different...
> 
> mh@namakemono:~/git/git$ git-archive --format=tar HEAD | tar -tvf -
> -rw-rw-r-- root/root      2365 2007-08-19 20:45 .gitignore
> -rw-rw-r-- root/root      1973 2007-08-19 20:45 .mailmap
> -rw-rw-r-- root/root     18787 2007-08-19 20:45 COPYING
> drwxrwxr-x root/root         0 2007-08-19 20:45 Documentation/

> mh@namakemono:~/git/git$ umask
> 0022
> 
> And no value is set for umask in git config...

In that case the default value for tar.umask applies, which is 002.  The
manpage needs an update..  Thanks for spotting this.

You can set it to 022 explicitly or to "user" to restrict permissions:

   $ git config tar.umask 022		# -rw-r--r--
   $ git config tar.umask user		# your Unix umask applies

Originally file permissions were simply copied into the archive, but
this was inconvenient for users that needed more permission bits set,
e.g. to share an extracted archive with with others by default.

Also please note that tar applies your umask when extracting files
(exception: GNU tar doesn't do that by default if run as root), so the
permissions of extracted files may look different from the output of
"tar -t".

René