mkottman / lua-git

An attempt to implement the basics of Git in pure Lua
40 stars 10 forks source link

Cannot checkout tags when git revisions present #10

Closed mnicky closed 11 years ago

mnicky commented 11 years ago

I don't understand git revisions (actually I didn't even know about them until luadist-git/#9), but the repository https://github.com/LuaDist/lua-spore.git seems to contain (or whatever verb is appropriate :) them:

$ git ls-remote --tags https://github.com/LuaDist/lua-spore.git
7f3b1cb33876af13cb46a9085a25c7387489032a    refs/tags/0.2.0
c0585b9ae54f12f5271461311910a0442527699e    refs/tags/0.2.1
545779d9a1100c9c9111c5ee235b21451b73f042    refs/tags/0.2.1^{}

When I want to use lua-git to fetch the tag 0.2.0, that's okay. But when I want to fetch the tag 0.2.1, it results in error:

$ bin/lua ../../test_fetch2.lua
Counting objects: 100, done.
Compressing objects: 100% (88/88), done.
Total 100 (delta 31), reused 58 (delta 11)
bin/lua: .../Repository/_install/bin/../lib/lua/git/repo.lua:69: c0585b9ae54f12f5271461311910a0442527699e (tag) is not a commit
stack traceback:
    [C]: in function 'assert'
    .../Repository/_install/bin/../lib/lua/git/repo.lua:69: in function 'commit'
    .../Repository/_install/bin/../lib/lua/git/repo.lua:158: in function 'checkout'
    ../../test_fetch2.lua:13: in main chunk
    [C]: ?

The test file is here:

package.path = package.path .. ';lua/?.lua'
package.cpath = package.cpath .. ';b/?.so'

require 'git'

os.execute('rm -rf /tmp/test.git')
os.execute('rm -rf /tmp/extracted')

git.repo.create('/tmp/test.git')

R = git.repo.open('/tmp/test.git')
local pack, sha = git.protocol.fetch('git://github.com/LuaDist/lua-spore.git', R, 'refs/tags/0.2.1')
R:checkout(sha, '/tmp/test.git')
mnicky commented 11 years ago

I've just found good explanation of ^{} in tags http://stackoverflow.com/questions/12938972/what-does-mean-in-git

mkottman commented 11 years ago

I'm working on it right now, thanks for the reference though.

mnicky commented 11 years ago

Thank you.