最新消息:

git ls-tree –full-name HEAD

git admin 4676浏览 0评论
 # git ls-tree --full-name HEAD 
100644 blob 57155a5f69e5754a281c6531f86c2ef529597898    Makefile
100644 blob e651adec208aa662d432af568c07673bc8a1fcab    README.md
100644 blob c5612433803345e1720532263640eded7418046e    Vagrantfile
040000 tree 0e4c41e663457cab0c699dcb92ca46283d162d39    api
040000 tree 091e0e8b592cc1c7f39c8363666a0352e6340b03    bin
100755 blob caea3556725a1e3fc05219858addced6f11da573    bootstrap.sh
100644 blob 6da20fad36a0a8d1c03214ebb21a92c16b3e39ae    composer.json
100644 blob 794fe554bddad78dcec29e233397b937a6b4415d    composer.lock
100644 blob fac70e7c35db31b2f89097634fb6b24bcfd3adb3    config.ini
040000 tree ec0b90a0cca23f9bb0a627059ed3f27d548caf06    doc
040000 tree aaa05e596f2cd038e6b42adcc0727f9f0242b820    etc
040000 tree 08ecdb83c8ff74ec4f1650ef1afb7c5973d05061    hooks
040000 tree 8491aff957a41c7b23dfc8a30c2d149b71d312ff    lib
040000 tree e09518ccb578d00d92af9b62936f9db68a866263    locale
040000 tree 4d0a1ccc319e9d3d3dc72ee5ed3b76866752a7b2    mods
100644 blob 06df06319f0de9ee6c0b30757b6df18712bfba61    my.logrotate
100644 blob 1b6265c541f5d9f27705ff8c40ac6c4d7d2fc7a2    rpm.spec
040000 tree 7a19a4f630df734df2faeba56e32eefde929080d    support
040000 tree 6ee8d5b840e24c2429e75f5bcdc8688410f8d663    vendor

The 6 digits show the file mode using the classical UNIX notations. First two digits show file type, the third one is about set-uid/set-gid/sticky bits, and you know the last three.

Here is how man 2 stat documents it on my GNU/Linux system:

The following flags are defined for the st_mode field:

    S_IFMT     0170000   bit mask for the file type bit fields
    S_IFSOCK   0140000   socket
    S_IFLNK    0120000   symbolic link
    S_IFREG    0100000   regular file
    S_IFBLK    0060000   block device
    S_IFDIR    0040000   directory
    S_IFCHR    0020000   character device
    S_IFIFO    0010000   FIFO
    S_ISUID    0004000   set UID bit
    S_ISGID    0002000   set-group-ID bit (see below)
    S_ISVTX    0001000   sticky bit (see below)
    S_IRWXU    00700     mask for file owner permissions
    S_IRUSR    00400     owner has read permission
    S_IWUSR    00200     owner has write permission
    S_IXUSR    00100     owner has execute permission
    S_IRWXG    00070     mask for group permissions
    S_IRGRP    00040     group has read permission
    S_IWGRP    00020     group has write permission
    S_IXGRP    00010     group has execute permission
    S_IRWXO    00007     mask for permissions for others (not in group)
    S_IROTH    00004     others have read permission           
    S_IWOTH    00002     others have write permission
    S_IXOTH    00001     others have execute permission

 

From the Git index-format.txt file, regarding the mode:

32-bit mode, split into (high to low bits)

    4-bit object type
      valid values in binary are 1000 (regular file), 1010 (symbolic link)
      and 1110 (gitlink)

    3-bit unused

    9-bit unix permission. Only 0755 and 0644 are valid for regular files.
    Symbolic links and gitlinks have value 0 in this field.

Also, a directory object type (binary 0100) and group-writeable (0664 permissions) regular file are allowed as indicated by the fsck.c fsck_tree method. The regular non-executable group-writeable file is a non-standard mode that was supported in earlier versions of Git.

This makes valid modes (as binary and octal):

  • 0100000000000000 (040000): Directory
  • 1000000110100100 (100644): Regular non-executable file
  • 1000000110110100 (100664): Regular non-executable group-writeable file
  • 1000000111101101 (100755): Regular executable file
  • 1010000000000000 (120000): Symbolic link
  • 1110000000000000 (160000): Gitlink

转载请注明:爱开源 » git ls-tree –full-name HEAD

您必须 登录 才能发表评论!