summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@gmx.de>2023-03-07 11:06:40 +0100
committerOswald Buddenhagen <oswald.buddenhagen@gmx.de>2023-06-01 08:15:17 +0000
commit5364d6a44194e630e0eca2fcde4495090e151d0b (patch)
treed569ff89980c511ef7892d2899da7499e513e79b
parent807c012a969af9c3f59c25a36f0b140586cba4d5 (diff)
gpush/gpick: factor out commit_metas_equal()
for de-duplication and improved legibility. Change-Id: I677e2f726207c9597d52c53248590573bc409259 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rwxr-xr-xbin/git-gpick3
-rwxr-xr-xbin/git-gpush3
-rw-r--r--bin/git_gpush.pm8
3 files changed, 10 insertions, 4 deletions
diff --git a/bin/git-gpick b/bin/git-gpick
index bc794a8..2edde65 100755
--- a/bin/git-gpick
+++ b/bin/git-gpick
@@ -2453,8 +2453,7 @@ sub can_recycle($$$)
return 0 if ($parent_tree ne get_1st_parent_tree($orig_commit));
# Finally compare the meta data.
- return 1 if (($$commit{message} eq $$orig_commit{message})
- && ("@{$$commit{author}}" eq "@{$$orig_commit{author}}")
+ return 1 if (commit_metas_equal($commit, $orig_commit)
&& (get_more_parents($commit) eq get_more_parents($orig_commit)));
# While the commit is not the same, the diff is, so pre-populate
diff --git a/bin/git-gpush b/bin/git-gpush
index 6d001a1..1e4b069 100755
--- a/bin/git-gpush
+++ b/bin/git-gpush
@@ -1358,8 +1358,7 @@ sub rebase_commit($$$$$)
# 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 (($$commit{message} eq $$orig_commit{message})
- && ("@{$$commit{author}}" eq "@{$$orig_commit{author}}")) {
+ 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.
return ($old_commit, 'recycled amended');
diff --git a/bin/git_gpush.pm b/bin/git_gpush.pm
index 9fc7cf7..6d08a48 100644
--- a/bin/git_gpush.pm
+++ b/bin/git_gpush.pm
@@ -579,6 +579,14 @@ sub init_commit($)
$commit_by_id{$id} = $commit;
}
+sub commit_metas_equal($$)
+{
+ my ($commit, $old_commit) = @_;
+
+ return ($$commit{message} eq $$old_commit{message})
+ && ("@{$$commit{author}}" eq "@{$$old_commit{author}}");
+}
+
sub changes_from_commits($)
{
my ($commits) = @_;