def get_tree_changes(repo):
 with open_repo_closing(repo) as r:
  index = r.open_index()
  tracked_changes = {'add': [], 'delete': [], 'modify': []}
  try:
   tree_id = r['HEAD'].tree
  except KeyError:
   tree_id = None
  for change in index.changes_from_tree(r.object_store, tree_id):
   if (not change[0][0]):
    tracked_changes['add'].append(change[0][1])
   elif (not change[0][1]):
    tracked_changes['delete'].append(change[0][0])
   elif (change[0][0] == change[0][1]):
    tracked_changes['modify'].append(change[0][0])
   else:
    raise AssertionError('git mv ops not yet supported')
  return tracked_changes

def get_tree_changes ( repo ) : with open_repo_closing ( repo ) as r : index = r . open_index ( ) tracked_changes = { 'add' : [ ] , 'delete' : [ ] , 'modify' : [ ] } try : tree_id = r [ 'HEAD' ] . tree except KeyError : tree_id = None for change in index . changes_from_tree ( r . object_store , tree_id ) : if ( not change [ 0 ] [ 0 ] ) : tracked_changes [ 'add' ] . append ( change [ 0 ] [ 1 ] ) elif ( not change [ 0 ] [ 1 ] ) : tracked_changes [ 'delete' ] . append ( change [ 0 ] [ 0 ] ) elif ( change [ 0 ] [ 0 ] == change [ 0 ] [ 1 ] ) : tracked_changes [ 'modify' ] . append ( change [ 0 ] [ 0 ] ) else : raise AssertionError ( 'git mv ops not yet supported' ) return tracked_changes
return add/delete/modify changes to tree by comparing index to head .