3 # situation: work tree is unknown rev
4 # arguments: git rev-list arguments
5 # we now identify the one revision with least differences
19 if $use_worktree; then
20 echo >&2 "Saving index..."
21 oldindex=`git write-tree`
23 trap 'echo >&2 "Restoring index..."; git reset "$oldindex" .' EXIT
24 trap 'exit 1' INT TERM
26 echo >&2 "Creating index..."
30 echo >&2 "Listing candidates..."
31 allrevs=`git rev-list "$@"`
33 echo >&2 "Evaluating candidates..."
36 for rev in $allrevs; do
37 score=`git diff $diffopts --cached "$rev" | wc -l`
38 if [ -z "$bestrevscore" ] || [ "$score" -lt "$bestrevscore" ]; then
39 echo >&2 "Improved to $rev (score: $score)"
47 git diff $diffopts --cached "$bestrev" >&2