From 4ec31dc8ac208f46baabe175be2ad7d25697d0e2 Mon Sep 17 00:00:00 2001 From: Peter Dillinger Date: Wed, 27 Oct 2021 12:25:06 -0700 Subject: [PATCH] Make format-diff.sh locale-independent (#9079) Summary: Force POSIX locale for calls to 'git remote' that might have locale-dependent formatting, as shown in https://github.com/facebook/rocksdb/issues/8731 comment Pull Request resolved: https://github.com/facebook/rocksdb/pull/9079 Test Plan: manual (haven't tried on a machine with non-english default locale) Reviewed By: ltamasi Differential Revision: D31943092 Pulled By: pdillinger fbshipit-source-id: 7dbe5915824f39f73b412cc3d1a86a2521cf76c1 --- build_tools/format-diff.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build_tools/format-diff.sh b/build_tools/format-diff.sh index c4377a8b8..3c16b08eb 100755 --- a/build_tools/format-diff.sh +++ b/build_tools/format-diff.sh @@ -127,11 +127,11 @@ uncommitted_code=`git diff HEAD` if [ -z "$uncommitted_code" ] then # Attempt to get name of facebook/rocksdb.git remote. - [ "$FORMAT_REMOTE" ] || FORMAT_REMOTE="$(git remote -v | grep 'facebook/rocksdb.git' | head -n 1 | cut -f 1)" + [ "$FORMAT_REMOTE" ] || FORMAT_REMOTE="$(LC_ALL=POSIX LANG=POSIX git remote -v | grep 'facebook/rocksdb.git' | head -n 1 | cut -f 1)" # Fall back on 'origin' if that fails [ "$FORMAT_REMOTE" ] || FORMAT_REMOTE=origin # Use main branch from that remote - [ "$FORMAT_UPSTREAM" ] || FORMAT_UPSTREAM="$FORMAT_REMOTE/$(git remote show $FORMAT_REMOTE | sed -n '/HEAD branch/s/.*: //p')" + [ "$FORMAT_UPSTREAM" ] || FORMAT_UPSTREAM="$FORMAT_REMOTE/$(LC_ALL=POSIX LANG=POSIX git remote show $FORMAT_REMOTE | sed -n '/HEAD branch/s/.*: //p')" # Get the common ancestor with that remote branch. Everything after that # common ancestor would be considered the contents of a pull request, so # should be relevant for formatting fixes.