Skip to content

Commit aec68c3

Browse files
committed
Merge branch 'rg/rerere-train-overwrite'
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
2 parents 1896562 + ad53bf7 commit aec68c3

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

contrib/rerere-train.sh

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,56 @@
33
# Prime rerere database from existing merge commits
44

55
me=rerere-train
6-
USAGE="$me rev-list-args"
6+
USAGE=$(cat <<-EOF
7+
usage: $me [--overwrite] <rev-list-args>
8+
9+
-h, --help show the help
10+
-o, --overwrite overwrite any existing rerere cache
11+
EOF
12+
)
713

814
SUBDIRECTORY_OK=Yes
9-
OPTIONS_SPEC=
15+
16+
overwrite=0
17+
18+
while test $# -gt 0
19+
do
20+
opt="$1"
21+
case "$opt" in
22+
-h|--help)
23+
echo "$USAGE"
24+
exit 0
25+
;;
26+
-o|--overwrite)
27+
overwrite=1
28+
shift
29+
break
30+
;;
31+
--)
32+
shift
33+
break
34+
;;
35+
*)
36+
break
37+
;;
38+
esac
39+
done
40+
41+
# Overwrite or help options are not valid except as first arg
42+
for opt in "$@"
43+
do
44+
case "$opt" in
45+
-h|--help)
46+
echo "$USAGE"
47+
exit 0
48+
;;
49+
-o|--overwrite)
50+
echo "$USAGE"
51+
exit 0
52+
;;
53+
esac
54+
done
55+
1056
. "$(git --exec-path)/git-sh-setup"
1157
require_work_tree
1258
cd_to_toplevel
@@ -34,6 +80,10 @@ do
3480
# Cleanly merges
3581
continue
3682
fi
83+
if test $overwrite = 1
84+
then
85+
git rerere forget .
86+
fi
3787
if test -s "$GIT_DIR/MERGE_RR"
3888
then
3989
git show -s --pretty=format:"Learning from %h %s" "$commit"

0 commit comments

Comments
 (0)