I have used the answer from Access the original label in cleveref's \crefformat to access the label of a cleveref reference. This worked fine until I through latexdiff into the game. Now, my highly simplified diff result looks like this:
\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{cleveref}
% https://tex.stackexchange.com/questions/319410/
\usepackage{xpatch}
\makeatletter
\apptocmd{\cref@getref}{\xdef\@lastusedlabel{#1}}{}{error}
\crefformat{section}{the #2``\nameref*{\@lastusedlabel}''#3 section}
\makeatother
% latexdiff preamble
\RequirePackage[normalem]{ulem}
\providecommand{\DIFadd}[1]{\texorpdfstring{\DIFaddtex{#1}}{#1}}
\providecommand{\DIFaddtex}[1]{\uwave{#1}}
\begin{document}
\section{\DIFadd{Foo}}
\label{foo}
\DIFadd{\mbox{\cref{foo}}}
\end{document}
The error message is ! Dimension too large.
\UL@on ...UL@height \advance \UL@height -\ULdepth
My guess is that I need to \protect one of the commands, but I can't really tell which one.
\section{\DIFadd{Foo}}by\section{\protect\DIFadd{Foo}}does not change anything (I had tried that - forgot to mention it). Also, replacing\providecommand{\DIFadd}[1]{\texorpdfstring{\DIFaddtex{#1}}{#1}}by\DeclareRobustCommand{\DIFadd}[1]{\texorpdfstring{\DIFaddtex{#1}}{#1}}(or the same with\DIFaddtex) does not help. Not even doing all three does anything, it seems. – bers Dec 01 '16 at 00:24\DIFaddaround\mbox{\cref{foo}}. – Hood Chatham Dec 01 '16 at 03:19latexdiffputs. It would be hard for me to find out when to remove\DIFadd, automatically. – bers Dec 01 '16 at 03:21