From: Bert Wesarg <bert.wesarg@googlemail.com>
To: Petr Baudis <pasky@suse.cz>
To: Petr Baudis <pasky@suse.cz>
Cc: Bert Wesarg <bert.wesarg@googlemail.com>, git@vger.kernel.org
Subject: [TopGit PATCH] prev/next/tsort: commands to explore dependencies
Date: Fri, 19 Sep 2008 11:55:00 +0200 [thread overview]
Message-ID: <1221818101-14333-1-git-send-email-bert.wesarg@googlemail.com> (raw)
I hacked 3 commands to explore the dependencies of TopGit patches:
I) tg prev [NAME]
outputs the dependencies of NAME
II) tg next [NAME]
outputs patches that depends on NAME
III) tg tsort [PATTERN]
outputs a topological order of all patches starting with PATTERN
I'm more than open for improvments.
Regards
Bert
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
.gitignore | 6 ++++++
tg-next.sh | 33 +++++++++++++++++++++++++++++++++
tg-prev.sh | 27 +++++++++++++++++++++++++++
tg-tsort.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 123 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index 8868f2d..b7fb70b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,3 +18,9 @@ tg-import.txt
tg-remote
tg-remote.txt
tg
+tg-next
+tg-next.txt
+tg-prev
+tg-prev.txt
+tg-tsort
+tg-tsort.txt
diff --git a/tg-next.sh b/tg-next.sh
new file mode 100644
index 0000000..8e17226
--- /dev/null
+++ b/tg-next.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+# TopGit - A different patch queue manager
+# (c) Petr Baudis <pasky@suse.cz> 2008
+# GPLv2
+
+name=
+
+
+## Parse options
+
+while [ -n "$1" ]; do
+ arg="$1"; shift
+ case "$arg" in
+ -*)
+ echo "Usage: tg next [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/##')"
+base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
+ die "not a TopGit-controlled branch"
+
+git for-each-ref --format='%(refname)' refs/top-bases |
+ while read topic; do
+ topic="${topic#refs/top-bases/}"
+ if git show "${topic}":.topdeps 2>/dev/null | grep -q "^${name}\$"; then
+ echo "${topic}"
+ fi
+ done
diff --git a/tg-prev.sh b/tg-prev.sh
new file mode 100644
index 0000000..801fb3e
--- /dev/null
+++ b/tg-prev.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# TopGit - A different patch queue manager
+# (c) Petr Baudis <pasky@suse.cz> 2008
+# GPLv2
+
+name=
+
+
+## Parse options
+
+while [ -n "$1" ]; do
+ arg="$1"; shift
+ case "$arg" in
+ -*)
+ echo "Usage: tg next [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/##')"
+base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
+ die "not a TopGit-controlled branch"
+
+git show "$name:.topdeps"
diff --git a/tg-tsort.sh b/tg-tsort.sh
new file mode 100644
index 0000000..8a7376a
--- /dev/null
+++ b/tg-tsort.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+# TopGit - A different patch queue manager
+# (c) Petr Baudis <pasky@suse.cz> 2008
+# GPLv2
+
+pattern=
+
+## Parse options
+
+while [ -n "$1" ]; do
+ arg="$1"; shift
+ case "$arg" in
+ -*)
+ echo "Usage: tg tsort [PATTERN]" >&2
+ exit 1;;
+ *)
+ [ -z "$pattern" ] || die "pattern already specified ($pattern)"
+ pattern="$arg";;
+ esac
+done
+
+# remove trailing /, they wont work with for-each-ref
+pattern="$(echo "refs/top-bases/$pattern" | sed -re 's#/+$##g')"
+
+name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
+base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
+ die "not a TopGit-controlled branch"
+
+rev_map="$(mktemp)"
+rev_map_uniq="$(mktemp)"
+rev_map_sed="$(mktemp)"
+tsort_out="$(mktemp)"
+trap 'rm -f "$rev_map" "$rev_map_uniq" "$rev_map_sed" "$tsort_out"' EXIT
+
+(
+ exec 3>"$rev_map"
+ cd "$git_dir"
+ git for-each-ref --format='%(refname)' $pattern |
+ while read topic; do
+ topic="${topic#refs/top-bases/}"
+ topic_rev="$(git rev-parse --verify "${topic}" 2>/dev/null)"
+ printf "%s\t%q\n" "${topic_rev}" "${topic}" >&3
+ git show "${topic}":.topdeps 2>/dev/null |
+ while read dep; do
+ dep_rev="$(git rev-parse --verify "${dep}" 2>/dev/null)"
+ printf "%s\t%q\n" "${dep_rev}" "${dep}" >&3
+ printf "%s\t%s\n" "${topic_rev}" "${dep_rev}"
+ done
+ done
+) | tsort | tac > "$tsort_out"
+
+LC_ALL=C sort "$rev_map" | uniq > "$rev_map_uniq"
+while read sha1 rev; do
+ printf "s#%s#%s#\n" "$sha1" "$rev"
+done < "$rev_map_uniq" > "$rev_map_sed"
+
+sed -f "$rev_map_sed" "$tsort_out"
--
tg: (370a0fd..) t/queue-movement (depends on: master)
next reply other threads:[~2008-09-19 9:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-19 9:55 Bert Wesarg [this message]
2008-09-19 9:55 ` [TopGit PATCH] tg-patch: add From/Date: line to header and print to file Bert Wesarg
2008-09-22 15:39 ` Petr Baudis
2008-09-22 18:10 ` Bert Wesarg
2008-09-22 15:36 ` [TopGit PATCH] prev/next/tsort: commands to explore dependencies Petr Baudis
2008-09-22 17:32 ` Bert Wesarg
2008-09-22 20:10 ` Uwe Kleine-König
2008-09-22 20:18 ` Bert Wesarg
2008-09-24 15:23 ` Petr Baudis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1221818101-14333-1-git-send-email-bert.wesarg@googlemail.com \
--to=bert.wesarg@googlemail.com \
--cc=git@vger.kernel.org \
--cc=pasky@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).