From: Ed Maste <emaste@freebsd.org>
To: git@vger.kernel.org
Subject: git-subtree split misbehaviour with a commit having empty ls-tree for the specified subdir
Date: Fri, 22 Nov 2019 11:55:47 -0500 [thread overview]
Message-ID: <CAPyFy2AsmaxU-BDf_teZJE5hiaVpTSZc8fftnuXPb_4-j7j5Fw@mail.gmail.com> (raw)
I encountered an issue while trying to use git subtree with the
FreeBSD svn->git mirror: I found that when "git subtree split"
encounters a commit with an empty "git ls-tree" for the subdirectory
being split, it ends up recording the original parent as the new
parent in the split history that's being created. This then leads to
unrelated history appearing in the split subtree.
Below is a shell script that demonstrates the issue - this is not the
precise case that I encountered in the FreeBSD repo, but the behaviour
is identical (and it doesn't take nearly 10 minutes to run). Running
the script and then "git log" of the commit printed by the final (git
subtree) command includes the unrelated history in dir2/.
It looks like this comes from the cache_set "$rev" "$rev" in
process_split_commit() added in 39f5fff0d53. This is under the
suspicious-looking "ugly. is there no better way to tell if this is a
subtree vs. a mainline commit? Does it matter" comment. However, I
don't yet understand enough of git-subtree's operation to propose a
fix.
--repro.sh--
#!/bin/sh
rm -rf subrepo-issue
mkdir -p subrepo-issue
cd subrepo-issue
git init .
mkdir -p dir1 dir2
touch dir1/file1 dir2/file2
git add dir1 dir2
git commit -m 'initial commit'
echo 'file2' > dir2/file2
git commit -m 'file2 modified' dir2/file2
git rm dir1/file1
git commit -m 'remove file1'
mkdir -p dir1
touch dir1/file1
git add dir1
git commit -m 'restore file1'
echo 'file1' > dir1/file1
git commit -m 'file1 modified' dir1/file1
git subtree split --prefix=dir1/
next reply other threads:[~2019-11-22 20:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-22 16:55 Ed Maste [this message]
2019-12-18 0:17 ` git-subtree split misbehaviour with a commit having empty ls-tree for the specified subdir Tom Clarkson
2019-12-18 10:23 ` Ed Maste
2019-12-19 0:57 ` Tom Clarkson
2019-12-20 15:56 ` Ed Maste
2019-12-22 14:01 ` Tom Clarkson
2020-01-21 22:36 ` Ed Maste
[not found] ` <DB65AE2F-12DE-43B7-8B20-4E173794CAF2@icloud.com>
2020-04-28 18:08 ` Ed Maste
2020-06-17 14:46 ` Ed Maste
2020-06-18 1:13 ` Tom Clarkson
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=CAPyFy2AsmaxU-BDf_teZJE5hiaVpTSZc8fftnuXPb_4-j7j5Fw@mail.gmail.com \
--to=emaste@freebsd.org \
--cc=git@vger.kernel.org \
/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).