Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jwiegley committed Aug 27, 2008
0 parents commit 3c301e7
Show file tree
Hide file tree
Showing 31 changed files with 2,882 additions and 0 deletions.
4 changes: 4 additions & 0 deletions git-addremove
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

git add -A
git ls-files --deleted -z | xargs -0 git rm
15 changes: 15 additions & 0 deletions git-all-commits
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

find .git/objects -type f | \
while read file; do
if echo $file | egrep -q '\.idx$'; then
git show-index < $file | awk '{print $2}'
elif echo $file | egrep -q '[0-9a-f]{38}$'; then
echo $(basename $(dirname $file))$(basename $file)
fi
done | \
while read hash; do
if [ "$(git cat-file -t $hash)" = commit ]; then
echo $hash
fi
done
26 changes: 26 additions & 0 deletions git-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

git clean -f -x -d
git checkout $1

rm -fr /usr/local/stow/git-$1

make prefix=/usr/local/stow/git-$1 -j3 install

git checkout origin/man

rsync -av man1/ /usr/local/stow/git-$1/share/man/man1/
rsync -av man5/ /usr/local/stow/git-$1/share/man/man5/
rsync -av man7/ /usr/local/stow/git-$1/share/man/man7/

git clean -f -x -d
git checkout master
chown -R johnw .

git reset --hard HEAD
git merge origin/master

cd /usr/local/stow
stow -D git-*

stow git-$1
79 changes: 79 additions & 0 deletions git-changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env python

# git-changelog
#
# version 1.0, by John Wiegley
#
# The purpose of this code is to turn "git log" output into a complete
# ChangeLog, for projects who wish to begin using a ChangeLog, but haven't
# been.

import datetime
import string
import sys
import re

from subprocess import *

p = Popen("git log --stat %s" % string.join(sys.argv[1:], " "),
shell = True, stdout = PIPE).stdout

line = p.readline()
while line:
match = re.match("commit ([0-9a-f]+)", line)
assert match
hash_id = match.group(1)

line = p.readline()

match = re.match("Author: (.+)", line)
assert match
author = match.group(1)
author = re.sub(" <", " <", author)

line = p.readline()

match = re.match("Date: +(.+?) [-+][0-9]{4}", line)
assert match
# Tue Sep 30 05:43:49 2003 +0000
date = datetime.datetime.strptime(match.group(1), '%a %b %d %H:%M:%S %Y')

line = p.readline() # absorb separator
line = p.readline()

log_text = ""
while line and line != '\n':
if not log_text:
log_text += line[4:]
else:
log_text += "\t" + line[4:]

line = p.readline()

line = p.readline()

files = []
while line and line != '\n':
match = re.match(" (.+?) +\\|", line)
if match:
files.append(match.group(1))
line = p.readline()
else:
break

line = p.readline()

fp = Popen("fmt", shell = True, stdin = PIPE, stdout = PIPE)

fp.stdin.write("\t* %s: %s\n" % (string.join(files, ",\n\t"), log_text))
fp.stdin.close()
log_text = fp.stdout.read()

del fp

print "%s %s\n\n%s\t* commit %s\n" % \
(date.strftime("%Y-%m-%d"), author, log_text, hash_id)

line = p.readline()

# git-changelog ends here
10 changes: 10 additions & 0 deletions git-children-of
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

commit=$1
branch=$2
if [[ -z "$branch" ]]; then
branch=HEAD
fi

git rev-list --children $branch --not $commit^@ | \
awk "/^$commit/ { print \$2 }"
21 changes: 21 additions & 0 deletions git-current
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

if [[ -z "$1" ]]; then
ancestor=master
else
ancestor=$1
shift 1
fi
current="$ancestor"

ancestor=$(git rev-parse $ancestor)

for head in $(git rev-parse --branches); do
if [[ $head != $ancestor ]]; then
if git rev-list -30 $head | grep -q $ancestor; then
current="$current $(git describe --all --abbrev=0 $head | sed 's/heads\///')"
fi
fi
done

git show-branch $current
18 changes: 18 additions & 0 deletions git-diff-directory
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

stat=true
if [[ "$1" == "-p" ]]; then
stat=false
shift 1
fi

if [[ $# == 2 ]]; then
git checkout $2
echo ======================================================================
fi

if [[ $stat == true ]]; then
diff -w -U3 -r -x .git . "$1" | diffstat | grep -v only$
else
diff -w -U3 -r -x .git . "$1"
fi
6 changes: 6 additions & 0 deletions git-empty-branch
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

git stash
git symbolic-ref HEAD refs/heads/$1
rm .git/index
git clean -f -d
3 changes: 3 additions & 0 deletions git-external-ediff
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

[ $# -eq 7 ] && emacsclient --eval "(ediff \"$2\" \"$PWD/$5\")"
13 changes: 13 additions & 0 deletions git-find-blob
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

filename=$1

want=$(git-hash-object "$filename")

git-rev-list --since="6 months ago" HEAD | while read commit ; do
git-ls-tree -r $commit | while read perm type hash filename; do
if test "$want" = "$hash"; then
echo matched $filename in commit $commit
fi
done
done
11 changes: 11 additions & 0 deletions git-find-children
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

if [[ $# == 0 ]]; then
echo usage: git find-children REFS...
fi

for ref in "$@"; do
for sha1 in $(git rev-list "$@")
do
done
done
32 changes: 32 additions & 0 deletions git-find-fetch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

find "$@" \( -name .git -o -name '*.git' \) -type d | \
while read repo_dir
do
if [[ -f "$repo_dir"/config ]]
then
# If this is a git-svn repo, use git svn fetch
if grep -q '^\[svn-remote ' "$repo_dir"/config
then
echo git svn fetch: $repo_dir
GIT_DIR="$repo_dir" git svn fetch

# If this is a gc-utils repo, use gc-utils update
elif grep -q '^\[gc-utils\]' "$repo_dir"/config
then
echo gc-utils update: $repo_dir
(cd "$repo_dir"; gc-utils update)

fi

GIT_DIR="$repo_dir" git remote update

for remote in $(GIT_DIR="$repo_dir" git remote)
do
if [[ $remote == mirror ]]; then
echo git push: $repo_dir -- $remote
GIT_DIR="$repo_dir" git push --mirror $remote
fi
done
fi
done
Loading

0 comments on commit 3c301e7

Please sign in to comment.