From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Bert Wesarg <bert.wesarg@googlemail.com>
Cc: git@vger.kernel.org, Peter Simons <simons@cryp.to>,
pasky@suse.cz, Per Cederqvist <ceder@lysator.liu.se>,
Olaf Dabrunz <odabrunz@gmx.net>,
Thomas Moschny <thomas.moschny@gmx.de>,
martin f krafft <madduck@madduck.net>
Subject: Re: [TopGit PATCH v3] tg-files: list files changed by the topic branch
Date: Tue, 5 Oct 2010 09:17:23 +0200 [thread overview]
Message-ID: <20101005071723.GG11737@pengutronix.de> (raw)
In-Reply-To: <1286216867-14701-1-git-send-email-bert.wesarg@googlemail.com>
Hello,
On Mon, Oct 04, 2010 at 08:27:47PM +0200, Bert Wesarg wrote:
> this could also be a --name-only option to tg-patch. But I Like the
> similarity to 'quilt files'.
>
> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
>
> ---
>
> Changes:
> v3:
> * use --index-output= option in read-tree
> * use $git_dir instead of $root_dir/.git
> * bring back the y
> v2:
> * work on trees
>
> .gitignore | 2 +
> README | 8 +++++++
> contrib/tg-completion.bash | 1 +
> tg-export.sh | 9 --------
> tg-files.sh | 43 ++++++++++++++++++++++++++++++++++++++
> tg.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++
> 6 files changed, 103 insertions(+), 9 deletions(-)
>
> diff --git a/.gitignore b/.gitignore
> index 0342e09..0dc4d0e 100644 .gitignore
> --- a/.gitignore
> +++ b/.gitignore
> @@ -22,6 +22,8 @@
> /tg-depend.txt
> /tg-export
> /tg-export.txt
> +/tg-files
> +/tg-files.txt
> /tg-import
> /tg-import.txt
> /tg-info
> diff --git a/README b/README
> index f103d92..46f564a 100644 README
> --- a/README
> +++ b/README
> @@ -272,6 +272,14 @@ tg depend
>
> TODO: Subcommand for removing dependencies, obviously
>
> +tg files
> +~~~~~~~~
> + List files changed by the current or specified topic branch.
> +
> + Options:
> + -i list files based on index instead of branch
> + -w list files based on working tree instead of branch
> +
> tg info
> ~~~~~~~
> Show a summary information about the current or specified
> diff --git a/contrib/tg-completion.bash b/contrib/tg-completion.bash
> index 0ee233c..38567d0 100755 contrib/tg-completion.bash
> --- a/contrib/tg-completion.bash
> +++ b/contrib/tg-completion.bash
> @@ -467,6 +467,7 @@ _tg ()
> delete) _tg_delete ;;
> depend) _tg_depend ;;
> export) _tg_export ;;
> + files) _tg_patch ;;
> help) _tg_help ;;
> import) _tg_import ;;
> info) _tg_info ;;
> diff --git a/tg-export.sh b/tg-export.sh
> index 6d82d55..4b0148c 100644 tg-export.sh
> --- a/tg-export.sh
> +++ b/tg-export.sh
> @@ -63,15 +63,6 @@ trap 'rm -rf "$playground"' EXIT
>
> ## Collapse driver
>
> -# pretty_tree NAME
> -# Output tree ID of a cleaned-up tree without tg's artifacts.
> -pretty_tree()
> -{
> - git ls-tree --full-tree "$1" \
> - | awk -F ' ' '$2 !~ /^.top/' \
> - | git mktree
> -}
> -
> create_tg_commit()
> {
> name="$1"
> diff --git a/tg-files.sh b/tg-files.sh
> new file mode 100644
> index 0000000..b88940a tg-files.sh
> --- /dev/null
> +++ b/tg-files.sh
> @@ -0,0 +1,43 @@
> +#!/bin/sh
> +# TopGit - A different patch queue manager
> +# (c) Petr Baudis <pasky@suse.cz> 2008
> +# GPLv2
> +
> +name=
> +topic=
> +
> +
> +## 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;;
this can be compressed to:
-i|-w)
[ -z "$topic" ] || die "-i and -w are mutually exclusive"
topic=$arg
;;
> + -*)
> + echo "Usage: tg [...] files [-i | -w] [NAME]" >&2
> + exit 1;;
> + *)
> + [ -z "$name" ] || die "name already specified ($name)"
> + name="$arg";;
> + esac
> +done
> +
> +
> +[ -n "$name" -a -n "$topic" ] &&
> + die "-i/-w are mutually exclusive with NAME"
What about
die "$topic is mutually exclusive with NAME"
?
> +
> +[ -n "$name" ] || name="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')"
> +base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
> + die "not a TopGit-controlled branch"
> +
> +b_tree=$(pretty_tree "$name" -b)
> +t_tree=$(pretty_tree "$name" $topic)
> +
> +git diff-tree --name-only -r $b_tree $t_tree
> +
> +# vim:noet
> diff --git a/tg.sh b/tg.sh
> index 9d08d63..2bc6bed 100644 tg.sh
> --- a/tg.sh
> +++ b/tg.sh
> @@ -39,6 +39,55 @@ cat_file()
> esac
> }
>
> +# get tree for the committed topic
> +get_tree_()
> +{
> + echo "$1"
> +}
> +
> +# get tree for the base
> +get_tree_b()
> +{
> + echo "refs/top-bases/$1"
> +}
> +
> +# get tree for the index
> +get_tree_i()
> +{
> + git write-tree
> +}
> +
> +# get tree for the worktree
> +get_tree_w()
> +{
> + i_tree=$(git write-tree)
> + (
> + # the file for --index-output needs to sit next to the
> + # current index file
> + : ${GIT_INDEX_FILE:="$git_dir/index"}
> + TMP_INDEX="$(mktemp "${GIT_INDEX_FILE}-tg.XXXXXX")"
> + git read-tree -m $i_tree --index-output="$TMP_INDEX" &&
> + GIT_INDEX_FILE="$TMP_INDEX" &&
> + export GIT_INDEX_FILE &&
> + git diff --name-only -z HEAD |
> + git update-index -z --add --remove --stdin &&
> + git write-tree &&
> + rm -f "$TMP_INDEX"
> + )
> +}
> +
> +# pretty_tree NAME [-b | -i | -w]
> +# Output tree ID of a cleaned-up tree without tg's artifacts.
> +# NAME will be ignored for -i and -w, but needs to be present
> +pretty_tree()
> +{
> + name=$1
> + source=${2#?}
> + git ls-tree --full-tree "$(get_tree_$source "$name")" |
> + awk -F ' ' '$2 !~ /^.top/' |
> + git mktree
> +}
> +
> # setup_hook NAME
> setup_hook()
> {
> --
> tg: (9404aa1..) bw/files (depends on: master)
>
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
next prev parent reply other threads:[~2010-10-05 7:17 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-03 19:15 planning a new topgit release Uwe Kleine-König
2010-10-03 21:21 ` Bert Wesarg
2010-10-03 21:25 ` [TopGit PATCH 1/6] Let tg-update take a branch parameter Bert Wesarg
2010-10-03 21:25 ` [TopGit PATCH 2/6] tg-remote: use default remote if non is given Bert Wesarg
2010-10-03 21:25 ` [TopGit PATCH 3/6] tg-files: list files changed by the topic branch Bert Wesarg
2010-10-03 21:25 ` [TopGit PATCH 4/6] tg-prev/tg-next: commands to explore dependencies Bert Wesarg
2010-10-03 21:25 ` [TopGit PATCH 5/6] put die() messages to stderr Bert Wesarg
2010-10-03 21:25 ` [TopGit PATCH 6/6] tg-log: short cut to git log Bert Wesarg
[not found] ` <AANLkTi=Kwx5avY7xRdWLS931zK2fi7cj5Q8u3++bqRO+@mail.gmail.com>
2010-10-04 6:45 ` Bert Wesarg
2010-10-04 19:06 ` [TopGit PATCH] tg-log: move note from tg base to tg log Bert Wesarg
2010-10-04 21:05 ` Štěpán Němec
2010-10-04 21:08 ` Bert Wesarg
2010-10-04 6:45 ` [TopGit PATCH 6/6] tg-log: short cut to git log Uwe Kleine-König
2010-10-03 21:55 ` [TopGit PATCH 4/6] tg-prev/tg-next: commands to explore dependencies Uwe Kleine-König
2010-10-04 6:48 ` Bert Wesarg
2010-10-03 22:03 ` [TopGit PATCH 3/6] tg-files: list files changed by the topic branch Uwe Kleine-König
2010-10-04 6:43 ` Bert Wesarg
2010-10-04 6:47 ` Uwe Kleine-König
2010-10-04 6:50 ` Bert Wesarg
2010-10-04 6:59 ` Uwe Kleine-König
2010-10-04 13:16 ` [TopGit PATCH] " Bert Wesarg
2010-10-04 13:52 ` Uwe Kleine-König
2010-10-04 16:02 ` Bert Wesarg
2010-10-04 18:27 ` [TopGit PATCH v3] " Bert Wesarg
2010-10-04 20:09 ` [TopGit PATCH] tg-patch: use pretty_tree Bert Wesarg
2010-10-04 23:02 ` Bert Wesarg
2010-10-05 7:18 ` Uwe Kleine-König
2010-10-05 8:05 ` Bert Wesarg
2010-10-05 19:04 ` [TopGit PATCH v2] " Bert Wesarg
2010-10-05 20:01 ` Uwe Kleine-König
2010-10-05 20:14 ` Bert Wesarg
2010-10-05 7:17 ` Uwe Kleine-König [this message]
2010-10-05 19:03 ` [TopGit PATCH v4] tg-files: list files changed by the topic branch Bert Wesarg
2010-10-05 22:02 ` Štěpán Němec
2010-10-06 6:11 ` Bert Wesarg
2010-10-03 22:00 ` [TopGit PATCH 2/6] tg-remote: use default remote if non is given Uwe Kleine-König
2010-10-04 3:13 ` Ævar Arnfjörð Bjarmason
2010-10-04 6:43 ` Uwe Kleine-König
2010-10-03 22:11 ` planning a new topgit release Uwe Kleine-König
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101005071723.GG11737@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=bert.wesarg@googlemail.com \
--cc=ceder@lysator.liu.se \
--cc=git@vger.kernel.org \
--cc=madduck@madduck.net \
--cc=odabrunz@gmx.net \
--cc=pasky@suse.cz \
--cc=simons@cryp.to \
--cc=thomas.moschny@gmx.de \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).