2 # TopGit - A different patch queue manager
3 # Copyright (C) Petr Baudis <pasky@suse.cz> 2008
24 echo "Usage: ${tgname:-tg} [...] patch [-i | -w] [--binary] [<name>] [--] [<git-diff-tree-option>...]" >&2
27 [ -z "$head_from" ] || die
"-i and -w are mutually exclusive"
32 if test="$(verify_topgit_branch "$arg" -f)"; then
33 [ -z "$name" ] || die
"name already specified ($name)"
39 [ -z "$name" ] || die
"name already specified ($name)"
45 head="$(git symbolic-ref -q HEAD)" ||
:
46 head="${head#refs/heads/}"
50 name
="$(verify_topgit_branch "$name")"
51 base_rev
="$(git rev-parse --short --verify "refs
/$topbases/$name" -- 2>/dev/null)" ||
52 die
"not a TopGit-controlled branch"
54 if [ -n "$head_from" ] && [ "$name" != "$head" ]; then
55 die
"$head_from makes only sense for the current branch"
60 # We now collect the rest of the code in this file into a function
61 # so we can redirect the output to the pager.
65 # put out the commit message
66 # and put an empty line out, if the last one in the message was not an empty line
67 # and put out "---" if the commit message does not have one yet
68 cat_file
"refs/heads/$name:.topmsg" $head_from |
87 b_tree
=$
(pretty_tree
"$name" -b)
88 t_tree
=$
(pretty_tree
"$name" $head_from)
90 if [ $b_tree = $t_tree ]; then
95 [ "$a" != "--" ] ||
{ hasdd
=1; break; }
97 if [ -z "$hasdd" ]; then
98 git diff-tree
-p --stat --summary ${binary:+--binary} "$@" $b_tree $t_tree
100 cmd
="git diff-tree -p --stat --summary ${binary:+--binary}"
101 while [ $# -gt 0 -a "$1" != "--" ]; do
102 cmd
="$cmd $(quotearg "$1")"
105 cmd
="$cmd $(quotearg "$b_tree") $(quotearg "$t_tree")"
106 while [ $# -gt 0 ]; do
107 cmd
="$cmd $(quotearg "$1")"
115 depon
="$(cat_file "refs
/heads
/$name:.topdeps
" $head_from 2>/dev/null | paste -s -d ' ' -)"
116 echo "$tgname: ($base_rev..) $name${depon:+ (depends on: $depon)}"
117 branch_contains
"refs/heads/$name" "refs/$topbases/$name" ||
118 echo "$tgname: The patch is out-of-date wrt. the base! Run \`$tgdisplay update\`."
123 # ... and then we run it through the pager with the page function