Skip to content

Commit

Permalink
Merge branch 'rg/rerere-train-overwrite'
Browse files Browse the repository at this point in the history
The "rerere-train" script (in contrib/) learned the "--overwrite"
option to allow overwriting existing recorded resolutions.

* rg/rerere-train-overwrite:
  contrib/rerere-train: optionally overwrite existing resolutions
  • Loading branch information
gitster committed Aug 11, 2017
2 parents 1896562 + ad53bf7 commit aec68c3
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions contrib/rerere-train.sh
Expand Up @@ -3,10 +3,56 @@
# Prime rerere database from existing merge commits

me=rerere-train
USAGE="$me rev-list-args"
USAGE=$(cat <<-EOF
usage: $me [--overwrite] <rev-list-args>
-h, --help show the help
-o, --overwrite overwrite any existing rerere cache
EOF
)

SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=

overwrite=0

while test $# -gt 0
do
opt="$1"
case "$opt" in
-h|--help)
echo "$USAGE"
exit 0
;;
-o|--overwrite)
overwrite=1
shift
break
;;
--)
shift
break
;;
*)
break
;;
esac
done

# Overwrite or help options are not valid except as first arg
for opt in "$@"
do
case "$opt" in
-h|--help)
echo "$USAGE"
exit 0
;;
-o|--overwrite)
echo "$USAGE"
exit 0
;;
esac
done

. "$(git --exec-path)/git-sh-setup"
require_work_tree
cd_to_toplevel
Expand Down Expand Up @@ -34,6 +80,10 @@ do
# Cleanly merges
continue
fi
if test $overwrite = 1
then
git rerere forget .
fi
if test -s "$GIT_DIR/MERGE_RR"
then
git show -s --pretty=format:"Learning from %h %s" "$commit"
Expand Down

0 comments on commit aec68c3

Please sign in to comment.