Skip to content

Instantly share code, notes, and snippets.

View peff's full-sized avatar

Jeff King peff

View GitHub Profile
@peff
peff / Makefile
Last active September 10, 2021 17:31
timing of a simple git command versus an in-process read
CFLAGS = -Wall -Werror -O2
all: foo

Keybase proof

I hereby claim:

  • I am peff on github.
  • I am peff (https://keybase.io/peff) on keybase.
  • I have a public key ASBUTdmbqRWiZXxKC56hC7t8_6Mvdb5_gs-53B3u9hFoqAo

To claim this, I am signing this object:

@peff
peff / git-du
Last active May 17, 2019 07:43
git-du script
#!/usr/bin/perl
#
# Generate a listing of all paths ever used in the repository, along with the
# disk space used by the path throughout the entire history. Note that sizes
# for trees are cumulative; they include the sizes of all of the paths below
# them, in addition to the tree storage itself. All sizes are in bytes, and
# reflect git's delta and zlib compression.
#
# One caveat is that this is just the _current_ on-disk size. The on-disk size
# of each object may change if git repacks and chooses different delta bases,
@peff
peff / sdl
Last active December 16, 2018 20:36
Hacky perl script to grep for Microsoft's SDL-banned functions.
#!/usr/bin/perl
#
# Usage: git grep -E "$(./sdl banned)" -- '*.c' '*.h'
my @TABLE = (
# Table 1. Banned string copy functions and replacements
BANNED => [qw(
strcpy
strcpyA
strcpyW
@peff
peff / README.md
Created May 22, 2012 07:26
many-ref repo

This repository has a very large number of refs, which shows some slow-down on certain git operations.

@peff
peff / ghpath.sh
Last active March 2, 2017 02:13
convert <file>:<line> into github permalink
#!/bin/sh
#
# Turn a file/line combination into a link to github.com.
# I use this from vim with:
#
# command! Link :exec "!ghpath %:p " . line(".")
#
# Running ":Link" anywhere will get you a link to the current file and
# line number. Remember to drop this as "ghpath" into your PATH, and
# to turn on the executable bit.
@peff
peff / README.md
Created April 28, 2012 11:16
git gc --aggressive case

This is a repository that has been packed over time with "git gc", but repacks from ~245M to ~145M with "git gc --aggressive". To narrow it down, I tried different packing options. With each of the following commands, I get these resulting pack sizes:

  • git repack -ad: 246M
  • git repack -ad -f: 376M
  • git repack -ad --window=250: 246M
  • git repack -ad -f --window=250: 145M
@peff
peff / last-used.sh
Created February 11, 2011 22:00
find the last commit that touched a file
#!/bin/sh
commit=HEAD
pathspec=
git log --format='%H%n %s' --name-status --no-merges --no-renames $commit -- $pathspec |
perl -e '
while(<>) {
if (/^[0-9a-f]{40}$/) {
$sha1 = $&;
@peff
peff / test
Created August 13, 2010 14:44
#!/bin/sh
# Create a repo with non-linear history.
rm -rf repo
commit() {
echo "$2" >>$1 && git add $1 && git commit -m "$1: $2"
}
push() {
@peff
peff / README.md
Last active August 29, 2015 14:21
deadlocked http-backend/apache strace output