Skip to content

Commit

Permalink
Don't require index line to render correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
xixixao committed Feb 10, 2016
1 parent 11213ba commit d243362
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions diff-so-fancy
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ color_code_regex=$'(\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)[m|K])?'
reset_color="\x1B\[m"
dim_magenta="\x1B\[38;05;146m"

git_index_line_pattern="^($color_code_regex)index .*"

format_diff_header () {
# simplify the unified patch diff header
sed -E "s/^($color_code_regex)diff --git .*$//g" | \
sed -E "s/^($color_code_regex)index .*$/\
\1$(print_horizontal_rule)/g" | \
sed -E "/$git_index_line_pattern/{N;s/$git_index_line_pattern\n//}" | \
sed -E "s/^($color_code_regex)\-\-\-(.*)$/\1$(print_horizontal_rule)\\
\-\-\-\5/g" |
sed -E "s/^($color_code_regex)\+\+\+(.*)$/\1\+\+\+\5\\
\1$(print_horizontal_rule)/g"
}
Expand Down

0 comments on commit d243362

Please sign in to comment.