Skip to content
This repository has been archived by the owner on Feb 17, 2018. It is now read-only.

Commit

Permalink
Merge commit 'index-wt~2' of git://repo.or.cz/topgit/bertw
Browse files Browse the repository at this point in the history
  • Loading branch information
Uwe Kleine-König committed Dec 26, 2010
2 parents 9b25e84 + 52c8d3c commit d279e29
Show file tree
Hide file tree
Showing 11 changed files with 244 additions and 50 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@
/tg-info.txt
/tg-mail
/tg-mail.txt
/tg-next
/tg-next.txt
/tg-log
/tg-log.txt
/tg-patch
/tg-patch.txt
/tg-prev
/tg-prev.txt
/tg-push
/tg-push.txt
/tg-remote
Expand Down
26 changes: 25 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ tg mail

to let `git send-email` ask for confirmation before sending any mail.

Options:
-i base patch generation on index instead of branch
-w base patch generation on working tree instead of branch

TODO: 'tg mail patchfile' to mail an already exported patch
TODO: mailing patch series
TODO: specifying additional options and addresses on command
Expand Down Expand Up @@ -370,6 +374,10 @@ tg summary
branches in a machine-readable format. Feed this to "tsort"
to get the output from --sort.

Options:
-i Use TopGit meta data from the index instead of branch
-w Use TopGit meta data from the working tree instead of branch

TODO: Speed up by an order of magnitude
TODO: Text graph view

Expand Down Expand Up @@ -531,8 +539,24 @@ tg log
Note: if you have merged changes from a different repository, this
command might not list all interesting commits.

TODO: tg rename
tg prev
~~~~~~~
Outputs the direct dependencies for the current or named patch.

Options:
-i show dependencies based on index instead of branch
-w show dependencies based on working tree instead of branch

tg next
~~~~~~~
Outputs all patches which directly depend on the current or
named patch.

Options:
-i show dependencies based on index instead of branch
-w show dependencies based on working tree instead of branch

TODO: tg rename

IMPLEMENTATION
--------------
Expand Down
46 changes: 46 additions & 0 deletions contrib/tg-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,14 @@ _tg_mail ()
local cur="${COMP_WORDS[COMP_CWORD]}"

case "$cur" in
-*)
__tgcomp "
-i
-w
-s
-r
"
;;
*)
__tgcomp "$(__tg_topics)"
esac
Expand Down Expand Up @@ -426,7 +434,11 @@ _tg_summary ()
*)
__tgcomp "
--graphviz
--sort
--deps
-t
-i
-w
"
esac
}
Expand All @@ -441,6 +453,38 @@ _tg_update ()
esac
}

_tg_next ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"

case "$cur" in
-*)
__tgcomp "
-i
-w
"
;;
*)
__tgcomp "$(__tg_heads)"
esac
}

_tg_prev ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"

case "$cur" in
-*)
__tgcomp "
-i
-w
"
;;
*)
__tgcomp "$(__tg_topics)"
esac
}

### }}}
### {{{ tg completion

Expand Down Expand Up @@ -488,7 +532,9 @@ _tg ()
info) _tg_info ;;
log) _tg_log ;;
mail) _tg_mail ;;
next) _tg_next ;;
patch) _tg_patch ;;
prev) _tg_prev ;;
push) _tg_push ;;
remote) _tg_remote ;;
summary) _tg_summary ;;
Expand Down
4 changes: 2 additions & 2 deletions tg-export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ collapsed_commit()
echo "TopGit-driven merge of branches:"
echo
cut -f 2 "$playground/$name^parents"
} | git commit-tree "$(pretty_tree "refs/top-bases/$name")" \
} | git commit-tree "$(pretty_tree "$name" -b)" \
$(for p in $parent; do echo -p $p; done))"
fi

Expand Down Expand Up @@ -217,7 +217,7 @@ linearize()
else
retmerge=0;

git merge-recursive "$(pretty_tree "refs/top-bases/$_dep")" -- HEAD "$(pretty_tree "refs/heads/$_dep")" || retmerge="$?";
git merge-recursive "$(pretty_tree "$_dep" -b)" -- HEAD "$(pretty_tree "refs/heads/$_dep")" || retmerge="$?";

if test "x$retmerge" != "x0"; then
git rerere;
Expand Down
25 changes: 14 additions & 11 deletions tg-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@
# GPLv2

name=
topic=
head_from=


## Parse options

while [ -n "$1" ]; do
arg="$1"; shift
case "$arg" in
-i)
[ -z "$topic" ] || die "-i and -w are mutually exclusive"
topic=-i;;
-w)
[ -z "$topic" ] || die "-i and -w are mutually exclusive"
topic=-w;;
-i|-w)
[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
head_from="$arg";;
-*)
echo "Usage: tg [...] files [-i | -w] [NAME]" >&2
exit 1;;
Expand All @@ -28,16 +25,22 @@ while [ -n "$1" ]; do
done


[ -n "$name" -a -n "$topic" ] &&
die "-i/-w are mutually exclusive with NAME"
head="$(git symbolic-ref HEAD)"
head="${head#refs/heads/}"

[ -n "$name" ] || name="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')"
[ -n "$name" ] ||
name="$head"
base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
die "not a TopGit-controlled branch"

if [ -n "$head_from" ] && [ "$name" != "$head" ]; then
die "$head_from makes only sense for the current branch"
fi

b_tree=$(pretty_tree "$name" -b)
t_tree=$(pretty_tree "$name" $topic)
t_tree=$(pretty_tree "$name" $head_from)

git diff-tree --name-only -r $b_tree $t_tree

# vim:noet

12 changes: 9 additions & 3 deletions tg-mail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# GPLv2

name=
head_from=
send_email_args=
in_reply_to=

Expand All @@ -12,20 +13,24 @@ in_reply_to=
while [ -n "$1" ]; do
arg="$1"; shift
case "$arg" in
-i|-w)
[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
head_from="$arg";;
-s)
send_email_args="$1"; shift;;
-r)
in_reply_to="$1"; shift;;
-*)
echo "Usage: tg [...] mail [-s SEND_EMAIL_ARGS] [-r REFERENCE_MSGID] [NAME]" >&2
echo "Usage: tg [...] mail [-s SEND_EMAIL_ARGS] [-r REFERENCE_MSGID] [-i | -w] [NAME]" >&2
exit 1;;
*)
[ -z "$name" ] || die "name already specified ($name)"
name="$arg";;
esac
done

[ -n "$name" ] || name="$(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"

Expand All @@ -36,7 +41,8 @@ fi

patchfile="$(get_temp tg-mail)"

$tg patch "$name" >"$patchfile"
# 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")"

Expand Down
45 changes: 45 additions & 0 deletions tg-next.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/sh
# TopGit - A different patch queue manager
# (c) Petr Baudis <pasky@suse.cz> 2008
# (c) Bert Wesarg <Bert.Wesarg@googlemail.com> 2009
# GPLv2

name=
head_from=


## Parse options

while [ -n "$1" ]; do
arg="$1"; shift
case "$arg" in
-i|-w)
[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
head_from="$arg";;
-*)
echo "Usage: tg next [-i | -w] [NAME]" >&2
exit 1;;
*)
[ -z "$name" ] || die "name already specified ($name)"
name="$arg";;
esac
done

head="$(git rev-parse --abbrev-ref=loose HEAD)"
[ -n "$name" ] ||
name="$head"

git for-each-ref --format='%(refname)' refs/top-bases |
while read ref; do
parent="${ref#refs/top-bases/}"

from=$head_from
# select .topdeps source for HEAD branch
[ "x$parent" = "x$head" ] ||
from=

cat_file "$parent:.topdeps" $from | fgrep -qx "$name" ||
continue

echo "$parent"
done
54 changes: 31 additions & 23 deletions tg-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,16 @@
name=

head_from=
diff_opts=
diff_committed_only=yes # will be unset for index/worktree


## Parse options

while [ -n "$1" ]; do
arg="$1"; shift
case "$arg" in
-i)
-i|-w)
[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
head_from=-i
diff_opts="$diff_opts --cached";
diff_committed_only=;;
-w)
[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
head_from=-w
diff_committed_only=;;
head_from="$arg";;
-*)
echo "Usage: tg [...] patch [-i | -w] [NAME]" >&2
exit 1;;
Expand All @@ -49,20 +41,36 @@ fi

setup_pager

cat_file "$name:.topmsg" $head_from
echo
[ -n "$(git grep $diff_opts '^[-]--' ${diff_committed_only:+"$name"} -- ".topmsg")" ] || echo '---'

# Evil obnoxious hack to work around the lack of git diff --exclude
git_is_stupid="$(get_temp tg-patch-changes)"
git diff --name-only $diff_opts "$base_rev" ${diff_committed_only:+"$name"} -- |
fgrep -vx ".topdeps" |
fgrep -vx ".topmsg" >"$git_is_stupid" || : # fgrep likes to fail randomly?
if [ -s "$git_is_stupid" ]; then
cd "$root_dir"
cat "$git_is_stupid" | xargs git diff -a --patch-with-stat $diff_opts "$base_rev" ${diff_committed_only:+"$name"} --
else

# put out the commit message
# and put an empty line out, if the last one in the message was not an empty line
# and put out "---" if the commit message does not have one yet
cat_file "$name:.topmsg" $head_from |
awk '
/^---/ {
has_3dash=1;
}
{
need_empty = 1;
if ($0 == "")
need_empty = 0;
print;
}
END {
if (need_empty)
print "";
if (!has_3dash)
print "---";
}
'

b_tree=$(pretty_tree "$name" -b)
t_tree=$(pretty_tree "$name" $head_from)

if [ $b_tree = $t_tree ]; then
echo "No changes."
else
git diff-tree -p --stat $b_tree $t_tree
fi

echo '-- '
Expand Down
Loading

0 comments on commit d279e29

Please sign in to comment.