planning a new topgit release
Hello,
In the last few days I got two mails about the status of topgit and was asked about a new release.
I'm willing to create a release as 0.8 was done quite some time ago and there were several patches merged since then---mostly bugfixes.
I'm sure I missed questions and patches in the recent past, so I ask you to resend anything you still have pending to me to get it included in 0.9.
Thanks
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Hey,
2010/10/3 Uwe Kleine-König <[email protected]>:
Quoted 11 lines
Hello,
In the last few days I got two mails about the status of topgit and was asked about a new release.
I'm willing to create a release as 0.8 was done quite some time ago and there were several patches merged since then---mostly bugfixes.
I'm sure I missed questions and patches in the recent past, so I ask you to resend anything you still have pending to me to get it included in 0.9.
Thanks for the heads-up. I will send my low and long hanging fruits in reply to this message. I haven't followed master recently. The missing important patch is the tg-graph one (which is probably my most used command these days). Which Per may find interesting, Maybe I find the time this week to update and send this out.
Bert
Quoted 3 lines
Thanks
Uwe
PATCH 1/6 Let tg-update take a branch parameter
--- README | 6 ++++-- contrib/tg-completion.bash | 7 ++++++- tg-update.sh | 18 ++++++++++++------ 3 files changed, 22 insertions(+), 9 deletions(-)
README +4 -2
@@ -472,13 +472,15 @@ tg import tg update ~~~~~~~~~ - Update the current topic branch wrt. changes in the branches - it depends on and remote branches. + Update the current or specified topic branch wrt. changes in the + branches it depends on and remote branches. This is performed in two phases - first, changes within the dependencies are merged to the base, then the base is merged into the topic branch. The output will guide you in case of conflicts. + After the update the current branch is the specified one. + In case your dependencies are not up-to-date, tg update will first recurse into them and update these.
contrib/tg-completion.bash +6 -1
@@ -423,7 +423,12 @@ _tg_summary () _tg_update () { - COMPREPLY=() + local cur="${COMP_WORDS[COMP_CWORD]}" + + case "$cur" in + *) + __tgcomp "$(__tg_topics)" + esac } ### }}}
tg-update.sh +13 -7
@@ -8,13 +8,19 @@ name= ## Parse options -if [ -n "$1" ]; then - echo "Usage: tg [...] update" >&2 - exit 1 -fi - - -name="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')" +while [ -n "$1" ]; do + arg="$1"; shift + case "$arg" in + -*) + echo "Usage: tg [...] update [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\|top-bases\)/##')" base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" || die "not a TopGit-controlled branch"
Signature · 1 line
tg: (29ab4cf..) bw/update-does-checkout (depends on: master)
PATCH 2/6 tg-remote: use default remote if non is given
This is usefull if the remote has new topics and you need to populate the local top-bases.
--- README | 2 +- tg-remote.sh | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-)
README +1 -1
@@ -327,7 +327,7 @@ tg remote and 'git push' to operate on them. (Do NOT use 'git push --all' for your pushes - plain 'git push' will do the right thing.) - It takes a mandatory remote name argument, and optional + It takes a optional remote name argument, and optional '--populate' switch - use that for your origin-style remote, it will seed the local topic branch system based on the remote topic branches. '--populate' will also make 'tg remote'
tg-remote.sh +4 -1
@@ -15,13 +15,16 @@ while [ -n "$1" ]; do --populate) populate=1;; -*) - echo "Usage: tg [...] remote [--populate] REMOTE" >&2 + echo "Usage: tg [...] remote [--populate] [REMOTE]" >&2 exit 1;; *) name="$arg";; esac done +[ -n "$name" ] || + name="$base_remote" + git config "remote.$name.url" >/dev/null || die "unknown remote '$name'"
Signature · 1 line
tg: (29ab4cf..) bw/tg-remote-use-defualt-remote (depends on: master)
PATCH 3/6 tg-files: list files changed by the topic branch
this could also be a --name-only option to tg-patch. But I Like the similarity to 'quilt files'.
--- .gitignore | 2 + README | 8 ++++++ contrib/tg-completion.bash | 1 + tg-files.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 0 deletions(-)
.gitignore +2 -0
@@ -22,6 +22,8 @@ /tg-depend.txt /tg-export /tg-export.txt +/tg-files +/tg-files.txt /tg-import /tg-import.txt /tg-info
README +8 -0
@@ -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
contrib/tg-completion.bash +1 -0
@@ -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 ;;
tg-files.sh new file +52 -0
52 lines not on this page · raw message
Signature · 1 line
tg: (9404aa1..) bw/files (depends on: master)
PATCH 4/6 tg-prev/tg-next: commands to explore dependencies
Two new commands to explore the dependencies of TopGit branches:
a) tg prev [-i | -w] [NAME]
outputs the dependencies of NAME
b) tg next [-i | -w] [NAME]
outputs branches which depends on NAME
Obviously, quilt next was the inspiration.
--- .gitignore | 4 +++ README | 16 +++++++++++++++ contrib/tg-completion.bash | 34 +++++++++++++++++++++++++++++++++ tg-next.sh | 45 ++++++++++++++++++++++++++++++++++++++++++++ tg-prev.sh | 38 +++++++++++++++++++++++++++++++++++++ 5 files changed, 137 insertions(+), 0 deletions(-)
.gitignore +4 -0
@@ -28,8 +28,12 @@ /tg-info.txt /tg-mail /tg-mail.txt +/tg-next +/tg-next.txt /tg-patch /tg-patch.txt +/tg-prev +/tg-prev.txt /tg-push /tg-push.txt /tg-remote
README +16 -0
@@ -522,6 +522,22 @@ tg base repository, so you will not see work done by your collaborators.) +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
contrib/tg-completion.bash +34 -0
@@ -426,6 +426,38 @@ _tg_update () COMPREPLY=() } +_tg_next () +{ + local cur="${COMP_WORDS[COMP_CWORD]}" + + case "$cur" in + -*) + __tgcomp " + -i + -w + " + ;; + *) + __tgcomp "$(__tg_topics)" + esac +} + +_tg_prev () +{ + local cur="${COMP_WORDS[COMP_CWORD]}" + + case "$cur" in + -*) + __tgcomp " + -i + -w + " + ;; + *) + __tgcomp "$(__tg_topics)" + esac +} + ### }}} ### {{{ tg completion
@@ -471,7 +503,9 @@ _tg () import) _tg_import ;; info) _tg_info ;; mail) _tg_mail ;; + next) _tg_next ;; patch) _tg_patch ;; + prev) _tg_prev ;; push) _tg_push ;; remote) _tg_remote ;; summary) _tg_summary ;;
tg-next.sh new file +45 -0
45 lines not on this page · raw message
tg-prev.sh new file +38 -0
@@ -0,0 +1,38 @@ +#!/bin/sh +# TopGit - A different patch queue manager +# (c) Petr Baudis <[email protected]> 2008 +# (c) Bert Wesarg <[email protected]> 2009 +# GPLv2 + +name= +head_deps= + + +## Parse options + +while [ -n "$1" ]; do + arg="$1"; shift + case "$arg" in + -i) + head_deps='(i)';; + -w) + head_deps='(w)';; + -*) + echo "Usage: tg next [-i | -w] [NAME]" >&2 + exit 1;; + *) + [ -z "$name" ] || die "name already specified ($name)" + name="$arg";; + esac +done + +head="$(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" + +deps_src=$name +# select .topdeps source for HEAD branch +[ "x$name" = "x$head" -a -n "$head_deps" ] && + deps_src=$head_deps +cat_file "$deps_src:.topdeps"
Signature · 1 line
tg: (9404aa1..) bw/next-prev-base (depends on: master)
PATCH 5/6 put die() messages to stderr
--- tg.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tg.sh +1 -1
@@ -14,7 +14,7 @@ info() die() { - info "fatal: $*" + info "fatal: $*" >&2 exit 1 }
Signature · 1 line
tg: (9404aa1..) bw/die-to-stderr (depends on: master)
PATCH 6/6 tg-log: short cut to git log
A short cut to show the history of a named topgit branch. Additional options to git log can be given after a '--'.
--- .gitignore | 2 ++ README | 3 +++ contrib/tg-completion.bash | 11 +++++++++++ tg-log.sh | 30 ++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 0 deletions(-)
.gitignore +2 -0
@@ -28,6 +28,8 @@ /tg-info.txt /tg-mail /tg-mail.txt +/tg-log +/tg-log.txt /tg-patch /tg-patch.txt /tg-push
README +3 -0
@@ -522,6 +522,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
contrib/tg-completion.bash +11 -0
@@ -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]}"
@@ -470,6 +480,7 @@ _tg () help) _tg_help ;; import) _tg_import ;; info) _tg_info ;; + log) _tg_log ;; mail) _tg_mail ;; patch) _tg_patch ;; push) _tg_push ;;
tg-log.sh new file +30 -0
@@ -0,0 +1,30 @@ +#!/bin/sh +# TopGit - A different patch queue manager +# (c) Petr Baudis <[email protected]> 2008 +# (c) Bert Wesarg <[email protected]> 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"
Signature · 1 line
tg: (9404aa1..) bw/log (depends on: master)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [TopGit PATCH 6/6] tg-log: short cut to git log
Hi,
Quoted 10 lines · Per Cederqvist
Using --first-parent to get only the interesting commits only works reliably when you only work locally. If you collaborate and you and your partner both make a commit before you push to a central server you will have to make a merge, where both parents are interesting.
I wish that git remembered which branch a commit was initially made on. That would make "tg log" easy to implement correctly. But since git doesn't, I don't think it is possible to implement it properly.
At least, a warning should be added to the README.
Oh right, I missed that, when looking over the patch. Maybe doing something like:
git log $name ^base(name) $(for d in dep(name); do echo ^$d)
would work?
Thanks
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [TopGit PATCH 6/6] tg-log: short cut to git log
In reply to a message not in the archiveQuoted 10 lines · Per Cederqvist
Using --first-parent to get only the interesting commits only works reliably when you only work locally. If you collaborate and you and your partner both make a commit before you push to a central server you will have to make a merge, where both parents are interesting.
I wish that git remembered which branch a commit was initially made on. That would make "tg log" easy to implement correctly. But since git doesn't, I don't think it is possible to implement it properly.
At least, a warning should be added to the README.
I've read it from your tg base help message and have no problem to copy/move it to tg log.
Bert
Quoted 2 lines
/ceder
PATCH 1/1 tg-log: move note from tg base to tg log
--- README | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-)
README +6 -9
@@ -514,20 +514,17 @@ tg base ~~~~~~~ Prints the base commit of the current topic branch. Silently exits with exit code 1 if you are not working on a TopGit - branch. The following command can be useful to get a summary - of the work you have made on a topic branch: - - git log --first-parent --no-merges `tg base`.. - - (Note: if you have shared the TopGit branch, the above command - only lists the commits that were made in the current - repository, so you will not see work done by your - collaborators.) + branch. tg log ~~~~~~ Prints the git log of the named topgit branch. + Note: if you have shared the TopGit branch, this command + only lists the commits that where made in the current + repository, so you will not see work done by your + collaborators. + TODO: tg rename
Signature · 1 line
tg: (ff59ac7..) bw/log (depends on: master)
Re: [TopGit PATCH] tg-log: move note from tg base to tg log
Quoted 1 line · Bert Wesarg
Signed-off-by Bert Wesarg <[email protected]>
[...]
README tg base · line 524
Quoted 12 lines
README +3
-4- (Note: if you have shared the TopGit branch, the above command - only lists the commits that were made in the current - repository, so you will not see work done by your - collaborators.) + branch. tg log ~~~~~~ Prints the git log of the named topgit branch. + Note: if you have shared the TopGit branch, this command + only lists the commits that where made in the current
^^^^^
You managed to introduce a typo while (mostly just) moving the paragraph. :-)
Štěpán
Re: [TopGit PATCH] tg-log: move note from tg base to tg log
Quoted 16 lines · Štěpán Němec
Quoted 1 line · Bert Wesarg
Signed-off-by Bert Wesarg <[email protected]>[...]
Quoted 10 lines
- (Note: if you have shared the TopGit branch, the above command
- only lists the commits that were made in the current
- repository, so you will not see work done by your
- collaborators.)
+ branch.tg log
~~~~~~
Prints the git log of the named topgit branch.
Quoted 5 lines
Quoted 2 lines
+ Note: if you have shared the TopGit branch, this command
+ only lists the commits that where made in the current^^^^^
You managed to introduce a typo while (mostly just) moving the paragraph. :-)
And I thought I fixed this typo ;-)
Thanks.
Bert
Quoted 3 lines
Štěpán
Re: [TopGit PATCH 4/6] tg-prev/tg-next: commands to explore dependencies
In reply to Bert WesargHi,
Quoted 7 lines · Bert Wesarg
Two new commands to explore the dependencies of TopGit branches:
a) tg prev [-i | -w] [NAME]
outputs the dependencies of NAMEb) tg next [-i | -w] [NAME]
outputs branches which depends on NAME
I wonder if this is somehow mergable with Per's checkout [next|prev]. (contained in git://repo.or.cz/topgit/tsort.git, t/checkout)
What do you think?
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [TopGit PATCH 4/6] tg-prev/tg-next: commands to explore dependencies
2010/10/3 Uwe Kleine-König <[email protected]>:
Quoted 8 lines
Hi,
Quoted 5 lines · Bert Wesarg
Two new commands to explore the dependencies of TopGit branches:
a) tg prev [-i | -w] [NAME]
outputs the dependencies of NAME
Quoted 6 lines
Quoted 2 lines
b) tg next [-i | -w] [NAME]
outputs branches which depends on NAMEI wonder if this is somehow mergable with Per's checkout [next|prev]. (contained in
git://repo.or.cz/topgit/tsort.git, t/checkout)What do you think?
While this is obviously possible. I'm more a friend of many small commands like quilt has it.
Also, I have a follow-up patch that prints all offending branches, not only the directly one (--all option).
Bert
Quoted 3 lines
Best regards
Uwe
Re: [TopGit PATCH 3/6] tg-files: list files changed by the topic branch
In reply to Bert WesargHi Bert,
Quoted 102 lines · Bert Wesarg
this could also be a --name-only option to tg-patch. But I Like the similarity to 'quilt files'.
Signed-off-by Bert Wesarg <[email protected]>--- .gitignore | 2 + README | 8 ++++++ contrib/tg-completion.bash | 1 + tg-files.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 0 deletions(-).gitignore +2
-0@@ -22,6 +22,8 @@ /tg-depend.txt /tg-export /tg-export.txt +/tg-files +/tg-files.txt /tg-import /tg-import.txt /tg-infoREADME +8
-0@@ -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 specifiedcontrib/tg-completion.bash +1
-0@@ -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 ;;tg-files.sh new file +40
-0@@ -0,0 +1,52 @@ +#!/bin/sh +# TopGit - A different patch queue manager +# (c) Petr Baudis <[email protected]> 2008 +# GPLv2 + +name= + +topic= +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) + topic='(i)' + diff_opts="$diff_opts --cached"; + diff_committed_only=;; + -w) + topic='(w)' + diff_committed_only=;; + -*) + echo "Usage: tg [...] files [-i | -w] [NAME]" >&2 + exit 1;; + *) + [ -z "$name" ] || die "name already specified ($name)" + name="$arg";; + esac +done + + +[ -n "$name" -a -z "$diff_committed_only" ] && + 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"
tg-files.sh line 50
Quoted 10 lines
tg-files.sh new file +10
-0+ +# if not index/worktree, topic is current branch +[ -z "$topic" ] && topic="$name" + + + +# Evil obnoxious hack to work around the lack of git diff --exclude +git diff --name-only $diff_opts "$base_rev" ${diff_committed_only:+"$name"} -- | + fgrep -vx ".topdeps" | + fgrep -vx ".topmsg" || : # fgrep likes to fail randomly?
Instead of using fgrep you could export the branch and call git diff --name-only $diff_opts on the resulting commit?
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [TopGit PATCH 3/6] tg-files: list files changed by the topic branch
Hi,
2010/10/4 Uwe Kleine-König <[email protected]>:
Quoted 109 lines
Hi Bert,
Quoted 106 lines · Bert Wesarg
this could also be a --name-only option to tg-patch. But I Like the similarity to 'quilt files'.
Signed-off-by Bert Wesarg <[email protected]>---
.gitignore | 2 +
README | 8 ++++++ contrib/tg-completion.bash | 1 +
tg-files.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++4 files changed, 63 insertions(+), 0 deletions(-).gitignore +0
-0@@ -22,6 +22,8 @@/tg-depend.txt
/tg-export
/tg-export.txt.gitignore +2
-0+/tg-files +/tg-files.txt/tg-import
/tg-import.txt
/tg-infoREADME +0
-0@@ -272,6 +272,14 @@ tg dependTODO: Subcommand for removing dependencies, obviously
README +8
-0+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 specifiedcontrib/tg-completion.bash +1
-0@@ -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 ;;tg-files.sh new file +44
-0@@ -0,0 +1,52 @@ +#!/bin/sh +# TopGit - A different patch queue manager +# (c) Petr Baudis <[email protected]> 2008 +# GPLv2 + +name= + +topic= +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) + topic='(i)' + diff_opts="$diff_opts --cached"; + diff_committed_only=;; + -w) + topic='(w)' + diff_committed_only=;; + -*) + echo "Usage: tg [...] files [-i | -w] [NAME]" >&2 + exit 1;; + *) + [ -z "$name" ] || die "name already specified ($name)" + name="$arg";; + esac +done + + +[ -n "$name" -a -z "$diff_committed_only" ] && + 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" + +# if not index/worktree, topic is current branch +[ -z "$topic" ] && topic="$name" +
Quoted 8 lines
tg-files.sh line 50
Quoted 6 lines
tg-files.sh new file +6
-0+ + +# Evil obnoxious hack to work around the lack of git diff --exclude +git diff --name-only $diff_opts "$base_rev" ${diff_committed_only:+"$name"} -- | + fgrep -vx ".topdeps" | + fgrep -vx ".topmsg" || : # fgrep likes to fail randomly?Instead of using fgrep you could export the branch and call git diff --name-only $diff_opts on the resulting commit?
If you mean using tg-export, than I think this is a bad idea. The operation will than be O(n), with n the total number of depending branches.
I think a pretty_tree on the base and the branch with git diff-tree should suffice:
git diff-tree --name-only $(pretty_tree refs/top-bases/$name) $(pretty_tree $name)
Bert
Quoted 8 lines
Best regards
Uwe--
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [TopGit PATCH 3/6] tg-files: list files changed by the topic branch
Hello Bert,
Quoted 123 lines · Bert Wesarg
2010/10/4 Uwe Kleine-König <[email protected]>:
Quoted 109 lines
Hi Bert,
Quoted 106 lines · Bert Wesarg
this could also be a --name-only option to tg-patch. But I Like the similarity to 'quilt files'.
Signed-off-by Bert Wesarg <[email protected]>---
.gitignore | 2 +
README | 8 ++++++ contrib/tg-completion.bash | 1 +
tg-files.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++4 files changed, 63 insertions(+), 0 deletions(-).gitignore +0
-0@@ -22,6 +22,8 @@/tg-depend.txt
/tg-export
/tg-export.txt.gitignore +2
-0+/tg-files +/tg-files.txt/tg-import
/tg-import.txt
/tg-infoREADME +0
-0@@ -272,6 +272,14 @@ tg dependTODO: Subcommand for removing dependencies, obviously
README +8
-0+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 specifiedcontrib/tg-completion.bash +1
-0@@ -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 ;;tg-files.sh new file +44
-0@@ -0,0 +1,52 @@ +#!/bin/sh +# TopGit - A different patch queue manager +# (c) Petr Baudis <[email protected]> 2008 +# GPLv2 + +name= + +topic= +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) + topic='(i)' + diff_opts="$diff_opts --cached"; + diff_committed_only=;; + -w) + topic='(w)' + diff_committed_only=;; + -*) + echo "Usage: tg [...] files [-i | -w] [NAME]" >&2 + exit 1;; + *) + [ -z "$name" ] || die "name already specified ($name)" + name="$arg";; + esac +done + + +[ -n "$name" -a -z "$diff_committed_only" ] && + 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" + +# if not index/worktree, topic is current branch +[ -z "$topic" ] && topic="$name" +Quoted 8 lines
tg-files.sh line 50
Quoted 6 lines
tg-files.sh new file +6
-0+ + +# Evil obnoxious hack to work around the lack of git diff --exclude +git diff --name-only $diff_opts "$base_rev" ${diff_committed_only:+"$name"} -- | + fgrep -vx ".topdeps" | + fgrep -vx ".topmsg" || : # fgrep likes to fail randomly?Instead of using fgrep you could export the branch and call git diff --name-only $diff_opts on the resulting commit?
If you mean using tg-export, than I think this is a bad idea. The operation will than be O(n), with n the total number of depending branches.
Quoted 5 lines
I think a
pretty_treeon the base and the branch with git diff-tree should suffice:git diff-tree --name-only $(pretty_tree refs/top-bases/$name) $(pretty_tree $name)
That's what I thought after sending the mail and shuting down my machine :-)
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [TopGit PATCH 3/6] tg-files: list files changed by the topic branch
2010/10/4 Uwe Kleine-König <[email protected]>:
Quoted 7 lines
Hello Bert,
Quoted 2 lines · Bert Wesarg
git diff-tree --name-only $(pretty_tree refs/top-bases/$name) $(pretty_tree $name)
That's what I thought after sending the mail and shuting down my machine :-)
But what about the -w and -i option now?
Quoted 2 lines
Uwe
Re: [TopGit PATCH 3/6] tg-files: list files changed by the topic branch
Hi Bert,
Quoted 8 lines · Bert Wesarg
2010/10/4 Uwe Kleine-König <[email protected]>:
Quoted 5 lines · Bert Wesarg
Quoted 2 lines
git diff-tree --name-only $(pretty_tree refs/top-bases/$name) $(pretty_tree $name)
That's what I thought after sending the mail and shuting down my machine :-)
But what about the -w and -i option now?
For these we need pretty_tree -i and pretty_tree -w?!
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/1 tg-files: list files changed by the topic branch
this could also be a --name-only option to tg-patch. But I Like the similarity to 'quilt files'.
---
Quoted 1 line
For these we need
pretty_tree-i andpretty_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(-)
.gitignore +2 -0
@@ -22,6 +22,8 @@ /tg-depend.txt /tg-export /tg-export.txt +/tg-files +/tg-files.txt /tg-import /tg-import.txt /tg-info
README +8 -0
@@ -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
contrib/tg-completion.bash +1 -0
@@ -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 ;;
tg-export.sh +0 -9
@@ -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"
tg-files.sh new file +43 -0
43 lines not on this page · raw message
tg.sh +49 -0
55 lines not on this page · raw message
Signature · 1 line
tg: (9404aa1..) bw/files (depends on: master)
Re: [TopGit PATCH] tg-files: list files changed by the topic branch
Quoted 157 lines · Bert Wesarg
this could also be a --name-only option to tg-patch. But I Like the similarity to 'quilt files'.
Signed-off-by Bert Wesarg <[email protected]>---
Quoted 1 line
For these we need
pretty_tree-i andpretty_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(-).gitignore +2
-0@@ -22,6 +22,8 @@ /tg-depend.txt /tg-export /tg-export.txt +/tg-files +/tg-files.txt /tg-import /tg-import.txt /tg-infoREADME +8
-0@@ -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 specifiedcontrib/tg-completion.bash +1
-0@@ -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 ;;tg-export.sh +0
-9@@ -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"tg-files.sh new file +43
-0@@ -0,0 +1,43 @@ +#!/bin/sh +# TopGit - A different patch queue manager +# (c) Petr Baudis <[email protected]> 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:noettg.sh +15
-0@@ -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() +{
tg.sh cat_file() · line 66
Quoted 10 lines
tg.sh +10
-0+ 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?
tg.sh cat_file() · line 71
Quoted 5 lines
tg.sh +5
-0+ : ${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"
tg.sh cat_file() · line 82
Quoted 11 lines
tg.sh +11
-0+ 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? :-)
Quoted 14 lines
tg.sh +8
-0+{ + name=$1 + source=${2#?} + git ls-tree --full-tree "$(get_tree_$source "$name")" | + awk -F ' ' '$2 !~ /^.top/' | + git mktree +} + # setup_hook NAME setup_hook() {Signature · 1 line
tg: (9404aa1..) bw/files (depends on: master)
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [TopGit PATCH] tg-files: list files changed by the topic branch
2010/10/4 Uwe Kleine-König <[email protected]>:
Quoted 161 lines · Bert Wesarg
Quoted 160 lines
this could also be a --name-only option to tg-patch. But I Like the similarity to 'quilt files'.
Signed-off-by Bert Wesarg <[email protected]>---
Quoted 1 line
For these we need
pretty_tree-i andpretty_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(-).gitignore +0
-0@@ -22,6 +22,8 @@/tg-depend.txt
/tg-export
/tg-export.txt.gitignore +2
-0+/tg-files +/tg-files.txt/tg-import
/tg-import.txt
/tg-infoREADME +0
-0@@ -272,6 +272,14 @@ tg dependTODO: Subcommand for removing dependencies, obviously
README +8
-0+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 specifiedcontrib/tg-completion.bash +1
-0@@ -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 ;;tg-export.sh +0
-9@@ -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"
tg-files.sh new file +43
-0@@ -0,0 +1,43 @@ +#!/bin/sh +# TopGit - A different patch queue manager +# (c) Petr Baudis <[email protected]> 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:noettg.sh +0
-0@@ -39,6 +39,55 @@ cat_file()esac
}tg.sh +18
-0+# 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 +} +
Quoted 8 lines
tg.sh cat_file() · line 66
Quoted 7 lines
tg.sh +7
-0+# 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.
Quoted 9 lines
Quoted 6 lines
+ : ${GIT_DIR:="$root_dir/.git"} &&
+ cp -p ${GIT_INDEX_FILE-"$GIT_DIR/index"} "$TMP_INDEX" &&
+ GIT_INDEX_FILE="$TMP_INDEX" &&
+ exportGIT_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.
Quoted 13 lines
tg.sh cat_file() · line 82
Quoted 12 lines
+ git diff --name-only -z HEAD |
+ git update-index -z --add --remove --stdin &&
+ git write-tree &&
+ rm -f "$TMP_INDEX"
+ )tg.sh +6
-0+} + +# 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
PATCH v3 1/1 tg-files: list files changed by the topic branch
this could also be a --name-only option to tg-patch. But I Like the similarity to 'quilt files'.
---
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(-)
.gitignore +2 -0
@@ -22,6 +22,8 @@ /tg-depend.txt /tg-export /tg-export.txt +/tg-files +/tg-files.txt /tg-import /tg-import.txt /tg-info
README +8 -0
@@ -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
contrib/tg-completion.bash +1 -0
@@ -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 ;;
tg-export.sh +0 -9
@@ -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"
tg-files.sh new file +43 -0
43 lines not on this page · raw message
tg.sh +49 -0
55 lines not on this page · raw message
Signature · 1 line
tg: (9404aa1..) bw/files (depends on: master)
PATCH 1/1 tg-patch: use pretty_tree
This applies the same treatment to tg-patch like tg-files got in v2.
--- tg-patch.sh | 56 ++++++++++++++++++++++++++++++++------------------------ 1 files changed, 32 insertions(+), 24 deletions(-)
tg-patch.sh +32 -24
@@ -4,11 +4,8 @@ # GPLv2 name= - topic= -diff_opts= -diff_committed_only=yes # will be unset for index/worktree - +topic_for_pretty_tree= ## Parse options
@@ -16,12 +13,13 @@ while [ -n "$1" ]; do arg="$1"; shift case "$arg" in -i) + [ -z "$topic" ] || die "-i and -w are mutually exclusive" topic='(i)' - diff_opts="$diff_opts --cached"; - diff_committed_only=;; + topic_for_pretty_tree=-i;; -w) + [ -z "$topic" ] || die "-i and -w are mutually exclusive" topic='(w)' - diff_committed_only=;; + topic_for_pretty_tree=-w;; -*) echo "Usage: tg [...] patch [-i | -w] [NAME]" >&2 exit 1;;
@@ -32,7 +30,7 @@ while [ -n "$1" ]; do done -[ -n "$name" -a -z "$diff_committed_only" ] && +[ -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\)/##')"
@@ -46,22 +44,32 @@ base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" setup_pager -cat_file "$topic:.topmsg" -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="$(mktemp -t tg-patch-changes.XXXXXX)" -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 - echo "No changes." -fi -rm "$git_is_stupid" +# 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 "$topic:.topmsg" | + 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" $topic_for_pretty_tree) + +git diff-tree -p --stat -r $b_tree $t_tree echo '-- ' echo "tg: ($base_rev..) $name (depends on: $(cat_file "$topic:.topdeps" | paste -s -d' '))"
Signature · 1 line
tg: (c9ca19b..) bw/tg-patch-pretty_tree (depends on: bw/files)
Re: [TopGit PATCH] tg-patch: use pretty_tree
Quoted 3 lines · Bert Wesarg
(quoted diff) +0
-0@@ -46,22 +44,32 @@ base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)"setup_pager
:
Quoted 1 line
+git diff-tree -p --stat -r $b_tree $t_tree
There is currently no color output and I don't know if a simple --color suffice here.
Bert
Quoted 6 lines
echo '-- '
echo "tg: ($base_rev..) $name (depends on: $(cat_file "$topic:.topdeps" | paste -s -d' '))" --
tg: (c9ca19b..) bw/tg-patch-pretty_tree (depends on: bw/files)
Re: [TopGit PATCH] tg-patch: use pretty_tree
Hello,
Quoted 9 lines · Bert Wesarg
Quoted 3 lines · Bert Wesarg
(quoted diff) +0
-0@@ -46,22 +44,32 @@ base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)"setup_pager
:
Quoted 1 line
+git diff-tree -p --stat -r $b_tree $t_tree
There is currently no color output and I don't know if a simple --color suffice here.
--color=auto maybe?
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [TopGit PATCH] tg-patch: use pretty_tree
2010/10/5 Uwe Kleine-König <[email protected]>:
Quoted 6 lines
Hello,
Quoted 3 lines · Bert Wesarg
Quoted 2 lines · Bert Wesarg
(quoted diff) +0
-0@@ -46,22 +44,32 @@ base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)"
Quoted 7 lines
Quoted 6 lines
Quoted 1 line
setup_pager
:
Quoted 1 line
+git diff-tree -p --stat -r $b_tree $t_tree
There is currently no color output and I don't know if a simple --color suffice here.
--color=auto maybe?
I think it should depend on the color.diff config option. Is auto the default, when this is not set?
Bert
Quoted 7 lines
Uwe
--
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 1/1 tg-patch: use pretty_tree
This applies the same treatment to tg-patch like tg-files got in v2.
---
Basing the decision whether to use the ui diff or the porcelain diff-tree is probably very unorthodox, but also makes sense, doesn't it?
Changes:
v2:
* apply suggestions from Uwe made to tg-files here too
* the running pager decides whether we use the ui diff or the porcelain diff-tree
tg-patch.sh | 67 +++++++++++++++++++++++++++++++++------------------------- 1 files changed, 38 insertions(+), 29 deletions(-)
tg-patch.sh +38 -29
@@ -4,24 +4,18 @@ # GPLv2 name= - topic= -diff_opts= -diff_committed_only=yes # will be unset for index/worktree - +topic_for_pretty_tree= ## Parse options while [ -n "$1" ]; do arg="$1"; shift case "$arg" in - -i) - topic='(i)' - diff_opts="$diff_opts --cached"; - diff_committed_only=;; - -w) - topic='(w)' - diff_committed_only=;; + -i|-w) + [ -z "$topic" ] || die "-i and -w are mutually exclusive" + topic="(${arg#-})" + topic_for_pretty_tree="$arg";; -*) echo "Usage: tg [...] patch [-i | -w] [NAME]" >&2 exit 1;;
@@ -32,8 +26,8 @@ while [ -n "$1" ]; do done -[ -n "$name" -a -z "$diff_committed_only" ] && - die "-i/-w are mutually exclusive with NAME" +[ -n "$name" -a -n "$topic" ] && + die "$topic 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)" ||
@@ -46,22 +40,37 @@ base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" setup_pager -cat_file "$topic:.topmsg" -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="$(mktemp -t tg-patch-changes.XXXXXX)" -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 - echo "No changes." -fi -rm "$git_is_stupid" +# 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 "$topic:.topmsg" | + 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" $topic_for_pretty_tree) + +# use the ui diff command when the pager is active +diff_command=diff +[ "x$GIT_PAGER_IN_USE" = "x1" ] || + diff_command=diff-tree + +git $diff_command -p --stat $b_tree $t_tree echo '-- ' echo "tg: ($base_rev..) $name (depends on: $(cat_file "$topic:.topdeps" | paste -s -d' '))"
Signature · 1 line
tg: (aaf1181..) bw/tg-patch-pretty_tree (depends on: bw/files)
Re: [TopGit PATCH v2] tg-patch: use pretty_tree
Quoted 8 lines · Bert Wesarg
This applies the same treatment to tg-patch like tg-files got in v2.
Signed-off-by Bert Wesarg <[email protected]>---
Basing the decision whether to use the ui diff or the porcelain diff-tree is probably very unorthodox, but also makes sense, doesn't it?
Uuuuuh, I'd feel better with git diff-tree --color=auto. Why did you decide against that?
Quoted 111 lines
Changes:
v2:
* apply suggestions from Uwe made to tg-files here too
* the running pager decides whether we use the ui diff or the porcelain diff-treetg-patch.sh | 67 +++++++++++++++++++++++++++++++++------------------------- 1 files changed, 38 insertions(+), 29 deletions(-)tg-patch.sh +38
-29@@ -4,24 +4,18 @@ # GPLv2 name= - topic= -diff_opts= -diff_committed_only=yes # will be unset for index/worktree - +topic_for_pretty_tree= ## Parse options while [ -n "$1" ]; do arg="$1"; shift case "$arg" in - -i) - topic='(i)' - diff_opts="$diff_opts --cached"; - diff_committed_only=;; - -w) - topic='(w)' - diff_committed_only=;; + -i|-w) + [ -z "$topic" ] || die "-i and -w are mutually exclusive" + topic="(${arg#-})" + topic_for_pretty_tree="$arg";; -*) echo "Usage: tg [...] patch [-i | -w] [NAME]" >&2 exit 1;;@@ -32,8 +26,8 @@ while [ -n "$1" ]; do done -[ -n "$name" -a -z "$diff_committed_only" ] && - die "-i/-w are mutually exclusive with NAME" +[ -n "$name" -a -n "$topic" ] && + die "$topic 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)" ||@@ -46,22 +40,37 @@ base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" setup_pager -cat_file "$topic:.topmsg" -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="$(mktemp -t tg-patch-changes.XXXXXX)" -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 - echo "No changes." -fi -rm "$git_is_stupid" +# 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 "$topic:.topmsg" | + 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" $topic_for_pretty_tree) + +# use the ui diff command when the pager is active +diff_command=diff +[ "x$GIT_PAGER_IN_USE" = "x1" ] || + diff_command=diff-tree + +git $diff_command -p --stat $b_tree $t_tree echo '-- ' echo "tg: ($base_rev..) $name (depends on: $(cat_file "$topic:.topdeps" | paste -s -d' '))"Signature · 1 line
tg: (aaf1181..) bw/tg-patch-pretty_tree (depends on: bw/files)
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [TopGit PATCH v2] tg-patch: use pretty_tree
2010/10/5 Uwe Kleine-König <[email protected]>:
Quoted 11 lines · Bert Wesarg
Quoted 8 lines
This applies the same treatment to tg-patch like tg-files got in v2.
Signed-off-by Bert Wesarg <[email protected]>---
Basing the decision whether to use the ui diff or the porcelain diff-tree is probably very unorthodox, but also makes sense, doesn't it?
Uuuuuh, I'd feel better with git diff-tree --color=auto. Why did you decide against that?
Because there are more config options which diff-tree ignores, for example diff.mnemonicprefix or diff.noprefix. While diff.mnemonicprefix unfortunately should not work in our case (git diff can't decide just from the two tree-ishs what is what) but we could provide our own prefixes with --{src,dst}-prefix. See diff.c:git_diff_ui_config() for the full list. I also have a small patch in my git tree which is only recognized by the ui diff.
BTW. I accidentally removed the '(No changes)' case, which I'm working on right now.
Bert
Re: [TopGit PATCH v3] tg-files: list files changed by the topic branch
In reply to Bert WesargHello,
Quoted 103 lines · Bert Wesarg
this could also be a --name-only option to tg-patch. But I Like the similarity to 'quilt files'.
Signed-off-by Bert Wesarg <[email protected]>---
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(-).gitignore +2
-0@@ -22,6 +22,8 @@ /tg-depend.txt /tg-export /tg-export.txt +/tg-files +/tg-files.txt /tg-import /tg-import.txt /tg-infoREADME +8
-0@@ -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 specifiedcontrib/tg-completion.bash +1
-0@@ -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 ;;tg-export.sh +0
-9@@ -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"tg-files.sh new file +10
-0@@ -0,0 +1,43 @@ +#!/bin/sh +# TopGit - A different patch queue manager +# (c) Petr Baudis <[email protected]> 2008 +# GPLv2 + +name= +topic= + + +## Parse options
tg-files.sh line 20
Quoted 10 lines
tg-files.sh new file +10
-0+ +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 ;;
tg-files.sh line 32
Quoted 12 lines
tg-files.sh new file +12
-0+ -*) + 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"
?
Quoted 74 lines
tg-files.sh new file +11
-0+ +[ -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:noettg.sh +49
-0@@ -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() {Signature · 1 line
tg: (9404aa1..) bw/files (depends on: master)
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v4 1/1 tg-files: list files changed by the topic branch
this could also be a --name-only option to tg-patch. But I Like the similarity to 'quilt files'.
---
Changes:
v4:
* apply Uwe's suggestions
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 | 40 +++++++++++++++++++++++++++++++++++ tg.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 100 insertions(+), 9 deletions(-)
.gitignore +2 -0
@@ -22,6 +22,8 @@ /tg-depend.txt /tg-export /tg-export.txt +/tg-files +/tg-files.txt /tg-import /tg-import.txt /tg-info
README +8 -0
@@ -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
contrib/tg-completion.bash +1 -0
@@ -482,6 +482,7 @@ _tg () delete) _tg_delete ;; depend) _tg_depend ;; export) _tg_export ;; + files) _tg_patch ;; help) _tg_help ;; import) _tg_import ;; info) _tg_info ;;
tg-export.sh +0 -9
@@ -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"
tg-files.sh new file +40 -0
@@ -0,0 +1,40 @@ +#!/bin/sh +# TopGit - A different patch queue manager +# (c) Petr Baudis <[email protected]> 2008 +# GPLv2 + +name= +topic= + + +## Parse options + +while [ -n "$1" ]; do + arg="$1"; shift + case "$arg" in + -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 "$topic 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=$(pretty_tree "$name" -b) +t_tree=$(pretty_tree "$name" $topic) + +git diff-tree --name-only -r $b_tree $t_tree + +# vim:noet
tg.sh +49 -0
55 lines not on this page · raw message
Signature · 1 line
tg: (ff59ac7..) bw/files (depends on: master)
Re: [TopGit PATCH v4] tg-files: list files changed by the topic branch
Quoted 10 lines · Bert Wesarg
this could also be a --name-only option to tg-patch. But I Like the similarity to 'quilt files'.
Signed-off-by Bert Wesarg <[email protected]>---
Changes:
v4:
* apply Uwe's suggestions
[...]
tg-files.sh line 29
Quoted 4 lines
tg-files.sh new file +4
-0+ + +[ -n "$name" -a -n "$topic" ] && + die "$topic are mutually exclusive with NAME"
...so, "are" should now be "is", as $topic will be _either_ -i' or -w', not both.
Štěpán
Re: [TopGit PATCH v4] tg-files: list files changed by the topic branch
Quoted 15 lines · Štěpán Němec
Quoted 10 lines · Bert Wesarg
this could also be a --name-only option to tg-patch. But I Like the similarity to 'quilt files'.
Signed-off-by Bert Wesarg <[email protected]>---
Changes:
v4:
* apply Uwe's suggestions[...]
Quoted 7 lines
tg-files.sh line 29
Quoted 4 lines
tg-files.sh new file +4
-0+ + +[ -n "$name" -a -n "$topic" ] && + die "$topic are mutually exclusive with NAME"...so, "are" should now be "is", as $topic will be _either_
-i' or-w', not both.
Thanks. Will fix.
Bert
Quoted 3 lines
Štěpán
Re: [TopGit PATCH 2/6] tg-remote: use default remote if non is given
In reply to Bert WesargHello,
Quoted 32 lines · Bert Wesarg
This is usefull if the remote has new topics and you need to populate the local top-bases.
Signed-off-by Bert Wesarg <[email protected]>--- README | 2 +- tg-remote.sh | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-)README +1
-1@@ -327,7 +327,7 @@ tg remote and 'git push' to operate on them. (Do NOT use 'git push --all' for your pushes - plain 'git push' will do the right thing.) - It takes a mandatory remote name argument, and optional + It takes a optional remote name argument, and optional '--populate' switch - use that for your origin-style remote, it will seed the local topic branch system based on the remote topic branches. '--populate' will also make 'tg remote'tg-remote.sh +0
-1@@ -15,13 +15,16 @@ while [ -n "$1" ]; do --populate) populate=1;; -*) - echo "Usage: tg [...] remote [--populate] REMOTE" >&2
tg-remote.sh while [ -n "$1" ]; do · line 27
Quoted 10 lines
tg-remote.sh +4
-0+ echo "Usage: tg [...] remote [--populate] [REMOTE]" >&2 exit 1;; *) name="$arg";; esac done +[ -n "$name" ] || + name="$base_remote" +
Doesn't this need error checking, i.e. what happens if tg remote was never called before? Hmm, seems to be a problem that already exists now?! Took your patch anyhow.
Quoted 6 lines
tg-remote.sh +0
-0git config "remote.$name.url" >/dev/null || die "unknown remote '$name'"Signature · 1 line
tg: (29ab4cf..) bw/tg-remote-use-defualt-remote (depends on: master)
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [TopGit PATCH 2/6] tg-remote: use default remote if non is given
In reply to Bert WesargOn Sun, Oct 3, 2010 at 21:25, Bert Wesarg <[email protected]> wrote:
Minor: I think you mean "none" in the subject, not "non".
Re: [TopGit PATCH 2/6] tg-remote: use default remote if non is given
Quoted 3 lines · Ævar Arnfjörð Bjarmason
On Sun, Oct 3, 2010 at 21:25, Bert Wesarg <[email protected]> wrote:
Minor: I think you mean "none" in the subject, not "non".
Right, I fixed that up when committing, together with s/usefull/useful/
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Hello Bert,
Quoted 15 lines · Bert Wesarg
Hey,
2010/10/3 Uwe Kleine-König <[email protected]>:
Quoted 11 lines
Hello,
In the last few days I got two mails about the status of topgit and was asked about a new release.
I'm willing to create a release as 0.8 was done quite some time ago and there were several patches merged since then---mostly bugfixes.
I'm sure I missed questions and patches in the recent past, so I ask you to resend anything you still have pending to me to get it included in 0.9.
Quoted 5 lines
Thanks for the heads-up. I will send my low and long hanging fruits in reply to this message. I haven't followed master recently. The missing important patch is the tg-graph one (which is probably my most used command these days). Which Per may find interesting, Maybe I find the time this week to update and send this out.
I took patches 1, 2 (with two typo fixes in the commit log), 5 and 6.
For 3 and 4 see my replies on the respective mails.
Thanks
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |