OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 # | 3 # |
4 # Copyright 2007 Google Inc. | 4 # Copyright 2007 Google Inc. |
5 # | 5 # |
6 # Licensed under the Apache License, Version 2.0 (the "License"); | 6 # Licensed under the Apache License, Version 2.0 (the "License"); |
7 # you may not use this file except in compliance with the License. | 7 # you may not use this file except in compliance with the License. |
8 # You may obtain a copy of the License at | 8 # You may obtain a copy of the License at |
9 # | 9 # |
10 # http://www.apache.org/licenses/LICENSE-2.0 | 10 # http://www.apache.org/licenses/LICENSE-2.0 |
(...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 # this by overriding the environment (but there is still a problem if the | 1295 # this by overriding the environment (but there is still a problem if the |
1296 # git config key "diff.external" is used). | 1296 # git config key "diff.external" is used). |
1297 env = os.environ.copy() | 1297 env = os.environ.copy() |
1298 if 'GIT_EXTERNAL_DIFF' in env: del env['GIT_EXTERNAL_DIFF'] | 1298 if 'GIT_EXTERNAL_DIFF' in env: del env['GIT_EXTERNAL_DIFF'] |
1299 # -M/-C will not print the diff for the deleted file when a file is renamed. | 1299 # -M/-C will not print the diff for the deleted file when a file is renamed. |
1300 # This is confusing because the original file will not be shown on the | 1300 # This is confusing because the original file will not be shown on the |
1301 # review when a file is renamed. So first get the diff of all deleted files, | 1301 # review when a file is renamed. So first get the diff of all deleted files, |
1302 # then the diff of everything except deleted files with rename and copy | 1302 # then the diff of everything except deleted files with rename and copy |
1303 # support enabled. | 1303 # support enabled. |
1304 cmd = [ | 1304 cmd = [ |
1305 "git", "diff", "--no-color", "--no-ext-diff", "--full-index", "--ignore-
submodules" | 1305 "git", "diff", "--no-color", "--no-ext-diff", "--full-index", |
| 1306 "--ignore-submodules", |
1306 ] | 1307 ] |
1307 diff = RunShell(cmd + ["--diff-filter=D"] + extra_args, env=env, | 1308 diff = RunShell( |
1308 silent_ok=True) | 1309 cmd + ["--diff-filter=D"] + extra_args, env=env, silent_ok=True) |
1309 diff += RunShell(cmd + ["-C", "--diff-filter=ACMRT"] + extra_args, env=env, | 1310 diff += RunShell( |
1310 silent_ok=True) | 1311 cmd + ["--find-copies-harder", "--diff-filter=ACMRT"] + extra_args, |
| 1312 env=env, silent_ok=True) |
| 1313 # The CL could be only file deletion or not. So accept silent diff for both |
| 1314 # commands then check for an empty diff manually. |
1311 if not diff: | 1315 if not diff: |
1312 ErrorExit("No output from %s" % (cmd + extra_args)) | 1316 ErrorExit("No output from %s" % (cmd + extra_args)) |
1313 return diff | 1317 return diff |
1314 | 1318 |
1315 def GetUnknownFiles(self): | 1319 def GetUnknownFiles(self): |
1316 status = RunShell(["git", "ls-files", "--exclude-standard", "--others"], | 1320 status = RunShell(["git", "ls-files", "--exclude-standard", "--others"], |
1317 silent_ok=True) | 1321 silent_ok=True) |
1318 return status.splitlines() | 1322 return status.splitlines() |
1319 | 1323 |
1320 def GetFileContent(self, file_hash, is_binary): | 1324 def GetFileContent(self, file_hash, is_binary): |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2344 os.environ['LC_ALL'] = 'C' | 2348 os.environ['LC_ALL'] = 'C' |
2345 RealMain(sys.argv) | 2349 RealMain(sys.argv) |
2346 except KeyboardInterrupt: | 2350 except KeyboardInterrupt: |
2347 print | 2351 print |
2348 StatusUpdate("Interrupted.") | 2352 StatusUpdate("Interrupted.") |
2349 sys.exit(1) | 2353 sys.exit(1) |
2350 | 2354 |
2351 | 2355 |
2352 if __name__ == "__main__": | 2356 if __name__ == "__main__": |
2353 main() | 2357 main() |
OLD | NEW |