public
Description: scripts that can help with using Changes.app and git
Clone URL: git://github.com/danimal/git-chdiff-scripts.git
check the file for existance
snag the revision from the repo to a tempfile
danimal (author)
Wed Feb 20 21:56:55 -0800 2008
commit  16a2f5f45a19705ec9e2be33ecaba58b619f0d64
tree    b913f8dbf5e6c7387cfc667bef11e2d9b2af036b
parent  996721787935e8534a926f9d5cdd48a0db7765e7
...
11
12
13
 
14
15
16
...
88
89
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
92
93
...
11
12
13
14
15
16
17
...
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
0
@@ -11,6 +11,7 @@ import getopt
0
 import os
0
 import subprocess
0
 import sys
0
+import tempfile
0
 
0
 help_message = '''
0
 git-chdiff <opts> [file1, file2, ...]
0
@@ -88,6 +89,29 @@ def main(argv=None):
0
                 continue
0
         except OSError, e:
0
             print >>sys.stderr, 'Execution failed:', e
0
+ # shadow the requested version of the file to a temp file
0
+ # so we have something to diff against
0
+ try:
0
+ p = subprocess.Popen('git show %s:%s' % (revision,nFile),
0
+ env=os.environ,
0
+ shell=True,
0
+ stdout=subprocess.PIPE,
0
+ stderr=subprocess.PIPE)
0
+ p.wait()
0
+ # git show, it appears, doesn't return a 1 when the
0
+ # revision/tag isn't valid so we have to scan the output
0
+ lines = p.stdout.readlines()
0
+ if lines[0].startswith('fatal:'):
0
+ print 'problem getting revision of file %s' % nFile
0
+ print line
0
+ else:
0
+ # save the file out
0
+ tFile = tempfile.mkstemp('.temp', 'git-chdiff', '/var/tmp')
0
+ if verbose:
0
+ print '\ttemp file: %s' % tFile[1]
0
+ os.fdopen(tFile[0], 'w').write(''.join(lines))
0
+ except OSError, e:
0
+ print >>sys.stderr, 'Execution failed:', e
0
 
0
 if __name__ == '__main__':
0
     sys.exit(main())

Comments

    No one has commented yet.