<commit_before>git = require '../git'
notifier = require '../notifier'

gitDifftool = (repo, {file}={}) ->
  file ?= repo.relativize(atom.workspace.getActiveTextEditor()?.getPath())
  if not file
    return notifier.addError "No open file. Select 'Diff All'."
  # We parse the output of git diff-index to handle the case of a staged file
  # when git-plus.includeStagedDiff is set to false.
  git.cmd
    args: ['diff-index', 'HEAD', '-z']
    cwd: repo.getWorkingDirectory()
    stdout: (data) ->
      diffIndex = data.split('\0')
      includeStagedDiff = atom.config.get 'git-plus.includeStagedDiff'
      for line, i in diffIndex by 2
        staged = diffIndex[i].split(' ')[3] isnt "0000000000000000000000000000000000000000"
        path = diffIndex[i+1]
        if path is file and (!staged or includeStagedDiff)
          args = ['difftool']
          args.push 'HEAD' if includeStagedDiff
          args.push file
          git.cmd
            args: args
            cwd: repo.getWorkingDirectory()
          return
      # If file is unchanged, or staged, but git-plus.includeStagedDiff unchecked
      notifier.addInfo 'Nothing to show.'
<commit_msg>Cosmetics: using a RegExp instead of an ugly chain of zeroes<commit_after>git = require '../git'
notifier = require '../notifier'

gitDifftool = (repo, {file}={}) ->
  file ?= repo.relativize(atom.workspace.getActiveTextEditor()?.getPath())
  if not file
    return notifier.addError "No open file. Select 'Diff All'."
  # We parse the output of git diff-index to handle the case of a staged file
  # when git-plus.includeStagedDiff is set to false.
  git.cmd
    args: ['diff-index', 'HEAD', '-z']
    cwd: repo.getWorkingDirectory()
    stdout: (data) ->
      diffIndex = data.split('\0')
      includeStagedDiff = atom.config.get 'git-plus.includeStagedDiff'
      for line, i in diffIndex by 2
        staged = not /^0{40}$/.test(diffIndex[i].split(' ')[3]);
        path = diffIndex[i+1]
        if path is file and (!staged or includeStagedDiff)
          args = ['difftool']
          args.push 'HEAD' if includeStagedDiff
          args.push file
          git.cmd
            args: args
            cwd: repo.getWorkingDirectory()
          return
      # If file is unchanged, or staged, but git-plus.includeStagedDiff unchecked
      notifier.addInfo 'Nothing to show.'

{'fraction_non_alphanumeric': 0.11732081911262798, 'fraction_numerical': 0.021757679180887373, 'mean_word_length': 2.6697965571205007, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, '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': '1530673', 'n_tokens_mistral': 758, 'n_tokens_neox': 708, 'n_words': 221}