{"thread":{"id":"15690","subject":"[PATCH] Add contrib/rerere-train script","startedAt":"2008-09-27T11:44:15Z","lastAt":"2008-09-29T12:39:26Z","messageCount":2,"participants":["Nanako Shiraishi","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"91740","messageId":"20080927204415.6117@nanako3.lavabit.com","threadId":"15690","inReplyTo":null,"subject":"[PATCH] Add contrib/rerere-train script","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2008-09-27T11:44:15Z","receivedAt":"2008-09-27T11:44:15Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"This script takes a range of commits (e.g. maint..next) as its arguments,\nrecreates merge commits in the range to prime rr-cache database.\n\nSigned-off-by: Nanako Shiraishi <nanako3@lavabit.com>\n---\n contrib/rerere-train.sh |   52 +++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 52 insertions(+), 0 deletions(-)\n create mode 100755 contrib/rerere-train.sh\n\ndiff --git a/contrib/rerere-train.sh b/contrib/rerere-train.sh\nnew file mode 100755\nindex 0000000..2cfe1b9\n--- /dev/null\n+++ b/contrib/rerere-train.sh\n@@ -0,0 +1,52 @@\n+#!/bin/sh\n+# Copyright (c) 2008, Nanako Shiraishi\n+# Prime rerere database from existing merge commits\n+\n+me=rerere-train\n+USAGE=\"$me rev-list-args\"\n+\n+SUBDIRECTORY_OK=Yes\n+OPTIONS_SPEC=\n+. git-sh-setup\n+require_work_tree\n+cd_to_toplevel\n+\n+# Remember original branch\n+branch=$(git symbolic-ref -q HEAD) ||\n+original_HEAD=$(git rev-parse --verify HEAD) || {\n+\techo >&2 \"Not on any branch and no commit yet?\"\n+\texit 1\n+}\n+\n+mkdir -p \"$GIT_DIR/rr-cache\" || exit\n+\n+git rev-list --parents \"$@\" |\n+while read commit parent1 other_parents\n+do\n+\tif test -z \"$other_parents\"\n+\tthen\n+\t\t# Skip non-merges\n+\t\tcontinue\n+\tfi\n+\tgit checkout -q \"$parent1^0\"\n+\tif git merge $other_parents >/dev/null 2>&1\n+\tthen\n+\t\t# Cleanly merges\n+\t\tcontinue\n+\tfi\n+\tif test -s \"$GIT_DIR/MERGE_RR\"\n+\tthen\n+\t\tgit show -s --pretty=format:\"Learning from %h %s\" \"$commit\"\n+\t\tgit rerere\n+\t\tgit checkout -q $commit -- .\n+\t\tgit rerere\n+\tfi\n+\tgit reset -q --hard\n+done\n+\n+if test -z \"$branch\"\n+then\n+\tgit checkout \"$original_HEAD\"\n+else\n+\tgit checkout \"${branch#refs/heads/}\"\n+fi\n-- \n1.6.0.2\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"},{"id":"91835","messageId":"alpine.DEB.1.00.0809291430050.16478@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"15690","inReplyTo":"20080927204415.6117@nanako3.lavabit.com","subject":"Re: [PATCH] Add contrib/rerere-train script","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-09-29T12:39:26Z","receivedAt":"2008-09-29T12:39:26Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 27 Sep 2008, Nanako Shiraishi wrote:\n\n> This script takes a range of commits (e.g. maint..next) as its \n> arguments, recreates merge commits in the range to prime rr-cache \n> database.\n\nCute idea.  However, I would _love_ to have this as an option to \ngit-rerere, which would work in memory only.\n\nThis is how I would do it (if I had enough time to play with Git):\n\n- teach merge_recursive_options not to write anything to the working \n  directory (should be relatively easy, as many parts of merge-recursive.c \n  already have no_wd/update_wd/!o->call_depth checks for that),\n\n- refactor handle_file() in rerere.c to provide an in-memory-only version,\n\n- teach rerere to call merge_recursive() with the in-memory-only option, \n  and then call the in-memory version of the handle_file() function for \n  all unmerged paths, using the resolutions from the given merge commit.\n\n- then teach this new function to take an arbitrary commit range (but only \n  handling the two-parent merges within it).\n\nCiao,\nDscho\n"}]}