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>
This commit is contained in:
Junio C Hamano 2008-02-13 00:34:39 -08:00
parent cd676a5136
commit c0cb4a0679
3 changed files with 10 additions and 3 deletions

View File

@ -170,10 +170,13 @@ endif::git-format-patch[]
Swap two inputs; that is, show differences from index or Swap two inputs; that is, show differences from index or
on-disk file to tree contents. on-disk file to tree contents.
--relative:: --relative[=<path>]::
When run from a subdirectory of the project, it can be When run from a subdirectory of the project, it can be
told to exclude changes outside the directory and show told to exclude changes outside the directory and show
pathnames relative to it with this option. pathnames relative to it with this option. When you are
not in a subdirectory (e.g. in a bare repository), you
can name which subdirectory to make the output relative
to by giving a <path> as an argument.
--text:: --text::
Treat all files as text. Treat all files as text.

4
diff.c
View File

@ -2302,6 +2302,10 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
options->detect_rename = 0; options->detect_rename = 0;
else if (!strcmp(arg, "--relative")) else if (!strcmp(arg, "--relative"))
DIFF_OPT_SET(options, RELATIVE_NAME); DIFF_OPT_SET(options, RELATIVE_NAME);
else if (!prefixcmp(arg, "--relative=")) {
DIFF_OPT_SET(options, RELATIVE_NAME);
options->prefix = arg + 11;
}
/* xdiff options */ /* xdiff options */
else if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space")) else if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space"))

View File

@ -720,7 +720,7 @@ void init_revisions(struct rev_info *revs, const char *prefix)
revs->commit_format = CMIT_FMT_DEFAULT; revs->commit_format = CMIT_FMT_DEFAULT;
diff_setup(&revs->diffopt); diff_setup(&revs->diffopt);
if (prefix) { if (prefix && !revs->diffopt.prefix) {
revs->diffopt.prefix = prefix; revs->diffopt.prefix = prefix;
revs->diffopt.prefix_length = strlen(prefix); revs->diffopt.prefix_length = strlen(prefix);
} }