Skip to content

Instantly share code, notes, and snippets.

@chalstrick
chalstrick / t.sh
Created June 10, 2020 07:33
Inspect native git behaviour on mergeConflicts on gitlinks
git init subm
touch subm/a
git -C subm add a
git -C subm commit -m initSubm
git init root
git -C root submodule add ../subm
git -C root commit -m addingSubm
echo forMaster >>root/subm/a
set -x
jgit --version
rm -fr gerrit.src.git gerrit.dst.git gerrit.client
git clone --bare --mirror https://gerrit.googlesource.com/gerrit gerrit.dst.git
cp -r gerrit.dst.git gerrit.dst.git.backup
git clone --bare --mirror gerrit.dst.git gerrit.src.git
git clone gerrit.src.git gerrit.client
( cd gerrit.client; date >>README.md; git add README.md; git commit -m "modify README.md"; git push origin; )
( cd gerrit.src.git; time jgit push origin HEAD:refs/heads/master; )
rm -fr gerrit.dst.git
import java.util.Objects;
public class TestHashPerformance {
private static final int N = 10000000;
public static void main(String args[]) {
int r[] = new int[N];
long start = System.currentTimeMillis();
long n1=0, n2=N;
for (int i = 0; i < N; i++) {
@chalstrick
chalstrick / PerfTest_NFSFile.java
Created June 7, 2018 14:07
test NFSFile performance
import java.io.File;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import org.eclipse.jgit.api.Git;
@chalstrick
chalstrick / testAllCheckoutSituations.sh
Created January 15, 2018 16:50
test all(?) combinations of content (even file<->dir), skipWorktree bits, sparse-checkout content during a git checkout
#!/bin/bash
#
# Sets up a lot of repos to test git-checkout operations. Setup test repos for all (?) possible
# combinations of contents in merge commit, index, workingtree and also for all combinations
# of skip-worktree bit and .git/info/sparse-checkout content
# After the repos are setup try to checkout and print status regarding worktree content, HEAD
#
# Requires that there is an executable 'jgit' in $PATH which is the command-line version
#
# usage: testAllCheckoutSituations.sh [-jgit]
git init subRepo
cd subRepo/
touch a
git add a
git commit -m addA
cd ..
git init rootRepo
cd rootRepo/
touch b
rm -fr writingClient*/ readingClient*/ server/
mkdir server
git init --bare server/repo.git
git daemon --base-path=server --export-all --enable=receive-pack &
git clone git://127.0.0.1/repo.git writingClient
cd writingClient
touch a
git add a
git commit -m add_a
git push origin HEAD:master
touch a b c
git add a b c
git commit -m init
git branch side
echo master >a
git commit -a -m m1
git checkout side
echo side >b
git commit -a -m s1
git merge --no-commit master
@chalstrick
chalstrick / gist:106303c9e6244d072311
Last active August 29, 2015 14:14
testGitBannedPathes
uname -a
git --version
[ -x ./gin ] || curl -O https://raw.githubusercontent.com/chalstrick/gin/master/gin && chmod +x gin
git init test
cd test
blobId=$(echo "test content" | git hash-object -w --stdin)
goodTree=$(echo -e "100644 blob $blobId\tf" | git mktree)
tree1Id=$(echo -e "100644 blob $blobId\tRAGGED~1.H" | git mktree)
tree2Id=$(echo -e "040000 tree $goodTree\ta\n040000 tree $tree1Id\tb\n040000 tree $goodTree\tc" | git mktree)
commitId=$(echo 'initial commit' | git commit-tree $tree2Id)
@chalstrick
chalstrick / testJGitAttributesPerf
Last active November 2, 2015 14:08
Test JGit gitattributes support regarding performance
#!/bin/bash
set -x
# we are working against linux repo (50000 versioned files), measure time of native git status
cd ../linux
git checkout v4.2
git ls-files | wc -l
git remote -v
echo "*.txt text" >.gitattributes
echo "*.sh text" >arch/.gitattributes