git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* planning a new topgit release
@ 2010-10-03 19:15 Uwe Kleine-König
  2010-10-03 21:21 ` Bert Wesarg
  0 siblings, 1 reply; 39+ messages in thread
From: Uwe Kleine-König @ 2010-10-03 19:15 UTC (permalink / raw)
  To: git
  Cc: Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz, Thomas Moschny,
	martin f krafft, Bert Wesarg

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

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: planning a new topgit release
  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 22:11   ` planning a new topgit release Uwe Kleine-König
  0 siblings, 2 replies; 39+ messages in thread
From: Bert Wesarg @ 2010-10-03 21:21 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft

Hey,

2010/10/3 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> 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

>
> Thanks
> Uwe

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [TopGit PATCH 1/6] Let tg-update take a branch parameter
  2010-10-03 21:21 ` Bert Wesarg
@ 2010-10-03 21:25   ` 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 22:11   ` planning a new topgit release Uwe Kleine-König
  1 sibling, 1 reply; 39+ messages in thread
From: Bert Wesarg @ 2010-10-03 21:25 UTC (permalink / raw)
  To: Uwe Kleine-Koenig, Uwe Kleine-Koenig
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft, Bert Wesarg

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

---
 README                     |    6 ++++--
 contrib/tg-completion.bash |    7 ++++++-
 tg-update.sh               |   18 ++++++++++++------
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/README b/README
index c418ff4..dba2345 100644 README
--- a/README
+++ b/README
@@ -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.
 
diff --git a/contrib/tg-completion.bash b/contrib/tg-completion.bash
index 0ee233c..5aabc92 100755 contrib/tg-completion.bash
--- a/contrib/tg-completion.bash
+++ b/contrib/tg-completion.bash
@@ -423,7 +423,12 @@ _tg_summary ()
 
 _tg_update ()
 {
-	COMPREPLY=()
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+
+	case "$cur" in
+	*)
+		__tgcomp "$(__tg_topics)"
+	esac
 }
 
 ### }}}
diff --git a/tg-update.sh b/tg-update.sh
index 73280c6..b256c7c 100644 tg-update.sh
--- a/tg-update.sh
+++ b/tg-update.sh
@@ -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"
 
-- 
tg: (29ab4cf..) bw/update-does-checkout (depends on: master)

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [TopGit PATCH 2/6] tg-remote: use default remote if non is given
  2010-10-03 21:25   ` [TopGit PATCH 1/6] Let tg-update take a branch parameter Bert Wesarg
@ 2010-10-03 21:25     ` Bert Wesarg
  2010-10-03 21:25       ` [TopGit PATCH 3/6] tg-files: list files changed by the topic branch Bert Wesarg
                         ` (2 more replies)
  0 siblings, 3 replies; 39+ messages in thread
From: Bert Wesarg @ 2010-10-03 21:25 UTC (permalink / raw)
  To: Uwe Kleine-Koenig, Petr Baudis
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft, Bert Wesarg, martin f krafft,
	Uwe Kleine-Koenig

This is usefull if the remote has new topics and you need to populate the local
top-bases.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

---
 README       |    2 +-
 tg-remote.sh |    5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/README b/README
index c418ff4..5a54468 100644 README
--- a/README
+++ b/README
@@ -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'
diff --git a/tg-remote.sh b/tg-remote.sh
index 86dcd9a..61774d7 100644 tg-remote.sh
--- a/tg-remote.sh
+++ b/tg-remote.sh
@@ -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'"
 
 
-- 
tg: (29ab4cf..) bw/tg-remote-use-defualt-remote (depends on: master)

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [TopGit PATCH 3/6] tg-files: list files changed by the topic branch
  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       ` Bert Wesarg
  2010-10-03 21:25         ` [TopGit PATCH 4/6] tg-prev/tg-next: commands to explore dependencies 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-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
  2 siblings, 2 replies; 39+ messages in thread
From: Bert Wesarg @ 2010-10-03 21:25 UTC (permalink / raw)
  To: Uwe Kleine-Koenig, Uwe Kleine-Koenig
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft, 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 <bert.wesarg@googlemail.com>

---
 .gitignore                 |    2 +
 README                     |    8 ++++++
 contrib/tg-completion.bash |    1 +
 tg-files.sh                |   52 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 63 insertions(+), 0 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-files.sh b/tg-files.sh
new file mode 100644
index 0000000..0723bf1 tg-files.sh
--- /dev/null
+++ b/tg-files.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+# TopGit - A different patch queue manager
+# (c) Petr Baudis <pasky@suse.cz>  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"
+
+
+
+# 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?
+
+# vim:noet
-- 
tg: (9404aa1..) bw/files (depends on: master)

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [TopGit PATCH 4/6] tg-prev/tg-next: commands to explore dependencies
  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         ` Bert Wesarg
  2010-10-03 21:25           ` [TopGit PATCH 5/6] put die() messages to stderr Bert Wesarg
  2010-10-03 21:55           ` [TopGit PATCH 4/6] tg-prev/tg-next: commands to explore dependencies Uwe Kleine-König
  2010-10-03 22:03         ` [TopGit PATCH 3/6] tg-files: list files changed by the topic branch Uwe Kleine-König
  1 sibling, 2 replies; 39+ messages in thread
From: Bert Wesarg @ 2010-10-03 21:25 UTC (permalink / raw)
  To: Uwe Kleine-Koenig, Uwe Kleine-Koenig
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft, Bert Wesarg

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.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

---
 .gitignore                 |    4 +++
 README                     |   16 +++++++++++++++
 contrib/tg-completion.bash |   34 +++++++++++++++++++++++++++++++++
 tg-next.sh                 |   45 ++++++++++++++++++++++++++++++++++++++++++++
 tg-prev.sh                 |   38 +++++++++++++++++++++++++++++++++++++
 5 files changed, 137 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index 0342e09..fe4bdc1 100644 .gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/README b/README
index f103d92..f2d18a2 100644 README
--- a/README
+++ b/README
@@ -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
 
diff --git a/contrib/tg-completion.bash b/contrib/tg-completion.bash
index 0ee233c..fd17d5c 100755 contrib/tg-completion.bash
--- a/contrib/tg-completion.bash
+++ b/contrib/tg-completion.bash
@@ -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 ;;
diff --git a/tg-next.sh b/tg-next.sh
new file mode 100644
index 0000000..9b352b3 tg-next.sh
--- /dev/null
+++ b/tg-next.sh
@@ -0,0 +1,45 @@
+#!/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=
+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
+
+git for-each-ref --format='%(refname)' refs/top-bases |
+	while read ref; do
+		parent="${ref#refs/top-bases/}"
+
+		deps_src=$parent
+		# select .topdeps source for HEAD branch
+		[ "x$parent" = "x$head" -a -n "$head_deps" ] &&
+			deps_src=$head_deps
+
+		cat_file "$deps_src":.topdeps | fgrep -qx "$name" ||
+			continue
+
+		echo "$parent"
+	done
diff --git a/tg-prev.sh b/tg-prev.sh
new file mode 100644
index 0000000..efef410 tg-prev.sh
--- /dev/null
+++ b/tg-prev.sh
@@ -0,0 +1,38 @@
+#!/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=
+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"
-- 
tg: (9404aa1..) bw/next-prev-base (depends on: master)

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [TopGit PATCH 5/6] put die() messages to stderr
  2010-10-03 21:25         ` [TopGit PATCH 4/6] tg-prev/tg-next: commands to explore dependencies Bert Wesarg
@ 2010-10-03 21:25           ` Bert Wesarg
  2010-10-03 21:25             ` [TopGit PATCH 6/6] tg-log: short cut to git log Bert Wesarg
  2010-10-03 21:55           ` [TopGit PATCH 4/6] tg-prev/tg-next: commands to explore dependencies Uwe Kleine-König
  1 sibling, 1 reply; 39+ messages in thread
From: Bert Wesarg @ 2010-10-03 21:25 UTC (permalink / raw)
  To: Uwe Kleine-Koenig, Petr Baudis
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft, Bert Wesarg

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

---
 tg.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tg.sh b/tg.sh
index 9d08d63..3925f49 100644 tg.sh
--- a/tg.sh
+++ b/tg.sh
@@ -14,7 +14,7 @@ info()
 
 die()
 {
-	info "fatal: $*"
+	info "fatal: $*" >&2
 	exit 1
 }
 
-- 
tg: (9404aa1..) bw/die-to-stderr (depends on: master)

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [TopGit PATCH 6/6] tg-log: short cut to git log
  2010-10-03 21:25           ` [TopGit PATCH 5/6] put die() messages to stderr Bert Wesarg
@ 2010-10-03 21:25             ` Bert Wesarg
       [not found]               ` <AANLkTi=Kwx5avY7xRdWLS931zK2fi7cj5Q8u3++bqRO+@mail.gmail.com>
  0 siblings, 1 reply; 39+ messages in thread
From: Bert Wesarg @ 2010-10-03 21:25 UTC (permalink / raw)
  To: Uwe Kleine-Koenig, Uwe Kleine-Koenig
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft, Bert Wesarg

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>

---
 .gitignore                 |    2 ++
 README                     |    3 +++
 contrib/tg-completion.bash |   11 +++++++++++
 tg-log.sh                  |   30 ++++++++++++++++++++++++++++++
 4 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index 0342e09..3298889 100644 .gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -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 f103d92..b5fdaaf 100644 README
--- a/README
+++ b/README
@@ -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
 
diff --git a/contrib/tg-completion.bash b/contrib/tg-completion.bash
index 0ee233c..c65398a 100755 contrib/tg-completion.bash
--- a/contrib/tg-completion.bash
+++ b/contrib/tg-completion.bash
@@ -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 ;;
diff --git a/tg-log.sh b/tg-log.sh
new file mode 100644
index 0000000..8a8d527 tg-log.sh
--- /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"
-- 
tg: (9404aa1..) bw/log (depends on: master)

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH 4/6] tg-prev/tg-next: commands to explore dependencies
  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:55           ` Uwe Kleine-König
  2010-10-04  6:48             ` Bert Wesarg
  1 sibling, 1 reply; 39+ messages in thread
From: Uwe Kleine-König @ 2010-10-03 21:55 UTC (permalink / raw)
  To: Per Cederqvist, Bert Wesarg
  Cc: git, Peter Simons, pasky, Olaf Dabrunz, Thomas Moschny,
	martin f krafft

Hi,

On Sun, Oct 03, 2010 at 11:25:55PM +0200, Bert Wesarg wrote:
> 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
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

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH 2/6] tg-remote: use default remote if non is given
  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 22:00       ` Uwe Kleine-König
  2010-10-04  3:13       ` Ævar Arnfjörð Bjarmason
  2 siblings, 0 replies; 39+ messages in thread
From: Uwe Kleine-König @ 2010-10-03 22:00 UTC (permalink / raw)
  To: Bert Wesarg
  Cc: Petr Baudis, git, Peter Simons, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft, martin f krafft

Hello,

On Sun, Oct 03, 2010 at 11:25:53PM +0200, Bert Wesarg wrote:
> This is usefull if the remote has new topics and you need to populate the local
> top-bases.
> 
> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
> 
> ---
>  README       |    2 +-
>  tg-remote.sh |    5 ++++-
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/README b/README
> index c418ff4..5a54468 100644 README
> --- a/README
> +++ b/README
> @@ -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'
> diff --git a/tg-remote.sh b/tg-remote.sh
> index 86dcd9a..61774d7 100644 tg-remote.sh
> --- a/tg-remote.sh
> +++ b/tg-remote.sh
> @@ -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"
> +
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.

>  git config "remote.$name.url" >/dev/null || die "unknown remote '$name'"
>  
>  
> -- 
> tg: (29ab4cf..) bw/tg-remote-use-defualt-remote (depends on: master)
> 

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH 3/6] tg-files: list files changed by the topic branch
  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 22:03         ` Uwe Kleine-König
  2010-10-04  6:43           ` Bert Wesarg
  1 sibling, 1 reply; 39+ messages in thread
From: Uwe Kleine-König @ 2010-10-03 22:03 UTC (permalink / raw)
  To: Bert Wesarg
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft

Hi Bert,

On Sun, Oct 03, 2010 at 11:25:54PM +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>
> 
> ---
>  .gitignore                 |    2 +
>  README                     |    8 ++++++
>  contrib/tg-completion.bash |    1 +
>  tg-files.sh                |   52 ++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 63 insertions(+), 0 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-files.sh b/tg-files.sh
> new file mode 100644
> index 0000000..0723bf1 tg-files.sh
> --- /dev/null
> +++ b/tg-files.sh
> @@ -0,0 +1,52 @@
> +#!/bin/sh
> +# TopGit - A different patch queue manager
> +# (c) Petr Baudis <pasky@suse.cz>  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"
> +
> +
> +
> +# 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

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: planning a new topgit release
  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 22:11   ` Uwe Kleine-König
  1 sibling, 0 replies; 39+ messages in thread
From: Uwe Kleine-König @ 2010-10-03 22:11 UTC (permalink / raw)
  To: Bert Wesarg
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft

Hello Bert,

On Sun, Oct 03, 2010 at 11:21:42PM +0200, Bert Wesarg wrote:
> Hey,
> 
> 2010/10/3 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> > 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.
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

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH 2/6] tg-remote: use default remote if non is given
  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 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
  2 siblings, 1 reply; 39+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2010-10-04  3:13 UTC (permalink / raw)
  To: Bert Wesarg
  Cc: Uwe Kleine-Koenig, Petr Baudis, git, Peter Simons, Per Cederqvist,
	Olaf Dabrunz, Thomas Moschny, martin f krafft, martin f krafft

On Sun, Oct 3, 2010 at 21:25, Bert Wesarg <bert.wesarg@googlemail.com> wrote:

Minor: I think you mean "none" in the subject, not "non".

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH 2/6] tg-remote: use default remote if non is given
  2010-10-04  3:13       ` Ævar Arnfjörð Bjarmason
@ 2010-10-04  6:43         ` Uwe Kleine-König
  0 siblings, 0 replies; 39+ messages in thread
From: Uwe Kleine-König @ 2010-10-04  6:43 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Bert Wesarg, Petr Baudis, git, Peter Simons, Per Cederqvist,
	Olaf Dabrunz, Thomas Moschny, martin f krafft, martin f krafft

On Mon, Oct 04, 2010 at 03:13:24AM +0000, Ævar Arnfjörð Bjarmason wrote:
> On Sun, Oct 3, 2010 at 21:25, Bert Wesarg <bert.wesarg@googlemail.com> 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

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH 3/6] tg-files: list files changed by the topic branch
  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
  0 siblings, 1 reply; 39+ messages in thread
From: Bert Wesarg @ 2010-10-04  6:43 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft

Hi,

2010/10/4 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> Hi Bert,
>
> On Sun, Oct 03, 2010 at 11:25:54PM +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>
>>
>> ---
>>  .gitignore                 |    2 +
>>  README                     |    8 ++++++
>>  contrib/tg-completion.bash |    1 +
>>  tg-files.sh                |   52 ++++++++++++++++++++++++++++++++++++++++++++
>>  4 files changed, 63 insertions(+), 0 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-files.sh b/tg-files.sh
>> new file mode 100644
>> index 0000000..0723bf1 tg-files.sh
>> --- /dev/null
>> +++ b/tg-files.sh
>> @@ -0,0 +1,52 @@
>> +#!/bin/sh
>> +# TopGit - A different patch queue manager
>> +# (c) Petr Baudis <pasky@suse.cz>  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"
>> +
>> +
>> +
>> +# 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

>
> Best regards
> Uwe
>
> --
> Pengutronix e.K.                           | Uwe Kleine-König            |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH 6/6] tg-log: short cut to git log
       [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  6:45                 ` [TopGit PATCH 6/6] tg-log: short cut to git log Uwe Kleine-König
  1 sibling, 1 reply; 39+ messages in thread
From: Bert Wesarg @ 2010-10-04  6:45 UTC (permalink / raw)
  To: Per Cederqvist
  Cc: Olaf Dabrunz, Peter Simons, martin f krafft, Uwe Kleine-Koenig,
	git, pasky, Thomas Moschny

On Mon, Oct 4, 2010 at 06:40, Per Cederqvist <ceder@lysator.liu.se> wrote:
> 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

>
>     /ceder

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH 6/6] tg-log: short cut to git log
       [not found]               ` <AANLkTi=Kwx5avY7xRdWLS931zK2fi7cj5Q8u3++bqRO+@mail.gmail.com>
  2010-10-04  6:45                 ` Bert Wesarg
@ 2010-10-04  6:45                 ` Uwe Kleine-König
  1 sibling, 0 replies; 39+ messages in thread
From: Uwe Kleine-König @ 2010-10-04  6:45 UTC (permalink / raw)
  To: Per Cederqvist
  Cc: Bert Wesarg, Olaf Dabrunz, Peter Simons, martin f krafft, git,
	pasky, Thomas Moschny

Hi,

On Mon, Oct 04, 2010 at 06:40:22AM +0200, Per Cederqvist wrote:
> 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

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH 3/6] tg-files: list files changed by the topic branch
  2010-10-04  6:43           ` Bert Wesarg
@ 2010-10-04  6:47             ` Uwe Kleine-König
  2010-10-04  6:50               ` Bert Wesarg
  0 siblings, 1 reply; 39+ messages in thread
From: Uwe Kleine-König @ 2010-10-04  6:47 UTC (permalink / raw)
  To: Bert Wesarg
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft

Hello Bert,

On Mon, Oct 04, 2010 at 08:43:52AM +0200, Bert Wesarg wrote:
> 2010/10/4 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> > Hi Bert,
> >
> > On Sun, Oct 03, 2010 at 11:25:54PM +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>
> >>
> >> ---
> >>  .gitignore                 |    2 +
> >>  README                     |    8 ++++++
> >>  contrib/tg-completion.bash |    1 +
> >>  tg-files.sh                |   52 ++++++++++++++++++++++++++++++++++++++++++++
> >>  4 files changed, 63 insertions(+), 0 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-files.sh b/tg-files.sh
> >> new file mode 100644
> >> index 0000000..0723bf1 tg-files.sh
> >> --- /dev/null
> >> +++ b/tg-files.sh
> >> @@ -0,0 +1,52 @@
> >> +#!/bin/sh
> >> +# TopGit - A different patch queue manager
> >> +# (c) Petr Baudis <pasky@suse.cz>  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"
> >> +
> >> +
> >> +
> >> +# 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)
That's what I thought after sending the mail and shuting down my machine
:-)

Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH 4/6] tg-prev/tg-next: commands to explore dependencies
  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
  0 siblings, 0 replies; 39+ messages in thread
From: Bert Wesarg @ 2010-10-04  6:48 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Per Cederqvist, git, Peter Simons, pasky, Olaf Dabrunz,
	Thomas Moschny, martin f krafft

2010/10/3 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> Hi,
>
> On Sun, Oct 03, 2010 at 11:25:55PM +0200, Bert Wesarg wrote:
>> 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
> 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?

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

>
> Best regards
> Uwe

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH 3/6] tg-files: list files changed by the topic branch
  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
  0 siblings, 1 reply; 39+ messages in thread
From: Bert Wesarg @ 2010-10-04  6:50 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft

2010/10/4 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> Hello Bert,
>
> On Mon, Oct 04, 2010 at 08:43:52AM +0200, Bert Wesarg wrote:
>> 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?

>
> Uwe

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH 3/6] tg-files: list files changed by the topic branch
  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
  0 siblings, 1 reply; 39+ messages in thread
From: Uwe Kleine-König @ 2010-10-04  6:59 UTC (permalink / raw)
  To: Bert Wesarg
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft

Hi Bert,

On Mon, Oct 04, 2010 at 08:50:11AM +0200, Bert Wesarg wrote:
> 2010/10/4 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> > On Mon, Oct 04, 2010 at 08:43:52AM +0200, Bert Wesarg wrote:
> >> 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

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [TopGit PATCH] tg-files: list files changed by the topic branch
  2010-10-04  6:59                 ` Uwe Kleine-König
@ 2010-10-04 13:16                   ` Bert Wesarg
  2010-10-04 13:52                     ` Uwe Kleine-König
  0 siblings, 1 reply; 39+ messages in thread
From: Bert Wesarg @ 2010-10-04 13:16 UTC (permalink / raw)
  To: Uwe Kleine-Koenig, Uwe Kleine-Koenig
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft, 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 <bert.wesarg@googlemail.com>

---

> 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@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;;
+	-*)
+		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" &&
+		: ${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 &&
+		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()
+{
+	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)

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH] tg-files: list files changed by the topic branch
  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
  0 siblings, 1 reply; 39+ messages in thread
From: Uwe Kleine-König @ 2010-10-04 13:52 UTC (permalink / raw)
  To: Bert Wesarg
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft

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@googlemail.com>
> 
> ---
> 
> > 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@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;;
> +	-*)
> +		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?

> +		: ${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"

> +		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? :-)

> +{
> +	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/  |

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH] tg-files: list files changed by the topic branch
  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
  0 siblings, 1 reply; 39+ messages in thread
From: Bert Wesarg @ 2010-10-04 16:02 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft

2010/10/4 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> 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@googlemail.com>
>>
>> ---
>>
>> > 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@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;;
>> +     -*)
>> +             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

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [TopGit PATCH v3] tg-files: list files changed by the topic branch
  2010-10-04 16:02                       ` Bert Wesarg
@ 2010-10-04 18:27                         ` Bert Wesarg
  2010-10-04 20:09                           ` [TopGit PATCH] tg-patch: use pretty_tree Bert Wesarg
  2010-10-05  7:17                           ` [TopGit PATCH v3] tg-files: list files changed by the topic branch Uwe Kleine-König
  0 siblings, 2 replies; 39+ messages in thread
From: Bert Wesarg @ 2010-10-04 18:27 UTC (permalink / raw)
  To: Uwe Kleine-Koenig, Uwe Kleine-Koenig
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft, 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 <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;;
+	-*)
+		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=$(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)

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [TopGit PATCH] tg-log: move note from tg base to tg log
  2010-10-04  6:45                 ` Bert Wesarg
@ 2010-10-04 19:06                   ` Bert Wesarg
  2010-10-04 21:05                     ` Štěpán Němec
  0 siblings, 1 reply; 39+ messages in thread
From: Bert Wesarg @ 2010-10-04 19:06 UTC (permalink / raw)
  To: Uwe Kleine-Koenig, Uwe Kleine-Koenig
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft, Bert Wesarg

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

---
 README |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/README b/README
index ce0c3a6..2331117 100644 README
--- a/README
+++ b/README
@@ -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
 
 
-- 
tg: (ff59ac7..) bw/log (depends on: master)

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [TopGit PATCH] tg-patch: use pretty_tree
  2010-10-04 18:27                         ` [TopGit PATCH v3] " Bert Wesarg
@ 2010-10-04 20:09                           ` Bert Wesarg
  2010-10-04 23:02                             ` Bert Wesarg
  2010-10-05  7:17                           ` [TopGit PATCH v3] tg-files: list files changed by the topic branch Uwe Kleine-König
  1 sibling, 1 reply; 39+ messages in thread
From: Bert Wesarg @ 2010-10-04 20:09 UTC (permalink / raw)
  To: Uwe Kleine-Koenig
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft, Bert Wesarg

This applies the same treatment to tg-patch like tg-files got in v2.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

---
 tg-patch.sh |   56 ++++++++++++++++++++++++++++++++------------------------
 1 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/tg-patch.sh b/tg-patch.sh
index 7bafdfe..0ebef7a 100644
--- a/tg-patch.sh
+++ b/tg-patch.sh
@@ -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' '))"
-- 
tg: (c9ca19b..) bw/tg-patch-pretty_tree (depends on: bw/files)

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH] tg-log: move note from tg base to tg log
  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
  0 siblings, 1 reply; 39+ messages in thread
From: Štěpán Němec @ 2010-10-04 21:05 UTC (permalink / raw)
  To: Bert Wesarg
  Cc: Uwe Kleine-Koenig, git, Peter Simons, pasky, Per Cederqvist,
	Olaf Dabrunz, Thomas Moschny, martin f krafft

Bert Wesarg <bert.wesarg@googlemail.com> writes:

> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

[...]

> -	(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

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH] tg-log: move note from tg base to tg log
  2010-10-04 21:05                     ` Štěpán Němec
@ 2010-10-04 21:08                       ` Bert Wesarg
  0 siblings, 0 replies; 39+ messages in thread
From: Bert Wesarg @ 2010-10-04 21:08 UTC (permalink / raw)
  To: Štěpán Němec
  Cc: Uwe Kleine-Koenig, git, Peter Simons, pasky, Per Cederqvist,
	Olaf Dabrunz, Thomas Moschny, martin f krafft

On Mon, Oct 4, 2010 at 23:05, Štěpán Němec <stepnem@gmail.com> wrote:
> Bert Wesarg <bert.wesarg@googlemail.com> writes:
>
>> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
>
> [...]
>
>> -     (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. :-)

And I thought I fixed this typo ;-)

Thanks.

Bert

>
> Štěpán
>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH] tg-patch: use pretty_tree
  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
  0 siblings, 1 reply; 39+ messages in thread
From: Bert Wesarg @ 2010-10-04 23:02 UTC (permalink / raw)
  To: Uwe Kleine-Koenig
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft, Bert Wesarg

On Mon, Oct 4, 2010 at 22:09, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> @@ -46,22 +44,32 @@ base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)"
>
>  setup_pager
:
> +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

>
>  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)
>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH v3] tg-files: list files changed by the topic branch
  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-05  7:17                           ` Uwe Kleine-König
  2010-10-05 19:03                             ` [TopGit PATCH v4] " Bert Wesarg
  1 sibling, 1 reply; 39+ messages in thread
From: Uwe Kleine-König @ 2010-10-05  7:17 UTC (permalink / raw)
  To: Bert Wesarg
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft

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/  |

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH] tg-patch: use pretty_tree
  2010-10-04 23:02                             ` Bert Wesarg
@ 2010-10-05  7:18                               ` Uwe Kleine-König
  2010-10-05  8:05                                 ` Bert Wesarg
  0 siblings, 1 reply; 39+ messages in thread
From: Uwe Kleine-König @ 2010-10-05  7:18 UTC (permalink / raw)
  To: Bert Wesarg
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft

Hello,

On Tue, Oct 05, 2010 at 01:02:07AM +0200, Bert Wesarg wrote:
> On Mon, Oct 4, 2010 at 22:09, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> > @@ -46,22 +44,32 @@ base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)"
> >
> >  setup_pager
> :
> > +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

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH] tg-patch: use pretty_tree
  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
  0 siblings, 1 reply; 39+ messages in thread
From: Bert Wesarg @ 2010-10-05  8:05 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft

2010/10/5 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> Hello,
>
> On Tue, Oct 05, 2010 at 01:02:07AM +0200, Bert Wesarg wrote:
>> On Mon, Oct 4, 2010 at 22:09, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
>> > @@ -46,22 +44,32 @@ base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)"
>> >
>> >  setup_pager
>> :
>> > +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

>
> Uwe
>
> --
> Pengutronix e.K.                           | Uwe Kleine-König            |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [TopGit PATCH v4] tg-files: list files changed by the topic branch
  2010-10-05  7:17                           ` [TopGit PATCH v3] tg-files: list files changed by the topic branch Uwe Kleine-König
@ 2010-10-05 19:03                             ` Bert Wesarg
  2010-10-05 22:02                               ` Štěpán Němec
  0 siblings, 1 reply; 39+ messages in thread
From: Bert Wesarg @ 2010-10-05 19:03 UTC (permalink / raw)
  To: Uwe Kleine-Koenig, Uwe Kleine-Koenig
  Cc: Bert Wesarg, git, Peter Simons, pasky, Per Cederqvist,
	Olaf Dabrunz, Thomas Moschny, martin f krafft

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:
  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(-)

diff --git a/.gitignore b/.gitignore
index 3298889..2a4d165 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 ce0c3a6..705791b 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 ccf1a32..48e47c7 100755 contrib/tg-completion.bash
--- a/contrib/tg-completion.bash
+++ b/contrib/tg-completion.bash
@@ -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 ;;
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..5983a7b tg-files.sh
--- /dev/null
+++ b/tg-files.sh
@@ -0,0 +1,40 @@
+#!/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|-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
diff --git a/tg.sh b/tg.sh
index 3718702..535120e 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: (ff59ac7..) bw/files (depends on: master)

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [TopGit PATCH v2] tg-patch: use pretty_tree
  2010-10-05  8:05                                 ` Bert Wesarg
@ 2010-10-05 19:04                                   ` Bert Wesarg
  2010-10-05 20:01                                     ` Uwe Kleine-König
  0 siblings, 1 reply; 39+ messages in thread
From: Bert Wesarg @ 2010-10-05 19:04 UTC (permalink / raw)
  To: Uwe Kleine-Koenig, Uwe Kleine-Koenig
  Cc: Bert Wesarg, git, Peter Simons, pasky, Per Cederqvist,
	Olaf Dabrunz, Thomas Moschny, martin f krafft

This applies the same treatment to tg-patch like tg-files got in v2.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

---

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(-)

diff --git a/tg-patch.sh b/tg-patch.sh
index 7bafdfe..e88985a 100644 tg-patch.sh
--- a/tg-patch.sh
+++ b/tg-patch.sh
@@ -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' '))"
-- 
tg: (aaf1181..) bw/tg-patch-pretty_tree (depends on: bw/files)

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH v2] tg-patch: use pretty_tree
  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
  0 siblings, 1 reply; 39+ messages in thread
From: Uwe Kleine-König @ 2010-10-05 20:01 UTC (permalink / raw)
  To: Bert Wesarg
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft

On Tue, Oct 05, 2010 at 09:04:46PM +0200, Bert Wesarg wrote:
> This applies the same treatment to tg-patch like tg-files got in v2.
> 
> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
> 
> ---
> 
> 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?

> 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(-)
> 
> diff --git a/tg-patch.sh b/tg-patch.sh
> index 7bafdfe..e88985a 100644 tg-patch.sh
> --- a/tg-patch.sh
> +++ b/tg-patch.sh
> @@ -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' '))"
> -- 
> tg: (aaf1181..) bw/tg-patch-pretty_tree (depends on: bw/files)
> 

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH v2] tg-patch: use pretty_tree
  2010-10-05 20:01                                     ` Uwe Kleine-König
@ 2010-10-05 20:14                                       ` Bert Wesarg
  0 siblings, 0 replies; 39+ messages in thread
From: Bert Wesarg @ 2010-10-05 20:14 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: git, Peter Simons, pasky, Per Cederqvist, Olaf Dabrunz,
	Thomas Moschny, martin f krafft

2010/10/5 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> On Tue, Oct 05, 2010 at 09:04:46PM +0200, Bert Wesarg wrote:
>> This applies the same treatment to tg-patch like tg-files got in v2.
>>
>> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
>>
>> ---
>>
>> 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

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH v4] tg-files: list files changed by the topic branch
  2010-10-05 19:03                             ` [TopGit PATCH v4] " Bert Wesarg
@ 2010-10-05 22:02                               ` Štěpán Němec
  2010-10-06  6:11                                 ` Bert Wesarg
  0 siblings, 1 reply; 39+ messages in thread
From: Štěpán Němec @ 2010-10-05 22:02 UTC (permalink / raw)
  To: Bert Wesarg
  Cc: Uwe Kleine-Koenig, git, Peter Simons, pasky, Per Cederqvist,
	Olaf Dabrunz, Thomas Moschny, martin f krafft

Bert Wesarg <bert.wesarg@googlemail.com> writes:

> 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:
>   v4:
>    * apply Uwe's suggestions

[...]

> +
> +
> +[ -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

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [TopGit PATCH v4] tg-files: list files changed by the topic branch
  2010-10-05 22:02                               ` Štěpán Němec
@ 2010-10-06  6:11                                 ` Bert Wesarg
  0 siblings, 0 replies; 39+ messages in thread
From: Bert Wesarg @ 2010-10-06  6:11 UTC (permalink / raw)
  To: Štěpán Němec
  Cc: Uwe Kleine-Koenig, git, Peter Simons, pasky, Per Cederqvist,
	Olaf Dabrunz, Thomas Moschny, martin f krafft

On Wed, Oct 6, 2010 at 00:02, Štěpán Němec <stepnem@gmail.com> wrote:
> Bert Wesarg <bert.wesarg@googlemail.com> writes:
>
>> 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:
>>   v4:
>>    * apply Uwe's suggestions
>
> [...]
>
>> +
>> +
>> +[ -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

>
> Štěpán
>

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2010-10-06  6:12 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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                           ` [TopGit PATCH v3] tg-files: list files changed by the topic branch Uwe Kleine-König
2010-10-05 19:03                             ` [TopGit PATCH v4] " 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

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).