New REuse REcorded REsolve tool.
RFC 1/1 New REuse REcorded REsolve tool.
What follows is a draft implementation of a different git-rerere tool.
Please use caution when testing this on any real repository. It has been very lightly tested and only for a small handful of cases. Its probably going to fail on something that I haven't tried yet. It could overwrite entries in your current index, making it possible to commit a file with <<<< === >>>> conflict markers in it. :-)
My goal with this tool is to get something that git-merge can use as a pre-filter to the current git-rerere and by which git-merge can automatically reuse prior resolutions on a more predictable basis then what happens with git-rerere today. Ideally I want git-rerere2 to make the merge commit for me if it was successful at resolving all unmerged entries and thus have git-merge return with an exit code of 0 rather than 1.
Lots of TODOs still exist:
- Prune cache at some threshold in size/age.
- Anchor prior recorded merge commits along a special ref (to prevent them from pruning while they are still in the cache).
- Automatically create merge commit if successfully resolved.
- Test cases.
- More/better documentation.
- Friendly error handling on invalid command line option combinations.
And all of the above means no signoff yet. :-)
-->8--
New REuse REcorded REsolve tool.
git-rerere2 attempts to remember lines of development that have been merged together before by tracking merge commits in .git/rr2-cache. When two lines of development are merged together again in the future git-rerere2 searches its cache for the most recent merge commit between the two branches and tries to select the merge commit that contains the maximum number of commits from each branch.
If such a commit exists in the cache then git-rerere2 attempts to resolve any unmerged index entries by comparing the conflicted stage 1/2/3 from the chosen prior merge against the current index; if stage 1 is unchanged and stage 2/3 are unchanged (but possibly permuted in order) then the working directory (and current index) are updated with resolved file as committed in the chosen commit.
Unlike git-rerere, git-rerere2 can remember and reuse structual modifications (adds/deletes, mode changes, type changes) as well as reuse binary file resolutions which the standard RCS merge tool wouldn't have been able to process. However, also unlike git-rerere, git-rerere2 does not attempt to merge the contents of a file.
--- .gitignore | 1 Makefile | 2 git-commit.sh | 4 + git-merge.sh | 4 + git-rerere2.perl | 281 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 291 insertions(+), 1 deletions(-)
.gitignore +1 -0
@@ -87,6 +87,7 @@ git-repack git-repo-config git-request-pull git-rerere +git-rerere2 git-reset git-resolve git-rev-list
Makefile +1 -1
@@ -147,7 +147,7 @@ SCRIPT_SH = \ SCRIPT_PERL = \ git-archimport.perl git-cvsimport.perl git-relink.perl \ - git-shortlog.perl git-rerere.perl \ + git-shortlog.perl git-rerere.perl git-rerere2.perl \ git-annotate.perl git-cvsserver.perl \ git-svnimport.perl git-mv.perl git-cvsexportcommit.perl \ git-send-email.perl git-svn.perl
git-commit.sh +4 -0
@@ -742,6 +742,10 @@ else fi ret="$?" rm -f "$GIT_DIR/COMMIT_MSG" "$GIT_DIR/COMMIT_EDITMSG" "$GIT_DIR/SQUASH_MSG" +if test -d "$GIT_DIR/rr2-cache" +then + git-rerere2 --record +fi if test -d "$GIT_DIR/rr-cache" then git-rerere
git-merge.sh +4 -0
@@ -375,6 +375,10 @@ Conflicts: sed -e 's/^[^ ]* / /' | uniq } >>"$GIT_DIR/MERGE_MSG" + if test -d "$GIT_DIR/rr2-cache" + then + git-rerere2 --reset --remember-unmerged --reuse "$head_arg" "$@" + fi if test -d "$GIT_DIR/rr-cache" then git-rerere
git-rerere2.perl new file +281 -0
281 lines not on this page · raw message
Signature · 1 line
1.4.1.gd3d5