Skip to content

Commit

Permalink
merge in git-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ddollar committed Dec 22, 2008
1 parent aa4350b commit a3bf339
Show file tree
Hide file tree
Showing 35 changed files with 2,737 additions and 3 deletions.
4 changes: 4 additions & 0 deletions git-addremove
Original file line number Original file line 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 Original file line 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 Original file line 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 Original file line 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 Original file line 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 Original file line 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
16 changes: 16 additions & 0 deletions git-diff-directory
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

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

HERE=$(pwd)

(cd "$1" && git --git-dir=$HERE/.git diff ${2:-HEAD}) | \
if [[ $stat == true ]]; then \
diffstat | grep -v only$; \
else \
cat; \
fi
6 changes: 6 additions & 0 deletions git-empty-branch
Original file line number Original file line 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
2 changes: 2 additions & 0 deletions git-erase-reflog
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
git reflog expire --expire=0 "$@"
3 changes: 3 additions & 0 deletions git-external-ediff
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

[ $# -eq 7 ] && emacsclient --eval "(ediff \"$2\" \"$PWD/$5\")"
Loading

0 comments on commit a3bf339

Please sign in to comment.