#!/usr/bin/env perl # Copyright (c) MediaTek USA Inc., 2020-2023 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at # your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see # . # # # gitblame [--p4] [--prefix path] [--abbrev regexp] [domain] pathname # # This script runs "git blame" for the specified file and formats the result # to match the diffcov(1) age/ownership annotation specification. # # If the '--p4' flag is used: # we assume that the GIT repo is cloned from Perforce - and look for # the line in the generated commit log message which tells us the perforce # changelist ID that we actually want. # # If specified, 'path' is prepended to 'pathname' (as 'path/pathname') # before processing. # # If passed a domain name (or domain regexp): # strip that domain from the author's address, and treat all users outside # the matching domain as "External". # The --abbrev argument enables you to specify one or more regexp patterns # which are used to compute the user name abbreviation that are applied. use strict; use FindBin; use lib "$FindBin::RealBin"; use gitblame qw(new); use annotateutil qw(call_annotate); if (-f $ARGV[-1] || '-' ne index($ARGV[-1], 1)) { call_annotate('gitblame', $0, @ARGV); } else { gitblame->new($0, @ARGV); }