Skip to content

Instantly share code, notes, and snippets.

@yiding
Created April 22, 2014 23:35
Show Gist options
  • Save yiding/11198010 to your computer and use it in GitHub Desktop.
Save yiding/11198010 to your computer and use it in GitHub Desktop.
topgit-0.9 patch for homebrew
diff --git a/Makefile b/Makefile
index 3ce39a5..2926f9e 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ bindir := $(prefix)/bin
cmddir := $(prefix)/libexec/topgit
sharedir := $(prefix)/share/topgit
hooksdir := $(cmddir)/hooks
-
+sed := gsed
commands_in := $(wildcard tg-*.sh)
hooks_in = hooks/pre-commit.sh
@@ -16,10 +16,11 @@ all:: tg $(commands_out) $(hooks_out) $(help_out)
tg $(commands_out) $(hooks_out): % : %.sh Makefile
@echo "[SED] $@"
- @sed -e 's#@cmddir@#$(cmddir)#g;' \
+ @$(sed) -e 's#@cmddir@#$(cmddir)#g;' \
-e 's#@hooksdir@#$(hooksdir)#g' \
-e 's#@bindir@#$(bindir)#g' \
-e 's#@sharedir@#$(sharedir)#g' \
+ -e 's#@sed@#$(sed)#g' \
[email protected] >$@+ && \
chmod +x $@+ && \
mv $@+ $@
diff --git a/tg-base.sh b/tg-base.sh
index d28cac1..789c23b 100644
--- a/tg-base.sh
+++ b/tg-base.sh
@@ -4,6 +4,6 @@
# (c) Per Cederqvist <[email protected]> 2010
# GPLv2
-name="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')"
+name="$(git symbolic-ref HEAD | @sed@ 's#^refs/\(heads\|top-bases\)/##')"
base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" || exit 1
echo $base_rev
diff --git a/tg-create.sh b/tg-create.sh
index 2215e2c..e2bba18 100644
--- a/tg-create.sh
+++ b/tg-create.sh
@@ -116,7 +116,7 @@ done
git update-ref "refs/top-bases/$name" "HEAD" ""
git checkout -b "$name"
-echo "$deps" | sed 's/ /\n/g' >"$root_dir/.topdeps"
+echo "$deps" | @sed@ 's/ /\n/g' >"$root_dir/.topdeps"
git add -f "$root_dir/.topdeps"
author="$(git var GIT_AUTHOR_IDENT)"
diff --git a/tg-depend.sh b/tg-depend.sh
index cf78946..f88e7fb 100644
--- a/tg-depend.sh
+++ b/tg-depend.sh
@@ -43,7 +43,7 @@ branchrev="$(git rev-parse --verify "$name" 2>/dev/null)" ||
die "invalid branch name: $name"
# Check that we are on a TopGit branch.
-current_name="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')"
+current_name="$(git symbolic-ref HEAD | @sed@ 's#^refs/\(heads\|top-bases\)/##')"
current_base_rev="$(git rev-parse --short --verify "refs/top-bases/$current_name" 2>/dev/null)" ||
die "not a TopGit-controlled branch"
diff --git a/tg-export.sh b/tg-export.sh
index e28871a..b5a6b17 100644
--- a/tg-export.sh
+++ b/tg-export.sh
@@ -30,7 +30,7 @@ while [ -n "$1" ]; do
if [ "$val" = "--strip" ]; then
strip=true
stripval=9999
- elif [ -n "$val" -a "x$(echo $val | sed -e 's/[0-9]//g')" = "x" ]; then
+ elif [ -n "$val" -a "x$(echo $val | @sed@ -e 's/[0-9]//g')" = "x" ]; then
strip=true
stripval=$val
else
@@ -67,7 +67,7 @@ done
if [ -z "$branches" ]; then
# this check is only needed when no branches have been passed
- name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
+ name="$(git symbolic-ref HEAD | @sed@ 's#^refs/heads/##')"
base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
die "not on a TopGit-controlled branch"
fi
@@ -87,10 +87,10 @@ create_tg_commit()
# Get commit message and authorship information
git cat-file blob "$name:.topmsg" | git mailinfo "$playground/^msg" /dev/null > "$playground/^info"
- GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$playground/^info")"
- GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$playground/^info")"
- GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$playground/^info")"
- SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$playground/^info")"
+ GIT_AUTHOR_NAME="$(@sed@ -n '/^Author/ s/Author: //p' "$playground/^info")"
+ GIT_AUTHOR_EMAIL="$(@sed@ -n '/^Email/ s/Email: //p' "$playground/^info")"
+ GIT_AUTHOR_DATE="$(@sed@ -n '/^Date/ s/Date: //p' "$playground/^info")"
+ SUBJECT="$(@sed@ -n '/^Subject/ s/Subject: //p' "$playground/^info")"
test -n "$GIT_AUTHOR_NAME" && export GIT_AUTHOR_NAME
test -n "$GIT_AUTHOR_EMAIL" && export GIT_AUTHOR_EMAIL
@@ -184,7 +184,7 @@ quilt()
[ "x$dn" = "x./" ] && dn=""
if "$flatten" && [ "$dn" ]; then
- bn="$(echo "$_dep_tmp.diff" | sed -e 's#_#__#g' -e 's#/#_#g')"
+ bn="$(echo "$_dep_tmp.diff" | @sed@ -e 's#_#__#g' -e 's#/#_#g')"
dn=""
fi
@@ -309,7 +309,7 @@ else
_dep_is_tgish=1
$driver
done
- name="$(echo "$branches" | sed 's/.*,//')"
+ name="$(echo "$branches" | @sed@ 's/.*,//')"
fi
diff --git a/tg-import.sh b/tg-import.sh
index cc345b0..84a78d3 100644
--- a/tg-import.sh
+++ b/tg-import.sh
@@ -51,7 +51,7 @@ get_commit_msg()
get_branch_name()
{
- # nice sed script from git-format-patch.sh
+ # nice @sed@ script from git-format-patch.sh
commit="$1"
titleScript='
s/[^-a-z.A-Z_0-9]/-/g
@@ -62,7 +62,7 @@ get_branch_name()
s/-$//
q
'
- git log -1 --pretty=format:"%s" "$commit" | sed -e "$titleScript"
+ git log -1 --pretty=format:"%s" "$commit" | @sed@ -e "$titleScript"
}
process_commit()
diff --git a/tg-info.sh b/tg-info.sh
index 0ff82d1..cf4512e 100644
--- a/tg-info.sh
+++ b/tg-info.sh
@@ -20,7 +20,7 @@ while [ -n "$1" ]; do
esac
done
-[ -n "$name" ] || name="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')"
+[ -n "$name" ] || name="$(git symbolic-ref HEAD | @sed@ 's#^refs/\(heads\|top-bases\)/##')"
base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
die "not a TopGit-controlled branch"
@@ -49,7 +49,7 @@ if has_remote "$name"; then
fi
git cat-file blob "$name:.topdeps" |
- sed '1{ s/^/Depends: /; n; }; s/^/ /;'
+ @sed@ '1{ s/^/Depends: /; n; }; s/^/ /;'
depcheck="$(get_temp tg-depcheck)"
missing_deps=
@@ -60,15 +60,15 @@ fi
if [ -s "$depcheck" ]; then
echo "Needs update from:"
cat "$depcheck" |
- sed 's/ [^ ]* *$//' | # last is $name
- sed 's/^: //' | # don't distinguish base updates
+ @sed@ 's/ [^ ]* *$//' | # last is $name
+ @sed@ 's/^: //' | # don't distinguish base updates
while read dep chain; do
echo -n "$dep "
- [ -n "$chain" ] && echo -n "(<= $(echo "$chain" | sed 's/ / <= /')) "
+ [ -n "$chain" ] && echo -n "(<= $(echo "$chain" | @sed@ 's/ / <= /')) "
dep_parent="${chain%% *}"
echo -n "($(measure_branch "$dep" "${dep2:-$name}"))"
echo
- done | sed 's/^/\t/'
+ done | @sed@ 's/^/\t/'
else
echo "Up-to-date."
fi
diff --git a/tg-log.sh b/tg-log.sh
index 4a57dc2..4152acb 100644
--- a/tg-log.sh
+++ b/tg-log.sh
@@ -23,7 +23,7 @@ while [ -n "$1" ]; do
esac
done
-[ -n "$name" ] || name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
+[ -n "$name" ] || name="$(git symbolic-ref HEAD | @sed@ 's#^refs/heads/##')"
base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
die "not a TopGit-controlled branch"
diff --git a/tg-mail.sh b/tg-mail.sh
index 3a5c998..d735ad2 100644
--- a/tg-mail.sh
+++ b/tg-mail.sh
@@ -29,7 +29,7 @@ while [ -n "$1" ]; do
esac
done
-head="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
+head="$(git symbolic-ref HEAD | @sed@ 's#^refs/heads/##')"
[ -n "$name" ] || name="$head"
base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
die "not a TopGit-controlled branch"
@@ -44,12 +44,12 @@ patchfile="$(get_temp tg-mail)"
# let tg patch sort out whether $head_from makes sense for $name
$tg patch "$name" $head_from >"$patchfile"
-header="$(sed -e '/^$/,$d' -e "s,','\\\\'',g" "$patchfile")"
+header="$(@sed@ -e '/^$/,$d' -e "s,','\\\\'',g" "$patchfile")"
-from="$(echo "$header" | grep '^From:' | sed 's/From:\s*//')"
-to="$(echo "$header" | grep '^To:' | sed 's/To:\s*//')"
+from="$(echo "$header" | grep '^From:' | @sed@ 's/From:\s*//')"
+to="$(echo "$header" | grep '^To:' | @sed@ 's/To:\s*//')"
people=
diff --git a/tg-push.sh b/tg-push.sh
index efaffc3..b7e9057 100644
--- a/tg-push.sh
+++ b/tg-push.sh
@@ -38,7 +38,7 @@ if [ -z "$remote" ]; then
fi
if [ -z "$branches" ]; then
- branches="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
+ branches="$(git symbolic-ref HEAD | @sed@ 's#^refs/heads/##')"
fi
for name in $branches; do
diff --git a/tg-summary.sh b/tg-summary.sh
index 1c99e22..aa1e63e 100644
--- a/tg-summary.sh
+++ b/tg-summary.sh
@@ -31,7 +31,7 @@ while [ -n "$1" ]; do
esac
done
-curname="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')"
+curname="$(git symbolic-ref HEAD | @sed@ 's#^refs/\(heads\|top-bases\)/##')"
[ "$terse$graphviz$sort$deps" = "" ] ||
[ "$terse$graphviz$sort$deps" = "1" ] ||
@@ -94,7 +94,7 @@ process_branch()
branch_contains "$name" "refs/top-bases/$name" || base_update='B'
if [ "$(git rev-parse "$name")" != "$rev" ]; then
- subject="$(cat_file "$name:.topmsg" $from | sed -n 's/^Subject: //p')"
+ subject="$(cat_file "$name:.topmsg" $from | @sed@ -n 's/^Subject: //p')"
else
# No commits yet
subject="(No commits)"
diff --git a/tg-update.sh b/tg-update.sh
index a6494f9..74d780f 100644
--- a/tg-update.sh
+++ b/tg-update.sh
@@ -31,7 +31,7 @@ while [ -n "$1" ]; do
done
[ -z "$pattern" ] && pattern=refs/top-bases
-current="$(git symbolic-ref HEAD 2>/dev/null | sed 's#^refs/\(heads\|top-bases\)/##')"
+current="$(git symbolic-ref HEAD 2>/dev/null | @sed@ 's#^refs/\(heads\|top-bases\)/##')"
if [ -z "$all" ]; then
if [ -z "$name" ]; then
name="$current"
@@ -66,9 +66,9 @@ update_branch() {
fi
cat "$depcheck" |
- sed 's/ [^ ]* *$//' | # last is $name
- sed 's/.* \([^ ]*\)$/+\1/' | # only immediate dependencies
- sed 's/^\([^+]\)/-\1/' | # now each line is +branch or -branch (+ == recurse)
+ @sed@ 's/ [^ ]* *$//' | # last is $name
+ @sed@ 's/.* \([^ ]*\)$/+\1/' | # only immediate dependencies
+ @sed@ 's/^\([^+]\)/-\1/' | # now each line is +branch or -branch (+ == recurse)
uniq -s 1 | # fold branch lines; + always comes before - and thus wins within uniq
while read depline; do
action="$(echo "$depline" | cut -c 1)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment