summaryrefslogtreecommitdiff
path: root/t/porting
diff options
context:
space:
mode:
authorGraham Knop <haarg@haarg.org>2022-08-18 12:27:01 +0200
committerYves Orton <demerphq@gmail.com>2022-08-18 21:29:56 +0200
commit16dd3f70cc16005d5af7146385733a7c945fb67e (patch)
tree542c3bda14bc71a5df4c3eca46be8e6a7b91b2f3 /t/porting
parentbf4a32d613b6736998d60a3c7ec23dd39cbe10a1 (diff)
downloadperl-16dd3f70cc16005d5af7146385733a7c945fb67e.tar.gz
fix t/porting/authors.t detection of merge commits
git-rev-parse HEAD^2` was used to detect if HEAD was a merge commit. When HEAD is not a merge commit then HEAD^2 produces an error; When HEAD is a merge commit then HEAD^2 points to the second parent. The problem was that `git rev-parse "HEAD^2"` also produced output on STDOUT which caused `$revision_range` to be set to something bogus. Example: $ git rev-parse HEAD^2 2>/dev/null ; echo $? HEAD^2 128 $ git log HEAD^1..HEAD^2 fatal: ambiguous argument 'HEAD^1..HEAD^2': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' The fix is to use --verify which doesn't give output on STDOUT for something invalid. It does print an error on STDERR (for invalid things) which can be silenced using -q $ git rev-parse --verify HEAD^2 fatal: Needed a single revision $ git rev-parse -q --verify HEAD^2 $ For an actual merge commit: $ git rev-parse -q --verify e91a97a^2 bee6601bbf238b5366ce11cd41f6b095bfeebfd8 (i.e. working as expected)
Diffstat (limited to 't/porting')
-rw-r--r--t/porting/authors.t4
1 files changed, 1 insertions, 3 deletions
diff --git a/t/porting/authors.t b/t/porting/authors.t
index f2de6bdff1..561d7d795a 100644
--- a/t/porting/authors.t
+++ b/t/porting/authors.t
@@ -9,7 +9,6 @@ BEGIN {
use TestInit qw(T); # T is chdir to the top level
use strict;
-use File::Spec;
find_git_or_skip('all');
skip_all(
@@ -30,8 +29,7 @@ elsif( $ENV{GITHUB_ACTIONS} && length $ENV{GITHUB_BASE_REF} ) {
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables
# we should be on a merge commit, but double check
- my $null = File::Spec->devnull;
- my $branch_head = `git rev-parse "HEAD^2" 2>$null`;
+ my $branch_head = `git rev-parse -q --verify "HEAD^2"`;
chomp $branch_head;
# gives the history of the branch being merged, excluding what it is