Skip to content

Commit

Permalink
diff: extract header line lookup
Browse files Browse the repository at this point in the history
This commit moves the code used to find the corresponding diff header
from a diff stat to its own function. This will allow to retrieve the
filename from a diff stat, even if the filename is truncated.

Refs jonas#404

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
  • Loading branch information
vivien committed Apr 26, 2015
1 parent b9fa048 commit 6348fac
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ diff_find_stat_entry(struct view *view, struct line *line, enum line_type type)
line == find_prev_line_by_type(view, marker, LINE_DIFF_HEADER);
}

enum request
diff_common_enter(struct view *view, enum request request, struct line *line)
static struct line *
diff_find_header_from_stat(struct view *view, struct line *line)
{
if (line->type == LINE_DIFF_STAT) {
int file_number = 0;
Expand All @@ -152,6 +152,17 @@ diff_common_enter(struct view *view, enum request request, struct line *line)
}
}

return line;
}

return NULL;
}

enum request
diff_common_enter(struct view *view, enum request request, struct line *line)
{
if (line->type == LINE_DIFF_STAT) {
line = diff_find_header_from_stat(view, line);
if (!line) {
report("Failed to find file diff");
return REQ_NONE;
Expand Down

0 comments on commit 6348fac

Please sign in to comment.