diff --git a/listversioned/listversioned.rb b/listversioned/listversioned.rb index e5db772..01c722a 100755 --- a/listversioned/listversioned.rb +++ b/listversioned/listversioned.rb @@ -105,7 +105,51 @@ class DSParse end # class DSParse class GitParse - # info over Git index files is te vinden op http://git.rsbx.net/Documents/Git_Data_Formats.txt +# info over Git index files is te vinden op http://git.rsbx.net/Documents/Git_Data_Formats.txt + +# voorspelbare bestanden: +# +# FETCH_HEAD +# HEAD +# ORIG_HEAD +# branches/ +# config +# description +# hooks/ +# hooks/applypatch-msg +# hooks/commit-msg +# hooks/post-commit +# hooks/post-receive +# hooks/post-update +# hooks/pre-applypatch +# hooks/pre-commit +# hooks/pre-rebase +# hooks/prepare-commit-msg +# hooks/update +# index +# info/ +# info/exclude +# logs/ +# logs/HEAD +# logs/heads/ +# logs/heads/master +# logs/remotes/ +# logs/remotes/origin/ +# logs/remotes/origin/master +# objects/ # hieronder grotendeels (zoniet helemaal) te halen uit 'index' (zie statinfo() notities) +# objects/info/ +# objects/pack/ # hieronder ook weer te halen uit iets anders +# packed-refs +# refs/ +# refs/heads/ +# refs/heads/master +# refs/remotes/ +# refs/remotes/origin/ +# refs/remotes/origin/HEAD +# refs/remotes/origin/master +# refs/tags/ # hieronder ook weer te halen uit iets anders + + def initialize @store = Array.new end @@ -122,6 +166,14 @@ class GitParse return string end + def arr2hexstring(arr) + string = "" + (0...arr.length).step{|i| + string += ("%02x" % arr[i]) + } + return string + end + def readfile(filename) @store = Array.new File.open(filename).each_byte{|byte| @@ -175,7 +227,20 @@ class GitParse #p size # entryid = arr2long(@store[offset+40, 4]) # hoe groot is zo'n object ID? -# entryflags = arr2long(@store[offset+44, 2]) + # The object ID, or "name", of an object is + # _sha-1_digest_( ). + # random sha1 voorbeeld: "42796666f0c5748b943956f367907ce6d9f42654" + # wikipedia zegt 160 bits, ofwel 20 bytes + entryid = arr2hexstring(@store[offset+40, 20]) +p entryid + +# opvallend: bestandsnamen onder .git/objects/??/* zijn 38 tekens lang +# de dir lijkt dan inderdaad de eerste 2 tekens van deze entryid te zijn! +# de naam de rest. Maar het bestaat niet bij alle entries! + + + +# entryflags = arr2long(@store[offset+60, 2]) i = offset+62 name = "" while true @@ -193,7 +258,7 @@ class GitParse plus += 8 - cl.modulo(8) end nextoffset = offset + plus - +p name return name, nextoffset end @@ -352,6 +417,7 @@ def svnparse(url) if body.nil? return end + dirs = Array.new case body[0].chr when '<' @@ -372,7 +438,7 @@ def svnparse(url) puts " Strange kind #{item.attribute("kind")}" end } - when '8', '9' + when '8', '9', '1' lastline = "" commitdate = "" author = "" @@ -552,6 +618,7 @@ def checkgit(url) puts "Git info found:" gitparse(url) rescue +puts "#{$!}" puts "No Git info found" end end