Explorar el Código

Use correct latest commit for files

The commit must match *all* parents, otherwise it is not the latest
commit for the file.  This means it must appear in the diff of the
commit against all its parents.

This behaviour has been adapted from the one in the libgit2 log example,
located in the `examples/log.c` file in libgit2.
Lucas Stadler %!s(int64=8) %!d(string=hace) años
padre
commit
d12ca4f82b
Se han modificado 1 ficheros con 23 adiciones y 17 borrados
  1. 23 17
      quit.go

+ 23 - 17
quit.go

@ -466,25 +466,31 @@ func (fc *FancyFile) Commit() (*FancyCommit, error) {
466 466
				return false
467 467
			}
468 468
469
			parentCommit := commit.Parent(0)
470
			parentTree, err := parentCommit.Tree()
471
			if err != nil {
472
				findErr = err
473
				return false
474
			}
475
476
			diff, err := fc.repo.DiffTreeToTree(parentTree, tree, &opts)
477
			if err != nil {
478
				findErr = err
479
				return false
469
			matchesAll := true
470
			for i := uint(0); i < commit.ParentCount(); i++ {
471
				parentCommit := commit.Parent(i)
472
				parentTree, err := parentCommit.Tree()
473
				if err != nil {
474
					findErr = err
475
					return false
476
				}
477
478
				diff, err := fc.repo.DiffTreeToTree(parentTree, tree, &opts)
479
				if err != nil {
480
					findErr = err
481
					return false
482
				}
483
484
				n, err := diff.NumDeltas()
485
				if err != nil {
486
					findErr = err
487
					return false
488
				}
489
490
				matchesAll = matchesAll && n > 0
480 491
			}
481 492
482
			n, err := diff.NumDeltas()
483
			if err != nil {
484
				findErr = err
485
				return false
486
			}
487
			if n <= 0 {
493
			if !matchesAll {
488 494
				return true
489 495
			}
490 496