Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
diff-highlight: split code into module
The diff-so-fancy project is also written in perl, and most of its users pipe diffs through both diff-highlight and diff-so-fancy. It would be nice if this could be done in a single script. So let's pull most of diff-highlight's code into its own module which can be used by diff-so-fancy. In addition, we'll abstract a few basic items like reading from stdio so that a script using the module can do more processing before or after diff-highlight handles the lines. See the README update for more details. One small downside is that the diff-highlight script must now be built using the Makefile. There are ways around this, but it quickly gets into perl arcana. Let's go with the simple solution. As a bonus, our Makefile now respects the PERL_PATH variable if it is set. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
Showing
5 changed files
with
82 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
shebang.perl | ||
diff-highlight |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
# nothing to build | ||
all: | ||
all: diff-highlight | ||
|
||
test: | ||
PERL_PATH = /usr/bin/perl | ||
-include ../../config.mak | ||
|
||
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) | ||
|
||
diff-highlight: shebang.perl DiffHighlight.pm diff-highlight.perl | ||
cat $^ >$@+ | ||
chmod +x $@+ | ||
mv $@+ $@ | ||
|
||
shebang.perl: FORCE | ||
@echo '#!$(PERL_PATH_SQ)' >$@+ | ||
@cmp $@+ $@ >/dev/null 2>/dev/null || mv $@+ $@ | ||
|
||
test: all | ||
$(MAKE) -C t | ||
|
||
.PHONY: FORCE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package main; | ||
|
||
# Some scripts may not realize that SIGPIPE is being ignored when launching the | ||
# pager--for instance scripts written in Python. | ||
$SIG{PIPE} = 'DEFAULT'; | ||
|
||
DiffHighlight::highlight_stdin(); | ||
exit 0; |