lib-log-graph: consolidate test_cmp_graph logic
Log graph comparision logic is duplicated many times in:
- t3430-rebase-merges.sh
- t4202-log.sh
- t4214-log-graph-octopus.sh
- t4215-log-skewed-merges.sh
Consolidate the core of the comparision and sanitization logic in
lib-log-graph, and use it to replace the existing tests.
While at it, lose the singular/plural transition magic from the
sanitize_output helper, which was necessary around 7f814632
("Use
correct grammar in diffstat summary line", 2012-02-01), that has
long outlived its usefulness.
Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
51ebf55b93
commit
989eea958b
22
t/lib-log-graph.sh
Executable file
22
t/lib-log-graph.sh
Executable file
@ -0,0 +1,22 @@
|
||||
# Helps shared by the test scripts for comparing log graphs.
|
||||
|
||||
sanitize_log_output () {
|
||||
sed -e 's/ *$//' \
|
||||
-e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
|
||||
-e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
|
||||
-e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
|
||||
-e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
|
||||
-e 's/index [0-9a-f]*\.\.[0-9a-f]*/index BEFORE..AFTER/'
|
||||
}
|
||||
|
||||
lib_test_cmp_graph () {
|
||||
git log --graph "$@" >output &&
|
||||
sed 's/ *$//' >output.sanitized <output &&
|
||||
test_i18ncmp expect output.sanitized
|
||||
}
|
||||
|
||||
lib_test_cmp_short_graph () {
|
||||
git log --graph --pretty=short "$@" >output &&
|
||||
sanitize_log_output >output.sanitized <output &&
|
||||
test_i18ncmp expect output.sanitized
|
||||
}
|
Reference in New Issue
Block a user