diff options
author | Oswald Buddenhagen <oswald.buddenhagen@gmx.de> | 2023-08-21 13:15:40 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@gmx.de> | 2024-01-09 16:34:58 +0000 |
commit | 66bbb6e430b85d14fda97532a605ff59d8f21e17 (patch) | |
tree | 7b4d6015f859818e770f2b7383be1e00b9779553 /bin/git-gpush | |
parent | 21d6a4925f883045d6750e7f50bbd566bbca3438 (diff) |
gpush: reuse trees more aggressively
handle the case of rebasing the same diff to the same base tree. this
occurs when ancestors are amended without tree modification, are split
or joined, or hunks are moved between them.
Change-Id: I75aaea557884658a4a4dcad7502360b61f590a9a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'bin/git-gpush')
-rwxr-xr-x | bin/git-gpush | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/bin/git-gpush b/bin/git-gpush index 2475611..6e85444 100755 --- a/bin/git-gpush +++ b/bin/git-gpush @@ -1340,8 +1340,7 @@ sub try_reuse_commit($$$$$$$$$) $old_commit, $old_base_id, $what, $ptree, $pdid) = @_; return 0 if (!defined($orig_id)); - return 0 if ($base_id ne $old_base_id); - if ($$commit{id} eq $orig_id) { + if (($$commit{id} eq $orig_id) && ($base_id eq $old_base_id)) { # We are picking the same commit to the same base, so # we can just reuse the previously created commit. $$pdid = "reused unmodified ($what)"; @@ -1351,11 +1350,18 @@ sub try_reuse_commit($$$$$$$$$) return 0 if (!$orig_commit); # Huuh? return 0 if ($$commit{tree} ne $$orig_commit{tree}); return 0 if (!parent_trees_equal($parent_id, $orig_commit)); - if (commit_metas_equal($commit, $orig_commit)) { - # We are picking the same content to the same base, so - # we can just reuse the previously created commit. - $$pdid = "reused amended ($what)"; - return 1; + if ($base_id eq $old_base_id) { + if (commit_metas_equal($commit, $orig_commit)) { + # We are picking the same content to the same base, so + # we can just reuse the previously created commit. + $$pdid = "reused amended ($what)"; + return 1; + } + } else { + my $base = $commit_by_id{$base_id}; + my $old_base = $commit_by_id{$old_base_id}; + return 0 if (!$base || !$old_base); + return 0 if ($$base{tree} ne $$old_base{tree}); } # We are picking the same diff to the same base, so # we can reuse the previously created tree. |