views.main: Use gitcmds.log_helper()
[git-cola.git] / win32 / dirname
blob182e170f4e2eb45d7a8bb81f2b1958e67e0fc816
1 #!/bin/sh
2 """:"
3 exec python $0 ${1+"$@"}; exit
4 """
5 # msysgit does not include dirname.exe, so this simple python
6 # script should do the trick.
7 import sys
8 if len(sys.argv) > 1:
9 item = sys.argv[1]
10 if '\\' in item:
11 joinchar = '\\' # allow win32..
12 else:
13 joinchar = '/' # but assume unix
14 item = item.rstrip(joinchar)
15 while joinchar+joinchar in item:
16 item = item.replace(joinchar+joinchar, joinchar)
17 items = item.split(joinchar)
18 dirname = joinchar.join(items[:-1])
19 print dirname or '.'
20 sys.exit(0)
21 else:
22 sys.exit(1)