forked from jwiegley/git-scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3c301e7
Showing
31 changed files
with
2,882 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
[ $# -eq 7 ] && emacsclient --eval "(ediff \"$2\" \"$PWD/$5\")" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.