Re: confused about preserved permissions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mike Hommey <mh@xxxxxxxxxxxx> wrote:
> > >> > sprintf "%06o %s\0%s", $mode, $file, pack("H[40]", $sha1)
> 
> The question here was why the permissions are encoded with "%06o" while
> the hash is packed. Anyways, it's just a boring detail.

Because text format is simple and pretty much everyone understands
it, especially when you are talking about UNIX mode/permission
bits in octal, the name is "text", and then oh, wait, those 40
bytes of hex is a lot of data - we'll just make that 20 bytes of
binary instead.  :-)

OK, I don't know if that's really true.  Probably only Linus can
speak to why the tree format is what it is.  Its just how I have
rationalized it myself.

Pack v4 changes the storage of the mode to be in binary, at least
within the packfile, but it does still have to convert it back to the
"%06o" format when computing the SHA-1 of a tree object.  Believe it
or not, pack v4 is being worked on again... so maybe in a future
version of Git the tree modes will take up a tiny bit less space.

I haven't specifically looked at this, but I would also suspect that
within any given tree's zlib dictionary the mode string portion is
given a reasonably short bit sequence.  So its doubtful that the
mode takes up 6 bytes when compressed by zlib, its probably more
likely around 1 byte.  Pack v4's big win here isn't due to the mode,
its due to the filenames being compressed better across trees.

-- 
Shawn.
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux