summaryrefslogtreecommitdiffstats
path: root/bin/git-gpush
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@gmx.de>2023-03-07 11:38:09 +0100
committerOswald Buddenhagen <oswald.buddenhagen@gmx.de>2023-06-01 08:16:18 +0000
commitd6f7767bb7de573aba86da9ff32821b159a4bbc7 (patch)
tree2c9cc2f088d2545f2429f40b8357ec66f3b80f9d /bin/git-gpush
parent5364d6a44194e630e0eca2fcde4495090e151d0b (diff)
gpush: factor out parent_trees_equal()
for improved legibility. Change-Id: Idc154c6f88d51fd65aa4f6c0bda7a8c7f0c94213 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'bin/git-gpush')
-rwxr-xr-xbin/git-gpush17
1 files changed, 12 insertions, 5 deletions
diff --git a/bin/git-gpush b/bin/git-gpush
index 1e4b069..e567d1b 100755
--- a/bin/git-gpush
+++ b/bin/git-gpush
@@ -1309,6 +1309,17 @@ sub prepare_rebase($$$)
return;
}
+sub parent_trees_equal($$$)
+{
+ my ($parent, $parent_id, $orig_commit) = @_;
+
+ # Upstream commits are not visited, so we get no tree id. However,
+ # as this code aims at series which were not rebased, using the base
+ # commit itself will work just as well for the series' first commit.
+ return ($parent ? $$parent{tree} : $parent_id)
+ eq get_1st_parent_tree($orig_commit);
+}
+
sub commits_equal($$$$)
{
my ($base_id, $tree, $commit, $old_commit) = @_;
@@ -1353,11 +1364,7 @@ sub rebase_commit($$$$$)
}
my $orig_commit = $commit_by_id{$orig_id};
if ($orig_commit && ($$commit{tree} eq $$orig_commit{tree})) {
- # Upstream commits are not visited, so we get no tree id. However,
- # as this code aims at series which were not rebased, using the base
- # commit itself will work just as well for the series' first commit.
- if (($parent ? $$parent{tree} : $parent_id)
- eq get_1st_parent_tree($orig_commit)) {
+ if (parent_trees_equal($parent, $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 recycle the previously created commit.