2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz> 2008
10 diff_committed_only
=yes # will be unset for index/worktree
19 [ -z "$head_from" ] || die
"-i and -w are mutually exclusive"
21 diff_opts
="$diff_opts --cached";
22 diff_committed_only
=;;
24 [ -z "$head_from" ] || die
"-i and -w are mutually exclusive"
26 diff_committed_only
=;;
28 echo "Usage: tg [...] patch [-i | -w] [NAME]" >&2
31 [ -z "$name" ] || die
"name already specified ($name)"
36 head="$(git symbolic-ref HEAD)"
37 head="${head#refs/heads/}"
41 base_rev
="$(git rev-parse --short --verify "refs
/top-bases
/$name" 2>/dev/null)" ||
42 die
"not a TopGit-controlled branch"
44 if [ -n "$head_from" ] && [ "$name" != "$head" ]; then
45 die
"$head_from makes only sense for the current branch"
52 cat_file
"$name:.topmsg" $head_from
54 [ -n "$(git grep $diff_opts '^[-]--' ${diff_committed_only:+"$name"} -- ".topmsg
")" ] ||
echo '---'
56 # Evil obnoxious hack to work around the lack of git diff --exclude
57 git_is_stupid
="$(get_temp tg-patch-changes)"
58 git
diff --name-only $diff_opts "$base_rev" ${diff_committed_only:+"$name"} -- |
59 fgrep
-vx ".topdeps" |
60 fgrep
-vx ".topmsg" >"$git_is_stupid" ||
: # fgrep likes to fail randomly?
61 if [ -s "$git_is_stupid" ]; then
63 cat "$git_is_stupid" |
xargs git
diff -a --patch-with-stat $diff_opts "$base_rev" ${diff_committed_only:+"$name"} --
69 echo "tg: ($base_rev..) $name (depends on: $(cat_file "$name:.topdeps
" $head_from | paste -s -d' '))"
70 branch_contains
"$name" "$base_rev" ||
71 echo "tg: The patch is out-of-date wrt. the base! Run \`$tg update\`."