2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz> 2008
23 echo "Usage: ${tgname:-tg} [...] patch [-i | -w] [--binary] [<name>] [--] [<git-diff-tree-option>...]" >&2
26 [ -z "$head_from" ] || die
"-i and -w are mutually exclusive"
31 if test="$(verify_topgit_branch "$arg" -f)"; then
32 [ -z "$name" ] || die
"name already specified ($name)"
38 [ -z "$name" ] || die
"name already specified ($name)"
45 printf '%s' "$1" |
sed 's/\(['\''!]\)/'\'\\\\\\1\''/g'
48 head="$(git symbolic-ref HEAD)"
49 head="${head#refs/heads/}"
53 name
="$(verify_topgit_branch "$name")"
54 base_rev
="$(git rev-parse --short --verify "refs
/top-bases
/$name" 2>/dev/null)" ||
55 die
"not a TopGit-controlled branch"
57 if [ -n "$head_from" ] && [ "$name" != "$head" ]; then
58 die
"$head_from makes only sense for the current branch"
65 # We now collect the rest of the code in this file into a block
66 # so we can redirect the output to the pager.
69 # put out the commit message
70 # and put an empty line out, if the last one in the message was not an empty line
71 # and put out "---" if the commit message does not have one yet
72 cat_file
"refs/heads/$name:.topmsg" $head_from |
91 b_tree
=$
(pretty_tree
"$name" -b)
92 t_tree
=$
(pretty_tree
"$name" $head_from)
94 if [ $b_tree = $t_tree ]; then
99 [ "$a" != "--" ] ||
{ hasdd
=1; break; }
101 if [ -z "$hasdd" ]; then
102 git diff-tree
-p --stat --summary ${binary:+--binary} "$@" $b_tree $t_tree
104 cmd
="git diff-tree -p --stat --summary ${binary:+--binary}"
105 while [ $# -gt 0 -a "$1" != "--" ]; do
106 cmd
="$cmd '$(quotearg "$1")'"
109 cmd
="$cmd '$(quotearg "$b_tree")' '$(quotearg "$t_tree")'"
110 while [ $# -gt 0 ]; do
111 cmd
="$cmd '$(quotearg "$1")'"
119 echo "$tgname: ($base_rev..) $name (depends on: $(cat_file "refs
/heads
/$name:.topdeps
" $head_from 2>/dev/null | paste -s -d ' ' -))"
120 branch_contains
"refs/heads/$name" "refs/top-bases/$name" ||
121 echo "$tgname: The patch is out-of-date wrt. the base! Run \`$tgdisplay update\`."
124 # ... and then we pipe all the output through the pager