Skydio / revup

Effortlessly create and manage pull requests without changing branches. Powers a stacked diffs workflow with python and git "plumbing" commands.
https://github.com/Skydio/revup
MIT License
309 stars 59 forks source link

git: Use merge-tree in patchsets #187

Open jerry-skydio opened 2 months ago

jerry-skydio commented 2 months ago

Previously patchsets used a hacky invocation of update-index to overlay changed files from old tree to new tree. In addition to being slower than necessary, this has the downside of showing upstream changes in the diff, even those that were not changed in the given review upload.

Using git merge-tree for this instead is cleaner, faster, and better. We do this by "cherry-picking" the old branch with git merge-tree, but providing -X ours as the strategy. This provides a tree that looks like the new base with the old changes applied. For cases where the old changes don't apply cleanly, the ours strategy prevents conflicts by taking the version in the old tree. Although this can be a bit confusing when looking at the file as a whole, it provides a succinct way to view a difference between the old version and new version.

Fixes: #183

jerry-skydio commented 2 months ago

Reviews in this chain: └https://github.com/Skydio/revup/pull/188 git: Add option for no_config in git shell  └https://github.com/Skydio/revup/pull/187 git: Use merge-tree in patchsets

jerry-skydio commented 2 months ago
# head base diff date summary
0 b427e643 740c5cdb diff Jul 3 12:15 PM 1 file changed, 21 insertions(+), 36 deletions(-)
1 672d68bd 740c5cdb diff Jul 3 12:53 PM 1 file changed, 1 insertion(+), 2 deletions(-)
2 6f599e77 740c5cdb diff Jul 3 13:03 PM 1 file changed, 7 insertions(+), 17 deletions(-)
3 61afb41d 740c5cdb diff Jul 3 13:04 PM 0 files changed
4 b4fe6239 740c5cdb diff Jul 3 13:25 PM 1 file changed, 1 insertion(+), 1 deletion(-)
5 775056df 740c5cdb diff Jul 3 13:58 PM 1 file changed, 14 deletions(-)
6 21f00572 1d315c52 diff Jul 3 14:06 PM 0 files changed
7 cbf755de cb8fa697 diff Jul 3 14:08 PM 1 file changed, 3 insertions(+), 4 deletions(-)
8 62ebf0b9 64fe866f diff Jul 8 16:07 PM 0 files changed
9 6729d4f5 4e463646 diff Sep 4 15:59 PM 1 file changed, 11 insertions(+), 2 deletions(-)