Skip to content

Commit d8e1e41

Browse files
committed
don't reassign ctx
1 parent 3faa3c6 commit d8e1e41

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

services/gitdiff/gitdiff.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,8 +1104,8 @@ func GetDiff(ctx context.Context, gitRepo *git.Repository, opts *DiffOptions, fi
11041104
return nil, err
11051105
}
11061106

1107-
ctx, cancel := context.WithCancel(ctx)
1108-
defer cancel()
1107+
cmdCtx, cmdCancel := context.WithCancel(ctx)
1108+
defer cmdCancel()
11091109

11101110
cmdDiff := git.NewCommand(ctx)
11111111
objectFormat, err := gitRepo.GetObjectFormat()
@@ -1169,9 +1169,9 @@ func GetDiff(ctx context.Context, gitRepo *git.Repository, opts *DiffOptions, fi
11691169
_ = writer.Close()
11701170
}()
11711171

1172-
diff, err := ParsePatch(ctx, opts.MaxLines, opts.MaxLineCharacters, opts.MaxFiles, reader, parsePatchSkipToFile)
1172+
diff, err := ParsePatch(cmdCtx, opts.MaxLines, opts.MaxLineCharacters, opts.MaxFiles, reader, parsePatchSkipToFile)
11731173
// Ensure the git process is killed if it didn't exit already
1174-
cancel()
1174+
cmdCancel()
11751175
if err != nil {
11761176
return nil, fmt.Errorf("unable to ParsePatch: %w", err)
11771177
}

0 commit comments

Comments
 (0)