diff options
author | pelya <x.pelya.x@gmail.com> | 2012-03-28 14:49:58 +0300 |
---|---|---|
committer | Shawn Pearce <sop@google.com> | 2012-04-13 09:20:10 -0700 |
commit | d67872d2f47b2f09a0e2aa4adfd62e6f69154c9b (patch) | |
tree | 654e38712aec5961e0e628b8be95b260b7eb9c80 /subcmds | |
parent | e9d6b611c5bec499360c175035770132f1e60c71 (diff) | |
download | git-repo-d67872d2f47b2f09a0e2aa4adfd62e6f69154c9b.tar.gz |
Option for 'repo diff' to generate output suitable for 'patch' cmd
The -u option causes 'repo diff' to generate diff output
with file paths relative to the repository root,
so the output can be applied to the Unix 'patch' command.
The name '-u' was selected for convenience, because
both 'diff' and 'git diff' accept the option with the same name
to generate an 'unified diff' output suitable for 'patch' command.
Change-Id: I79c8356db4ed20ecaccc258b3ba139db76666fe0
Reviewed-on: https://gerrit-review.googlesource.com/34380
Reviewed-by: Shawn Pearce <sop@google.com>
Tested-by: Shawn Pearce <sop@google.com>
Diffstat (limited to 'subcmds')
-rw-r--r-- | subcmds/diff.py | 15 |
1 files changed, 14 insertions, 1 deletions
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) |