Returns changed lines in modified file.
 @param file [String] Path to modified files.

 @return [Array<GitDiffParser::Line>] Modified lines
960703
def changed_lines(file)
      diff = git.diff_for_file(file)
      GitDiffParser::Patch.new(diff.patch).changed_lines
    end
1367628
public static List<String> readCommentedTextFile(final String file) throws IOException {
        BufferedReader reader = getBufferedReaderForUtf8(file);
        try {
            final List<String> lines = new ArrayList<String>();
            for (String line = reader.readLine(); line != null; line = reader.readLine()) {
                final String trimmed = line.trim();
                if (trimmed.length() == 0) {
                    continue;
                }
                final int hashIndex = trimmed.indexOf('#');
                if (hashIndex == -1) {
                    lines.add(trimmed);
                } else {
                    final String realPart = trimmed.substring(0, hashIndex).trim();
                    if (realPart.length() > 0) {
                        lines.add(realPart);
                    }
                }
            }
            return lines;
        } finally {
            try {
                reader.close();
            } catch (final IOException e) {
                // intentionally empty
            }
        }
    }
531284
def partialized(file)
        partial_file = file.split(File::SEPARATOR)
        partial_file[-1] = "_#{partial_file[-1]}" unless partial_file[-1].start_with?("_")
        partial_file.join(File::SEPARATOR)
      end
286721
function(diff) {
	var ret = [];

	diff.push({ value: '', lines: [] });  // Append an empty value to make cleanup easier

	// Formats a given set of lines for printing as context lines in a patch
	function contextLines(lines) {
		return lines.map(function(entry) { return ' ' + entry; });
	}

	var oldRangeStart = 0;
	var newRangeStart = 0;
	var curRange = [];
	var oldLine = 1;
	var newLine = 1;

	for (var i = 0; i < diff.length; i++) {
		var current = diff[i];
		var lines = current.lines || current.value.replace(/\n$/, '').split('\n');
		current.lines = lines;

		if (current.added || current.removed) {
			// If we have previous context, start with that
			if (!oldRangeStart) {
				var prev = diff[i - 1];
				oldRangeStart = oldLine;
				newRangeStart = newLine;

				if (prev) {
					curRange = contextLines(prev.lines.slice(-4));
					oldRangeStart -= curRange.length;
					newRangeStart -= curRange.length;
				}
			}

			// Output our changes
			curRange.push.apply(curRange, lines.map(function(entry) {
				return (current.added ? '+' : '-') + entry;
			}));

			// Track the updated file position
			if (current.added) {
				newLine += lines.length;
			} else {
				oldLine += lines.length;
			}
		} else {
			// Identical context lines. Track line changes
			if (oldRangeStart) {
				// Close out any changes that have been output (or join overlapping)
				if (lines.length <= 8 && i < diff.length - 2) {
					// Overlapping
					curRange.push.apply(curRange, contextLines(lines));
				} else {
					// end the range and output
					var contextSize = Math.min(lines.length, 4);
					ret.push(
						'@@ -' + oldRangeStart + ',' + (oldLine - oldRangeStart + contextSize)
						+ ' +' + newRangeStart + ',' + (newLine - newRangeStart + contextSize)
						+ ' @@');
					ret.push.apply(ret, curRange);
					ret.push.apply(ret, contextLines(lines.slice(0, contextSize)));

					oldRangeStart = 0;
					newRangeStart = 0;
					curRange = [];
				}
			}
			oldLine += lines.length;
			newLine += lines.length;
		}
	}

	return ret.join('\n') + '\n';
}
748943
function diff () {
  const files = getConfigFiles()

  debug('diff files: %o', files)

  const output = []

  files.forEach(f => {
    const result = jsDiff.structuredPatch(f[0].name, f[1].name, f[0].content, f[1].content)

    debug('diff result: %o', result)

    output.push('-------------------------------------------------\n')
    // eslint-disable-next-line max-len
    output.push(`diff ${chalk.blue(result.newFileName)} ${chalk.blue(result.oldFileName)}\n`)
    output.push('-------------------------------------------------\n')

    result.hunks.forEach(hunk => {
      fillLineNumber(hunk)

      const lines = hunk.lines.map(line => {
        if (line.startsWith('+')) {
          return chalk.green(line)
        }
        if (line.startsWith('-')) {
          return chalk.red(line)
        }
        return line
      })

      output.push(lines.join('\n'))
      output.push('\n')
    })

    output.push('\n')
  })

  console.log(output.join(''))
}
832196
def update(self, file):
        
        params = {
            "message": file.logs,
            "author": file.author.dict(),
            "content": file.base64,
            "sha": file.blob,
            "branch": file.branch
        }
        uri = "{api}/repos/{origin}/contents/{path}".format(
            api=self.github_api_url,
            origin=self.origin,
            path=file.path
        )
        data = self.request("PUT", uri, data=params)
        if data.status_code == 200:
            file.pushed = True
            return file
        else:
            reply = json.loads(data.content.decode("utf-8"))
            return self.ProxyError(
                data.status_code, (reply, "message"),
                step="update", context={
                    "uri": uri,
                    "params": params
                }
            )
588625
def process_file(vcs, commit, force, gitlint_config, file_data):
    
    filename, extra_data = file_data

    if force:
        modified_lines = None
    else:
        modified_lines = vcs.modified_lines(
            filename, extra_data, commit=commit)
    result = linters.lint(filename, modified_lines, gitlint_config)
    result = result[filename]

    return filename, result
55138
def get_changed_files(self) -> List[str]:
        
        out = shell_tools.output_of(
            'git',
            'diff',
            '--name-only',
            self.compare_commit_id,
            self.actual_commit_id,
            '--',
            cwd=self.destination_directory)
        return [e for e in out.split('\n') if e.strip()]
623964
def diff_lines(self):
    """"""
    start_lines = self._build_file_source_lines[:]
    end_lines = self.build_file_lines()
    diff_generator = unified_diff(start_lines,
                                  end_lines,
                                  fromfile=self.build_file.relpath,
                                  tofile=self.build_file.relpath,
                                  lineterm='')
    return list(diff_generator)
64122
def parse_file path, matcher
      File.open(path) do |f|
        f.each do |line|
          if m = matcher.call(line)
            return m
          end
        end
      end

      raise "#{path}: found no matching lines."
    end
986690
def format_diff
      gemfile.changes.map do |gem, details|
        ERB.new(template, nil, '<>').result(binding)
      end
    end
1245977
private static List<String> getPathList(File file) throws IOException {
        //Make sure the canonical file is being parsed
        file = file.getCanonicalFile();

        //Build a List of the parts of the path
        final List<String> pathParts = new LinkedList<String>();
        while (file != null) {
            pathParts.add(file.getName());
            file = file.getParentFile();
        }
        
        return pathParts;
    }
1188856
def entry_lines(file)
      entries = []
      ::Zip::ZipFile.foreach(file) do |zentry|
        entries << zentry
      end
      entries
    end
984064
def current_files
      if commit_range.is_range?
        execute("git #{git_directory_params} -c diff.renames=0 -c diff.renameLimit=1000 diff -M -C -c --name-only --ignore-submodules=all --diff-filter=AM #{encoding_opt} #{default_params} #{commit_range.to_s}") do |result|
          filter_files(result.to_s.split(/\n/))
        end
      else
        submodules = current_submodules
        execute("git #{git_directory_params} ls-tree -r #{commit_range.to_s} --name-only") do |result|
          filter_files(result.to_s.split(/\n/).select { |f| !submodules.index(f) })
        end
      end
    end
698977
def modified_lines_in_file(file)
      staged = squash?
      refs = 'HEAD^ HEAD' if merge_commit?
      @modified_lines ||= {}
      @modified_lines[file] ||=
        Overcommit::GitRepo.extract_modified_lines(file, staged: staged, refs: refs)
    end
325109
def diffs_of_interest
      files_of_interest.map do |file|
        diff = EmptyDiff.new
        begin
          diff = git.diff_for_file(file)
        rescue NoMethodError
          log_unable_to_find_diff(file.inspect)
        end
        diff
      end
    end
82533
def diff_initial(commit_sha)
        data = commit_information(commit_sha)
        value = {
          total: {
            insertions: 0,
            deletions: 0,
            lines: 0,
            files: data.length
          },
          files: {}
        }
        data.each do |d|
          item = d.split("\t")
          insertions = item[0].to_i
          value[:total][:insertions] += insertions
          value[:total][:lines] += insertions
          value[:files][item[2]] = {
            insertions: insertions,
            deletions: 0,
            lines_added: ["0..#{item[0]}"]
          }
        end
        value
      end