Compare commits

...

16 commits

Author SHA1 Message Date
Fabien Potencier e5e71931e0
Merge pull request #72 from splitsh/deprecated-features-removal
Remove the --quiet and --legacy options
2023-10-26 03:11:09 +02:00
Fabien Potencier 806f4764e8 Remove the --quiet and --legacy options 2023-10-25 18:09:56 -07:00
Fabien Potencier f2d9253550 Add more detail about how to compile the binary 2023-10-25 18:09:24 -07:00
Fabien Potencier 852bb257f0
Merge pull request #71 from splitsh/github-actions
Add GitHub actions
2023-10-25 23:55:50 +02:00
Fabien Potencier f394dc9e6e Add GitHub actions 2023-10-25 14:54:04 -07:00
Fabien Potencier f69839fdbe Fix tests 2023-10-25 12:43:55 -07:00
Fabien Potencier cb8dc18103 Fix installation instructions 2023-10-25 12:27:32 -07:00
Fabien Potencier 6e0e2b2401 Fix more issues with tests 2023-10-25 12:19:35 -07:00
Fabien Potencier faf6867922 Fix CS 2023-10-25 12:12:32 -07:00
Fabien Potencier a11445a29c Simplify README 2023-10-25 12:09:21 -07:00
Fabien Potencier cd4e65afcd Update CHANGELOG 2023-10-25 12:08:12 -07:00
Fabien Potencier 000fd5e163
Merge pull request #69 from kdambekalns/task/compile-on-arm
Allow to compile on Apple silicon, use go modules
2023-10-25 21:04:06 +02:00
Karsten Dambekalns 93e0ef1670
Adjust manual install part in README.md 2023-10-23 11:54:45 +02:00
Karsten Dambekalns dba129b8af
Update go modules
Result of

    $ go get -u
    go: downloading golang.org/x/crypto v0.14.0
    go: downloading golang.org/x/sys v0.13.0
    go: downloading golang.org/x/term v0.13.0
    go: upgraded golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c => v0.14.0
    go: upgraded golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 => v0.13.0
    $ go mod tidy
2023-10-23 11:45:12 +02:00
Karsten Dambekalns f54790e733
Use "original" libgit2/git2go
Works with libgit2 1.5.0 installed using ´brew install libgit2`
2022-10-06 19:37:16 +02:00
Morel Sébastien 493f39ffeb
Make it work with M1 2022-10-06 18:48:02 +02:00
12 changed files with 313 additions and 218 deletions

38
.github/workflows/tests.yml vendored Normal file
View file

@ -0,0 +1,38 @@
name: tests
on:
pull_request:
push:
jobs:
update:
name: Run tests
runs-on: ubuntu-latest
steps:
-
name: Install libgit2-dev
run: sudo apt-get install -y libgit2-dev
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '^1.21.1'
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
-
name: Set the right libgit2 version
run: |
sed -i -e 's/v34/v31/g' go.mod splitter/*.go
go mod tidy
-
name: Test
run: go test -v ./...

View file

@ -1,14 +1,17 @@
CHANGELOG CHANGELOG
========= =========
* 1.1.0 (2019-XX-XX) * 2.0.0 (2023-XX-XX)
* deprecated the `--quiet` option (append `2>/dev/null` to the command instead) * move to go.mod
* moved information console display to stderr instead of stdout * remove the `--quiet` option (append `2>/dev/null` to the command instead)
* remove the `--legacy` option (same as `--git '<1.8.2'`)
* move information console display to stderr instead of stdout
* 1.0.1 (2017-02-24) * 1.0.1 (2017-02-24)
* added the `--version` flag * add the `--version` flag
* 1.0.0 (2017-01-02) * 1.0.0 (2017-01-02)

View file

@ -34,14 +34,41 @@ a monorepo, use the [tomono](https://github.com/unravelin/tomono) tool.
Installation Installation
------------ ------------
The fastest way to get started is to download a [binary][1] for your platform Manual Installation
and unarchive it with: -------------------
First, you need to install `libgit2`, preferably using your package manager of
choice.
If you get version `1.5`, jump to the compilation step below. If not, you first
need to change the version used in the code. Using the table on the
[libgit2](https://github.com/libgit2/git2go#which-go-version-to-use)
repository, figure out which version you need. Lets say you need version `v31`:
```bash ```bash
sudo tar -zxpf lite_linux_amd64.tar.gz --directory /usr/local/bin/ sed -i -e 's/v34/v31/g' go.mod splitter/*.go
go mod tidy
``` ```
You can also [install it manually](#manual-installation). Then, compile `splitsh-lite`:
```bash
go build -o splitsh-lite github.com/splitsh/lite
```
If everything goes fine, a `splitsh-lite` binary should be available in the
current directory.
If you get errors about an incompatible `libgit2` library, try exporting the
needed flags, e.g.
```bash
export LDFLAGS="-L/opt/homebrew/opt/libgit2@1.5/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libgit2@1.5/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/libgit2@1.5/lib/pkgconfig"
```
before running `go build`.
If you want to integrate splitsh with Git, install it like this (and use it via If you want to integrate splitsh with Git, install it like this (and use it via
`git splitsh`): `git splitsh`):
@ -114,9 +141,6 @@ Available options:
* `--progress` displays a progress bar; * `--progress` displays a progress bar;
* `--quiet` suppresses all output on stderr (useful when run from an automated
script);
* `--scratch` flushes the cache (useful when a branch is force pushed or in * `--scratch` flushes the cache (useful when a branch is force pushed or in
case of a cache corruption). case of a cache corruption).
@ -130,29 +154,3 @@ However, note that older versions of `git subtree split` used broken
algorithms, and so generated different `sha1`s than the latest version. You can algorithms, and so generated different `sha1`s than the latest version. You can
simulate those version via the `--git` flag. Use `<1.8.2` or `<2.8.0` depending simulate those version via the `--git` flag. Use `<1.8.2` or `<2.8.0` depending
on which version of `git subtree split` you want to simulate. on which version of `git subtree split` you want to simulate.
Manual Installation
-------------------
If you want to contribute to `splitsh-lite` or use it as a library, you first
need to install `libgit2`:
```bash
go get -d github.com/libgit2/git2go
cd $GOPATH/src/github.com/libgit2/git2go
git checkout next
git submodule update --init
make install
```
Then, compile `splitsh-lite`:
```bash
go get github.com/splitsh/lite
go build -o splitsh-lite github.com/splitsh/lite
```
If everything goes fine, a `splitsh-lite` binary should be available in the
current directory.
[1]: https://github.com/splitsh/lite/releases

13
go.mod Normal file
View file

@ -0,0 +1,13 @@
module github.com/splitsh/lite
go 1.21
require (
github.com/boltdb/bolt v1.3.1
github.com/libgit2/git2go/v34 v34.0.0
)
require (
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/sys v0.13.0 // indirect
)

52
go.sum Normal file
View file

@ -0,0 +1,52 @@
github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/libgit2/git2go/v34 v34.0.0 h1:UKoUaKLmiCRbOCD3PtUi2hD6hESSXzME/9OUZrGcgu8=
github.com/libgit2/git2go/v34 v34.0.0/go.mod h1:blVco2jDAw6YTXkErMMqzHLcAjKkwF0aWIRHBqiJkZ0=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

21
main.go
View file

@ -42,7 +42,7 @@ func (p *prefixesFlag) Set(value string) error {
var prefixes prefixesFlag var prefixes prefixesFlag
var origin, target, commit, path, gitVersion string var origin, target, commit, path, gitVersion string
var scratch, debug, quiet, legacy, progress, v bool var scratch, debug, progress, v bool
func init() { func init() {
flag.Var(&prefixes, "prefix", "The directory(ies) to split") flag.Var(&prefixes, "prefix", "The directory(ies) to split")
@ -52,8 +52,6 @@ func init() {
flag.StringVar(&path, "path", ".", "The repository path (optional, current directory by default)") flag.StringVar(&path, "path", ".", "The repository path (optional, current directory by default)")
flag.BoolVar(&scratch, "scratch", false, "Flush the cache (optional)") flag.BoolVar(&scratch, "scratch", false, "Flush the cache (optional)")
flag.BoolVar(&debug, "debug", false, "Enable the debug mode (optional)") flag.BoolVar(&debug, "debug", false, "Enable the debug mode (optional)")
flag.BoolVar(&quiet, "quiet", false, "[DEPRECATED] Suppress the output (optional)")
flag.BoolVar(&legacy, "legacy", false, "[DEPRECATED] Enable the legacy mode for projects migrating from an old version of git subtree split (optional)")
flag.StringVar(&gitVersion, "git", "latest", "Simulate a given version of Git (optional)") flag.StringVar(&gitVersion, "git", "latest", "Simulate a given version of Git (optional)")
flag.BoolVar(&progress, "progress", false, "Show progress bar (optional, cannot be enabled when debug is enabled)") flag.BoolVar(&progress, "progress", false, "Show progress bar (optional, cannot be enabled when debug is enabled)")
flag.BoolVar(&v, "version", false, "Show version") flag.BoolVar(&v, "version", false, "Show version")
@ -72,22 +70,13 @@ func main() {
os.Exit(1) os.Exit(1)
} }
if legacy {
fmt.Fprintln(os.Stderr, `The --legacy option is deprecated (use --git="<1.8.2" instead)`)
gitVersion = "<1.8.2"
}
if quiet {
fmt.Fprintln(os.Stderr, `The --quiet option is deprecated (append 2>/dev/null to the command instead)`)
}
config := &splitter.Config{ config := &splitter.Config{
Path: path, Path: path,
Origin: origin, Origin: origin,
Prefixes: []*splitter.Prefix(prefixes), Prefixes: []*splitter.Prefix(prefixes),
Target: target, Target: target,
Commit: commit, Commit: commit,
Debug: debug && !quiet, Debug: debug,
Scratch: scratch, Scratch: scratch,
GitVersion: gitVersion, GitVersion: gitVersion,
} }
@ -95,7 +84,7 @@ func main() {
result := &splitter.Result{} result := &splitter.Result{}
var ticker *time.Ticker var ticker *time.Ticker
if progress && !debug && !quiet { if progress && !debug {
ticker = time.NewTicker(time.Millisecond * 50) ticker = time.NewTicker(time.Millisecond * 50)
go func() { go func() {
for range ticker.C { for range ticker.C {
@ -113,9 +102,7 @@ func main() {
ticker.Stop() ticker.Stop()
} }
if !quiet { fmt.Fprintf(os.Stderr, "%d commits created, %d commits traversed, in %s\n", result.Created(), result.Traversed(), result.Duration(time.Millisecond))
fmt.Fprintf(os.Stderr, "%d commits created, %d commits traversed, in %s\n", result.Created(), result.Traversed(), result.Duration(time.Millisecond))
}
if result.Head() != nil { if result.Head() != nil {
fmt.Println(result.Head().String()) fmt.Println(result.Head().String())

View file

@ -1,167 +1,171 @@
#!/bin/bash #!/bin/bash
set -e set -euo pipefail
set -f
switchAsSammy()
{
AUTHOR_DATE=$1
COMMITTER_DATE=$2
export GIT_AUTHOR_NAME="Sammy Cobol"
export GIT_AUTHOR_EMAIL="<sammy.cobol@example.com>"
export GIT_AUTHOR_DATE="${AUTHOR_DATE}"
export GIT_COMMITTER_NAME="Fred Foobar"
export GIT_COMMITTER_EMAIL="<fred.foobar@example.com>"
export GIT_COMMITTER_DATE="${COMMITTER_DATE}"
}
switchAsFred() {
AUTHOR_DATE=$1
COMMITTER_DATE=$2
export GIT_AUTHOR_NAME="Fred Foobar"
export GIT_AUTHOR_EMAIL="<fred.foobar@example.com>"
export GIT_AUTHOR_DATE="${AUTHOR_DATE}"
export GIT_COMMITTER_NAME="Sammy Cobol"
export GIT_COMMITTER_EMAIL="<sammy.cobol@example.com>"
export GIT_COMMITTER_DATE="${COMMITTER_DATE}"
}
simpleTest() {
rm -rf simple
mkdir simple
cd simple
git init > /dev/null
switchAsSammy "Sat, 24 Nov 1973 19:01:02 +0200" "Sat, 24 Nov 1973 19:11:22 +0200"
echo "a" > a
git add a
git commit -m"added a" > /dev/null
switchAsFred "Sat, 24 Nov 1973 20:01:02 +0200" "Sat, 24 Nov 1973 20:11:22 +0200"
mkdir b/
echo "b" > b/b
git add b
git commit -m"added b" > /dev/null
switchAsFred "Sat, 24 Nov 1973 21:01:02 +0200" "Sat, 24 Nov 1973 21:11:22 +0200"
echo "aa" > a
git add a
git commit -m"updated a" > /dev/null
switchAsFred "Sat, 24 Nov 1973 22:01:02 +0200" "Sat, 24 Nov 1973 22:11:22 +0200"
git rm a > /dev/null
git commit -m"updated a" > /dev/null
switchAsFred "Sat, 24 Nov 1973 23:01:02 +0200" "Sat, 24 Nov 1973 23:11:22 +0200"
echo "bb" > b/b
git add b/
git commit -m"updated b" > /dev/null
GIT_SUBTREE_SPLIT_SHA1=`git subtree split --prefix=b/ -q`
GIT_SPLITSH_SHA1=`$LITE_PATH --prefix=b/ 2>/dev/null`
if [ "$GIT_SUBTREE_SPLIT_SHA1" == "$GIT_SPLITSH_SHA1" ]; then
echo "Test #1 - OK ($GIT_SUBTREE_SPLIT_SHA1 == $GIT_SPLITSH_SHA1)"
else
echo "Test #1 - NOT OK ($GIT_SUBTREE_SPLIT_SHA1 != $GIT_SPLITSH_SHA1)"
exit 1
fi
GIT_SUBTREE_SPLIT_SHA1=`git subtree split --prefix=b/ -q 71777969e7c0ddd02e0c060c5c892c083971b953`
GIT_SPLITSH_SHA1=`$LITE_PATH --prefix=b/ --commit=71777969e7c0ddd02e0c060c5c892c083971b953 2>/dev/null`
if [ "$GIT_SUBTREE_SPLIT_SHA1" == "$GIT_SPLITSH_SHA1" ]; then
echo "Test #2 - OK ($GIT_SUBTREE_SPLIT_SHA1 == $GIT_SPLITSH_SHA1)"
else
echo "Test #2 - NOT OK ($GIT_SUBTREE_SPLIT_SHA1 != $GIT_SPLITSH_SHA1)"
exit 1
fi
cd ../
}
mergeTest() {
rm -rf merge
mkdir -p merge/src
cd merge
git init > /dev/null
switchAsSammy "Sat, 24 Nov 1973 19:01:01 +0200" "Sat, 24 Nov 1973 19:01:01 +0200"
echo -e "a\n\nb\n\nc\n\n" > src/foo
git add src/foo
git commit -m"init" > /dev/null
git checkout -b branch1 2> /dev/null
switchAsSammy "Sat, 24 Nov 1973 19:02:02 +0200" "Sat, 24 Nov 1973 19:02:02 +0200"
echo -e "a\n\nb\nchange 2\nc\n\n" > src/foo
git commit -a -m"change 2" > /dev/null
switchAsSammy "Sat, 24 Nov 1973 19:02:02 +0200" "Sat, 24 Nov 1973 19:02:02 +0200"
echo -e "a\n\nb\nchange 2\nc\nchange 3\n" > src/foo
git commit -a -m"change 3" > /dev/null
git checkout main 2> /dev/null
switchAsSammy "Sat, 24 Nov 1973 19:02:02 +0200" "Sat, 24 Nov 1973 19:02:02 +0200"
echo -e "a\nchange 1\nb\n\nc\n\n" > src/foo
git commit -a -m"change 1" > /dev/null
git checkout -b branch2 2> /dev/null
switchAsSammy "Sat, 24 Nov 1973 19:02:02 +0200" "Sat, 24 Nov 1973 19:02:02 +0200"
echo -e "a\n\nb\nchange 2\nc\n\n" > src/foo
git commit -a -m"change 2" > /dev/null
git checkout main 2> /dev/null
git checkout -b branch3 2> /dev/null
git merge branch1 --no-edit > /dev/null
git merge branch2 --no-edit -s ours > /dev/null
GIT_SUBTREE_SPLIT_SHA1_2="a2c4245703f8dac149ab666242a12e1d4b2510d9"
GIT_SUBTREE_SPLIT_SHA1_3="ba0dab2c4e99d68d11088f2c556af92851e93b14"
GIT_SPLITSH_SHA1_2=`$LITE_PATH --git="<2.8.0" --prefix=src/ 2>/dev/null`
GIT_SPLITSH_SHA1_3=`$LITE_PATH --prefix=src/ 2>/dev/null`
if [ "$GIT_SUBTREE_SPLIT_SHA1_2" == "$GIT_SPLITSH_SHA1_2" ]; then
echo "Test #3 - OK ($GIT_SUBTREE_SPLIT_SHA1_2 == $GIT_SPLITSH_SHA1_2)"
else
echo "Test #3 - NOT OK ($GIT_SUBTREE_SPLIT_SHA1_2 != $GIT_SPLITSH_SHA1_2)"
exit 1
fi
if [ "$GIT_SUBTREE_SPLIT_SHA1_3" == "$GIT_SPLITSH_SHA1_3" ]; then
echo "Test #4 - OK ($GIT_SUBTREE_SPLIT_SHA1_3 == $GIT_SPLITSH_SHA1_3)"
else
echo "Test #4 - NOT OK ($GIT_SUBTREE_SPLIT_SHA1_3 != $GIT_SPLITSH_SHA1_3)"
exit 1
fi
cd ../
}
twigSplitTest() {
# run on some Open-Source repositories
if [ ! -d Twig ]; then
git clone https://github.com/twigphp/Twig > /dev/null
fi
GIT_SUBTREE_SPLIT_SHA1="ea449b0f2acba7d489a91f88154687250d2bdf42"
GIT_SPLITSH_SHA1=`$LITE_PATH --prefix=lib/ --origin=refs/tags/v1.24.1 --path=Twig --scratch 2>/dev/null`
if [ "$GIT_SUBTREE_SPLIT_SHA1" == "$GIT_SPLITSH_SHA1" ]; then
echo "Test #5 - OK ($GIT_SUBTREE_SPLIT_SHA1 == $GIT_SPLITSH_SHA1)"
else
echo "Test #5 - NOT OK ($GIT_SUBTREE_SPLIT_SHA1 != $GIT_SPLITSH_SHA1)"
exit 1
fi
cd ../
}
LITE_PATH=`pwd`/splitsh-lite
if [ ! -e $LITE_PATH ]; then
echo "You first need to compile the splitsh-lite binary"
exit 1
fi
if [ ! -d splitter-lite-tests ]; then if [ ! -d splitter-lite-tests ]; then
mkdir splitter-lite-tests mkdir splitter-lite-tests
fi fi
cd splitter-lite-tests cd splitter-lite-tests
rm -rf simple simpleTest
mkdir simple mergeTest
cd simple twigSplitTest
git init > /dev/null
export GIT_AUTHOR_NAME="Sammy Cobol"
export GIT_AUTHOR_EMAIL="<sammy.cobol@example.com>"
export GIT_AUTHOR_DATE="Sat, 24 Nov 1973 19:01:02 +0200"
export GIT_COMMITTER_NAME="Fred Foobar"
export GIT_COMMITTER_EMAIL="<fred.foobar@example.com>"
export GIT_COMMITTER_DATE="Sat, 24 Nov 1973 19:11:22 +0200"
echo "a" > a
git add a
git commit -m"added a" > /dev/null
export GIT_AUTHOR_NAME="Fred Foobar"
export GIT_AUTHOR_EMAIL="<fred.foobar@example.com>"
export GIT_AUTHOR_DATE="Sat, 24 Nov 1973 20:01:02 +0200"
export GIT_COMMITTER_NAME="Sammy Cobol"
export GIT_COMMITTER_EMAIL="<sammy.cobol@example.com>"
export GIT_COMMITTER_DATE="Sat, 24 Nov 1973 20:11:22 +0200"
mkdir b/
echo "b" > b/b
git add b
git commit -m"added b" > /dev/null
export GIT_AUTHOR_NAME="Fred Foobar"
export GIT_AUTHOR_EMAIL="<fred.foobar@example.com>"
export GIT_AUTHOR_DATE="Sat, 24 Nov 1973 21:01:02 +0200"
export GIT_COMMITTER_NAME="Sammy Cobol"
export GIT_COMMITTER_EMAIL="<sammy.cobol@example.com>"
export GIT_COMMITTER_DATE="Sat, 24 Nov 1973 21:11:22 +0200"
echo "aa" > a
git add a
git commit -m"updated a" > /dev/null
export GIT_AUTHOR_NAME="Fred Foobar"
export GIT_AUTHOR_EMAIL="<fred.foobar@example.com>"
export GIT_AUTHOR_DATE="Sat, 24 Nov 1973 22:01:02 +0200"
export GIT_COMMITTER_NAME="Sammy Cobol"
export GIT_COMMITTER_EMAIL="<sammy.cobol@example.com>"
export GIT_COMMITTER_DATE="Sat, 24 Nov 1973 22:11:22 +0200"
git rm a > /dev/null
git commit -m"updated a" > /dev/null
export GIT_AUTHOR_NAME="Fred Foobar"
export GIT_AUTHOR_EMAIL="<fred.foobar@example.com>"
export GIT_AUTHOR_DATE="Sat, 24 Nov 1973 23:01:02 +0200"
export GIT_COMMITTER_NAME="Sammy Cobol"
export GIT_COMMITTER_EMAIL="<sammy.cobol@example.com>"
export GIT_COMMITTER_DATE="Sat, 24 Nov 1973 23:11:22 +0200"
echo "bb" > b/b
git add b/
git commit -m"updated b" > /dev/null
GIT_SUBTREE_SPLIT_SHA1=`git subtree split --prefix=b/ -q`
GIT_SPLITSH_SHA1=`$GOPATH/src/github.com/splitsh/lite/lite --prefix=b/ --quiet`
if [ "$GIT_SUBTREE_SPLIT_SHA1" == "$GIT_SUBTREE_SPLIT_SHA1" ]; then
echo "OK ($GIT_SUBTREE_SPLIT_SHA1 == $GIT_SUBTREE_SPLIT_SHA1)"
else
echo "OK ($GIT_SUBTREE_SPLIT_SHA1 != $GIT_SUBTREE_SPLIT_SHA1)"
exit 1
fi
GIT_SUBTREE_SPLIT_SHA1=`git subtree split --prefix=b/ -q bff8cdfaaf78a8842b8d9241ccfd8fb6e026f508...`
GIT_SPLITSH_SHA1=`$GOPATH/src/github.com/splitsh/lite/lite --prefix=b/ --quiet --commit=bff8cdfaaf78a8842b8d9241ccfd8fb6e026f508`
if [ "$GIT_SUBTREE_SPLIT_SHA1" == "$GIT_SUBTREE_SPLIT_SHA1" ]; then
echo "OK ($GIT_SUBTREE_SPLIT_SHA1 == $GIT_SUBTREE_SPLIT_SHA1)"
else
echo "OK ($GIT_SUBTREE_SPLIT_SHA1 != $GIT_SUBTREE_SPLIT_SHA1)"
exit 1
fi
cd ../
rm -rf merge
mkdir -p merge/src
cd merge
git init > /dev/null
export GIT_AUTHOR_NAME="Sammy Cobol"
export GIT_AUTHOR_EMAIL="<sammy.cobol@example.com>"
export GIT_AUTHOR_DATE="Sat, 24 Nov 1973 19:01:01 +0200"
export GIT_COMMITTER_NAME="Fred Foobar"
export GIT_COMMITTER_EMAIL="<fred.foobar@example.com>"
export GIT_COMMITTER_DATE="Sat, 24 Nov 1973 19:01:01 +0200"
echo -e "a\n\nb\n\nc\n\n" > src/foo
git add src/foo
git commit -m"init" > /dev/null
git checkout -b branch1 2> /dev/null
export GIT_AUTHOR_DATE="Sat, 24 Nov 1973 19:02:02 +0200"
export GIT_COMMITTER_DATE="Sat, 24 Nov 1973 19:02:02 +0200"
echo -e "a\n\nb\nchange 2\nc\n\n" > src/foo
git commit -a -m"change 2" > /dev/null
export GIT_AUTHOR_DATE="Sat, 24 Nov 1973 19:02:02 +0200"
export GIT_COMMITTER_DATE="Sat, 24 Nov 1973 19:02:02 +0200"
echo -e "a\n\nb\nchange 2\nc\nchange 3\n" > src/foo
git commit -a -m"change 3" > /dev/null
git checkout master 2> /dev/null
export GIT_AUTHOR_DATE="Sat, 24 Nov 1973 19:02:02 +0200"
export GIT_COMMITTER_DATE="Sat, 24 Nov 1973 19:02:02 +0200"
echo -e "a\nchange 1\nb\n\nc\n\n" > src/foo
git commit -a -m"change 1" > /dev/null
git checkout -b branch2 2> /dev/null
export GIT_AUTHOR_DATE="Sat, 24 Nov 1973 19:02:02 +0200"
export GIT_COMMITTER_DATE="Sat, 24 Nov 1973 19:02:02 +0200"
echo -e "a\n\nb\nchange 2\nc\n\n" > src/foo
git commit -a -m"change 2" > /dev/null
git checkout master 2> /dev/null
git checkout -b branch3 2> /dev/null
git merge branch1 --no-edit > /dev/null
git merge branch2 --no-edit -s ours > /dev/null
GIT_SUBTREE_SPLIT_SHA1_2="a2c4245703f8dac149ab666242a12e1d4b2510d9"
GIT_SUBTREE_SPLIT_SHA1_3="ba0dab2c4e99d68d11088f2c556af92851e93b14"
GIT_SPLITSH_SHA1_2=`$GOPATH/src/github.com/splitsh/lite/lite --git="<2.8.0" --prefix=src/ --quiet`
GIT_SPLITSH_SHA1_3=`$GOPATH/src/github.com/splitsh/lite/lite --prefix=src/ --quiet`
if [ "$GIT_SUBTREE_SPLIT_SHA1_2" == "$GIT_SUBTREE_SPLIT_SHA1_2" ]; then
echo "OK ($GIT_SUBTREE_SPLIT_SHA1_2 == $GIT_SUBTREE_SPLIT_SHA1_2)"
else
echo "OK ($GIT_SUBTREE_SPLIT_SHA1_2 != $GIT_SUBTREE_SPLIT_SHA1_2)"
exit 1
fi
if [ "$GIT_SUBTREE_SPLIT_SHA1_3" == "$GIT_SUBTREE_SPLIT_SHA1_3" ]; then
echo "OK ($GIT_SUBTREE_SPLIT_SHA1_3 == $GIT_SUBTREE_SPLIT_SHA1_3)"
else
echo "OK ($GIT_SUBTREE_SPLIT_SHA1_3 != $GIT_SUBTREE_SPLIT_SHA1_3)"
exit 1
fi
cd ../
# run on some Open-Source repositories
if [ ! -d Twig ]; then
git clone https://github.com/twigphp/Twig > /dev/null
fi
GIT_SUBTREE_SPLIT_SHA1="ea449b0f2acba7d489a91f88154687250d2bdf42"
GIT_SPLITSH_SHA1=`$GOPATH/src/github.com/splitsh/lite/lite --prefix=lib/ --origin=refs/tags/v1.24.1 --path=Twig --quiet --scratch`
if [ "$GIT_SUBTREE_SPLIT_SHA1" == "$GIT_SUBTREE_SPLIT_SHA1" ]; then
echo "OK ($GIT_SUBTREE_SPLIT_SHA1 == $GIT_SUBTREE_SPLIT_SHA1)"
else
echo "OK ($GIT_SUBTREE_SPLIT_SHA1 != $GIT_SUBTREE_SPLIT_SHA1)"
exit 1
fi
cd ../

View file

@ -9,7 +9,7 @@ import (
"time" "time"
"github.com/boltdb/bolt" "github.com/boltdb/bolt"
"github.com/libgit2/git2go" git "github.com/libgit2/git2go/v34"
) )
type cache struct { type cache struct {

View file

@ -6,7 +6,7 @@ import (
"sync" "sync"
"github.com/boltdb/bolt" "github.com/boltdb/bolt"
"github.com/libgit2/git2go" git "github.com/libgit2/git2go/v34"
) )
// Prefix represents which paths to split // Prefix represents which paths to split

View file

@ -4,7 +4,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/libgit2/git2go" git "github.com/libgit2/git2go/v34"
) )
// Result represents the outcome of a split // Result represents the outcome of a split

View file

@ -8,7 +8,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/libgit2/git2go" git "github.com/libgit2/git2go/v34"
) )
type state struct { type state struct {

View file

@ -7,7 +7,7 @@ import (
"regexp" "regexp"
"strings" "strings"
"github.com/libgit2/git2go" git "github.com/libgit2/git2go/v34"
) )
var messageNormalizer = regexp.MustCompile(`\s*\r?\n`) var messageNormalizer = regexp.MustCompile(`\s*\r?\n`)