Question

I've been saving some automatically-generated performance data for my code in perf.txt. Every time I improve my code, I run a script that overwrites perf.txt with the new performance data. I'll then commit perf.txt.

In retrospect, overwriting perf.txt was a bone-headed mistake, and now, I'd like to make some analysis/plot a graph of my improvement, but can't. Of course, the old perf.txt files are still out there in my commit history. Is there any easy way to get them? Ideally I'd like to have perf~1.txt, perf~2.txt, etc. in a new directory, along with time stamps.

Alternatively, if I could simply "replay" the commit history (e.g. git next perf.txt) like git-bisect does - but linearly - that would work too.

Was it helpful?

Solution

Ok, I managed to create a shell script for this. Let me know if it works fine.

Update:

i=0; git rev-list HEAD package.json | while read sha1; do; git show "$sha1:package.json" > "$(printf "%04d" $i)-$sha1-package.json"; ((i++)); done

Will output:

$ ls *-package.json | cat
0000-a15147199edff1b1c0fab89c66214abfb8c65d7c-package.json
0001-51feba61197b837b7d55754a56e12f66f0624ba1-package.json
0002-ed9e34482a303e7e64c397f89533dbe64f51cfbf-package.json
0003-d01253e20158f53c08aa6bc0c1cf66806cd19148-package.json
0004-d57363e800535a7400fde56e97d0a4cd424cffbb-package.json
0005-6e995583a11b63bf1d94142da6408955ee93e7cc-package.json
0006-6bc2a87943f59ad277cdee26aec1c25949c0f091-package.json
0007-e06a8cae3a1de58b770a66cbd124cf50e809fb31-package.json
0008-81bf63359641255dfd340714d0635be03bda8de9-package.json
0009-95559f5117c8a21c1b8cc99f4badc320fd3dcbda-package.json
0010-5e906366dd86dda95df050257513c95834020e5e-package.json
0011-717cb2a5c7909ed16f7c599b02759b27fd2e4258-package.json
0012-f18b75940e61a52ef9c0cf41a4bda3bcdae5c46c-package.json
0013-3c86547a3b841807c4744af0fa4ee3894cc17a33-package.json
0014-d5658e978d9a7234e537d57c45069ce223cb3853-package.json
0015-286c4d91dde12ba32f4a56273d05374b1cbb79e7-package.json
0016-46d680458b74fcf956f6161a2b73b6b00fc2541d-package.json
0017-e64f89d9aaf26c2dae6c7f1ef29a2d3cadd0b4b2-package.json
0018-bd84aad6cdde8cf3ce7842df1febb82fe9816647-package.json
0019-6cf1542a8b823c6bdacf7e6e01dfcb58e9949ff4-package.json
0020-1434b5b56756d02190afe552b626823c97b11a49-package.json

Which will remain in correct order when sorted.


Original:

i=0; git rev-list HEAD package.json | while read sha1; do; git show "$sha1:package.json" > "$i-$sha1-package.json"; ((i++)); done

Replace package.json with the file you want in all the 3 places.

This will create files like this:

$ ls *-package.json | cat
0-a15147199edff1b1c0fab89c66214abfb8c65d7c-package.json
1-51feba61197b837b7d55754a56e12f66f0624ba1-package.json
10-5e906366dd86dda95df050257513c95834020e5e-package.json
11-717cb2a5c7909ed16f7c599b02759b27fd2e4258-package.json
12-f18b75940e61a52ef9c0cf41a4bda3bcdae5c46c-package.json
13-3c86547a3b841807c4744af0fa4ee3894cc17a33-package.json
14-d5658e978d9a7234e537d57c45069ce223cb3853-package.json
15-286c4d91dde12ba32f4a56273d05374b1cbb79e7-package.json
16-46d680458b74fcf956f6161a2b73b6b00fc2541d-package.json
17-e64f89d9aaf26c2dae6c7f1ef29a2d3cadd0b4b2-package.json
18-bd84aad6cdde8cf3ce7842df1febb82fe9816647-package.json
19-6cf1542a8b823c6bdacf7e6e01dfcb58e9949ff4-package.json
2-ed9e34482a303e7e64c397f89533dbe64f51cfbf-package.json
20-1434b5b56756d02190afe552b626823c97b11a49-package.json
3-d01253e20158f53c08aa6bc0c1cf66806cd19148-package.json
4-d57363e800535a7400fde56e97d0a4cd424cffbb-package.json
5-6e995583a11b63bf1d94142da6408955ee93e7cc-package.json
6-6bc2a87943f59ad277cdee26aec1c25949c0f091-package.json
7-e06a8cae3a1de58b770a66cbd124cf50e809fb31-package.json
8-81bf63359641255dfd340714d0635be03bda8de9-package.json
9-95559f5117c8a21c1b8cc99f4badc320fd3dcbda-package.json
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top