git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Taylor Jones via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Taylor Jones <tjones629@gmail.com>, tjones629 <tjones629@gmail.com>
Subject: [PATCH] subtree : fix split output containing unrelated history
Date: Thu, 04 Feb 2021 18:25:36 +0000	[thread overview]
Message-ID: <pull.867.git.1612463137244.gitgitgadget@gmail.com> (raw)

From: tjones629 <tjones629@gmail.com>

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.

Signed-off-by: Taylor Jones <tjones629@gmail.com>
---
    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(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 868e18b9a1ab..f1b8a3b2e74c 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -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
-- 
gitgitgadget

                 reply	other threads:[~2021-02-04 18:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.867.git.1612463137244.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=tjones629@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).