From 49a6af92db204536f6752583c1c24a34c1070c8c Mon Sep 17 00:00:00 2001
From: Caleb Maclennan <caleb@alerque.com>
Date: Sat, 19 Oct 2013 19:11:52 -0600
Subject: [PATCH] add hooks to enable auto handing of merge conflicts

These hooks before and after the actual checkout process
will enable a pair of hook scripts to automatically handle
conflicts and potentially allow the checkout of repositories
over existing file sets
---
 doc/hooks | 6 ++++++
 vcsh      | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/doc/hooks b/doc/hooks
index 54ff795..30cd373 100644
--- a/doc/hooks
+++ b/doc/hooks
@@ -14,6 +14,12 @@ Available hooks are:
 * post-enter
 * pre-init
 * post-init
+* pre-merge
+    Use this hook to detect and handle merge conflicts before vcsh's native code
+	finds and errors on them. This is useful for allowing clones on top of existing
+	files.
+* post-merge
+    Use this hook to finish handling any merge conflicts found in the pre-merge hook.
 * pre-pull
 * post-pull
 * pre-push
diff --git a/vcsh b/vcsh
index 6ce5320..a6d8213 100755
--- a/vcsh
+++ b/vcsh
@@ -152,6 +152,7 @@ clone() {
 		exit
 	fi
 	git fetch
+	hook pre-merge
 	git ls-tree -r --name-only origin/master | (while read object; do
 		[ -e "$object" ] &&
 			error "'$object' exists." &&
@@ -161,6 +162,7 @@ clone() {
 		fatal "will stop after fetching and not try to merge!
   Once this situation has been resolved, run 'vcsh run $VCSH_REPO_NAME git pull' to finish cloning." 17
 	git merge origin/master
+	hook post-merge
 	hook post-clone
 	retire
 	hook post-clone-retired
-- 
GitLab