Skip to content

Commit

Permalink
packfile: add Index type
Browse files Browse the repository at this point in the history
Updates #12
  • Loading branch information
zombiezen committed Jan 16, 2021
1 parent 49cf25a commit 4f56935
Show file tree
Hide file tree
Showing 19 changed files with 791 additions and 29 deletions.
12 changes: 9 additions & 3 deletions CHANGELOG.md
Expand Up @@ -12,16 +12,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- A new `packfile/client` package enables downloading commits from and
uploading commits to remote Git repositories.
([#7](https://github.com/gg-scm/gg-git/issues/7))
- The `githash` package is now the home for the `Ref` type. This permits
ref string manipulation without depending on the larger `git` package.
`git.Ref` is now a type alias for `githash.Ref`.
- `*object.Commit` and `*object.Tag` now implement `BinaryMarshaler` and
`BinaryUnmarshaler` in addition to `TextMarshaler` and `TextUnmarshaler`.
This is for symmetry with `object.Tree`.
- The `packfile.DeltaReader` type is a flexible way of expanding a deltified
object from a packfile.
- The `packfile.Index` type stores a packfile object ID lookup table that is
interoperable with Git packfile index files.
([#12](https://github.com/gg-scm/gg-git/issues/12))
- `packfile.ReadHeader` enables random access to a packfile.

### Changed

- The `githash` package is now the home for the `Ref` type. This permits
ref string manipulation without depending on the larger `git` package.
`git.Ref` is now a type alias for `githash.Ref`.

### Removed

- Removed the `packfile.ApplyDelta` function. The `packfile.DeltaReader` type
Expand Down
16 changes: 8 additions & 8 deletions misc/genpack.go
Expand Up @@ -33,13 +33,13 @@ import (

func main() {
funcMap := map[string]func() error{
"Empty": empty,
"FirstCommit": firstCommit,
"DeltaOffset": deltaOffset,
"ObjectOffset": objectOffset,
"EmptyBlob": emptyBlob,
"TooLong": tooLong,
"TooShort": tooShort,
"Empty": empty,
"FirstCommit": firstCommit,
"DeltaOffset": deltaOffset,
"DeltaObject": deltaObject,
"EmptyBlob": emptyBlob,
"TooLong": tooLong,
"TooShort": tooShort,
}
var names []string
for k := range funcMap {
Expand Down Expand Up @@ -187,7 +187,7 @@ func deltaOffset() (err error) {
return nil
}

func objectOffset() (err error) {
func deltaObject() (err error) {
w := packfile.NewWriter(os.Stdout, 2)
defer func() {
if closeErr := w.Close(); err == nil && closeErr != nil {
Expand Down
30 changes: 30 additions & 0 deletions misc/indexpack.sh
@@ -0,0 +1,30 @@
#!/bin/bash
# Copyright 2021 The gg Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail
if [[ $# -eq 0 ]]; then
echo "usage: indexpack.sh PACKFILE [...]" 1>&2
exit 64
fi
for packfile in "$@"; do
idx1="${packfile/%.pack/.idx1}"
git index-pack --index-version=1 -o "$idx1" "$packfile"
idx2="${packfile/%.pack/.idx2}"
git index-pack --index-version=2 -o "$idx2" "$packfile"
# git-index-pack does not set the writable bit.
chmod u+w "$idx1" "$idx2"
done

0 comments on commit 4f56935

Please sign in to comment.