diff options
-rw-r--r-- | project.py | 5 | ||||
-rw-r--r-- | subcmds/diff.py | 15 |
2 files changed, 18 insertions, 2 deletions
@@ -749,7 +749,7 @@ class Project(object): | |||
749 | 749 | ||
750 | return 'DIRTY' | 750 | return 'DIRTY' |
751 | 751 | ||
752 | def PrintWorkTreeDiff(self): | 752 | def PrintWorkTreeDiff(self, absolute_paths=False): |
753 | """Prints the status of the repository to stdout. | 753 | """Prints the status of the repository to stdout. |
754 | """ | 754 | """ |
755 | out = DiffColoring(self.config) | 755 | out = DiffColoring(self.config) |
@@ -757,6 +757,9 @@ class Project(object): | |||
757 | if out.is_on: | 757 | if out.is_on: |
758 | cmd.append('--color') | 758 | cmd.append('--color') |
759 | cmd.append(HEAD) | 759 | cmd.append(HEAD) |
760 | if absolute_paths: | ||
761 | cmd.append('--src-prefix=a/%s/' % self.relpath) | ||
762 | cmd.append('--dst-prefix=b/%s/' % self.relpath) | ||
760 | cmd.append('--') | 763 | cmd.append('--') |
761 | p = GitCommand(self, | 764 | p = GitCommand(self, |
762 | cmd, | 765 | cmd, |
diff --git a/subcmds/diff.py b/subcmds/diff.py index e0247140..f233f690 100644 --- a/subcmds/diff.py +++ b/subcmds/diff.py | |||
@@ -20,8 +20,21 @@ class Diff(PagedCommand): | |||
20 | helpSummary = "Show changes between commit and working tree" | 20 | helpSummary = "Show changes between commit and working tree" |
21 | helpUsage = """ | 21 | helpUsage = """ |
22 | %prog [<project>...] | 22 | %prog [<project>...] |
23 | |||
24 | The -u option causes '%prog' to generate diff output with file paths | ||
25 | relative to the repository root, so the output can be applied | ||
26 | to the Unix 'patch' command. | ||
23 | """ | 27 | """ |
24 | 28 | ||
29 | def _Options(self, p): | ||
30 | def cmd(option, opt_str, value, parser): | ||
31 | setattr(parser.values, option.dest, list(parser.rargs)) | ||
32 | while parser.rargs: | ||
33 | del parser.rargs[0] | ||
34 | p.add_option('-u', '--absolute', | ||
35 | dest='absolute', action='store_true', | ||
36 | help='Paths are relative to the repository root') | ||
37 | |||
25 | def Execute(self, opt, args): | 38 | def Execute(self, opt, args): |
26 | for project in self.GetProjects(args): | 39 | for project in self.GetProjects(args): |
27 | project.PrintWorkTreeDiff() | 40 | project.PrintWorkTreeDiff(opt.absolute) |