- (ref, date, path) = namesplit(d)
- if not ref:
- for (name,sha) in git.list_refs():
- name = re.sub('^refs/heads/', '', name)
- if opt.hash:
- print '%s %s' % (sha.encode('hex'), name)
- else:
- print name
- elif not date:
- dates = list(git.rev_list(ref))
- dates.sort()
- for (date,commit) in dates:
- l = time.localtime(date)
- print repr((time.strftime('%Y-%m-%d-%H%M%S', l),commit))
- else:
- dates = list(git.rev_list(ref))
- dates.sort(reverse=True)
- try:
- dp = time.strptime(date, '%Y-%m-%d-%H%M%S')
- except ValueError:
- dp = time.strptime(date, '%Y-%m-%d')
- dt = time.mktime(dp)
- commit = None
- for (d,commit) in dates:
- if d <= dt: break
- assert(commit)
- it = cp.get('%s:%s' % (commit.encode('hex'), path or ''))
- type = it.next()
- if type == 'tree':
- for (mode,name,sha) in git._treeparse(''.join(it)):
- if opt.hash:
- print '%s %s' % (sha.encode('hex'), name)
- else:
- print name