Use git ls-tree
, just give it more arguments:
$ git ls-tree HEAD xdiff*
100644 blob 54236f24b9786710f91650ac63f6004cdeb012e6 xdiff-interface.c
100644 blob fbb5a1c3949b6ef6ba0dfb758723a48f3b402190 xdiff-interface.h
040000 tree 4c60b91db5de467cf05e864429dce1b44cb843e7 xdiff
The first output word is the mode, which for a blob is always either 100644
or 100755
. If it is 100755
the executable bit is set, otherwise it is not. (Interesting aside: git stores the entire mode value internally, as an octal string with no leading zeros. The leading zero in the last quoted line above is generated by git ls-tree
.)
Keep the file or directory name if needed; if it is a directory (mode 040000
or type tree
βthe type
string is actually determined from the mode
internally, in this case) and you want to check its contents, add a trailing slash:
$ git ls-tree HEAD xdiff/
100644 blob 4fb7e79410c22fba1fb390af2e09008e932f5ea8 xdiff/xdiff.h
100644 blob 2358a2d6326e54308413cb8a5e6b61eba06324e9 xdiff/xdiffi.c
100644 blob 8b81206c9af0767bd91c4b9e453f7c5c2bde47b1 xdiff/xdiffi.h
100644 blob 993724b11c40bacffee8df927018e5790a265bd4 xdiff/xemit.c
100644 blob d29710770ce40bafa6e9eb2b2ea7c9c8ba43c727 xdiff/xemit.h
100644 blob 73210cb6f3fb5d1cb90b1c5959a5a90e058ea1f2 xdiff/xhistogram.c
100644 blob 526ccb344d231fb978f53b80deb17ec6c8fed368 xdiff/xinclude.h
100644 blob 165a895a93e04b33ca7c8f3839ee85e0eccb4a07 xdiff/xmacros.h
100644 blob f338ad6c757cda29a052960a504715c062ab5dda xdiff/xmerge.c
100644 blob 04e1a1ab2a863814df3b9a91d4e854704d47f3f5 xdiff/xpatience.c
100644 blob 13b55aba7441bc84d2c5c075110e9ef798ba18f8 xdiff/xprepare.c
100644 blob 8fb06a537451cbf3335ab4bdacb0f992e9744338 xdiff/xprepare.h
100644 blob 2511aef8d89ab52be5ec6a5e46236b4b6bcd07ea xdiff/xtypes.h
100644 blob 62cb23dfd37743e4985655998ccabd56db160233 xdiff/xutils.c
100644 blob 4646ce575251b07053f20285be99422d6576603e xdiff/xutils.h
(Note that there is a hard tab \t
between the SHA-1 and the path, which I have left in the original text here since StackOverflow displays this OK.)