From 3d810726afcd53590f28fa7fcb8b4c649ae6b7c3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Jul 2023 15:43:29 -0400 Subject: [PATCH] diffdriver --text support options for diff Sponsored-by: KDM on Patreon --- Command/DiffDriver.hs | 12 +++++++----- doc/git-annex-diffdriver.mdwn | 3 ++- doc/todo/Improving_diffdriver_--text.mdwn | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Command/DiffDriver.hs b/Command/DiffDriver.hs index c63994d8ab..d4057763ac 100644 --- a/Command/DiffDriver.hs +++ b/Command/DiffDriver.hs @@ -70,7 +70,9 @@ serializeReq req@(Req {}) = map Param parseReq :: Options -> (Req, Differ) parseReq opts - | textDiff opts = (mk (restOptions opts), textDiffer) + | textDiff opts = case separate (== "--") (restOptions opts) of + (_,[]) -> (mk (restOptions opts), textDiffer []) + (ps,rest) -> (mk rest, textDiffer ps) | otherwise = case separate (== "--") (restOptions opts) of (c:ps, l) -> (mk l, externalDiffer c ps) ([],_) -> badopts @@ -117,13 +119,13 @@ fixupReq req@(Req {}) = externalDiffer :: String -> [String] -> Differ externalDiffer c ps = \req -> boolSystem c (map Param ps ++ serializeReq req ) -textDiffer :: Differ -textDiffer req = do +textDiffer :: [String] -> Differ +textDiffer diffopts req = do putStrLn ("diff a/" ++ rPath req ++ " b/" ++ rPath req) -- diff exits nonzero on difference, so ignore exit status - void $ boolSystem "diff" + void $ boolSystem "diff" $ [ Param "-u" , Param (rOldFile req) , Param (rNewFile req) - ] + ] ++ map Param diffopts return True diff --git a/doc/git-annex-diffdriver.mdwn b/doc/git-annex-diffdriver.mdwn index f0915b0de2..c2c2537cf5 100644 --- a/doc/git-annex-diffdriver.mdwn +++ b/doc/git-annex-diffdriver.mdwn @@ -4,7 +4,7 @@ git-annex diffdriver - git diff driver # SYNOPSIS -git annex diffdriver --text +git annex diffdriver --text [-- --opts --] git annex diffdriver `-- cmd --opts --` @@ -42,6 +42,7 @@ set `GIT_EXTERNAL_DIFF="git-annex diffdriver -- j-c-diff --"` # OPTIONS To diff text files with diff(1), use the "--text" option. +To pass additional options to diff(1), use eg "--text -- --color --" To use an external diff driver command, the options must start with "--" followed by the diff driver command, its options, and another "--" diff --git a/doc/todo/Improving_diffdriver_--text.mdwn b/doc/todo/Improving_diffdriver_--text.mdwn index 36423d5aed..4ad12ff20c 100644 --- a/doc/todo/Improving_diffdriver_--text.mdwn +++ b/doc/todo/Improving_diffdriver_--text.mdwn @@ -28,3 +28,5 @@ How about having `git annex diffdriver --text` always using `diff --text`? That Thanks again a ton for git-annex, the Tübix2023-Workshop was well appreciated and lots of fun. 👍 Yann + +> [[done]] --[[Joey]]