spine-generic / data-multi-subject

Multi-subject data for the Spine Generic project
Creative Commons Attribution 4.0 International
22 stars 15 forks source link

Adding height and weight into participants #85

Closed kousu closed 3 years ago

kousu commented 3 years ago

This was https://github.com/spine-generic/data-multi-subject/pull/57, but I accidentally closed that by pushing the wrong branch to the wrong remote after resolving the merge conflicts. Sorry! It's all still here.

kousu commented 3 years ago

Because it was a bit tricky, here's a record of how I merged master into this while retaining all the commits cleanly:

  1. First I checked out, and made a backup because I'm planning to rebase which is always a bit scary.
$ git remote add r git@github.com:renelabounek/data-multi-subject.git
$ git fetch r
$ git checkout -b r-master-backup r/master
$ git push -u origin HEAD:rl/height-weight
$ git checkout -b r-master-rebase r/master
  1. I rebased onto the most recent point I could, which turned out to be #83 == 27ac875fe87e4ef18954a27bb79db0aa9e3ac2ae; #77 brought in merge conflicts with this so I couldn't easily just pick that yet.
$ git rebase 27ac875fe87e4ef18954a27bb79db0aa9e3ac2ae
  1. I fixed the line-endings problem once and for all with this incantation:
$ git rebase -x 'dos2unix participants.tsv && git add participants.tsv && git commit --amend -C HEAD' -X theirs 27ac875fe87e4ef18954a27bb79db0aa9e3ac2ae

This is a bit hard to explain but I'll try:

  1. rebase: replay each commit
  2. -x: after each commit, run dos2unix over the file and recommit it
  3. -X: when there is a conflict pick the older version; and there usually are conflicts, because in the original patch, all the lines had Windows line endings, which appear to be conflicts to git. So to fix this, just pick the version with the Windows line ending, but then immediately -x happens, rewriting participants.tsv to the proper form and recommitting
    • ("theirs" in the context of a rebase means the branch you're trying to rebase into, the feature branch; it's confusing; even the git-rebase manpage notes that it's confusing)

To double check this worked, compare the patches:

diff --color -u <(git format-patch --stdout 27ac875fe87e4ef18954a27bb79db0aa9e3ac2ae..r-master) <(git format-patch --stdout 27ac875fe87e4ef18954a27bb79db0aa9e3ac2ae..HEAD)

I've also extracted this to a linter in #87, along with a .tsv linter in #86, and I am hoping those will be merged first so that the format will be tested, as requested by @jcohenadad in https://github.com/spine-generic/data-multi-subject/pull/57#issuecomment-702247465.

  1. Next, after trying a couple a different things, I thought I should squash the first 6 commits because these added empty height, weight columns, which means they touched every line, which git sees as a conflict with #77. By squashing them I will only need to do one conflict resolution. Plus most of them were just fixup commits to the first anyway.
git rebase -i 27ac875fe87e4ef18954a27bb79db0aa9e3ac2ae

with this rebase-todo:

pick 2de478de9 Update participants.tsv
s 484560d7c Update participants.tsv
s f9b2f4fc8 Update participants.tsv
s 472c78c2a Update participants.json
s a1b505323 Update participants.tsv
s 8004dc491 Update participants.tsv
pick f52cdd5f8 Update participants.tsv
pick ca01dccd8 add unf metadata
pick 18305ddb0 added height and weight for cmrrb dataset
pick 6ba2d682c added height and weight for brnoCeitec
pick 9cff345a4 scan date updated for sub-brnoCetitec02
pick df2139698 update info sub-perform01,03,05,06
  1. So now I'm down to:
$ git log --oneline
298c02ee4 (HEAD -> r-master-rebase) update info sub-perform01,03,05,06
37140f685 scan date updated for sub-brnoCetitec02
082b89171 added height and weight for brnoCeitec
094e94f02 added height and weight for cmrrb dataset
fd8c61ecc add unf metadata
a12499c4c Update participants.tsv
026c9ab73 Added height and height columns
27ac875fe Handle testing forks. (#83)
  1. Okay now merge with master and do the conflict resolution:
$ git rebase master
$ git rebase master
Auto-merging participants.tsv
CONFLICT (content): Merge conflict in participants.tsv
error: could not apply 026c9ab73... Added height and height columns
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 026c9ab73... Added height and height columns
vi participants.tsv

I needed to copy the ucdavis lines down, and add empty height/weight columns to them.

I also made sure to dos2unix the file:

$ dos2unix participants.tsv
$ git add participants.tsv 

Finish merging:

$ git rebase --continue
  1. Okay now the conflicts are fixed and I can upload it:
$ git push -f -u r master
Enter passphrase for key '/home/kousu/.ssh/id_rsa.github': 
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:renelabounek/data-multi-subject.git
 + 1c48531b4...46df26243 master -> master (forced update)
Branch 'master' set up to track remote branch 'master' from 'r'.

...ah but this last step was a mistake, and is why we're here in this thread and not over in #57 now. :shrug: . Sorry.

kousu commented 3 years ago

Thank you for taking the time to improve this dataset @renelabounek. Sorry it took so long to get it merged.