pr-git-1452/john-cai/jc/attr-diff-algo-v4
tagged this
20 Feb 21:04
When a repository contains different kinds of files, it may be desirable to use different algorithms based on file type. This is currently not feasible through the command line or using git configs. However, we can leverage the fact that gitattributes are path aware. Teach the diff machinery to check gitattributes when diffing files by using the existing diff. scheme, and add an "algorithm" type to the external driver config. Change since V3: * cleaned up documentation, typos * minor cleanup such as if statement ordering, and overly long lines Changes since V2: * minor clean up and variable renaming * avoid parsing attribute files for the driver if the diff algorithm is set through the command line Changes since V1: * utilize the existing diff.<driver>.* scheme where the driver is defined in gitattributes, but the algorithm is defined in the gitconfig. To address some of the performance concerns in the previous series, a benchmark shows that now only a minor performance penalty is incurred, now that we are no longer adding an additional attributes parsing call: $ echo "*.[ch] diff=other" >> .gitattributes $ hyperfine -r 10 -L a git-bin-wrapper,git '{a} -c diff.other.algorithm=myers diff v2.0.0 v2.28.0' Benchmark 1: git-bin-wrapper -c diff.other.algorithm=myers diff v2.0.0 v2.28.0 Time (mean ± σ): 716.3 ms ± 3.8 ms [User: 660.2 ms, System: 50.8 ms] Range (min … max): 709.8 ms … 720.6 ms 10 runs Benchmark 2: git -c diff.other.algorithm=myers diff v2.0.0 v2.28.0 Time (mean ± σ): 704.3 ms ± 2.9 ms [User: 656.6 ms, System: 44.3 ms] Range (min … max): 700.1 ms … 708.6 ms 10 runs Summary 'git -c diff.other.algorithm=myers diff v2.0.0 v2.28.0' ran 1.02 ± 0.01 times faster than 'git-bin-wrapper -c diff.other.algorithm=myers diff v2.0.0 v2.28.0' John Cai (2): diff: consolidate diff algorithm option parsing diff: teach diff to read algorithm from diff driver Documentation/gitattributes.txt | 31 ++++++++++++ diff.c | 90 ++++++++++++++++++++++++--------- diff.h | 1 + t/lib-diff-alternative.sh | 38 +++++++++++++- userdiff.c | 4 +- userdiff.h | 1 + 6 files changed, 140 insertions(+), 25 deletions(-) base-commit: c867e4fa180bec4750e9b54eb10f459030dbebfd Submitted-As: https://lore.kernel.org/git/pull.1452.v4.git.git.1676927082.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.1452.git.git.1675568781.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.1452.v2.git.git.1676410819.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.1452.v3.git.git.1676665285.gitgitgadget@gmail.com
Assets 2
-
2023-02-20T21:04:42Z -
2023-02-20T21:04:42Z -