Permalink
Browse files

diff: get pathname of combined diff headers

With combined diffs, the diff header line contains --cc or --combined,
instead of a/ or b/ prefixes. This patch allows to get the pathname from
combined diff headers as well.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
  • Loading branch information...
1 parent 98760f2 commit 03443da3639edc058239767769cf27993d95f8b7 @vivien vivien committed with jonas Aug 23, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 tig.c
View
9 tig.c
@@ -4446,14 +4446,17 @@ static const char *
diff_get_pathname(struct view *view, struct line *line)
{
const struct line *header;
- const char *dst, *prefix = " b/";
+ const char *dst, *prefixes[] = { " b/", "cc ", "combined " };
+ int i;
header = find_prev_line_by_type(view, line, LINE_DIFF_HEADER);
if (!header)
return NULL;
- dst = strstr(header->data, prefix);
- return dst ? dst + strlen(prefix) : NULL;
+ for (i = 0; i < ARRAY_SIZE(prefixes) && !dst; i++)
+ dst = strstr(header->data, prefixes[i]);
+
+ return dst ? dst + strlen(prefixes[--i]) : NULL;
}
static enum request

0 comments on commit 03443da

Please sign in to comment.