Inspired by the eckes suggestion , I cracked the following shell script:
#!/bin/sh
if [ "$#" -lt 1 ]; then
echo "Usage: $0 path-to-export [rev-list-options...]"
exit 1
fi
alt_work_tree=$1
shift
git rev-list "$@" | {
min_changes=$(git --work-tree="$alt_work_tree" status --porcelain | wc -l)
closest_revs=$(git rev-parse HEAD)
lines=0
while read revision; do
git checkout -q "$revision"
n_changes=$(git --work-tree="$alt_work_tree" status --porcelain | wc -l)
if [ "$n_changes" -lt "$min_changes" ]; then
min_changes=$n_changes
closest_revs=$revision
elif [ "$n_changes" -eq "$min_changes" ]; then
closest_revs="$closest_revs $revision"
fi
lines=$((lines + 1))
printf "rev: %s n: %s min_changes: %s \r" "$revision" "$lines" "$min_changes"
done
echo
echo "Number of changes left: $min_changes"
echo "Possible revisions: $closest_revs"
echo "Checking out: ${closest_revs%% *}"
git checkout -q "${closest_revs%% *}"
}
In one case, I tried to find a fix that matches, in the other case it found something that makes sense, and there was no exact match, so I think it is doing its job.
script , , . git status .
, .