Changeset 3200

Show
Ignore:
Timestamp:
02/08/08 16:08:04 (10 months ago)
Author:
hvr
Message:

GitPlugin: use zero-termination mode of diff-tree (and thus avoid escaping newlines and tabs)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gitplugin/0.11/gitplugin/PyGIT.py

    r3199 r3200  
    351351        if limit is None: 
    352352            limit = -1 
    353         for rev in self._git_call_f("rev-list",  
    354                                     ["--max-count=%d" % limit,  
     353        for rev in self._git_call_f("rev-list", 
     354                                    ["--max-count=%d" % limit, 
    355355                                     str(sha), "--", path]).readlines(): 
    356356            if(skip > 0): 
     
    403403        if tree1 is None: 
    404404            tree1 = "--root" 
    405         for chg in self._git_call_f("diff-tree", ["-r", 
    406                                                   str(tree1), 
    407                                                   str(tree2), 
    408                                                   "--", path]).readlines(): 
    409             if chg.startswith(tree2): 
     405 
     406        next_is_path = False 
     407        for chg in self._git_call("diff-tree", ["-z", "-r", 
     408                                                str(tree1), 
     409                                                str(tree2), 
     410                                                "--", path]).split('\0'): 
     411            if not chg: 
     412                assert not next_is_path 
    410413                continue 
    411             (mode1,mode2,obj1,obj2,action,path) = chg[:-1].split(None, 5) 
     414 
     415            if next_is_path: 
     416                next_is_path = False 
     417                path = chg 
     418                yield (mode1,mode2,obj1,obj2,action,path) 
     419                continue 
     420 
     421            if not chg.startswith(':'): 
     422                continue 
     423 
     424            (mode1,mode2,obj1,obj2,action) = chg.split(None) 
    412425            mode1 = mode1[1:] 
    413             yield (mode1,mode2,obj1,obj2,action,path) 
     426            next_is_path = True 
     427 
     428        assert not next_is_path 
    414429 
    415430if __name__ == '__main__':