diff --relative: help working in a bare repository
This allows the --relative option to say which subdirectory to pretend to be in, so that in a bare repository, you can say: $ git log --relative=drivers/ v2.6.20..v2.6.22 -- drivers/scsi/ Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Feb 13, 2008 at 00:34 UTC
c0cb4a067972700f0682fbab13768bcc7dc7a3c3
3 files changed
+10
-3
Documentation/diff-options.txt
+5
-2
@@ -170,10 +170,13 @@ endif::git-format-patch[]
170
Swap two inputs; that is, show differences from index or
171
on-disk file to tree contents.
172
173
---relative::
173
+--relative[=<path>]::
174
When run from a subdirectory of the project, it can be
175
told to exclude changes outside the directory and show
176
- pathnames relative to it with this option.
176
+ pathnames relative to it with this option. When you are
177
+ not in a subdirectory (e.g. in a bare repository), you
178
+ can name which subdirectory to make the output relative
179
+ to by giving a <path> as an argument.
180
181
--text::
182
Treat all files as text.
diff.c
+4
@@ -2302,6 +2302,10 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
2302
options->detect_rename = 0;
2303
else if (!strcmp(arg, "--relative"))
2304
DIFF_OPT_SET(options, RELATIVE_NAME);
2305
+ else if (!prefixcmp(arg, "--relative=")) {
2306
+ DIFF_OPT_SET(options, RELATIVE_NAME);
2307
+ options->prefix = arg + 11;
2308
+ }
2309
2310
/* xdiff options */
2311
else if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space"))
revision.c
+1
-1
@@ -720,7 +720,7 @@ void init_revisions(struct rev_info *revs, const char *prefix)
720
revs->commit_format = CMIT_FMT_DEFAULT;
721
722
diff_setup(&revs->diffopt);
723
- if (prefix) {
723
+ if (prefix && !revs->diffopt.prefix) {
724
revs->diffopt.prefix = prefix;
725
revs->diffopt.prefix_length = strlen(prefix);
726
}