{"thread":{"id":"65685","subject":"[PATCH 0/1] bugfix git subtree split","startedAt":"2026-05-24T21:24:04Z","lastAt":"2026-05-24T21:24:08Z","messageCount":2,"participants":["Roland Conybeare"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"544011","messageId":"20260524212339.1493145-1-rconybeare@gmail.com","threadId":"65685","inReplyTo":null,"subject":"[PATCH 0/1] bugfix git subtree split","fromName":"Roland Conybeare","fromEmail":"rconybeare@gmail.com","sentAt":"2026-05-24T21:23:38Z","receivedAt":"2026-05-24T21:24:04Z","isPatch":true,"body":"I have a project that combines multiple independent repos\ninto an unmbrella repo, relying on git subtree.\nEncountered a unrecoverable fatal error\nfrom 'git subtree split' with error\n\n    fatal: cache for <hash> already exists!\n\nProblem arises because history to be split contains merge commits\nthat cause DAG traversal to consider the same umbrella commit on\nmultiple paths. The fatal triggers when 'git subtree split' tries\nto cache the same commit twice; enclosed patch prunes these duplicate\npaths.\n\nRoland Conybeare (1):\n  subtree: fix cache_set failure on commit reachable by multiple paths\n\n contrib/subtree/git-subtree.sh | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)\n\n\nbase-commit: 6a4418c36d6bad69a599044b3cf49dcbd049cb45\n--\n2.50.1\n"},{"id":"544012","messageId":"20260524212339.1493145-2-rconybeare@gmail.com","threadId":"65685","inReplyTo":"20260524212339.1493145-1-rconybeare@gmail.com","subject":"[PATCH 1/1] subtree: fix cache_set failure on commit reachable by multiple paths","fromName":"Roland Conybeare","fromEmail":"rconybeare@gmail.com","sentAt":"2026-05-24T21:23:39Z","receivedAt":"2026-05-24T21:24:08Z","isPatch":true,"body":"When splitting a subtree, committs that do not intersect prefix\nreceive identity mapping (oldrev -> oldrev). If such commit\nis reachable by multiple paths in the revision DAG, the cache_set()\nfunction may be called twice for the same (oldrev -> newrev) pair.\n\nThis triggers fatal error \"cache for <hash> already exists\"\n\nBugfix is to make cache_set() idempotent when the same\n(oldrev -> newrev) pair appears multiple times.\n\nSigned-off-by: Roland Conybeare <rconybeare@gmail.com>\n---\n contrib/subtree/git-subtree.sh | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex 791fd8260c..64590e05e0 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -343,7 +343,13 @@ cache_set () {\n \t\ttest \"$oldrev\" != \"latest_new\" &&\n \t\ttest -e \"$cachedir/$oldrev\"\n \tthen\n-\t\tdie \"fatal: cache for $oldrev already exists!\"\n+\t\texisting=$(cat \"$cachedir/$oldrev\")\n+\t\tif test \"$existing\" = \"$newrev\"\n+\t\tthen\n+\t\t\treturn\n+\t\telse\n+\t\t\tdie \"fatal: cache for $oldrev already exists!\"\n+\t\tfi\n \tfi\n \techo \"$newrev\" >\"$cachedir/$oldrev\"\n }\n-- \n2.50.1\n\n"}]}