2 # Copyright (c) 2008, Nanako Shiraishi
3 # Prime rerere database from existing merge commits
7 usage: $me [--overwrite] <rev-list-args>
9 -h, --help show the help
10 -o, --overwrite overwrite any existing rerere cache
41 # Overwrite or help options are not valid except as first arg
56 .
"$(git --exec-path)/git-sh-setup"
60 # Remember original branch
61 branch
=$
(git symbolic-ref
-q HEAD
) ||
62 original_HEAD
=$
(git rev-parse
--verify HEAD
) ||
{
63 echo >&2 "Not on any branch and no commit yet?"
67 mkdir
-p "$GIT_DIR/rr-cache" ||
exit
69 git rev-list
--parents "$@" |
70 while read commit parent1 other_parents
72 if test -z "$other_parents"
77 git checkout
-q "$parent1^0"
78 if git merge
$other_parents >/dev
/null
2>&1
83 if test $overwrite = 1
87 if test -s "$GIT_DIR/MERGE_RR"
89 git show
-s --pretty=format
:"Learning from %h %s" "$commit"
91 git checkout
-q $commit -- .
99 git checkout
"$original_HEAD"
101 git checkout
"${branch#refs/heads/}"