Skip to content

Commit 31bdc7f

Browse files
committed
begin extensions: add some extensions
1 parent 10be6ee commit 31bdc7f

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

bin/git-amend-date

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
# Change the commit and author date of last git commit (ammend).
4+
# Usage: git ammend-date <commit date> [author date]
5+
#
6+
7+
_COMMIT_DATE="${1-}"
8+
_AUTHOR_DATE="${2-}"
9+
10+
if test -z "$_COMMIT_DATE"; then
11+
echo "Commit date not set." >&2
12+
exit 1
13+
fi
14+
15+
GIT_COMMITTER_DATE="$_COMMIT_DATE"
16+
17+
if test -n "$_AUTHOR_DATE"; then
18+
GIT_AUTHOR_DATE="$_AUTHOR_DATE"
19+
else
20+
GIT_AUTHOR_DATE="$_COMMIT_DATE"
21+
fi
22+
23+
export GIT_COMMITTER_DATE
24+
export GIT_AUTHOR_DATE
25+
26+
git commit --amend --date "$GIT_AUTHOR_DATE"
27+
28+
unset GIT_COMMITTER_DATE
29+
unset GIT_AUTHOR_DATE
30+

bin/git-logmerges

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
git log --graph --full-history --merges --color --pretty=tformat:"%x1b[31m%h%x09%x1b[0m%ad%x09%x1b[32m%d%x1b[0m%x20%s%x20%x1b[33m(%an)%x1b[0m" --date=short | grep '^\*'

bin/git-rewrite-date

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/sh
2+
3+
#
4+
# Change the commit and/or author date of git commits.
5+
#
6+
# rewrite-date [-f] commit-to-change [branch-to-rewrite [commit-date [author-date]]]
7+
#
8+
# If -f is supplied it is passed to "git filter-branch".
9+
#
10+
# If <branch-to-rewrite> is not provided or is empty HEAD will be used.
11+
# Use "--all" or a space separated list (e.g. "master next") to rewrite
12+
# multiple branches.
13+
#
14+
15+
# Based on http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit
16+
17+
force=''
18+
if test "x$1" = "x-f"; then
19+
force='-f'
20+
shift
21+
fi
22+
23+
die() {
24+
printf '%s\n' "$@"
25+
exit 128
26+
}
27+
targ="$(git rev-parse --verify "$1" 2>/dev/null)" || die "$1 is not a commit"
28+
br="${2:-HEAD}"
29+
30+
TARG_COMMIT="$targ"
31+
TARG_COMMIT_DATE="${3-}"
32+
TARG_AUTHOR_DATE="${4-}"
33+
34+
export TARG_COMMIT TARG_COMMIT_DATE TARG_AUTHOR_DATE
35+
36+
if test -z "$TARG_COMMIT_DATE"; then
37+
echo "Commit date not set."
38+
exit 1
39+
fi
40+
41+
filt='
42+
if test "$GIT_COMMIT" = "$TARG_COMMIT"; then
43+
GIT_COMMITTER_DATE="$TARG_COMMIT_DATE"
44+
export GIT_COMMITTER_DATE
45+
46+
if test -n "$TARG_AUTHOR_DATE"; then
47+
GIT_AUTHOR_DATE="$TARG_AUTHOR_DATE"
48+
else
49+
GIT_AUTHOR_DATE="$TARG_COMMIT_DATE"
50+
fi
51+
export GIT_AUTHOR_DATE
52+
fi
53+
54+
'
55+
56+
git filter-branch $force --env-filter "$filt" -- $br
57+

0 commit comments

Comments
 (0)