doc: Add git-cola-1.3.7 release notes
[git-cola.git] / cola / gitcmds.py
blobee312e882bfab4a5941aabf3fa627584b1db2c7e
1 """Provides commands and queries for Git."""
3 import cola
4 from cola import core
7 def default_remote():
8 model = cola.model()
9 branch = model.currentbranch
10 branchconfig = 'branch.%s.remote' % branch
11 return model.local_config(branchconfig, 'origin')
13 def corresponding_remote_ref():
14 model = cola.model()
15 remote = default_remote()
16 branch = model.currentbranch
17 best_match = '%s/%s' % (remote, branch)
18 remote_branches = model.remote_branches
19 if not remote_branches:
20 return remote
21 for rb in remote_branches:
22 if rb == best_match:
23 return rb
24 return remote_branches[0]
26 def diff_filenames(arg):
27 """Return a list of filenames that have been modified"""
28 model = cola.model()
29 diff_zstr = model.git.diff(arg, name_only=True, z=True).rstrip('\0')
30 return [core.decode(f) for f in diff_zstr.split('\0') if f]