chiark / gitweb /
tg-log: short cut to git log
authorBert Wesarg <bert.wesarg@googlemail.com>
Sun, 3 Oct 2010 21:25:57 +0000 (23:25 +0200)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Sun, 3 Oct 2010 22:07:35 +0000 (00:07 +0200)
A short cut to show the history of a named topgit branch.  Additional options
to git log can be given after a '--'.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
.gitignore
README
contrib/tg-completion.bash
tg-log.sh [new file with mode: 0644]

index 0342e09..3298889 100644 (file)
@@ -28,6 +28,8 @@
 /tg-info.txt
 /tg-mail
 /tg-mail.txt
+/tg-log
+/tg-log.txt
 /tg-patch
 /tg-patch.txt
 /tg-push
diff --git a/README b/README
index 15d20df..ce0c3a6 100644 (file)
--- a/README
+++ b/README
@@ -524,6 +524,9 @@ tg base
        repository, so you will not see work done by your
        collaborators.)
 
+tg log
+~~~~~~
+       Prints the git log of the named topgit branch.
 
 TODO: tg rename
 
index 5aabc92..ccf1a32 100755 (executable)
@@ -344,6 +344,16 @@ _tg_info ()
        esac
 }
 
+_tg_log ()
+{
+       local cur="${COMP_WORDS[COMP_CWORD]}"
+
+       case "$cur" in
+       *)
+               __tgcomp "$(__tg_topics)"
+       esac
+}
+
 _tg_mail ()
 {
        local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -475,6 +485,7 @@ _tg ()
        help)        _tg_help ;;
        import)      _tg_import ;;
        info)        _tg_info ;;
+       log)         _tg_log ;;
        mail)        _tg_mail ;;
        patch)       _tg_patch ;;
        push)        _tg_push ;;
diff --git a/tg-log.sh b/tg-log.sh
new file mode 100644 (file)
index 0000000..8a8d527
--- /dev/null
+++ b/tg-log.sh
@@ -0,0 +1,30 @@
+#!/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=
+
+
+## Parse options
+
+while [ -n "$1" ]; do
+       arg="$1"; shift
+       case "$arg" in
+       --)
+               break;;
+       -*)
+               echo "Usage: tg [...] log [NAME] [-- GIT LOG OPTIONS...]" >&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 log --first-parent --no-merges "$@" "refs/top-bases/$name".."$name"