Source

aurum / python / aurum / augit.py

Diff from to

File python/aurum/augit.py

 outermethod      = outermethodgen(g_repo, flush)
 autoexportmethod = autoexportmethodgen(g_repo, globals())
 
-# XXX Does not support references like HEAD^. Must be used after getrevhex using normal git was run.
-# FIXME libgit2 does support HEAD^, make pygit2 and this code use this support
 def g_cs(repo, rev):
-    try:
-        ref = repo.lookup_reference(rev)
-        r = repo[ref.resolve().oid]
-    except KeyError:
+    if hasattr(repo, 'revparse_single'):
         try:
-            r = repo[unicode(rev, 'utf-8')]
+            # TODO Check this. Currently it works only in development branch
+            r = repo.revparse_single(rev)
+        except Exception: # FIXME be more specific
+            vim_throw('norev', rev, repo.path)
+    else:
+        try:
+            ref = repo.lookup_reference(rev)
+            r = repo[ref.resolve().oid]
         except KeyError:
-            vim_throw('norev', rev, repo.path)
+            try:
+                r = repo[unicode(rev, 'utf-8')]
+            except KeyError:
+                vim_throw('norev', rev, repo.path)
 
     while not isinstance(r, git.Commit):
         if isinstance(r, git.Tag):
         status = repo.status()
         statuses = status.iteritems()
         if clean:
-            r['clean'] = [fname for fname in list_tree_files(g_cs('HEAD').tree)
+            r['clean'] = [fname for fname in list_tree_files(g_cs(repo, 'HEAD').tree)
                           if fname not in status]
     while True:
         try:
             continue
         if status == git.GIT_STATUS_CURRENT:
             r['clean'].append(fname)
-        elif status & (git.GIT_STATUS_INDEX_MODIFIED | git.GIT_STATUS_WT_MODIFIED):
-            r['modified'].append(fname)
-        elif status & git.GIT_STATUS_IGNORED:
-            r['ignored'].append(fname)
         elif status & git.GIT_STATUS_INDEX_DELETED:
             r['removed'].append(fname)
         elif status & git.GIT_STATUS_WT_DELETED:
             r['added'].append(fname)
         elif status & git.GIT_STATUS_WT_NEW:
             r['unknown'].append(fname)
+        elif status & (git.GIT_STATUS_INDEX_MODIFIED | git.GIT_STATUS_WT_MODIFIED):
+            r['modified'].append(fname)
+        elif status & git.GIT_STATUS_IGNORED:
+            r['ignored'].append(fname)
+    for v in r.itervalues():
+        v.sort()
     return r
 
 def set_rev_dict(cs, cs_vim):