<commit_before>#!/usr/bin/env zsh
WT=$(mktemp -d -u worktree-diff.XXXXXX)

trap 'rm -rf ${WT}' EXIT SIGHUP SIGTERM

macros=avadanlik/viachristus.m4

git worktree add ${WT} ${1}

m4 ${macros} ${WT}/${2} | git hash-object --stdin -w | read A
m4 ${macros} ${2} | git hash-object --stdin -w | read B

if git diff ${A}..${B} --quiet; then
    git show ${B}
else
    git diff --no-color --word-diff -U99999 ${A}..${B} |
        sed -e '1,5d' |
            perl -pn \
                -e 's/\[-[^\]]*?-\]\{\+([^\}]*?==.*?)\+\}/\1/g' |
            sed \
                -e 's/\[-/{--/g' -e 's/-\]/--}/g' \
                -e 's/{+/{++/g' -e 's/+}/++}/g'
fi<commit_msg>Clean up git worktrees<commit_after>#!/usr/bin/env zsh
WT=$(mktemp -d -u worktree-diff.XXXXXX)

trap 'rm -rf ${WT}' EXIT SIGHUP SIGTERM

macros=avadanlik/viachristus.m4

git worktree prune
git worktree add --detach ${WT} ${1}

m4 ${macros} ${WT}/${2} | git hash-object --stdin -w | read A
m4 ${macros} ${2} | git hash-object --stdin -w | read B

if git diff ${A}..${B} --quiet; then
    git show ${B}
else
    git diff --no-color --word-diff -U99999 ${A}..${B} |
        sed -e '1,5d' |
            perl -pn \
                -e 's/\[-[^\]]*?-\]\{\+([^\}]*?==.*?)\+\}/\1/g' |
            sed \
                -e 's/\[-/{--/g' -e 's/-\]/--}/g' \
                -e 's/{+/{++/g' -e 's/+}/++}/g'
fi
{'fraction_non_alphanumeric': 0.2774907749077491, 'fraction_numerical': 0.020664206642066422, 'mean_word_length': 1.669291338582677, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1044240', 'n_tokens_mistral': 611, 'n_tokens_neox': 585, 'n_words': 146}