Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

references: sort: compare author timestamps when commit timestamps are equal. Fixes #725 #727

Merged
merged 231 commits into from
Oct 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
231 commits
Select commit Hold shift + click to select a range
ba267cb
references: sort: compare author timestamps when commit timestamps ar…
krylovsk Jan 21, 2018
66f08b8
new methods Worktree.[AddGlob|AddDirectory]
mcuadros Feb 1, 2018
0c19e6b
blame.go: Add blame line data
shanedasilva Feb 19, 2018
721449a
Merge pull request #754 from shanedasilva/add_blame_line_data
mcuadros Feb 21, 2018
779c88d
Return error when creating public keys from invalid PEM
mdelillo Feb 25, 2018
defd0b8
Merge pull request #759 from mdelillo/invalid-ssh-key
mcuadros Feb 25, 2018
9fb58fc
plumbing: format index, Index.Add and Index.Glob methods
mcuadros Feb 25, 2018
6d23b50
new methods Worktree.[AddGlob|RemoveBlob] and recursive Worktree.[Add…
mcuadros Feb 25, 2018
4397264
Merge pull request #739 from mcuadros/add
mcuadros Feb 28, 2018
7fd7090
plubming: transport, Escape the user and password for endpoint. Fixes…
zkry Feb 28, 2018
6588614
remove unused result parameter from objectsToPush
mvdan Mar 1, 2018
ede92fa
all: remove some unused code
mvdan Mar 1, 2018
e850aea
all: make the upcoming Go 1.11's vet happy
mvdan Mar 1, 2018
d8d17e7
Merge pull request #766 from mvdan/patches
mcuadros Mar 1, 2018
43fe660
Merge pull request #762 from zkry/escape-basic-auth-user-pswd
mcuadros Mar 1, 2018
fa6b152
storage/filesystem: optimize packfile iterator
Mar 3, 2018
d0fcd71
add LogOrder, LogOptions.Order, implement Order=LogOrderCommitterTime…
ilius Mar 5, 2018
dad9207
Fix "too few values in struct initializer" in repository_test.go
ilius Mar 5, 2018
ecda5c1
Merge pull request #769 from dennwc/optimize-1
mcuadros Mar 5, 2018
3b75e0c
add tests for NewCommitIterCTime and NewCommitIterBSF
ilius Mar 6, 2018
1d28459
Merge pull request #771 from ilius/PR-log-order
mcuadros Mar 12, 2018
4915f58
Added support for non-symlink checkouts on Windows when elevated righ…
fkollmann Mar 12, 2018
71e3741
Merge pull request #778 from konsorten/fix-windows-symlink3
mcuadros Mar 12, 2018
d873056
Fix RefSpec.Src()
maguro Mar 14, 2018
87b7078
Add more unit tests for RefSpec
maguro Mar 14, 2018
a39fae6
Merge pull request #783 from maguro/refspec-src
orirawlings Mar 14, 2018
4127002
*: skip time consuming tests
mcuadros Mar 21, 2018
160e6d5
Merge pull request #786 from mcuadros/test-short
mcuadros Mar 22, 2018
0b52302
Resolve HEAD if symRefs capability is not supported
ajnavarro Mar 26, 2018
05c414a
*: Use CheckClose with named returns
jfontan Mar 26, 2018
7a02aee
plumbing: transport, make target repo writeable in tests
jfontan Mar 27, 2018
a3cf123
Add commit hash to blame result
shanedasilva Mar 28, 2018
6e07548
storage: filesystem/dotgit, fix typo in return param
jfontan Mar 28, 2018
0c2618b
Merge pull request #794 from jfontan/fix/checkclose
mcuadros Apr 2, 2018
3293140
Merge pull request #795 from shanedasilva/add_commit_hash_to_blame_re…
mcuadros Apr 2, 2018
2cbff8d
Merge pull request #792 from ajnavarro/fix/support-no-symref-capability
mcuadros Apr 2, 2018
b4177b8
plumbing: format: pktline, Accept oversized pkt-lines up to 65524 bytes
josephvusich Apr 2, 2018
247cf69
Merge pull request #797 from jvusich/fix/oversize-pkt-line
mcuadros Apr 3, 2018
5e8e011
add PlainOpen variant to find .git in parent dirs
mvdan Mar 14, 2018
c4ace4d
Merge pull request #784 from mvdan/open-detect
mcuadros Apr 4, 2018
8338105
use bsd superset for conditional compilation
wardn Apr 10, 2018
02335b1
config: adds branches to config for tracking branches against remotes…
TheHipbot Apr 7, 2018
4099191
Merge pull request #804 from wardn/master
mcuadros Apr 11, 2018
0db54e8
Merge pull request #803 from TheHipbot/branch-tracking-on-clone
mcuadros Apr 11, 2018
6ea6016
dotgit: ignore filenames that don't match a hash
strib Apr 13, 2018
c3a1610
storage: dotgit, init fixtures in benchmark. Fixes #770
jfontan Apr 16, 2018
a042efa
Merge pull request #808 from jfontan/fix/benchmark-fixtures
mcuadros Apr 16, 2018
75da837
git: remote, Add shallow commits instead of substituting. Fixes #412
jfontan Apr 16, 2018
79db8cf
dotgit: add test for bad file in pack directory
strib Apr 16, 2018
0c7d7c6
Resolve full commit sha to plumbing hash
Jan 2, 2018
eec77c3
Merge pull request #807 from keybase/strib/src-d-ignore-non-hash-files
mcuadros Apr 17, 2018
60fd949
Merge pull request #810 from jfontan/fix/update-shallow
mcuadros Apr 17, 2018
46a247f
storage: filesystem, close shallow file when read
mcuadros Apr 17, 2018
b30763c
Merge pull request #706 from antham/resolve-commit-sha1
mcuadros Apr 17, 2018
6b33126
git: worktree, Skip special git directory. Fixes #814
Apr 18, 2018
87cc819
Merge pull request #815 from kuba--/fix-worktree/814
mcuadros Apr 18, 2018
47417ae
travis: dropping 1.8.x support due to golang.org/x/crypto/ssh require…
mcuadros May 2, 2018
2eb97fb
Use remote name in fetch while clone
fooker May 9, 2018
e63b032
Worktree: Provide ability to add excludes (#825)
maguro May 11, 2018
939793b
git: remote, Do not iterate all references on update.
jfontan May 14, 2018
57570e8
Merge pull request #833 from jfontan/slow-reference-update
mcuadros May 16, 2018
689e334
idxfile: optimise allocations in readObjectNames
dsymonds May 30, 2018
cf532f9
packfile: improve Index memory representation to be more compact
dsymonds May 30, 2018
79b7f24
config: modules, Ignore submodules with dotdot '..' path components. …
josephvusich May 30, 2018
d87faec
worktree: Don't allow .gitmodules to be a symlink. Fixes CVE-2018-11235
josephvusich May 30, 2018
8955f06
Merge pull request #845 from dsymonds/master
mcuadros Jun 5, 2018
b0d807a
dotgit: Move package outside internal.
ajnavarro Jun 5, 2018
c39bd4d
Remove println
ajnavarro Jun 5, 2018
ae788cf
Merge pull request #854 from ajnavarro/dotgit-not-internal
mcuadros Jun 6, 2018
d33d3ef
Merge pull request #848 from josephvusich/fix/cve-2018-11235
mcuadros Jun 6, 2018
73c775e
Merge pull request #846 from dsymonds/compact
mcuadros Jun 6, 2018
f019589
plumbing: object, adds tree path cache to trees. Fixes #793
jfontan Jun 6, 2018
a8a12e0
Merge pull request #855 from jfontan/improvement/cache-tree-findentry
mcuadros Jun 7, 2018
88f0dc3
plumbing: packfile, Don't push empty objects. Fixes #840
Jun 7, 2018
b235700
Merge pull request #856 from kuba--/fix-840/corrupted-objects
mcuadros Jun 8, 2018
ecd2bd5
storage: filesystem, make ObjectStorage constructor public
erizocosmico Jun 8, 2018
bf61908
plumbing/transport: http, Adds token authentication support [Fixes #858]
Jun 8, 2018
e7cf6d2
Merge pull request #857 from erizocosmico/feature/object-storage-public
mcuadros Jun 11, 2018
0710c6c
Merge pull request #859 from ebilling/fix-858/token-authentication
mcuadros Jun 11, 2018
960fe7b
Fix documentation for Notes
thehowl Jun 13, 2018
2d9816a
packfile: optimise NewIndexFromIdxFile for a very common case
dsymonds Jun 21, 2018
b53ba8d
Remote.Fetch: error on missing remote reference
mcuadros Jun 21, 2018
b11eaab
Merge pull request #869 from dsymonds/compact
mcuadros Jun 21, 2018
da5d474
storage/filesystem: avoid norwfs build flag
smola Jun 15, 2018
662e2c2
Merge pull request #870 from mcuadros/fetch-error
mcuadros Jun 26, 2018
7d9b66f
utils: diff, skip useless rune->string conversion
Jun 26, 2018
fcfd239
Merge pull request #873 from smola/fix-diff
mcuadros Jun 27, 2018
9251ea7
plumbing: add context to allow cancel on diff/patch computing
Jun 26, 2018
e1c2694
worktree: add test for correct tree sorting (issue #881)
spottybenny Jul 2, 2018
7ff71b5
worktree: sort the tree object. Fixes #881
spottybenny Jul 3, 2018
8ad72db
Merge pull request #864 from smola/no-norwfs
mcuadros Jul 6, 2018
f0c4318
worktree: address PR comments: sort imports appropriately
spottybenny Jul 8, 2018
b304997
plumbing: object, expose ErrEntryNotFound in FindEntry. Fixes #883
jsravn Jul 5, 2018
3bd5e82
Merge pull request #874 from smola/patchcontext
mcuadros Jul 10, 2018
54d8c38
plumbing/transport/internal: common, add support of Gogs for ErrRepos…
jeromedoucet Jul 14, 2018
400b083
Merge pull request #888 from jeromedoucet/tech/add_gog_repository_not…
mcuadros Jul 16, 2018
5b1d537
Merge pull request #885 from jsravn/findentry-return-file-not-found
mcuadros Jul 16, 2018
9f00789
Merge pull request #862 from thehowl/patch-1
mcuadros Jul 16, 2018
8df413f
plumbing/object: fix pgp signature encoder/decoder
jfontan Jul 18, 2018
009f106
plumbing/format/idxfile: add new Index and MemoryIndex
erizocosmico Jul 19, 2018
a8ff3e5
Merge pull request #896 from erizocosmico/feature/new-index-decoder
erizocosmico Jul 26, 2018
da5677f
plumbing/packfile: add new packfile parser
jfontan Jul 19, 2018
ce91d71
plumbing/packfile: disable lookup by offset
jfontan Jul 19, 2018
355cfc3
plumbing: idxfile, add idxfile.Writer with Observer interface
jfontan Jul 19, 2018
4e3765a
plumbing/idxfile: use Entry to hold object data
jfontan Jul 20, 2018
65e8359
plumbing/idxfile: support offset64 generating indexes
jfontan Jul 20, 2018
a716126
plumbing/packfile: preallocate memory in PatchDelta
jfontan Jul 24, 2018
7418b41
plumbing/idxfile: fix bug searching in MemoryIndex
jfontan Jul 26, 2018
4ddd678
plumbing/idxfile: add offset/hash mapping to index
jfontan Jul 26, 2018
74f56f3
plumbing/idxfile: index is created only once and retrieved with Index
jfontan Jul 26, 2018
79f2494
plumbing, storage: integrate new index
jfontan Jul 26, 2018
a08061a
Merge pull request #898 from jfontan/feature/new-packfile-parser
jfontan Jul 26, 2018
ffdfb7d
plumbing: packfile, new Packfile representation
erizocosmico Jul 20, 2018
bc565c1
plumbing, packfile: delete index_test as is no longer used
jfontan Jul 26, 2018
4b366ac
plumbing: fix two errors in idxfile and packfile decoder
jfontan Jul 26, 2018
3657a32
storage/filesystem: add back IndexStorage
jfontan Jul 27, 2018
b713101
Merge pull request #902 from jfontan/feature/new-packfile-parser
jfontan Jul 27, 2018
ccd0fa0
plumbing: packfile, lazy object reads with DiskObjects
erizocosmico Jul 27, 2018
0ade8fb
Merge pull request #899 from erizocosmico/feature/new-packfile
erizocosmico Jul 27, 2018
823abfe
plumbing/idxfile: test FindHash and writer with 64 bit offsets
jfontan Jul 27, 2018
6f8f2ed
storage/filesystem: remove duplicated IndexStorage
jfontan Jul 27, 2018
b4cd089
plumbing/packfile: add index generation to decoder
jfontan Jul 27, 2018
d314e86
Merge pull request #904 from jfontan/feature/new-packfile-parser
jfontan Jul 27, 2018
3d2bcda
Fix wrong godoc on Tags() method.
ajnavarro Jul 30, 2018
6f7fc05
plumbing: packfile, fix package tests
erizocosmico Jul 30, 2018
b173cc0
Merge pull request #907 from erizocosmico/feature/fix-tests
erizocosmico Aug 1, 2018
c58d68a
Merge pull request #905 from ajnavarro/fix/tag-godoc
mcuadros Aug 2, 2018
43d17e1
Merge pull request #892 from jfontan/fix/get-pgp-signature
mcuadros Aug 7, 2018
6a24b4c
*: use parser to populate non writable storages and bug fixes
erizocosmico Aug 7, 2018
7b12481
Fixed cloning of a single tag
fkorotkov Aug 8, 2018
5889a3b
plumbing: packfile, allow non-seekable sources on Parser
erizocosmico Aug 8, 2018
b3d995f
plumbing: packfile, add Parse benchmark
erizocosmico Aug 9, 2018
c374092
Merge pull request #910 from fkorotkov/fedor/fix-tag-cloning
mcuadros Aug 9, 2018
71a3c91
plumbing: packfile, read object content only once
erizocosmico Aug 9, 2018
34cc506
storage: filesystem, benchmark PackfileIter
erizocosmico Aug 9, 2018
65dc4f9
plumbing: packfile, rename DiskObject to FSObject
erizocosmico Aug 9, 2018
038cf23
storage: filesystem, close Packfile after iterating objects
erizocosmico Aug 9, 2018
d93b386
storage: filesystem, add PackfileIter benchmark reading object content
erizocosmico Aug 9, 2018
56c5e91
plumbing: packfile, open and close packfile on FSObject reads
erizocosmico Aug 9, 2018
b944bc4
git: add benchmark for iterating repository objects
erizocosmico Aug 10, 2018
8d75d23
plumbing: idxfile, Crc32 to CRC32 and return ok from findHashIndex
erizocosmico Aug 10, 2018
a28c2ce
Merge pull request #906 from src-d/perf/packfile-reads
mcuadros Aug 14, 2018
a8c4426
plumbing: add buffer cache and use it in packfile parser
jfontan Aug 14, 2018
555a6ca
plumbing/pacfile: tidy up objectInfo struct
jfontan Aug 14, 2018
eb2aa9b
plumbing/packfile: do not compute sha1 for already undeltified objects
jfontan Aug 14, 2018
ae55016
added hook support
Aug 14, 2018
ec3d2a8
plumbing: object, Don't add new line at end of commit signature
vancluever Aug 17, 2018
0ef699d
git: Add ability to PGP sign commits
vancluever Aug 17, 2018
c9b2eac
git: Remove use of strings.Builder
vancluever Aug 17, 2018
b2edb6d
git: Remove old hash validation code
vancluever Aug 17, 2018
39954f2
git: Add extra test for testing bad key error case
vancluever Aug 17, 2018
ba0f659
Merge pull request #916 from jfontan/improvement/memory-consumption-n…
mcuadros Aug 17, 2018
7b6c126
Merge pull request #920 from vancluever/f-add-commit-signkey
mcuadros Aug 17, 2018
8cf7edb
dotgit: fix object delete test
smola Aug 17, 2018
1666236
object: fix panic when reading object header
jfontan Aug 17, 2018
7b4a837
Fixed an edge case for .gitignore
fkorotkov Aug 19, 2018
1cef577
Merge pull request #924 from fkorotkov/fedor/fix-issue-923
mcuadros Aug 20, 2018
8120de8
Merge pull request #921 from jfontan/fix/empty-headers
mcuadros Aug 21, 2018
cc27d4a
Merge pull request #887 from noxora/hook-support
mcuadros Aug 21, 2018
f84c6b1
plumbing/idxfile: object iterators returns entries in offset order
jfontan Aug 21, 2018
cdfa0bb
Merge pull request #927 from jfontan/fix/iterate-objects-by-offset
mcuadros Aug 21, 2018
b9f5efe
git: Add tagging support
vancluever Aug 18, 2018
9b73a3e
plumbing: object, correct tag PGP encoding
vancluever Aug 22, 2018
8c3c8b3
plumbing: object, don't add extra newline on PGP signature
vancluever Aug 22, 2018
2c2b532
git: Canonicalize incoming annotated tag messages
vancluever Aug 22, 2018
8d8d4c5
git: Replace test signing key with one with longer expiry
vancluever Aug 22, 2018
790191e
plumbing, storage: add bases to the common cache
jfontan Aug 22, 2018
005d5dc
Merge pull request #929 from jfontan/fix/reuse-base-cache
mcuadros Aug 22, 2018
119459a
git: Discern tag target type from supplied hash
vancluever Aug 23, 2018
01631f0
git: Don't return tag object with Tag, adjust docs for Tag and Tags
vancluever Aug 23, 2018
c7a4011
storage/dotgit: search for incoming dir only once
jfontan Aug 25, 2018
b1da90b
storage/dotgit: use HasPrefix instead of Split
jfontan Aug 27, 2018
5cc316b
Merge pull request #935 from jfontan/improvement/cache-incoming-direc…
mcuadros Aug 29, 2018
0167dab
Remove empty dirs when cleaning with Dir opt.
Aug 24, 2018
75fa41d
Add Status.IsUntracked function
Aug 29, 2018
ba3ee05
plumbing: object: Clamp object timestamps before unix epoch to unix e…
taruti Aug 29, 2018
34b101e
Merge pull request #933 from kuba--/fix-895/clean-dir
mcuadros Aug 29, 2018
14d9faa
config: add commentChar to core config struct
zaquestion Aug 29, 2018
7f42492
Merge pull request #937 from zaquestion/comment_char
mcuadros Aug 30, 2018
1e1a7d0
git: add Static option to PlainOpen
jfontan Aug 30, 2018
82945e3
git, storer: use a common storer.Options for storer and PlainOpen
jfontan Aug 30, 2018
d7e6cf5
dotgit: fix typo in comment
jfontan Aug 30, 2018
2a7c664
git: do not expose storage options in PlainOpen
jfontan Aug 31, 2018
cf62667
plumbing/storer: rename Static option to ExclusiveAccess
jfontan Aug 31, 2018
95acbf6
storage/filesystem: make Storage options private
jfontan Sep 3, 2018
874f669
storage/filesystem: move Options to filesytem and dotgit
jfontan Sep 3, 2018
659ec44
storage/dotgit: add ExclusiveAccess tests in dotgit
jfontan Sep 3, 2018
8e76874
Merge pull request #939 from keybase/taruti/cherrypick-for-upstream-c…
mcuadros Sep 4, 2018
2f15838
Merge pull request #941 from jfontan/improvement/static-mode
mcuadros Sep 4, 2018
6384ab9
storage/dotgit: add KeepDescriptors option
jfontan Aug 30, 2018
5260b87
plumbing/storer: do not expose Close in EncodedObjectStorer interface
jfontan Sep 4, 2018
9013dde
storage/filesystem: add KeepDescriptors test
jfontan Sep 5, 2018
8176f08
storage/filesystem: compare files using offset in test
jfontan Sep 6, 2018
174f373
Merge pull request #942 from jfontan/improvement/maintain-packfiles-open
mcuadros Sep 6, 2018
d3cec13
worktree: solve merge conflicts
mcuadros Sep 6, 2018
a4b12e4
plumbing/transport: ssh check if list of known_hosts files is empty
kuba-- Sep 7, 2018
80170bd
Fix fatal corrupt patch in unified diff format
ajnavarro Sep 7, 2018
8f6b312
Expose Storage cache.
Sep 7, 2018
6b3f46b
git: s/fetch/returns/ on Tag function doc
vancluever Sep 7, 2018
1000bc0
git: Add Tag objects to the list of supported objects for walking
vancluever Sep 7, 2018
b19b3b8
git: Don't touch tag objects orphaned by tag deletion
vancluever Sep 7, 2018
9cc654c
git: Add some tests for annotated tag deletion
vancluever Sep 7, 2018
f8adfff
git: s/TagObjectOptions/CreateTagOptions/
vancluever Sep 7, 2018
208b3c3
Merge pull request #949 from kuba--/custom-cache
mcuadros Sep 8, 2018
a2d62f5
Merge pull request #932 from flant/fix-negative-range-info
mcuadros Sep 10, 2018
bf0593d
Merge branch 'master' of github.com:src-d/go-git into f-add-tagging-s…
mcuadros Sep 10, 2018
9ce4eea
repository: fix test for new Storage constructor
mcuadros Sep 10, 2018
38060c9
Merge pull request #928 from vancluever/f-add-tagging-support
mcuadros Sep 10, 2018
83649a1
*: go modules support
mcuadros Sep 10, 2018
2fb32d2
travis: drop go1.9 add go1.11
mcuadros Sep 10, 2018
4896974
Fix potential LRU cache size issue.
Sep 17, 2018
edfc16e
Remove empty space to trigger windows build.
Sep 17, 2018
f69f530
Merge pull request #958 from kuba--/fix-cachesize
mcuadros Sep 18, 2018
82c7a30
storage/filesystem: keep packs open in PackfileIter
jfontan Sep 20, 2018
a7b0102
storage/filesystem: add more doc to NewPackfileIter
jfontan Sep 21, 2018
c2ab4ac
Merge pull request #962 from jfontan/fix/do-not-close-files-in-iterator
mcuadros Sep 21, 2018
156d632
all: remove extra 's' in "mismatch"
jmkim Sep 26, 2018
1fdd36c
Merge pull request #966 from jmkim/fix-typo
mcuadros Sep 26, 2018
37f80c6
test: improve test for urlencoded user:pass
smola Sep 27, 2018
41af429
use time.IsZero in Prune
u5surf Oct 2, 2018
c2ba07b
Add test for Windows local paths.
filipnavara Oct 5, 2018
da56abd
git: Fix Status.IsClean() documentation
urld Oct 6, 2018
80afdec
Merge pull request #968 from smola/improve-test-weird-userpass
mcuadros Oct 9, 2018
ba9c38b
Merge pull request #974 from u5surf/issue-813
mcuadros Oct 9, 2018
37caf1f
Merge pull request #978 from urld/isclean
mcuadros Oct 9, 2018
299f583
Merge pull request #977 from filipnavara/config-test
mcuadros Oct 9, 2018
0bfe038
Plumbing: object, Add support for Log with filenames. Fixes #826 (#979)
gnithin Oct 11, 2018
529f843
use remote name in fetch while clone, test
mcuadros Oct 15, 2018
0381008
Merge pull request #828 from fooker/patch-1
mcuadros Oct 15, 2018
d4848fd
Merge branch 'bugfix/references-sort-timestamps' of github.com:krylov…
mcuadros Oct 15, 2018
e250584
references: sort: compare author timestamps when commit timestamps ar…
mcuadros Oct 15, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
coverage.out
*~
coverage.txt
profile.out
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
language: go

go:
- 1.8.x
- 1.9.x
- "1.10"
- "1.11"

go_import_path: gopkg.in/src-d/go-git.v4

Expand Down
2 changes: 1 addition & 1 deletion _examples/branch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func main() {

// Create a new plumbing.HashReference object with the name of the branch
// and the hash from the HEAD. The reference name should be a full reference
// name and now a abbreviated one, as is used on the git cli.
// name and not an abbreviated one, as is used on the git cli.
//
// For tags we should use `refs/tags/%s` instead of `refs/heads/%s` used
// for branches.
Expand Down
11 changes: 9 additions & 2 deletions blame.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"strconv"
"strings"
"time"
"unicode/utf8"

"gopkg.in/src-d/go-git.v4/plumbing"
Expand Down Expand Up @@ -106,12 +107,18 @@ type Line struct {
Author string
// Text is the original text of the line.
Text string
// Date is when the original text of the line was introduced
Date time.Time
// Hash is the commit hash that introduced the original line
Hash plumbing.Hash
}

func newLine(author, text string) *Line {
func newLine(author, text string, date time.Time, hash plumbing.Hash) *Line {
return &Line{
Author: author,
Text: text,
Hash: hash,
Date: date,
}
}

Expand All @@ -121,7 +128,7 @@ func newLines(contents []string, commits []*object.Commit) ([]*Line, error) {
}
result := make([]*Line, 0, len(contents))
for i := range contents {
l := newLine(commits[i].Author.Email, contents[i])
l := newLine(commits[i].Author.Email, contents[i], commits[i].Author.When, commits[i].Hash)
result = append(result, l)
}
return result, nil
Expand Down
6 changes: 6 additions & 0 deletions blame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ func (s *BlameSuite) TestBlame(c *C) {
obt, err := Blame(commit, t.path)
c.Assert(err, IsNil)
c.Assert(obt, DeepEquals, exp)

for i, l := range obt.Lines {
c.Assert(l.Hash.String(), Equals, t.blames[i])
}
}
}

Expand All @@ -53,6 +57,8 @@ func (s *BlameSuite) mockBlame(c *C, t blameTest, r *Repository) (blame *BlameRe
l := &Line{
Author: commit.Author.Email,
Text: lines[i],
Date: commit.Author.When,
Hash: commit.Hash,
}
blamedLines = append(blamedLines, l)
}
Expand Down
20 changes: 4 additions & 16 deletions common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/cache"
"gopkg.in/src-d/go-git.v4/plumbing/format/packfile"
"gopkg.in/src-d/go-git.v4/plumbing/transport"
"gopkg.in/src-d/go-git.v4/storage/filesystem"
Expand Down Expand Up @@ -59,10 +60,7 @@ func (s *BaseSuite) NewRepository(f *fixtures.Fixture) *Repository {
dotgit = f.DotGit()
worktree = memfs.New()

st, err := filesystem.NewStorage(dotgit)
if err != nil {
panic(err)
}
st := filesystem.NewStorage(dotgit, cache.NewObjectLRUDefault())

r, err := Open(st, worktree)
if err != nil {
Expand All @@ -89,10 +87,7 @@ func (s *BaseSuite) NewRepositoryWithEmptyWorktree(f *fixtures.Fixture) *Reposit

worktree := memfs.New()

st, err := filesystem.NewStorage(dotgit)
if err != nil {
panic(err)
}
st := filesystem.NewStorage(dotgit, cache.NewObjectLRUDefault())

r, err := Open(st, worktree)
if err != nil {
Expand All @@ -113,14 +108,7 @@ func (s *BaseSuite) NewRepositoryFromPackfile(f *fixtures.Fixture) *Repository {
p := f.Packfile()
defer p.Close()

n := packfile.NewScanner(p)
d, err := packfile.NewDecoder(n, storer)
if err != nil {
panic(err)
}

_, err = d.Decode()
if err != nil {
if err := packfile.UpdateObjectStorage(storer, p); err != nil {
panic(err)
}

Expand Down
71 changes: 71 additions & 0 deletions config/branch.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package config

import (
"errors"

"gopkg.in/src-d/go-git.v4/plumbing"
format "gopkg.in/src-d/go-git.v4/plumbing/format/config"
)

var (
errBranchEmptyName = errors.New("branch config: empty name")
errBranchInvalidMerge = errors.New("branch config: invalid merge")
)

// Branch contains information on the
// local branches and which remote to track
type Branch struct {
// Name of branch
Name string
// Remote name of remote to track
Remote string
// Merge is the local refspec for the branch
Merge plumbing.ReferenceName

raw *format.Subsection
}

// Validate validates fields of branch
func (b *Branch) Validate() error {
if b.Name == "" {
return errBranchEmptyName
}

if b.Merge != "" && !b.Merge.IsBranch() {
return errBranchInvalidMerge
}

return nil
}

func (b *Branch) marshal() *format.Subsection {
if b.raw == nil {
b.raw = &format.Subsection{}
}

b.raw.Name = b.Name

if b.Remote == "" {
b.raw.RemoveOption(remoteSection)
} else {
b.raw.SetOption(remoteSection, b.Remote)
}

if b.Merge == "" {
b.raw.RemoveOption(mergeKey)
} else {
b.raw.SetOption(mergeKey, string(b.Merge))
}

return b.raw
}

func (b *Branch) unmarshal(s *format.Subsection) error {
b.raw = s

b.Name = b.raw.Name
b.Remote = b.raw.Options.Get(remoteSection)
b.Merge = plumbing.ReferenceName(b.raw.Options.Get(mergeKey))

return b.Validate()
}
76 changes: 76 additions & 0 deletions config/branch_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package config

import (
. "gopkg.in/check.v1"
"gopkg.in/src-d/go-git.v4/plumbing"
)

type BranchSuite struct{}

var _ = Suite(&BranchSuite{})

func (b *BranchSuite) TestValidateName(c *C) {
goodBranch := Branch{
Name: "master",
Remote: "some_remote",
Merge: "refs/heads/master",
}
badBranch := Branch{
Remote: "some_remote",
Merge: "refs/heads/master",
}
c.Assert(goodBranch.Validate(), IsNil)
c.Assert(badBranch.Validate(), NotNil)
}

func (b *BranchSuite) TestValidateMerge(c *C) {
goodBranch := Branch{
Name: "master",
Remote: "some_remote",
Merge: "refs/heads/master",
}
badBranch := Branch{
Name: "master",
Remote: "some_remote",
Merge: "blah",
}
c.Assert(goodBranch.Validate(), IsNil)
c.Assert(badBranch.Validate(), NotNil)
}

func (b *BranchSuite) TestMarshall(c *C) {
expected := []byte(`[core]
bare = false
[branch "branch-tracking-on-clone"]
remote = fork
merge = refs/heads/branch-tracking-on-clone
`)

cfg := NewConfig()
cfg.Branches["branch-tracking-on-clone"] = &Branch{
Name: "branch-tracking-on-clone",
Remote: "fork",
Merge: plumbing.ReferenceName("refs/heads/branch-tracking-on-clone"),
}

actual, err := cfg.Marshal()
c.Assert(err, IsNil)
c.Assert(string(actual), Equals, string(expected))
}

func (b *BranchSuite) TestUnmarshall(c *C) {
input := []byte(`[core]
bare = false
[branch "branch-tracking-on-clone"]
remote = fork
merge = refs/heads/branch-tracking-on-clone
`)

cfg := NewConfig()
err := cfg.Unmarshal(input)
c.Assert(err, IsNil)
branch := cfg.Branches["branch-tracking-on-clone"]
c.Assert(branch.Name, Equals, "branch-tracking-on-clone")
c.Assert(branch.Remote, Equals, "fork")
c.Assert(branch.Merge, Equals, plumbing.ReferenceName("refs/heads/branch-tracking-on-clone"))
}
Loading