summaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
authorLibravatar Bo Yang <struggleyb.nku@gmail.com>2010-05-29 23:32:06 +0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2010-05-31 18:02:20 -0700
commit4297c0aeb5cc6b9c1c87d770c91e09ac2a837320 (patch)
tree324732eb9407dcbe426ecab6c4157e7249e646ef /perl
parentgraph.c: register a callback for graph output (diff)
downloadtgif-4297c0aeb5cc6b9c1c87d770c91e09ac2a837320.tar.xz
Make --color-words work well with --graph
'--color-words' algorithm can be described as: 1. collect a the minus/plus lines of a diff hunk, divided into minus-lines and plus-lines; 2. break both minus-lines and plus-lines into words and place them into two mmfile_t with one word for each line; 3. use xdiff to run diff on the two mmfile_t to get the words level diff; And for the common parts of the both file, we output the plus side text. diff_words->current_plus is used to trace the current position of the plus file which printed. diff_words->last_minus is used to trace the last minus word printed. For '--graph' to work with '--color-words', we need to output the graph prefix on each line of color words output. Generally, there are two conditions on which we should output the prefix. 1. diff_words->last_minus == 0 && diff_words->current_plus == diff_words->plus.text.ptr that is: the plus text must start as a new line, and if there is no minus word printed, a graph prefix must be printed. 2. diff_words->current_plus > diff_words->plus.text.ptr && *(diff_words->current_plus - 1) == '\n' that is: a graph prefix must be printed following a '\n' Signed-off-by: Bo Yang <struggleyb.nku@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'perl')
0 files changed, 0 insertions, 0 deletions