From 7edcafd7a13feaa2bec9d2ed9f49aabd326e7664 Mon Sep 17 00:00:00 2001 From: alfsb Date: Fri, 13 Dec 2024 06:57:09 -0300 Subject: [PATCH] Show non default branch in git status (#205) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: André L F S Bacci --- configure.php | 22 +++++++++++++--------- scripts/genPHP_INI_ENTRY.php | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/configure.php b/configure.php index 4e1d662f9..5abb4e634 100755 --- a/configure.php +++ b/configure.php @@ -643,16 +643,20 @@ function getFileModificationHistory(): array { $repos[$ac['LANG']] = "{$ac['rootdir']}/{$ac['LANG']}"; $repos = array_unique($repos); -foreach ($repos as $name => $path) +$output = ""; +foreach ( $repos as $name => $path ) { - $driveSwitch = is_windows() ? '/d' : ''; - $output = str_pad( "$name:" , 10 ); - $output .= `cd $driveSwitch $path && git rev-parse HEAD`; - $output .= `cd $driveSwitch $path && git status -s`; - $output .= `cd $driveSwitch $path && git for-each-ref --format="%(push:track)" refs/heads`; - echo trim($output) . "\n"; -} -echo "\n"; + $path = escapeshellarg( $path ); + $branch = trim( `git -C $path rev-parse --abbrev-ref HEAD` ); + $branch = $branch == "master" ? "" : " (branch $branch)"; + $output .= str_pad( "$name:" , 10 ); + $output .= rtrim( `git -C $path rev-parse HEAD` ?? "" ) . "$branch\n"; + $output .= rtrim( `git -C $path status -s` ?? "" ) . "\n"; + $output .= rtrim( `git -C $path for-each-ref --format="%(push:track)" refs/heads` ?? "" ) . "\n"; +} +while( str_contains( $output , "\n\n" ) ) + $output = str_replace( "\n\n" , "\n" , $output ); +echo "\n" , trim( $output ) . "\n\n"; foreach ($infiles as $in) { $in = chop("{$ac['basedir']}/{$in}"); diff --git a/scripts/genPHP_INI_ENTRY.php b/scripts/genPHP_INI_ENTRY.php index c5fb33d00..a7b0733ce 100644 --- a/scripts/genPHP_INI_ENTRY.php +++ b/scripts/genPHP_INI_ENTRY.php @@ -180,7 +180,7 @@ function findINI($fname) {/*{{{*/ $data = file_get_contents($fname); //$re = '/PHP_INI_ENTRY\("([^"]+)",\s+"([^"]+)",\s+([A-Z_]),/'; $re = '/(PHP_INI_ENTRY|PHP_INI_ENTRY_EX|PHP_INI_BOOLEAN)\(([^)]+)/'; - preg_match_all($re, $data, &$matches); + preg_match_all($re, $data, $matches); $re2 = '/"([^"]+)",\s*"([^"]+)",\s*([A-Z_]+)/'; foreach ($matches[2] as $match) {