Closed SitaramRK closed 1 year ago
Hi @SitaramRK , your requirement is right: you should not lose any history at all, and no changes should be necessary.
I have a full example script here: https://tomono.0brg.net/#tests
When you run that, it should create a temporary directory with three fresh repositories (foo, 中文 and lib/zim) and merge them all into a directory core
. I just ran it locally, and it keeps the history for all of them:
$ git log --oneline --graph --all
* cd64755 (empty-branch) Merge zim/empty-branch
|\
| * a5b0344 (zim/empty-branch) zim’s tricky empty orphan branch
* 2cc5987 Root commit for monorepo branch empty-branch
* c7aa809 (master) Merge zim/master
|\
* \ e3f3d5f Merge 中文/master
|\ \
* \ \ 4dc152e Merge foo/master
|\ \ \
* | | | 4619756 Root commit for monorepo branch master
/ / /
| | | * 819fb42 (HEAD -> branch-a) Merge zim/branch-a
| | | |\
| | | | * af585a8 (zim/branch-a) zim’s feature branch A
| | | |/
| | |/|
| | | * d7591dd Merge 中文/branch-a
| | | |\
| | | | * ede8448 (中文/branch-a) new 中文 feature branch A
| | |_|/
| |/| |
| | | * 3c6e29f Merge foo/branch-a
| | | |\
| | | | * 17297a8 (foo/branch-a) foo’s feature branch A
| |_|_|/
|/| | |
* | | | eff259e (tag: foo/v1.0, foo/master) foo’s master
* | | | 2445681 foo’s empty root
/ / /
| | * b6ce242 Root commit for monorepo branch branch-a
| | * 9c20d0d (branch-b) Merge 中文/branch-b
| | |\
| | | * 11d9614 (中文/branch-b) 中文’s feature branch B
| |_|/
|/| |
* | | a9994dd (tag: 中文/v1.0, 中文/master) 中文的root
/ /
| * 308ef09 Root commit for monorepo branch branch-b
| * 9f515f4 (tag: zim/leaking-you) I am unreachable
|/
* b6d6ee0 (zim/master) zim’s master
Can you adapt this test script somehow to trigger the bug? Or show me something similar where it goes wrong, on your end?
Hi @hraban,
Thank you very much for your reply.
I have already run the script with four repositories (say repoA, repoB, repoC and repoD) and the merge went fine. The merged repository name is "CORE". However I noticed that the commit history of the first repository "repoA" is missing from the commit history of the merged repository "CORE". I can only see the commit history of repoB, repoC and repoD in the "CORE" repository but not the commit history of "repoA".
The order that I followed to merge the four repositories is as follows:
tomono <<EOF
$PWD/repoA repoA
$PWD/repoB repoB
$PWD/repoC repoC
$PWD/repoD repoD
EOF
Result: The merge went well but the commit history of repoA is missing in the commit history of the merged repository "CORE"
I changed the order to the following:
tomono <<EOF
$PWD/repoB repoB
$PWD/repoA repoA
$PWD/repoC repoC
$PWD/repoD repoD
EOF
Result: The merge went well but the commit history of repoB is missing in the commit history of the merged repository "CORE"
The first repository's commit history is missing in the merged repository whatever the order that I followed.
Am I missing anything? Can you please help?
Thanks, Sitaram
Reversing the order of the input lines was a good idea, and it definitely rules out some bugs.
It's a very odd issue and I've never seen it before.
DEBUGSH=true
and try again, look in the output for any lines suggesting something's off.If it still doesn't work, it'll be hard for me to help without a more concrete example. You'll need to adapt the test script to something that fails so I can debug it. I'm assuming the repos are private?
Closing for lack of activity and lack of ability to reproduce. Feel free to continue discussing, or reopen once you have more information. As it stands I don't know what the bug is, so I can't do anything about it.
Hi @hraban,
Sorry for the delay in responding back.
I have added a dummy repository as the first one followed by four actual (private and huge) repositories, that makes five individual repositories to be merged. The merge went well and it shows the history of all the repositories now (at high level).
However, is there a standard procedure to validate the merged repository so that all the branches, the commit history, the tags, etc. are intact after the merge?
Thanks, Sitaram
Not besides a human touch, just looking for any revs you expect to be present, etc. Until I have more info to debug with (see my two previous comments on this issue) I'm afraid I can't help any further.
All the best! I'll keep an eye out, in case someone else reports the same.
Hi @hraban,
I do not see any visible error or a failure during or after the merge. I followed the steps that you mentioned and I do not see any issues now. The merge went well and the commit history of all the repositories seems to be intact at a high level.
However, these private repositories are too huge to validate everything after the merge. I was just wondering what you would do to validate the merged repository (a combination of four/five repositories).
Thanks, Sitaram
Hi, Thanks for the solution.
I have tried merging four repositories together with this script.
However when we check the commit history of the merged repository, we found that the first repository's commit history is completely missing from the overall merged repo commits.
Is this expected or should we make any changes to the script to get the commit history of all four repos in the merged repository?
We just want to have the commit history INTACT (combination of all commits together across these 4 repos) on the merged repo.
Thanks, Sitaram