swh-revhash computes the raw commit hash (as in git) using our swh.model api. ``` $ swh-revhash 'tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904\nparent 22c0fa5195a53f2e733ec75a9b6e9d1624a8b771\nauthor seanius 1138341044 +0000\ncommitter seanius 1138341044 +0000\n\nmaking dir structure...\n' 17a631d474f49bbebfdf3d885dcde470d7faafd7 ``` Note: swh-revhash is in swh-model/bin/ (https://forge.softwareheritage.org/diffusion/DMOD/browse/master/bin/swh-revhash). To have the same git hash (using git), we need to remove the trailing slash... ``` $ echo -e 'tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904\nparent 22c0fa5195a53f2e733ec75a9b6e9d1624a8b771\nauthor seanius 1138341044 +0000\ncommitter seanius 1138341044 +0000\n\nmaking dir structure...' | git hash-object -t commit --stdin 17a631d474f49bbebfdf3d885dcde470d7faafd7 ``` -- Answer: The problem is in the git checking step. echo adds an extra line. To avoid this, the command should have been: ``` $ echo -ne 'tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904\nparent 22c0fa5195a53f2e733ec75a9b6e9d1624a8b771\nauthor seanius 1138341044 +0000\ncommitter seanius 1138341044 +0000\n\nmaking dir structure...\n' | git hash-object -t commit --stdin 17a631d474f49bbebfdf3d885dcde470d7faafd7 ```