Browse Source

contrib/rerere-train: optionally overwrite existing resolutions

Provide the user an option to overwrite existing resolutions using an
`--overwrite` flag. This might be used, for example, if the user knows
that they already have an entry in their rerere cache for a conflict,
but wish to drop it and retrain based on the merge commit(s) passed to
the rerere-train script.

Signed-off-by: Raman Gupta <rocketraman@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Raman Gupta 8 years ago committed by Junio C Hamano
parent
commit
ad53bf79aa
  1. 54
      contrib/rerere-train.sh

54
contrib/rerere-train.sh

@ -3,10 +3,56 @@
# Prime rerere database from existing merge commits # Prime rerere database from existing merge commits


me=rerere-train 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 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" . "$(git --exec-path)/git-sh-setup"
require_work_tree require_work_tree
cd_to_toplevel cd_to_toplevel
@ -34,6 +80,10 @@ do
# Cleanly merges # Cleanly merges
continue continue
fi fi
if test $overwrite = 1
then
git rerere forget .
fi
if test -s "$GIT_DIR/MERGE_RR" if test -s "$GIT_DIR/MERGE_RR"
then then
git show -s --pretty=format:"Learning from %h %s" "$commit" git show -s --pretty=format:"Learning from %h %s" "$commit"

Loading…
Cancel
Save