(raw string)
| 1031 | current = strings.TrimSpace(current) |
| 1032 | if current == oid { |
| 1033 | return current, nil |
| 1034 | } |
| 1035 | if _, err := runGit(ctx, repo.GitDir, "merge-base", "--is-ancestor", current, oid); err != nil { |
| 1036 | return "", fmt.Errorf("prepared git dir branch %s would be overwritten; refusing non-fast-forward update", branch) |
| 1037 | } |
| 1038 | return current, nil |
| 1039 | } |
| 1040 | |
| 1041 | func zeroOIDForGitDir(ctx context.Context, gitDir string) (string, error) { |
| 1042 | format, err := runGit(ctx, gitDir, "rev-parse", "--show-object-format") |
| 1043 | if err != nil { |
| 1044 | return "", err |
| 1045 | } |
| 1046 | switch strings.TrimSpace(format) { |
| 1047 | case "sha1": |
| 1048 | return strings.Repeat("0", 40), nil |
| 1049 | case "sha256": |
| 1050 | return strings.Repeat("0", 64), nil |
| 1051 | default: |
| 1052 | return "", fmt.Errorf("unsupported Git object format %q", format) |
| 1053 | } |
| 1054 | } |
no test coverage detected