Weblate: Wrong history shown on git merge

Created on 17 Jan 2018  路  6Comments  路  Source: WeblateOrg/weblate

Steps to reproduce

  1. Let Weblate create merge commit.
  2. Look at it on GitHub (or other tool which shows diff for merge commit)

Actual behaviour

The diff in upstream changes is shown, for example:
https://github.com/WeblateOrg/weblate/commit/4e50b8ce278989d85b5a2560e13c8d3ea691e36b

Expected behaviour

The diff with Weblate changes should be shown.

The problem

All tools seem to use the second parent as branch to show diff, so Weblate should create the merge commit in reverse order. However there seems to be no way to tell git to do this.

As a workaround Weblate could do following:

# Create local branch for upstream
git branch tmp origin/master
# Checkout upstream branch
git checkout tmp
# Merge current Weblate changes, this can lead to conflict
git merge master
# Checkout branch with Weblate changes
git checkout master
# Merge temporary branch (this is fast forward so does not create merge commit)
git merge tmp
# Delete temporary branch
git branch -d tmp

As this involves quite a lot of manipulations with the repository, it can lead to performance issues. Also this really looks too complex for simple thing we want to achieve.

PS: Asked this question on StackOverflow.

enhancement help wanted

Most helpful comment

Another approach (using a bit of git plumbing):

$ git merge --squash origin/master 
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committing as requested
$ git write-tree
c8ffd97c94cf0fb11591671e4e5d1b84db2906a3
$ git commit-tree -p origin/master -p master  -m "message" c8ffd97c94cf0fb11591671e4e5d1b84db2906a3
e2d1013adf2ab47663da455012536a837937a74e
$ git reset --hard e2d1013adf2ab47663da455012536a837937a74e
HEAD is now at e2d1013 message

All 6 comments

Another approach (using a bit of git plumbing):

$ git merge --squash origin/master 
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committing as requested
$ git write-tree
c8ffd97c94cf0fb11591671e4e5d1b84db2906a3
$ git commit-tree -p origin/master -p master  -m "message" c8ffd97c94cf0fb11591671e4e5d1b84db2906a3
e2d1013adf2ab47663da455012536a837937a74e
$ git reset --hard e2d1013adf2ab47663da455012536a837937a74e
HEAD is now at e2d1013 message

Thank you for your report, the issue you have reported has just been fixed.

  • In case you see problem with the fix, please comment on this issue.
  • In case you see similar problem, please open separate issue.
  • If you are happy with the outcome, consider supporting Weblate by donating.

Cool!
Is it live on https://hosted.weblate.org/?

Not yet, it's only in git so far. Will be probably deployed next week.

Is it live? If not, how can I be notified about it?

Was this page helpful?
0 / 5 - 0 ratings