<commit_before>import { git } from './core'

import { Tip, TipState } from '../../models/tip'
import { getCurrentBranch } from './for-each-ref'
import { Repository } from '../../models/repository'

import { fatalError } from '../../lib/fatal-error'

/** Get the name of the current branch. */
export async function getTip(repository: Repository): Promise<Tip> {

  const revParse = await git([ 'rev-parse', 'HEAD' ], repository.path, 'getTip', { successExitCodes: new Set([ 0, 128 ]) })
  if (revParse.exitCode === 128) {
    // fatal: ambiguous argument 'HEAD': unknown revision or path not in the
    // working tree.
    const symbolicRef = await git([ 'symbolic-ref', 'HEAD' ], repository.path, 'getTip')
    const ref = symbolicRef.stdout.replace('refs/heads/', '').trim()
    return {
      kind: TipState.Unborn,
      ref,
    }
  }
<commit_msg>use --short to get the value directly<commit_after>import { git } from './core'

import { Tip, TipState } from '../../models/tip'
import { getCurrentBranch } from './for-each-ref'
import { Repository } from '../../models/repository'

import { fatalError } from '../../lib/fatal-error'

/** Get the name of the current branch. */
export async function getTip(repository: Repository): Promise<Tip> {

  const revParse = await git([ 'rev-parse', 'HEAD' ], repository.path, 'getTip', { successExitCodes: new Set([ 0, 128 ]) })
  if (revParse.exitCode === 128) {
    // fatal: ambiguous argument 'HEAD': unknown revision or path not in the
    // working tree.
    const symbolicRef = await git([ 'symbolic-ref', 'HEAD', '--short' ], repository.path, 'getTip')
    const ref = symbolicRef.stdout.trim()
    return {
      kind: TipState.Unborn,
      ref,
    }
  }

{'fraction_non_alphanumeric': 0.16627771295215868, 'fraction_numerical': 0.008168028004667444, 'mean_word_length': 3.2034313725490198, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3269148', 'n_tokens_mistral': 530, 'n_tokens_neox': 516, 'n_words': 164}