3 # situation: work tree is unknown rev
4 # arguments: git rev-list arguments
5 # we now identify the one revision with least differences
9 echo "Usage: $0 [--cached] git-rev-list args..."
11 echo "Example: $0 --all"
12 echo "Compares current work tree to all revisions, and identifies the"
15 echo "Example: $0 --cached v1.0..HEAD"
16 echo "Compares current work tree to all revisions between v1.0 and HEAD,"
17 echo "and identifies the closest match."
41 if $use_worktree; then
42 echo >&2 "Saving index..."
43 oldindex=`git write-tree`
45 trap 'echo >&2 "Restoring index..."; git reset "$oldindex" .' EXIT
46 trap 'exit 1' INT TERM
48 echo >&2 "Creating index..."
52 echo >&2 "Listing candidates..."
53 allrevs=`git rev-list "$@"`
55 echo >&2 "Evaluating candidates..."
58 for rev in $allrevs; do
59 score=`git diff $diffopts --cached "$rev" | wc -l`
60 if [ -z "$bestrevscore" ] || [ "$score" -lt "$bestrevscore" ]; then
61 echo >&2 "Improved to $rev (score: $score)"
64 if [ $score -eq 0 ]; then
71 if [ -z "$bestrevscore" ]; then
76 git diff $diffopts --cached "$bestrev" >&2