Skip to content

Commit 7edcafd

Browse files
alfsbAndré L F S Bacci
andauthored
Show non default branch in git status (#205)
Co-authored-by: André L F S Bacci <[email protected]>
1 parent 0ef7804 commit 7edcafd

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

configure.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -643,16 +643,20 @@ function getFileModificationHistory(): array {
643643
$repos[$ac['LANG']] = "{$ac['rootdir']}/{$ac['LANG']}";
644644
$repos = array_unique($repos);
645645

646-
foreach ($repos as $name => $path)
646+
$output = "";
647+
foreach ( $repos as $name => $path )
647648
{
648-
$driveSwitch = is_windows() ? '/d' : '';
649-
$output = str_pad( "$name:" , 10 );
650-
$output .= `cd $driveSwitch $path && git rev-parse HEAD`;
651-
$output .= `cd $driveSwitch $path && git status -s`;
652-
$output .= `cd $driveSwitch $path && git for-each-ref --format="%(push:track)" refs/heads`;
653-
echo trim($output) . "\n";
654-
}
655-
echo "\n";
649+
$path = escapeshellarg( $path );
650+
$branch = trim( `git -C $path rev-parse --abbrev-ref HEAD` );
651+
$branch = $branch == "master" ? "" : " (branch $branch)";
652+
$output .= str_pad( "$name:" , 10 );
653+
$output .= rtrim( `git -C $path rev-parse HEAD` ?? "" ) . "$branch\n";
654+
$output .= rtrim( `git -C $path status -s` ?? "" ) . "\n";
655+
$output .= rtrim( `git -C $path for-each-ref --format="%(push:track)" refs/heads` ?? "" ) . "\n";
656+
}
657+
while( str_contains( $output , "\n\n" ) )
658+
$output = str_replace( "\n\n" , "\n" , $output );
659+
echo "\n" , trim( $output ) . "\n\n";
656660

657661
foreach ($infiles as $in) {
658662
$in = chop("{$ac['basedir']}/{$in}");

scripts/genPHP_INI_ENTRY.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function findINI($fname) {/*{{{*/
180180
$data = file_get_contents($fname);
181181
//$re = '/PHP_INI_ENTRY\("([^"]+)",\s+"([^"]+)",\s+([A-Z_]),/';
182182
$re = '/(PHP_INI_ENTRY|PHP_INI_ENTRY_EX|PHP_INI_BOOLEAN)\(([^)]+)/';
183-
preg_match_all($re, $data, &$matches);
183+
preg_match_all($re, $data, $matches);
184184
$re2 = '/"([^"]+)",\s*"([^"]+)",\s*([A-Z_]+)/';
185185

186186
foreach ($matches[2] as $match) {

0 commit comments

Comments
 (0)