Skip to contentSkip to conversation

subtree : fix split output containing unrelated history

PATCH New Taylor Jones via GitGitGadget 1 participant 1 message Feb 4, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 subtree : fix split output containing unrelated history

From: tjones629 <[email protected]>

When a subtree is deleted and re-added at the same location with the --squash arguement the history created by "git subtree split" will contain commits that do not affect the files in the given prefix resulting in an incorrect history for the subtree.

This commit fixes the issue by removing lines that create cache files for commits that did not contain the given prefix after new parent commits have been created. The history created by "git subtree split" with this change no longer contains unrelated commits or commits that occured before the subtree was removed and re-added.

---
Bugfix for subtree split function

This patch fixes a bug in the subtree split command. The bug can be reproduced by adding a squashed subtree to a repository then removing it and squash adding it again with the same prefix. This will result in the subtree split history containing every commit from the main repository instead of just the commits that affect the subtree.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-867%2Ftjones629%2Fbugfix-subtree_removal-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-867/tjones629/bugfix-subtree_removal-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/867

 contrib/subtree/git-subtree.sh | 4 ----
 1 file changed, 4 deletions(-)
contrib/subtree/git-subtree.sh +0 -4
index 868e18b9a1ab..f1b8a3b2e74c 100755
@@ -667,10 +667,6 @@ process_split_commit () {
 	if test -z "$tree"
 	then
 		set_notree "$rev"
-		if test -n "$newparents"
-		then
-			cache_set "$rev" "$rev"
-		fi
 		return
 	fi
 

base-commit: 71ca53e8125e36efbda17293c50027d31681a41f

Signature · 1 line
gitgitgadget