2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz> 2008
15 echo "Usage: tg patch [NAME]" >&2
18 [ -z "$name" ] || die "name already specified ($name)"
23 [ -n "$name" ] || name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
24 base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
25 die "not a TopGit-controlled branch"
27 git cat-file blob "$name:.topmsg"
29 [ -n "$(git grep '^[-]--' "$name" -- ".topmsg")" ] || echo '---'
31 # Evil obnoxious hack to work around the lack of git diff --exclude
32 git_is_stupid="$(mktemp)"
33 git diff-tree --name-only "$base_rev" "$name" |
34 fgrep -vx ".topdeps" |
35 fgrep -vx ".topmsg" >"$git_is_stupid" || : # fgrep likes to fail randomly?
36 if [ -s "$git_is_stupid" ]; then
37 cat "$git_is_stupid" | xargs git diff --patch-with-stat "$base_rev" "$name" --
44 echo "tg: ($base_rev..) $name (depends on: $(git cat-file blob "$name:.topdeps" | paste -s -d' '))"
45 branch_contains "$name" "$base_rev" ||
46 echo "tg: The patch is out-of-date wrt. the base! Run \`tg update\`."