<commit_before>#!/bin/bash

usage() {
me=$(basename $0)
cat <<EOF
Usage:
  $me [ options ] <repository> [ <refspec> ]

Options:
  -d <directory>  Remote directory name of the sparse-checlout. Default: docs/
  -t <path>       Target path of the checkout. Default: repository basename
EOF

exit 1
}

while getopts 'd:t:' OPT
do
  case ${OPT} in
    d)
      DIRECTORY="${OPTARG}"
      ;;
    t)
      TARGET="${OPTARG}"
      ;;
    *)
      usage
      ;;
  esac
done

shift $((OPTIND-1))

[ $# -ge 1 ] || usage

REPOSITORY="$1"
REFSPEC="$2"

if [[ -z "${DIRECTORY}" ]]; then
    DIRECTORY="docs/"
fi

if [[ -z "${TARGET}" ]]; then
    TARGET=$(basename "${REPOSITORY}")
fi

mkdir -p "${TARGET}"
cd "${TARGET}"

git init

git config core.sparsecheckout true
echo "${DIRECTORY}" > .git/info/sparse-checkout

git pull --depth=1 "${REPOSITORY}" "${REFSPEC}"<commit_msg>Handle repository changes more helpful in checkout<commit_after>#!/bin/bash

usage() {
me=$(basename $0)
cat <<EOF
Usage:
  $me [ options ] <repository> [ <refspec> ]

Options:
  -d <directory>  Remote directory name of the sparse-checlout. Default: docs/
  -t <path>       Target path of the checkout. Default: repository basename
EOF

exit 1
}

while getopts 'd:t:' OPT
do
  case ${OPT} in
    d)
      DIRECTORY="${OPTARG}"
      ;;
    t)
      TARGET="${OPTARG}"
      ;;
    *)
      usage
      ;;
  esac
done

shift $((OPTIND-1))

[ $# -ge 1 ] || usage

REPOSITORY="$1"
REFSPEC="$2"

if [[ -z "${DIRECTORY}" ]]; then
    DIRECTORY="docs/"
fi

if [[ -z "${TARGET}" ]]; then
    TARGET=$(basename "${REPOSITORY}")
fi

mkdir -p "${TARGET}"
cd "${TARGET}"

git init

git config core.sparsecheckout true
echo "${DIRECTORY}" > .git/info/sparse-checkout

if ! git remote | grep -q origin; then
  git remote add origin "${REPOSITORY}"
fi
git fetch --depth=1 origin "${REFSPEC}"
git reset --hard origin/"${REFSPEC}"
{'fraction_non_alphanumeric': 0.1776595744680851, 'fraction_numerical': 0.007446808510638298, 'mean_word_length': 3.0891304347826085, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7107543', 'n_tokens_mistral': 709, 'n_tokens_neox': 677, 'n_words': 200}