mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 09:07:54 +01:00
Backport #30626 by @wxiaoguang Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
4aba4f8dc3
commit
706fc596a0
@ -136,14 +136,18 @@ func (t *TemporaryUploadRepository) LsFiles(filenames ...string) ([]string, erro
|
|||||||
|
|
||||||
// RemoveFilesFromIndex removes the given files from the index
|
// RemoveFilesFromIndex removes the given files from the index
|
||||||
func (t *TemporaryUploadRepository) RemoveFilesFromIndex(filenames ...string) error {
|
func (t *TemporaryUploadRepository) RemoveFilesFromIndex(filenames ...string) error {
|
||||||
|
objFmt, err := t.gitRepo.GetObjectFormat()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to get object format for temporary repo: %q, error: %w", t.repo.FullName(), err)
|
||||||
|
}
|
||||||
stdOut := new(bytes.Buffer)
|
stdOut := new(bytes.Buffer)
|
||||||
stdErr := new(bytes.Buffer)
|
stdErr := new(bytes.Buffer)
|
||||||
stdIn := new(bytes.Buffer)
|
stdIn := new(bytes.Buffer)
|
||||||
for _, file := range filenames {
|
for _, file := range filenames {
|
||||||
if file != "" {
|
if file != "" {
|
||||||
stdIn.WriteString("0 0000000000000000000000000000000000000000\t")
|
// man git-update-index: input syntax (1): mode SP sha1 TAB path
|
||||||
stdIn.WriteString(file)
|
// mode=0 means "remove from index", then hash part "does not matter as long as it is well formatted."
|
||||||
stdIn.WriteByte('\000')
|
_, _ = fmt.Fprintf(stdIn, "0 %s\t%s\x00", objFmt.EmptyObjectID(), file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,8 +158,7 @@ func (t *TemporaryUploadRepository) RemoveFilesFromIndex(filenames ...string) er
|
|||||||
Stdout: stdOut,
|
Stdout: stdOut,
|
||||||
Stderr: stdErr,
|
Stderr: stdErr,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error("Unable to update-index for temporary repo: %s (%s) Error: %v\nstdout: %s\nstderr: %s", t.repo.FullName(), t.basePath, err, stdOut.String(), stdErr.String())
|
return fmt.Errorf("unable to update-index for temporary repo: %q, error: %w\nstdout: %s\nstderr: %s", t.repo.FullName(), err, stdOut.String(), stdErr.String())
|
||||||
return fmt.Errorf("Unable to update-index for temporary repo: %s Error: %w\nstdout: %s\nstderr: %s", t.repo.FullName(), err, stdOut.String(), stdErr.String())
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user