lite icon indicating copy to clipboard operation
lite copied to clipboard

Commit hashes different between `splitsh-lite` and `git subtree split`

Open Blacksmoke16 opened this issue 4 years ago • 1 comments

I ran into an issue where the hashes are different between this lib and a standard subtree split. This is causing issues when trying to push the changes to a child repos, while using git subtree push works fine.

$ git version
git version 2.34.1

$ splitsh-lite --version
splitsh-lite version v1.0.1

This issue can be reproduced via this script using https://github.com/crystal-manyrepos/two (but also reproduces when using this repo for example):

mkdir mono
cd mono/
git init
touch README.md
git add -A
git commit -m "Initialize mono repo"

git subtree add --prefix=libs/two/ [email protected]:crystal-manyrepos/two.git master

splitsh-lite --scratch --prefix=libs/two && git subtree split --prefix=libs/two

More details below, but it seems like splitsh isn't gathering all the expected commits which results in the hash being different in the end. I'm not using --squash so I don't think it's related to https://github.com/splitsh/lite/issues/15. I actually also tried with that Docker image in that issue and same problem.

Output:

Initialized empty Git repository in /home/george/dev/git/crystal-many/mono/.git/
[master (root-commit) 1a613f0] Initialize mono repo
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README.md
git fetch [email protected]:crystal-manyrepos/two.git master
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 20 (delta 3), reused 19 (delta 2), pack-reused 0
Unpacking objects: 100% (20/20), 4.01 KiB | 373.00 KiB/s, done.
From github.com:crystal-manyrepos/two
* branch            master     -> FETCH_HEAD
Added dir 'libs/two'
1 commits created, 5 commits traversed, in 6ms
c8f28643a1f9cb160a075e1672addd1a30d63d6b
88ce77827ecd614fcca6e2bbb6983999daab2367

Debug output:

$ splitsh-lite --prefix=libs/two/ --scratch --debug
2021/12/12 10:25:17 Splitting refs/heads/master
2021/12/12 10:25:17   From "libs/two/" to "ROOT"
2021/12/12 10:25:17 Processing commit: 1a613f0abf4fd5ce57a6d7ec2c9e70bef0c61127
2021/12/12 10:25:17   parents:
2021/12/12 10:25:17   newparents:
2021/12/12 10:25:17 Processing commit: 6e5fa9f03d5350ebee79b6899de1072a3dd126e9
2021/12/12 10:25:17   parents:
2021/12/12 10:25:17   newparents:
2021/12/12 10:25:17 Processing commit: 686027d84b670d9fa7861fe9b16c24a79428a2d4
2021/12/12 10:25:17   parents: 6e5fa9f03d5350ebee79b6899de1072a3dd126e9
2021/12/12 10:25:17   newparents:
2021/12/12 10:25:17 Processing commit: 88ce77827ecd614fcca6e2bbb6983999daab2367
2021/12/12 10:25:17   parents: 686027d84b670d9fa7861fe9b16c24a79428a2d4
2021/12/12 10:25:17   newparents:
2021/12/12 10:25:17 Processing commit: 868052990df6cddf09cc35c4bcbf63c4ade5c66c
2021/12/12 10:25:17   parents: 1a613f0abf4fd5ce57a6d7ec2c9e70bef0c61127 88ce77827ecd614fcca6e2bbb6983999daab2367
2021/12/12 10:25:17   newparents:
2021/12/12 10:25:17   tree is: 774bd095bf0c560acd754e6351f389fe2d1451f0
2021/12/12 10:25:17   copy commit "868052990df6cddf09cc35c4bcbf63c4ade5c66c" "774bd095bf0c560acd754e6351f389fe2d1451f0" ""
2021/12/12 10:25:17   newrev is: c8f28643a1f9cb160a075e1672addd1a30d63d6b
1 commits created, 5 commits traversed, in 4ms
c8f28643a1f9cb160a075e1672addd1a30d63d6b

Git log (master):

$ git log
commit 868052990df6cddf09cc35c4bcbf63c4ade5c66c (HEAD -> master)
Merge: 1a613f0 88ce778
Author: George Dietrich <[email protected]>
Date:   Sun Dec 12 10:24:46 2021 -0500

Add 'libs/two/' from commit '88ce77827ecd614fcca6e2bbb6983999daab2367'

git-subtree-dir: libs/two
git-subtree-mainline: 1a613f0abf4fd5ce57a6d7ec2c9e70bef0c61127
git-subtree-split: 88ce77827ecd614fcca6e2bbb6983999daab2367

commit 1a613f0abf4fd5ce57a6d7ec2c9e70bef0c61127
Author: George Dietrich <[email protected]>
Date:   Sun Dec 12 10:24:45 2021 -0500

Initialize mono repo

commit 88ce77827ecd614fcca6e2bbb6983999daab2367
Author: George Dietrich <[email protected]>
Date:   Sat Dec 11 23:19:21 2021 -0500

Bump component versions

commit 686027d84b670d9fa7861fe9b16c24a79428a2d4
Author: George Dietrich <[email protected]>
Date:   Sat Dec 11 22:39:52 2021 -0500

Add .summary method

commit 6e5fa9f03d5350ebee79b6899de1072a3dd126e9
Author: George Dietrich <[email protected]>
Date:   Sat Dec 11 22:39:10 2021 -0500

Initial commit

Git log, branch created via splitsh:

$ splitsh-lite --prefix=libs/two/ --scratch --target=refs/heads/splitsh
1 commits created, 5 commits traversed, in 6ms
c8f28643a1f9cb160a075e1672addd1a30d63d6b

$ git co splitsh

$ git log
commit c8f28643a1f9cb160a075e1672addd1a30d63d6b (HEAD -> splitsh)
Author: George Dietrich <[email protected]>
Date:   Sun Dec 12 10:24:46 2021 -0500

Add 'libs/two/' from commit '88ce77827ecd614fcca6e2bbb6983999daab2367'

git-subtree-dir: libs/two
git-subtree-mainline: 1a613f0abf4fd5ce57a6d7ec2c9e70bef0c61127
git-subtree-split: 88ce77827ecd614fcca6e2bbb6983999daab2367

Git log, branch created via subtree split:

$ git subtree split -P libs/two -b subtree-split
Created branch 'subtree-split'
88ce77827ecd614fcca6e2bbb6983999daab2367

$ git co subtree-split

$ git log
commit 88ce77827ecd614fcca6e2bbb6983999daab2367 (HEAD -> subtree-split)
Author: George Dietrich <[email protected]>
Date:   Sat Dec 11 23:19:21 2021 -0500

Bump component versions

commit 686027d84b670d9fa7861fe9b16c24a79428a2d4
Author: George Dietrich <[email protected]>
Date:   Sat Dec 11 22:39:52 2021 -0500

Add .summary method

commit 6e5fa9f03d5350ebee79b6899de1072a3dd126e9
Author: George Dietrich <[email protected]>
Date:   Sat Dec 11 22:39:10 2021 -0500

Initial commit

Blacksmoke16 avatar Dec 12 '21 15:12 Blacksmoke16

Looking at using this (again), and still seeing differences in the hashes. The discussion in #26 indicates the differences are nothing to worry about, eventually.

In case it helps with debugging, here is a screenshot showing where things (start to) differ in my testcase. For this I split the 8.2 branch of https://github.com/neos/flow-development-collection into https://github.com/kdambekalns/flow/tree/8.2-splitsh.

git-difference-splitsh-lite

At point (1) the branches have the same "root", up to that point they are identical. Point (2) shows the first commits being different in both branches - the "same" PR being merged. In point (3) the PR branch (red) shows a difference, the merge of neos/flow-development-collection#1919 is missing in the splitsh-lite split…

Here is the original history bit:

git-original-history

One merge commit for neos/flow-development-collection#1917 clearly having the merge of neos/flow-development-collection#1919. The latter is actually empty (no code changes), so maybe it got "optimized away"? Or maybe the equivalent of https://github.com/git/git/commit/dd65a9e5e3b6298e4fa52e21680008e7fd5556ea#diff-59f70cbe935ec223e3df413b94cab740 (as mentioned in #26)?

kdambekalns avatar Oct 07 '22 11:10 kdambekalns