Re: [TopGit PATCH] tg-files: list files changed by the topic branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2010/10/4 Uwe Kleine-KÃnig <u.kleine-koenig@xxxxxxxxxxxxxx>:
> On Mon, Oct 04, 2010 at 03:16:34PM +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@xxxxxxxxxxxxxx>
>>
>> ---
>>
>> > For these we need pretty_tree -i and pretty_tree -w?!
>> Done and moved to tg.sh. tg-patch should now be updated.
>>
>> Regards,
>> Bert
>>
>> Â.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..4e9c5cd 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@xxxxxxx> Â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;;
>> + Â Â -*)
>> + Â Â Â Â Â Â 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"
>> +
>> +[ -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=$(prett_tree "$name" -b)
>> +t_tree=$(prett_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..ff39483 100644 tg.sh
>> --- a/tg.sh
>> +++ b/tg.sh
>> @@ -39,6 +39,55 @@ cat_file()
>> Â Â Â esac
>> Â}
>>
>> +# get tree for topic
>> +get_tree_()
>> +{
>> + Â Â echo "$1"
>> +}
>> +
>> +# get tree for base
>> +get_tree_b()
>> +{
>> + Â Â echo "refs/top-bases/$1"
>> +}
>> +
>> +# get tree for index
>> +get_tree_i()
>> +{
>> + Â Â git write-tree
>> +}
>> +
>> +# get tree for worktree
>> +get_tree_w()
>> +{
>> + Â Â i_tree=$(git write-tree)
>> + Â Â (
>> + Â Â Â Â Â Â TMP_INDEX="$(mktemp -t tg-files-index.XXXXXX)"
>> + Â Â Â Â Â Â rm -f "$TMP_INDEX" &&
> why remove the temp file here?

This code block was from git-stash. Will remove that.

>
>> + Â Â Â Â Â Â : ${GIT_DIR:="$root_dir/.git"} &&
>> + Â Â Â Â Â Â cp -p ${GIT_INDEX_FILE-"$GIT_DIR/index"} "$TMP_INDEX" &&
>> + Â Â Â Â Â Â GIT_INDEX_FILE="$TMP_INDEX" &&
>> + Â Â Â Â Â Â export GIT_INDEX_FILE &&
>> + Â Â Â Â Â Â git read-tree -m $i_tree &&
> Couldn't the same be done by just doing:
>
> Â Â Â Âgit read-tree -m $i_tree --index-output="$TMP_INDEX"

I don't know. Maybe. But the subsequent git commands need to operate
on $TMP_INDEX, so the only thing we safe is the cp.

>
>> + Â Â Â Â Â Â 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
>> +prett_tree()
> Can we please have the y back? :-)

Sure.

Bert
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]