Page MenuHomeSoftware Heritage

[Answer: No] hash revision computation difference?
ActivePublic

Authored by ardumont on Jun 23 2016, 11:57 AM.
swh-revhash computes the raw commit hash (as in git) using our swh.model api.
```
$ swh-revhash 'tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904\nparent 22c0fa5195a53f2e733ec75a9b6e9d1624a8b771\nauthor seanius <seanius@3187e211-bb14-4c82-9596-0b59d67cd7f4> 1138341044 +0000\ncommitter seanius <seanius@3187e211-bb14-4c82-9596-0b59d67cd7f4> 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 <seanius@3187e211-bb14-4c82-9596-0b59d67cd7f4> 1138341044 +0000\ncommitter seanius <seanius@3187e211-bb14-4c82-9596-0b59d67cd7f4> 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 <seanius@3187e211-bb14-4c82-9596-0b59d67cd7f4> 1138341044 +0000\ncommitter seanius <seanius@3187e211-bb14-4c82-9596-0b59d67cd7f4> 1138341044 +0000\n\nmaking dir structure...\n' | git hash-object -t commit --stdin
17a631d474f49bbebfdf3d885dcde470d7faafd7
```

Event Timeline

ardumont changed the title of this paste from hash revision computation difference? to [Answer: No] hash revision computation difference?.Jun 23 2016, 12:31 PM
ardumont edited the content of this paste. (Show Details)