<commit_before>var fs = require('fs');
var nodePath = require('path');
var index = require('./index');
var files = require('./files');
var objects = require('./objects');
var refs = require('./refs');
var diff = require('./diff');
var util = require('./util');

var checkout = module.exports = {
  readChangedFilesCheckoutWouldOverwrite: function(checkoutHash) {
    var localChanges = diff.readDiff("HEAD");
    var headToBranchChanges = diff.readDiff("HEAD", checkoutHash);
    return Object.keys(localChanges)
      .filter(function(path) { return path in headToBranchChanges; });
  },

  writeCheckout: function(ref) {
    addModifyDelete("HEAD", refs.readHash(ref));
    refs.write("HEAD", objects.read(ref) ? ref : refs.nameToBranchRef(ref));
  }
};

function addModifyDelete(diffFromRef, diffToRef) {
  var changes = diff.readDiff(diffFromRef, diffToRef);
  var checkoutIndex = index.readCommitIndex(diffToRef);
  Object.keys(changes).forEach(function(path) {
    if (changes[path] === diff.FILE_STATUS.ADD ||<commit_msg>Delete empty dirs after checking out<commit_after>var fs = require('fs');
var nodePath = require('path');
var index = require('./index');
var files = require('./files');
var objects = require('./objects');
var refs = require('./refs');
var diff = require('./diff');
var util = require('./util');

var checkout = module.exports = {
  readChangedFilesCheckoutWouldOverwrite: function(checkoutHash) {
    var localChanges = diff.readDiff("HEAD");
    var headToBranchChanges = diff.readDiff("HEAD", checkoutHash);
    return Object.keys(localChanges)
      .filter(function(path) { return path in headToBranchChanges; });
  },

  writeCheckout: function(ref) {
    addModifyDelete("HEAD", refs.readHash(ref));
    fs.readdirSync(files.repoDir())
      .filter(function(dirChild) { return dirChild !== ".gitlet"; })
      .filter(function(dirChild) { return fs.statSync(dirChild).isDirectory(); })
      .forEach(function(dirChild) { files.deleteEmptyDirs(dirChild); });

    refs.write("HEAD", objects.read(ref) ? ref : refs.nameToBranchRef(ref));
  }
};

function addModifyDelete(diffFromRef, diffToRef) {
  var changes = diff.readDiff(diffFromRef, diffToRef);
  var checkoutIndex = index.readCommitIndex(diffToRef);
  Object.keys(changes).forEach(function(path) {
    if (changes[path] === diff.FILE_STATUS.ADD ||
{'fraction_non_alphanumeric': 0.15982905982905982, 'fraction_numerical': 0.0, 'mean_word_length': 5.0490956072351425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2830514', 'n_tokens_mistral': 713, 'n_tokens_neox': 707, 'n_words': 145}