MCPcopy
hub / github.com/desktop/desktop / getBranchMergeBaseDiff

Function getBranchMergeBaseDiff

app/src/lib/git/diff.ts:154–187  ·  view source on GitHub ↗
(
  repository: Repository,
  file: FileChange,
  baseBranchName: string,
  comparisonBranchName: string,
  hideWhitespaceInDiff: boolean = false,
  latestCommit: string
)

Source from the content-addressed store, hash-verified

152 * (Show what would be the result of merge)
153 */
154export async function getBranchMergeBaseDiff(
155 repository: Repository,
156 file: FileChange,
157 baseBranchName: string,
158 comparisonBranchName: string,
159 hideWhitespaceInDiff: boolean = false,
160 latestCommit: string
161): Promise<IDiff> {
162 const args = [
163 'diff',
164 '--merge-base',
165 baseBranchName,
166 comparisonBranchName,
167 ...(hideWhitespaceInDiff ? ['-w'] : []),
168 '--patch-with-raw',
169 '-z',
170 '--no-color',
171 '--',
172 ensureRelativePath(file.path),
173 ]
174
175 if (
176 file.status.kind === AppFileStatusKind.Renamed ||
177 file.status.kind === AppFileStatusKind.Copied
178 ) {
179 args.push(ensureRelativePath(file.status.oldPath))
180 }
181
182 const result = await git(args, repository.path, 'getBranchMergeBaseDiff', {
183 encoding: 'buffer',
184 })
185
186 return buildDiff(result.stdout, repository, file, latestCommit, latestCommit)
187}
188
189/**
190 * Render the difference between two commits for a file

Callers 2

diff-test.tsFile · 0.90

Calls 4

gitFunction · 0.90
ensureRelativePathFunction · 0.85
buildDiffFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected