|
7 | 7 | "errors" |
8 | 8 | "fmt" |
9 | 9 | "io" |
10 | | - "io/ioutil" |
11 | 10 | "os" |
12 | 11 | "os/exec" |
13 | 12 | "path/filepath" |
@@ -407,62 +406,6 @@ func (repo *Repository) NewObjectIter(args ...string) ( |
407 | 406 | }, in1, nil |
408 | 407 | } |
409 | 408 |
|
410 | | -// CreateObject creates a new Git object, of the specified type, in |
411 | | -// `Repository`. `writer` is a function that writes the object in `git |
412 | | -// hash-object` input format. This is used for testing only. |
413 | | -func (repo *Repository) CreateObject(t ObjectType, writer func(io.Writer) error) (OID, error) { |
414 | | - cmd := repo.gitCommand("hash-object", "-w", "-t", string(t), "--stdin") |
415 | | - in, err := cmd.StdinPipe() |
416 | | - if err != nil { |
417 | | - return OID{}, err |
418 | | - } |
419 | | - |
420 | | - out, err := cmd.StdoutPipe() |
421 | | - if err != nil { |
422 | | - return OID{}, err |
423 | | - } |
424 | | - |
425 | | - cmd.Stderr = os.Stderr |
426 | | - |
427 | | - err = cmd.Start() |
428 | | - if err != nil { |
429 | | - return OID{}, err |
430 | | - } |
431 | | - |
432 | | - err = writer(in) |
433 | | - err2 := in.Close() |
434 | | - if err != nil { |
435 | | - cmd.Wait() |
436 | | - return OID{}, err |
437 | | - } |
438 | | - if err2 != nil { |
439 | | - cmd.Wait() |
440 | | - return OID{}, err2 |
441 | | - } |
442 | | - |
443 | | - output, err := ioutil.ReadAll(out) |
444 | | - err2 = cmd.Wait() |
445 | | - if err != nil { |
446 | | - return OID{}, err |
447 | | - } |
448 | | - if err2 != nil { |
449 | | - return OID{}, err2 |
450 | | - } |
451 | | - |
452 | | - return NewOID(string(bytes.TrimSpace(output))) |
453 | | -} |
454 | | - |
455 | | -func (repo *Repository) UpdateRef(refname string, oid OID) error { |
456 | | - var cmd *exec.Cmd |
457 | | - |
458 | | - if oid == NullOID { |
459 | | - cmd = repo.gitCommand("update-ref", "-d", refname) |
460 | | - } else { |
461 | | - cmd = repo.gitCommand("update-ref", refname, oid.String()) |
462 | | - } |
463 | | - return cmd.Run() |
464 | | -} |
465 | | - |
466 | 409 | // Next returns the next object, or EOF when done. |
467 | 410 | func (l *ObjectIter) Next() (OID, ObjectType, counts.Count32, error) { |
468 | 411 | line, err := l.f.ReadString('\n') |
|
0 commit comments