Created
February 9, 2016 05:33
-
-
Save ytkhs/8d2f1076baf9f544703b to your computer and use it in GitHub Desktop.
コミットのオブジェクトファイルからコミットハッシュを求めるやり方
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# tmp.txtは `git cat-file -p <commit id>` の中身 | |
$contents = file_get_contents('tmp.txt'); | |
$obj = sprintf("commit %d\0%s", strlen($contents), $contents); | |
echo sha1($obj); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment