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
main
Peter Dillinger 3 years ago committed by Facebook GitHub Bot
parent dc00e4b120
commit 4ec31dc8ac
  1. 4
      build_tools/format-diff.sh

@ -127,11 +127,11 @@ uncommitted_code=`git diff HEAD`
if [ -z "$uncommitted_code" ] if [ -z "$uncommitted_code" ]
then then
# Attempt to get name of facebook/rocksdb.git remote. # 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 # Fall back on 'origin' if that fails
[ "$FORMAT_REMOTE" ] || FORMAT_REMOTE=origin [ "$FORMAT_REMOTE" ] || FORMAT_REMOTE=origin
# Use main branch from that remote # 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 # Get the common ancestor with that remote branch. Everything after that
# common ancestor would be considered the contents of a pull request, so # common ancestor would be considered the contents of a pull request, so
# should be relevant for formatting fixes. # should be relevant for formatting fixes.

Loading…
Cancel
Save