git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3] contrib/rerere-train: optionally overwrite existing resolutions

From
Raman Gupta <rocketraman@gmail.com>
Date
Jul 26, 2017, 19:08 UTC
Message-ID
<3a11f2f2-9fa1-bd7b-44dc-141c7fff8127@gmail.com>
In-Reply-To
<xmqqmv7rrs45.fsf@gitster.mtv.corp.google.com>

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>
---
 contrib/rerere-train.sh | 54 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 2 deletions(-)
diff --git a/contrib/rerere-train.sh b/contrib/rerere-train.sh
index 52ad9e4..eeee45d 100755
--- a/contrib/rerere-train.sh
+++ b/contrib/rerere-train.sh
@@ -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
@@ -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"
-- 
2.9.4
Previous: Raman Gupta
Message 8 of 8 in “contrib: rerere-train overwrites existing resolutions”
  1. contrib: rerere-train overwrites existing resolutionsRaman Gupta, Jul 25, 2017
  2. Junio C HamanoJul 25, 2017
  3. contrib/rerere-train: optionally overwrite existing resolutionsRaman Gupta, Jul 25, 2017
  4. Junio C HamanoJul 26, 2017
  5. Raman GuptaJul 26, 2017
  6. Junio C HamanoJul 26, 2017
  7. Raman GuptaJul 28, 2017
  8. contrib/rerere-train: optionally overwrite existing resolutionsRaman Gupta, Jul 26, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.