|
7 | 7 | "errors" |
8 | 8 | "fmt" |
9 | 9 | "io" |
10 | | - "io/ioutil" |
11 | 10 | "os" |
12 | 11 | "os/exec" |
13 | 12 | "path/filepath" |
@@ -477,62 +476,6 @@ func (repo *Repository) NewObjectIter(args ...string) ( |
477 | 476 | }, in1, nil |
478 | 477 | } |
479 | 478 |
|
480 | | -// CreateObject creates a new Git object, of the specified type, in |
481 | | -// `Repository`. `writer` is a function that writes the object in `git |
482 | | -// hash-object` input format. This is used for testing only. |
483 | | -func (repo *Repository) CreateObject(t ObjectType, writer func(io.Writer) error) (OID, error) { |
484 | | - cmd := repo.gitCommand("hash-object", "-w", "-t", string(t), "--stdin") |
485 | | - in, err := cmd.StdinPipe() |
486 | | - if err != nil { |
487 | | - return OID{}, err |
488 | | - } |
489 | | - |
490 | | - out, err := cmd.StdoutPipe() |
491 | | - if err != nil { |
492 | | - return OID{}, err |
493 | | - } |
494 | | - |
495 | | - cmd.Stderr = os.Stderr |
496 | | - |
497 | | - err = cmd.Start() |
498 | | - if err != nil { |
499 | | - return OID{}, err |
500 | | - } |
501 | | - |
502 | | - err = writer(in) |
503 | | - err2 := in.Close() |
504 | | - if err != nil { |
505 | | - cmd.Wait() |
506 | | - return OID{}, err |
507 | | - } |
508 | | - if err2 != nil { |
509 | | - cmd.Wait() |
510 | | - return OID{}, err2 |
511 | | - } |
512 | | - |
513 | | - output, err := ioutil.ReadAll(out) |
514 | | - err2 = cmd.Wait() |
515 | | - if err != nil { |
516 | | - return OID{}, err |
517 | | - } |
518 | | - if err2 != nil { |
519 | | - return OID{}, err2 |
520 | | - } |
521 | | - |
522 | | - return NewOID(string(bytes.TrimSpace(output))) |
523 | | -} |
524 | | - |
525 | | -func (repo *Repository) UpdateRef(refname string, oid OID) error { |
526 | | - var cmd *exec.Cmd |
527 | | - |
528 | | - if oid == NullOID { |
529 | | - cmd = repo.gitCommand("update-ref", "-d", refname) |
530 | | - } else { |
531 | | - cmd = repo.gitCommand("update-ref", refname, oid.String()) |
532 | | - } |
533 | | - return cmd.Run() |
534 | | -} |
535 | | - |
536 | 479 | // Next returns the next object, or EOF when done. |
537 | 480 | func (l *ObjectIter) Next() (OID, ObjectType, counts.Count32, error) { |
538 | 481 | line, err := l.f.ReadString('\n') |
|
0 commit comments