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>
Raman Gupta committed
Jul 26, 2017 at 15:08 UTC
ad53bf79aa4ea20a8a94af9e2df5a8311ca1e55e
1 file changed
+52
-2
contrib/rerere-train.sh
+52
-2
@@ -3,10 +3,56 @@
3
# Prime rerere database from existing merge commits
4
5
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
+)
13
14
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
+
56
. "$(git --exec-path)/git-sh-setup"
57
require_work_tree
58
cd_to_toplevel
@@ -34,6 +80,10 @@ do
80
# Cleanly merges
81
continue
82
fi
83
+ if test $overwrite = 1
84
+ then
85
+ git rerere forget .
86
+ fi
87
if test -s "$GIT_DIR/MERGE_RR"
88
then
89
git show -s --pretty=format:"Learning from %h %s" "$commit"