#!/bin/sh
set -e

if [ -z "$VSCODE_GIT_ASKPASS_NODE" ] || [ -z "$VSCODE_GIT_ASKPASS_MAIN" ]; then
  echo '' >&2
  exit 0
fi

VSCODE_GIT_ASKPASS_PIPE=$(mktemp) || {
  echo '' >&2
  exit 0
}
ELECTRON_RUN_AS_NODE="1" VSCODE_GIT_ASKPASS_PIPE="$VSCODE_GIT_ASKPASS_PIPE" VSCODE_GIT_ASKPASS_TYPE="https" "$VSCODE_GIT_ASKPASS_NODE" "$VSCODE_GIT_ASKPASS_MAIN" $VSCODE_GIT_ASKPASS_EXTRA_ARGS $* || {
  rm -f "$VSCODE_GIT_ASKPASS_PIPE"
  echo '' >&2
  exit 0
}
cat $VSCODE_GIT_ASKPASS_PIPE
rm -f $VSCODE_GIT_ASKPASS_PIPE
