Skip to content

Commit da4fdef

Browse files
committed
Support SHA-256 repositories
Git will start to support SHA-256 as a hash for repositories in the near future. Let's update gitobj to version 2 to support SHA-256 repositories properly. We initialize the repository based on the extensions.objectFormat value, if one is provided, since this is the configuration key that represents the hash algorithm. Vendor the proper dependencies in place.
1 parent 3d0efde commit da4fdef

61 files changed

Lines changed: 240 additions & 147 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

commands/command_migrate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/git-lfs/git-lfs/git"
1111
"github.com/git-lfs/git-lfs/git/githistory"
1212
"github.com/git-lfs/git-lfs/tasklog"
13-
"github.com/git-lfs/gitobj"
13+
"github.com/git-lfs/gitobj/v2"
1414
"github.com/spf13/cobra"
1515
)
1616

commands/command_migrate_export.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/git-lfs/git-lfs/lfs"
1313
"github.com/git-lfs/git-lfs/tasklog"
1414
"github.com/git-lfs/git-lfs/tools"
15-
"github.com/git-lfs/gitobj"
15+
"github.com/git-lfs/gitobj/v2"
1616
"github.com/spf13/cobra"
1717
)
1818

commands/command_migrate_import.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/git-lfs/git-lfs/lfs"
1818
"github.com/git-lfs/git-lfs/tasklog"
1919
"github.com/git-lfs/git-lfs/tools"
20-
"github.com/git-lfs/gitobj"
20+
"github.com/git-lfs/gitobj/v2"
2121
"github.com/spf13/cobra"
2222
)
2323

commands/command_migrate_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/git-lfs/git-lfs/tasklog"
1414
"github.com/git-lfs/git-lfs/tools"
1515
"github.com/git-lfs/git-lfs/tools/humanize"
16-
"github.com/git-lfs/gitobj"
16+
"github.com/git-lfs/gitobj/v2"
1717
"github.com/spf13/cobra"
1818
)
1919

git/git.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
lfserrors "github.com/git-lfs/git-lfs/errors"
2727
"github.com/git-lfs/git-lfs/subprocess"
2828
"github.com/git-lfs/git-lfs/tools"
29-
"github.com/git-lfs/gitobj"
29+
"github.com/git-lfs/gitobj/v2"
3030
"github.com/rubyist/tracerx"
3131
)
3232

@@ -1427,6 +1427,21 @@ func IsWorkingCopyDirty() (bool, error) {
14271427
}
14281428

14291429
func ObjectDatabase(osEnv, gitEnv Environment, gitdir, tempdir string) (*gitobj.ObjectDatabase, error) {
1430+
var options []gitobj.Option
14301431
alternates, _ := osEnv.Get("GIT_ALTERNATE_OBJECT_DIRECTORIES")
1431-
return gitobj.FromFilesystemWithAlternates(filepath.Join(gitdir, "objects"), tempdir, alternates)
1432+
if alternates != "" {
1433+
options = append(options, gitobj.Alternates(alternates))
1434+
}
1435+
hashAlgo, _ := gitEnv.Get("extensions.objectformat")
1436+
if hashAlgo != "" {
1437+
options = append(options, gitobj.ObjectFormat(gitobj.ObjectFormatAlgorithm(hashAlgo)))
1438+
}
1439+
odb, err := gitobj.FromFilesystem(filepath.Join(gitdir, "objects"), tempdir, options...)
1440+
if err != nil {
1441+
return nil, err
1442+
}
1443+
if odb.Hasher() == nil {
1444+
return nil, fmt.Errorf("unsupported repository hash algorithm %q", hashAlgo)
1445+
}
1446+
return odb, nil
14321447
}

git/gitattr/tree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package gitattr
33
import (
44
"strings"
55

6-
"github.com/git-lfs/gitobj"
6+
"github.com/git-lfs/gitobj/v2"
77
)
88

99
// Tree represents the .gitattributes file at one layer of the tree in a Git

git/gitattr/tree_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66
"testing"
77

8-
"github.com/git-lfs/gitobj"
8+
"github.com/git-lfs/gitobj/v2"
99
"github.com/git-lfs/wildmatch"
1010
"github.com/stretchr/testify/assert"
1111
"github.com/stretchr/testify/require"

git/githistory/fixtures_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"strings"
1212
"testing"
1313

14-
"github.com/git-lfs/gitobj"
14+
"github.com/git-lfs/gitobj/v2"
1515
"github.com/stretchr/testify/assert"
1616
)
1717

git/githistory/ref_updater.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/git-lfs/git-lfs/git"
1010
"github.com/git-lfs/git-lfs/tasklog"
1111
"github.com/git-lfs/git-lfs/tools"
12-
"github.com/git-lfs/gitobj"
12+
"github.com/git-lfs/gitobj/v2"
1313
)
1414

1515
// refUpdater is a type responsible for moving references from one point in the

git/githistory/rewriter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/git-lfs/git-lfs/filepathfilter"
1313
"github.com/git-lfs/git-lfs/git"
1414
"github.com/git-lfs/git-lfs/tasklog"
15-
"github.com/git-lfs/gitobj"
15+
"github.com/git-lfs/gitobj/v2"
1616
)
1717

1818
// Rewriter allows rewriting topologically equivalent Git histories

0 commit comments

Comments
 (0)