git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [TopGit PATCH 01/10] cat_file: take -i/-w parameters
@ 2010-10-08  7:57 Bert Wesarg
  2010-10-08  7:58 ` [TopGit PATCH 02/10] pretty_tree: globalize and respect -i/-w options Bert Wesarg
  2010-10-09 20:32 ` [TopGit PATCH 01/10] cat_file: take -i/-w parameters Uwe Kleine-König
  0 siblings, 2 replies; 16+ messages in thread
From: Bert Wesarg @ 2010-10-08  7:57 UTC (permalink / raw)
  To: Uwe Kleine-Koenig; +Cc: git, pasky, martin f krafft, Bert Wesarg

This changes the way how cat_file selects the source of the file. It
accepts an optional parameter which is either -i or -w and will react on this
instead of the branch name. tg-patch is updated accordingly and can now
accepts the current branch name as argument with -i or -w given.

cat_file was also broken for the worktree case when we are not in the top level.

Also, tg-patch allowed to be on the top-base branch, but -i and -w doesn't
make sense there too.

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

---

I will probably never understand why TopGit accepts to be on a top-base branch.
I will probably never understand why TopGit not changes the cwd to the top level.
I will probably never understand why TopGit does not use the git-sh-setup.sh.
---
 tg-patch.sh |   25 ++++++++++++++-----------
 tg.sh       |   27 +++++++++++++++------------
 2 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/tg-patch.sh b/tg-patch.sh
index 7bafdfe..5b7386a 100644 tg-patch.sh
--- a/tg-patch.sh
+++ b/tg-patch.sh
@@ -5,7 +5,7 @@
 
 name=
 
-topic=
+head_from=
 diff_opts=
 diff_committed_only=yes	# will be unset for index/worktree
 
@@ -16,11 +16,13 @@ while [ -n "$1" ]; do
 	arg="$1"; shift
 	case "$arg" in
 	-i)
-		topic='(i)'
+		[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
+		head_from=-i
 		diff_opts="$diff_opts --cached";
 		diff_committed_only=;;
 	-w)
-		topic='(w)'
+		[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
+		head_from=-w
 		diff_committed_only=;;
 	-*)
 		echo "Usage: tg [...] patch [-i | -w] [NAME]" >&2
@@ -31,22 +33,23 @@ while [ -n "$1" ]; do
 	esac
 done
 
+head="$(git symbolic-ref HEAD)"
+head="${head#refs/heads/}"
 
-[ -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\)/##')"
+[ -n "$name" ] ||
+	name="$head"
 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"
+if [ -n "$head_from" ] && [ "$name" != "$head" ]; then
+	die "$head_from makes only sense for the current branch"
+fi
 
 
 
 setup_pager
 
-cat_file "$topic:.topmsg"
+cat_file "$name:.topmsg" $head_from
 echo
 [ -n "$(git grep $diff_opts '^[-]--' ${diff_committed_only:+"$name"} -- ".topmsg")" ] || echo '---'
 
@@ -64,7 +67,7 @@ fi
 rm "$git_is_stupid"
 
 echo '-- '
-echo "tg: ($base_rev..) $name (depends on: $(cat_file "$topic:.topdeps" | paste -s -d' '))"
+echo "tg: ($base_rev..) $name (depends on: $(cat_file "$name:.topdeps" $head_from | paste -s -d' '))"
 branch_contains "$name" "$base_rev" ||
 	echo "tg: The patch is out-of-date wrt. the base! Run \`$tg update\`."
 
diff --git a/tg.sh b/tg.sh
index 3718702..4d7d4ef 100644 tg.sh
--- a/tg.sh
+++ b/tg.sh
@@ -18,24 +18,27 @@ die()
 	exit 1
 }
 
-# cat_file "topic:file"
-# Like `git cat-file blob $1`, but topics '(i)' and '(w)' means index and worktree
+# cat_file TOPIC:PATH FROM
+# cat the file PATH from branch TOPIC when FROM is empty.
+# FROM can be -i or -w, than the file will be from the index or worktree,
+# respectively. The caller should than ensure that HEAD is TOPIC, to make sense.
 cat_file()
 {
-	arg="$1"
-	case "$arg" in
-	'(w):'*)
-		arg=$(echo "$arg" | tail --bytes=+5)
-		cat "$arg"
-		return
+	path="$1"
+	case "${2-}" in
+	-w)
+		cat "$root_dir/${path#*:}"
 		;;
-	'(i):'*)
+	-i)
 		# ':file' means cat from index
-		arg=$(echo "$arg" | tail --bytes=+5)
-		git cat-file blob ":$arg"
+		git cat-file blob ":${path#*:}"
+		;;
+	'')
+		git cat-file blob "$path"
 		;;
 	*)
-		git cat-file blob "$arg"
+		die "Wrong argument to cat_file: '$2'"
+		;;
 	esac
 }
 
-- 
1.7.1.1067.g5aeb7

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

* [TopGit PATCH 02/10] pretty_tree: globalize and respect -i/-w options
  2010-10-08  7:57 [TopGit PATCH 01/10] cat_file: take -i/-w parameters Bert Wesarg
@ 2010-10-08  7:58 ` Bert Wesarg
  2010-10-08  7:58   ` [TopGit PATCH 03/10] branch_empty: use pretty_tree and therefore respect -i/-w Bert Wesarg
  2010-10-09 20:32 ` [TopGit PATCH 01/10] cat_file: take -i/-w parameters Uwe Kleine-König
  1 sibling, 1 reply; 16+ messages in thread
From: Bert Wesarg @ 2010-10-08  7:58 UTC (permalink / raw)
  To: Uwe Kleine-Koenig; +Cc: git, pasky, martin f krafft, Bert Wesarg

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 tg-export.sh |   13 ++-----------
 tg.sh        |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 11 deletions(-)

diff --git a/tg-export.sh b/tg-export.sh
index 6d82d55..5c707ce 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"
@@ -112,7 +103,7 @@ collapsed_commit()
 			echo "TopGit-driven merge of branches:"
 			echo
 			cut -f 2 "$playground/$name^parents"
-		} | git commit-tree "$(pretty_tree "refs/top-bases/$name")" \
+		} | git commit-tree "$(pretty_tree "$name" -b)" \
 			$(for p in $parent; do echo -p $p; done))"
 	fi
 
@@ -227,7 +218,7 @@ linearize()
 	else
 		retmerge=0;
 
-		git merge-recursive "$(pretty_tree "refs/top-bases/$_dep")" -- HEAD "$(pretty_tree "refs/heads/$_dep")" || retmerge="$?";
+		git merge-recursive "$(pretty_tree "$_dep" -b)" -- HEAD "$(pretty_tree "refs/heads/$_dep")" || retmerge="$?";
 
 		if test "x$retmerge" != "x0"; then
 			git rerere;
diff --git a/tg.sh b/tg.sh
index 4d7d4ef..308ed28 100644 tg.sh
--- a/tg.sh
+++ b/tg.sh
@@ -42,6 +42,53 @@ 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()
+{
+	git ls-tree --full-tree "$(get_tree_${2#-} "$1")" |
+		awk -F '	' '$2 !~ /^.top/' |
+		git mktree
+}
+
 # setup_hook NAME
 setup_hook()
 {
-- 
1.7.1.1067.g5aeb7

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

* [TopGit PATCH 03/10] branch_empty: use pretty_tree and therefore respect -i/-w
  2010-10-08  7:58 ` [TopGit PATCH 02/10] pretty_tree: globalize and respect -i/-w options Bert Wesarg
@ 2010-10-08  7:58   ` Bert Wesarg
  2010-10-08  7:58     ` [TopGit PATCH 04/10] tg-path: use pretty_tree and diff-tree to generate the patch Bert Wesarg
  0 siblings, 1 reply; 16+ messages in thread
From: Bert Wesarg @ 2010-10-08  7:58 UTC (permalink / raw)
  To: Uwe Kleine-Koenig; +Cc: git, pasky, martin f krafft, Bert Wesarg

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 tg.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tg.sh b/tg.sh
index 308ed28..a166a70 100644 tg.sh
--- a/tg.sh
+++ b/tg.sh
@@ -283,10 +283,10 @@ needs_update()
 	recurse_deps branch_needs_update "$@"
 }
 
-# branch_empty NAME
+# branch_empty NAME [-i | -w]
 branch_empty()
 {
-	[ -z "$(git diff-tree "refs/top-bases/$1" "$1" -- | fgrep -v "	.top")" ]
+	[ "$(pretty_tree "$1" -b)" = "$(pretty_tree "$1" ${2-})" ]
 }
 
 # list_deps
-- 
1.7.1.1067.g5aeb7

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

* [TopGit PATCH 04/10] tg-path: use pretty_tree and diff-tree to generate the patch
  2010-10-08  7:58   ` [TopGit PATCH 03/10] branch_empty: use pretty_tree and therefore respect -i/-w Bert Wesarg
@ 2010-10-08  7:58     ` Bert Wesarg
  2010-10-08  7:58       ` [TopGit PATCH 05/10] list_deps: accept -i/-w Bert Wesarg
  0 siblings, 1 reply; 16+ messages in thread
From: Bert Wesarg @ 2010-10-08  7:58 UTC (permalink / raw)
  To: Uwe Kleine-Koenig; +Cc: git, pasky, martin f krafft, Bert Wesarg

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 tg-patch.sh |   55 +++++++++++++++++++++++++++++++------------------------
 1 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/tg-patch.sh b/tg-patch.sh
index 5b7386a..9def6e5 100644 tg-patch.sh
--- a/tg-patch.sh
+++ b/tg-patch.sh
@@ -6,8 +6,6 @@
 name=
 
 head_from=
-diff_opts=
-diff_committed_only=yes	# will be unset for index/worktree
 
 
 ## Parse options
@@ -15,15 +13,9 @@ diff_committed_only=yes	# will be unset for index/worktree
 while [ -n "$1" ]; do
 	arg="$1"; shift
 	case "$arg" in
-	-i)
+	-i|-w)
 		[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
-		head_from=-i
-		diff_opts="$diff_opts --cached";
-		diff_committed_only=;;
-	-w)
-		[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
-		head_from=-w
-		diff_committed_only=;;
+		head_from="$arg";;
 	-*)
 		echo "Usage: tg [...] patch [-i | -w] [NAME]" >&2
 		exit 1;;
@@ -49,22 +41,37 @@ fi
 
 setup_pager
 
-cat_file "$name:.topmsg" $head_from
-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
+
+# 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 "$name:.topmsg" $head_from |
+	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" $head_from)
+
+if [ $b_tree = $t_tree ]; then
 	echo "No changes."
+else
+	git diff-tree -p --stat $b_tree $t_tree
 fi
-rm "$git_is_stupid"
 
 echo '-- '
 echo "tg: ($base_rev..) $name (depends on: $(cat_file "$name:.topdeps" $head_from | paste -s -d' '))"
-- 
1.7.1.1067.g5aeb7

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

* [TopGit PATCH 05/10] list_deps: accept -i/-w
  2010-10-08  7:58     ` [TopGit PATCH 04/10] tg-path: use pretty_tree and diff-tree to generate the patch Bert Wesarg
@ 2010-10-08  7:58       ` Bert Wesarg
  2010-10-08  7:58         ` [TopGit PATCH 06/10] tg-summary: " Bert Wesarg
  0 siblings, 1 reply; 16+ messages in thread
From: Bert Wesarg @ 2010-10-08  7:58 UTC (permalink / raw)
  To: Uwe Kleine-Koenig
  Cc: git, pasky, martin f krafft, Bert Wesarg, Per Cederqvist

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 tg.sh |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tg.sh b/tg.sh
index a166a70..72ee9f5 100644 tg.sh
--- a/tg.sh
+++ b/tg.sh
@@ -289,9 +289,13 @@ branch_empty()
 	[ "$(pretty_tree "$1" -b)" = "$(pretty_tree "$1" ${2-})" ]
 }
 
-# list_deps
+# list_deps [-i | -w]
+# -i/-w apply only to HEAD
 list_deps()
 {
+	head="$(git symbolic-ref HEAD)"
+	head="${head#refs/heads/}"
+
 	git for-each-ref refs/top-bases |
 		while read rev type ref; do
 			name="${ref#refs/top-bases/}"
@@ -299,7 +303,10 @@ list_deps()
 				continue;
 			fi
 
-			git cat-file blob "$name:.topdeps" | while read dep; do
+			from=$head_from
+			[ "$name" = "$head" ] ||
+				from=
+			cat_file "$name:.topdeps" $from | while read dep; do
 				dep_is_tgish=true
 				ref_exists "refs/top-bases/$dep"  ||
 					dep_is_tgish=false
-- 
1.7.1.1067.g5aeb7

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

* [TopGit PATCH 06/10] tg-summary: accept -i/-w
  2010-10-08  7:58       ` [TopGit PATCH 05/10] list_deps: accept -i/-w Bert Wesarg
@ 2010-10-08  7:58         ` Bert Wesarg
  2010-10-08  7:58           ` [TopGit PATCH 07/10] tg-files: list files changed by the topic branch Bert Wesarg
  0 siblings, 1 reply; 16+ messages in thread
From: Bert Wesarg @ 2010-10-08  7:58 UTC (permalink / raw)
  To: Uwe Kleine-Koenig
  Cc: git, pasky, martin f krafft, Bert Wesarg, Per Cederqvist

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 README                     |    4 ++++
 contrib/tg-completion.bash |    4 ++++
 tg-summary.sh              |   21 +++++++++++++++------
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/README b/README
index ce0c3a6..c96dc5a 100644 README
--- a/README
+++ b/README
@@ -362,6 +362,10 @@ tg summary
 	branches in a machine-readable format.  Feed this to "tsort"
 	to get the output from --sort.
 
+	Options:
+	  -i		Use TopGit meta data from the index instead of branch
+	  -w		Use TopGit meta data from the working tree instead of branch
+
 	TODO: Speed up by an order of magnitude
 	TODO: Text graph view
 
diff --git a/contrib/tg-completion.bash b/contrib/tg-completion.bash
index ccf1a32..6a1e182 100755 contrib/tg-completion.bash
--- a/contrib/tg-completion.bash
+++ b/contrib/tg-completion.bash
@@ -426,7 +426,11 @@ _tg_summary ()
 	*)
 		__tgcomp "
 			--graphviz
+			--sort
+			--deps
 			-t
+			-i
+			-w
 		"
 	esac
 }
diff --git a/tg-summary.sh b/tg-summary.sh
index af16888..113efc2 100644 tg-summary.sh
--- a/tg-summary.sh
+++ b/tg-summary.sh
@@ -7,13 +7,16 @@ terse=
 graphviz=
 sort=
 deps=
-
+head_from=
 
 ## Parse options
 
 while [ -n "$1" ]; do
 	arg="$1"; shift
 	case "$arg" in
+	-i|-w)
+		[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
+		head_from="$arg";;
 	-t)
 		terse=1;;
 	--graphviz)
@@ -23,7 +26,7 @@ while [ -n "$1" ]; do
 	--deps)
 		deps=1;;
 	*)
-		echo "Usage: tg [...] summary [-t | --sort | --deps | --graphviz]" >&2
+		echo "Usage: tg [...] summary [-t | --sort | --deps | --graphviz] [-i | -w]" >&2
 		exit 1;;
 	esac
 done
@@ -69,8 +72,11 @@ process_branch()
 
 	current=' '
 	[ "$name" != "$curname" ] || current='>'
+	from=$head_from
+	[ "$name" = "$curname" ] ||
+		from=
 	nonempty=' '
-	! branch_empty "$name" || nonempty='0'
+	! branch_empty "$name" $from || nonempty='0'
 	remote=' '
 	[ -z "$base_remote" ] || remote='l'
 	! has_remote "$name" || remote='r'
@@ -89,7 +95,7 @@ process_branch()
 	branch_contains "$name" "refs/top-bases/$name" || base_update='B'
 
 	if [ "$(git rev-parse "$name")" != "$rev" ]; then
-		subject="$(git cat-file blob "$name:.topmsg" | sed -n 's/^Subject: //p')"
+		subject="$(cat_file "$name:.topmsg" $from | sed -n 's/^Subject: //p')"
 	else
 		# No commits yet
 		subject="(No commits)"
@@ -100,7 +106,7 @@ process_branch()
 }
 
 if [ -n "$deps" ]; then
-	list_deps
+	list_deps $head_from
 	exit 0
 fi
 
@@ -114,7 +120,10 @@ git for-each-ref refs/top-bases |
 		if [ -n "$terse" ]; then
 			echo "$name"
 		elif [ -n "$graphviz$sort" ]; then
-			git cat-file blob "$name:.topdeps" | while read dep; do
+			from=$head_from
+			[ "$name" = "$curname" ] ||
+				from=
+			cat_file "$name:.topdeps" $from | while read dep; do
 				dep_is_tgish=true
 				ref_exists "refs/top-bases/$dep"  ||
 					dep_is_tgish=false
-- 
1.7.1.1067.g5aeb7

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

* [TopGit PATCH 07/10] tg-files: list files changed by the topic branch
  2010-10-08  7:58         ` [TopGit PATCH 06/10] tg-summary: " Bert Wesarg
@ 2010-10-08  7:58           ` Bert Wesarg
  2010-10-08  7:58             ` [TopGit PATCH 08/10] tg-prev/tg-next: commands to explore dependencies Bert Wesarg
  0 siblings, 1 reply; 16+ messages in thread
From: Bert Wesarg @ 2010-10-08  7:58 UTC (permalink / raw)
  To: Uwe Kleine-Koenig; +Cc: git, pasky, 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                |   43 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 54 insertions(+), 0 deletions(-)
 create mode 100644 tg-files.sh

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 c96dc5a..552a2f1 100644 README
--- a/README
+++ b/README
@@ -532,6 +532,14 @@ tg log
 ~~~~~~
 	Prints the git log of the named topgit branch.
 
+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
+
 TODO: tg rename
 
 
diff --git a/contrib/tg-completion.bash b/contrib/tg-completion.bash
index 6a1e182..eff85ee 100755 contrib/tg-completion.bash
--- a/contrib/tg-completion.bash
+++ b/contrib/tg-completion.bash
@@ -486,6 +486,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..ab97624 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=
+head_from=
+
+
+## Parse options
+
+while [ -n "$1" ]; do
+	arg="$1"; shift
+	case "$arg" in
+	-i|-w)
+		[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
+		head_from="$arg";;
+	-*)
+		echo "Usage: tg [...] files [-i | -w] [NAME]" >&2
+		exit 1;;
+	*)
+		[ -z "$name" ] || die "name already specified ($name)"
+		name="$arg";;
+	esac
+done
+
+
+head="$(git symbolic-ref HEAD)"
+head="${head#refs/heads/}"
+
+[ -n "$name" ] ||
+	name="$head"
+base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
+	die "not a TopGit-controlled branch"
+
+if [ -n "$head_from" ] && [ "$name" != "$head" ]; then
+	die "$head_from makes only sense for the current branch"
+fi
+
+b_tree=$(pretty_tree "$name" -b)
+t_tree=$(pretty_tree "$name" $head_from)
+
+git diff-tree --name-only -r $b_tree $t_tree
-- 
1.7.1.1067.g5aeb7

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

* [TopGit PATCH 08/10] tg-prev/tg-next: commands to explore dependencies
  2010-10-08  7:58           ` [TopGit PATCH 07/10] tg-files: list files changed by the topic branch Bert Wesarg
@ 2010-10-08  7:58             ` Bert Wesarg
  2010-10-08  7:58               ` [TopGit PATCH 09/10] [RFC] tg-patch: use ui diff when pager is active Bert Wesarg
  0 siblings, 1 reply; 16+ messages in thread
From: Bert Wesarg @ 2010-10-08  7:58 UTC (permalink / raw)
  To: Uwe Kleine-Koenig; +Cc: git, pasky, 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                     |   18 ++++++++++++++++-
 contrib/tg-completion.bash |   34 +++++++++++++++++++++++++++++++++
 tg-next.sh                 |   45 ++++++++++++++++++++++++++++++++++++++++++++
 tg-prev.sh                 |   38 +++++++++++++++++++++++++++++++++++++
 5 files changed, 138 insertions(+), 1 deletions(-)
 create mode 100644 tg-next.sh
 create mode 100644 tg-prev.sh

diff --git a/.gitignore b/.gitignore
index 2a4d165..6cfab6e 100644 .gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -30,10 +30,14 @@
 /tg-info.txt
 /tg-mail
 /tg-mail.txt
+/tg-next
+/tg-next.txt
 /tg-log
 /tg-log.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 552a2f1..3b6d0fd 100644 README
--- a/README
+++ b/README
@@ -540,8 +540,24 @@ tg files
 	  -i		list files based on index instead of branch
 	  -w		list files based on working tree instead of branch
 
-TODO: tg rename
+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
 
 IMPLEMENTATION
 --------------
diff --git a/contrib/tg-completion.bash b/contrib/tg-completion.bash
index eff85ee..e468474 100755 contrib/tg-completion.bash
--- a/contrib/tg-completion.bash
+++ b/contrib/tg-completion.bash
@@ -445,6 +445,38 @@ _tg_update ()
 	esac
 }
 
+_tg_next ()
+{
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+
+	case "$cur" in
+	-*)
+		__tgcomp "
+			-i
+			-w
+		"
+		;;
+	*)
+		__tgcomp "$(__tg_heads)"
+	esac
+}
+
+_tg_prev ()
+{
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+
+	case "$cur" in
+	-*)
+		__tgcomp "
+			-i
+			-w
+		"
+		;;
+	*)
+		__tgcomp "$(__tg_topics)"
+	esac
+}
+
 ### }}}
 ### {{{ tg completion
 
@@ -492,7 +524,9 @@ _tg ()
 	info)        _tg_info ;;
 	log)         _tg_log ;;
 	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..93dd5b5 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_from=
+
+
+## Parse options
+
+while [ -n "$1" ]; do
+	arg="$1"; shift
+	case "$arg" in
+	-i|-w)
+		[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
+		head_from="$arg";;
+	-*)
+		echo "Usage: tg next [-i | -w] [NAME]" >&2
+		exit 1;;
+	*)
+		[ -z "$name" ] || die "name already specified ($name)"
+		name="$arg";;
+	esac
+done
+
+head="$(git rev-parse --abbrev-ref=loose HEAD)"
+[ -n "$name" ] ||
+	name="$head"
+
+git for-each-ref --format='%(refname)' refs/top-bases |
+	while read ref; do
+		parent="${ref#refs/top-bases/}"
+
+		from=$head_from
+		# select .topdeps source for HEAD branch
+		[ "x$parent" = "x$head" ] ||
+			from=
+
+		cat_file "$parent:.topdeps" $from | fgrep -qx "$name" ||
+			continue
+
+		echo "$parent"
+	done
diff --git a/tg-prev.sh b/tg-prev.sh
new file mode 100644
index 0000000..1f1e0c1 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_from=
+
+
+## Parse options
+
+while [ -n "$1" ]; do
+	arg="$1"; shift
+	case "$arg" in
+	-i|-w)
+		[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
+		head_from="$arg";;
+	-*)
+		echo "Usage: tg next [-i | -w] [NAME]" >&2
+		exit 1;;
+	*)
+		[ -z "$name" ] || die "name already specified ($name)"
+		name="$arg";;
+	esac
+done
+
+head="$(git rev-parse --abbrev-ref=loose HEAD)"
+[ -n "$name" ] ||
+	name="$head"
+base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
+	die "not a TopGit-controlled branch"
+
+# select .topdeps source for HEAD branch
+[ "x$name" = "x$head" ] ||
+	head_from=
+
+cat_file "$name:.topdeps" $head_from
-- 
1.7.1.1067.g5aeb7

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

* [TopGit PATCH 09/10] [RFC] tg-patch: use ui diff when pager is active
  2010-10-08  7:58             ` [TopGit PATCH 08/10] tg-prev/tg-next: commands to explore dependencies Bert Wesarg
@ 2010-10-08  7:58               ` Bert Wesarg
  2010-10-08  7:58                 ` [TopGit PATCH 10/10] [RFC] tg-patch: simulate mnemonic prefixes Bert Wesarg
  2010-10-09 20:43                 ` [TopGit PATCH 09/10] [RFC] tg-patch: use ui diff when pager is active Uwe Kleine-König
  0 siblings, 2 replies; 16+ messages in thread
From: Bert Wesarg @ 2010-10-08  7:58 UTC (permalink / raw)
  To: Uwe Kleine-Koenig; +Cc: git, pasky, martin f krafft, Bert Wesarg

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 tg-patch.sh |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/tg-patch.sh b/tg-patch.sh
index 9def6e5..dcce672 100644 tg-patch.sh
--- a/tg-patch.sh
+++ b/tg-patch.sh
@@ -70,7 +70,12 @@ t_tree=$(pretty_tree "$name" $head_from)
 if [ $b_tree = $t_tree ]; then
 	echo "No changes."
 else
-	git diff-tree -p --stat $b_tree $t_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
 fi
 
 echo '-- '
-- 
1.7.1.1067.g5aeb7

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

* [TopGit PATCH 10/10] [RFC] tg-patch: simulate mnemonic prefixes
  2010-10-08  7:58               ` [TopGit PATCH 09/10] [RFC] tg-patch: use ui diff when pager is active Bert Wesarg
@ 2010-10-08  7:58                 ` Bert Wesarg
  2010-10-09 20:46                   ` Uwe Kleine-König
  2010-10-09 20:43                 ` [TopGit PATCH 09/10] [RFC] tg-patch: use ui diff when pager is active Uwe Kleine-König
  1 sibling, 1 reply; 16+ messages in thread
From: Bert Wesarg @ 2010-10-08  7:58 UTC (permalink / raw)
  To: Uwe Kleine-Koenig; +Cc: git, pasky, martin f krafft, Bert Wesarg

b/ is for base, i/ and w/ correspond to -i/-w and t/ is the committed
topic.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 tg-patch.sh |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tg-patch.sh b/tg-patch.sh
index dcce672..c8ad723 100644 tg-patch.sh
--- a/tg-patch.sh
+++ b/tg-patch.sh
@@ -6,7 +6,7 @@
 name=
 
 head_from=
-
+dst_prefix="t/"
 
 ## Parse options
 
@@ -15,7 +15,8 @@ while [ -n "$1" ]; do
 	case "$arg" in
 	-i|-w)
 		[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
-		head_from="$arg";;
+		head_from="$arg"
+		dst_prefix="${arg#-}/";;
 	-*)
 		echo "Usage: tg [...] patch [-i | -w] [NAME]" >&2
 		exit 1;;
@@ -72,6 +73,9 @@ if [ $b_tree = $t_tree ]; then
 else
 	# use the ui diff command when the pager is active
 	diff_command=diff
+	if $(git config --bool diff.mnemonicprefix); then
+		diff_command="$diff_command --src-prefix=b/ --dst-prefix=$dst_prefix"
+	fi
 	[ "x$GIT_PAGER_IN_USE" = "x1" ] ||
 		diff_command=diff-tree
 
-- 
1.7.1.1067.g5aeb7

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

* Re: [TopGit PATCH 01/10] cat_file: take -i/-w parameters
  2010-10-08  7:57 [TopGit PATCH 01/10] cat_file: take -i/-w parameters Bert Wesarg
  2010-10-08  7:58 ` [TopGit PATCH 02/10] pretty_tree: globalize and respect -i/-w options Bert Wesarg
@ 2010-10-09 20:32 ` Uwe Kleine-König
  2010-10-09 20:57   ` Bert Wesarg
  1 sibling, 1 reply; 16+ messages in thread
From: Uwe Kleine-König @ 2010-10-09 20:32 UTC (permalink / raw)
  To: Bert Wesarg; +Cc: git, pasky, martin f krafft

Hi Bert,

On Fri, Oct 08, 2010 at 09:57:59AM +0200, Bert Wesarg wrote:
> This changes the way how cat_file selects the source of the file. It
> accepts an optional parameter which is either -i or -w and will react on this
> instead of the branch name. tg-patch is updated accordingly and can now
> accepts the current branch name as argument with -i or -w given.
> 
> cat_file was also broken for the worktree case when we are not in the top level.
> 
> Also, tg-patch allowed to be on the top-base branch, but -i and -w doesn't
> make sense there too.
> 
> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
doesn't apply anymore.  Do you care to fix and resend?  I think it's
your own change to cat_file BTW ... :-)


> ---
> 
> I will probably never understand why TopGit accepts to be on a top-base branch.
/me shrugs.

> I will probably never understand why TopGit not changes the cwd to the top level.
I can imagine that strange things can happen then, but I don't have an
example.

> I will probably never understand why TopGit does not use the git-sh-setup.sh.
I'm not sure this works in all cases.  And I think it's not sensibe as
we don't have control over this file.  And what if it starts providing a
function with the same name as one of our's?

Best regards
Uwe

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

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

* Re: [TopGit PATCH 09/10] [RFC] tg-patch: use ui diff when pager is active
  2010-10-08  7:58               ` [TopGit PATCH 09/10] [RFC] tg-patch: use ui diff when pager is active Bert Wesarg
  2010-10-08  7:58                 ` [TopGit PATCH 10/10] [RFC] tg-patch: simulate mnemonic prefixes Bert Wesarg
@ 2010-10-09 20:43                 ` Uwe Kleine-König
  2010-10-10  8:04                   ` Bert Wesarg
  1 sibling, 1 reply; 16+ messages in thread
From: Uwe Kleine-König @ 2010-10-09 20:43 UTC (permalink / raw)
  To: Bert Wesarg; +Cc: git, pasky, martin f krafft

Hi Bert,


On Fri, Oct 08, 2010 at 09:58:07AM +0200, Bert Wesarg wrote:
> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

can you tell me the motivation for this patch again?  It should go into
the commit log, too.

Thanks
Uwe

> ---
>  tg-patch.sh |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/tg-patch.sh b/tg-patch.sh
> index 9def6e5..dcce672 100644 tg-patch.sh
> --- a/tg-patch.sh
> +++ b/tg-patch.sh
> @@ -70,7 +70,12 @@ t_tree=$(pretty_tree "$name" $head_from)
>  if [ $b_tree = $t_tree ]; then
>  	echo "No changes."
>  else
> -	git diff-tree -p --stat $b_tree $t_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
>  fi
>  
>  echo '-- '
> -- 
> 1.7.1.1067.g5aeb7
> 
> 

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

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

* Re: [TopGit PATCH 10/10] [RFC] tg-patch: simulate mnemonic prefixes
  2010-10-08  7:58                 ` [TopGit PATCH 10/10] [RFC] tg-patch: simulate mnemonic prefixes Bert Wesarg
@ 2010-10-09 20:46                   ` Uwe Kleine-König
  2010-10-09 21:03                     ` Bert Wesarg
  0 siblings, 1 reply; 16+ messages in thread
From: Uwe Kleine-König @ 2010-10-09 20:46 UTC (permalink / raw)
  To: Bert Wesarg; +Cc: git, pasky, martin f krafft

On Fri, Oct 08, 2010 at 09:58:08AM +0200, Bert Wesarg wrote:
> b/ is for base, i/ and w/ correspond to -i/-w and t/ is the committed
> topic.
> 
> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
> ---
>  tg-patch.sh |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/tg-patch.sh b/tg-patch.sh
> index dcce672..c8ad723 100644 tg-patch.sh
> --- a/tg-patch.sh
> +++ b/tg-patch.sh
> @@ -6,7 +6,7 @@
>  name=
>  
>  head_from=
> -
> +dst_prefix="t/"
>  
>  ## Parse options
>  
> @@ -15,7 +15,8 @@ while [ -n "$1" ]; do
>  	case "$arg" in
>  	-i|-w)
>  		[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
> -		head_from="$arg";;
> +		head_from="$arg"
> +		dst_prefix="${arg#-}/";;
>  	-*)
>  		echo "Usage: tg [...] patch [-i | -w] [NAME]" >&2
>  		exit 1;;
> @@ -72,6 +73,9 @@ if [ $b_tree = $t_tree ]; then
>  else
>  	# use the ui diff command when the pager is active
>  	diff_command=diff
> +	if $(git config --bool diff.mnemonicprefix); then
> +		diff_command="$diff_command --src-prefix=b/ --dst-prefix=$dst_prefix"
> +	fi
Do I assume right, that diff.mnemonicprefix is topgitish only?   Maybe
it should go then into a topgit namespace?

Hmm, nice idea, the only thing about it I don't like ad hoc is that b/
is already used by default and so it might be confusing.  OTOH you need
to enabled it in the config, ...  Hmm, will think about it.

Uwe

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

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

* Re: [TopGit PATCH 01/10] cat_file: take -i/-w parameters
  2010-10-09 20:32 ` [TopGit PATCH 01/10] cat_file: take -i/-w parameters Uwe Kleine-König
@ 2010-10-09 20:57   ` Bert Wesarg
  0 siblings, 0 replies; 16+ messages in thread
From: Bert Wesarg @ 2010-10-09 20:57 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: git, pasky, martin f krafft

2010/10/9 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> Hi Bert,
>
> On Fri, Oct 08, 2010 at 09:57:59AM +0200, Bert Wesarg wrote:
>> This changes the way how cat_file selects the source of the file. It
>> accepts an optional parameter which is either -i or -w and will react on this
>> instead of the branch name. tg-patch is updated accordingly and can now
>> accepts the current branch name as argument with -i or -w given.
>>
>> cat_file was also broken for the worktree case when we are not in the top level.
>>
>> Also, tg-patch allowed to be on the top-base branch, but -i and -w doesn't
>> make sense there too.
>>
>> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
> doesn't apply anymore.  Do you care to fix and resend?  I think it's
> your own change to cat_file BTW ... :-)

Right, Sorry. I should have done a git fetch. Will resend now.

>
>
>> ---
>>
>> I will probably never understand why TopGit accepts to be on a top-base branch.
> /me shrugs.
>
>> I will probably never understand why TopGit not changes the cwd to the top level.
> I can imagine that strange things can happen then, but I don't have an
> example.
>
>> I will probably never understand why TopGit does not use the git-sh-setup.sh.
> I'm not sure this works in all cases.  And I think it's not sensibe as
> we don't have control over this file.  And what if it starts providing a
> function with the same name as one of our's?

It does already: die.

Regards,
Bert

>
> Best regards
> Uwe
>
h

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

* Re: [TopGit PATCH 10/10] [RFC] tg-patch: simulate mnemonic prefixes
  2010-10-09 20:46                   ` Uwe Kleine-König
@ 2010-10-09 21:03                     ` Bert Wesarg
  0 siblings, 0 replies; 16+ messages in thread
From: Bert Wesarg @ 2010-10-09 21:03 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: git, pasky, martin f krafft

2010/10/9 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> On Fri, Oct 08, 2010 at 09:58:08AM +0200, Bert Wesarg wrote:
>> b/ is for base, i/ and w/ correspond to -i/-w and t/ is the committed
>> topic.
>>
>> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
>> ---
>>  tg-patch.sh |    8 ++++++--
>>  1 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/tg-patch.sh b/tg-patch.sh
>> index dcce672..c8ad723 100644 tg-patch.sh
>> --- a/tg-patch.sh
>> +++ b/tg-patch.sh
>> @@ -6,7 +6,7 @@
>>  name=
>>
>>  head_from=
>> -
>> +dst_prefix="t/"
>>
>>  ## Parse options
>>
>> @@ -15,7 +15,8 @@ while [ -n "$1" ]; do
>>       case "$arg" in
>>       -i|-w)
>>               [ -z "$head_from" ] || die "-i and -w are mutually exclusive"
>> -             head_from="$arg";;
>> +             head_from="$arg"
>> +             dst_prefix="${arg#-}/";;
>>       -*)
>>               echo "Usage: tg [...] patch [-i | -w] [NAME]" >&2
>>               exit 1;;
>> @@ -72,6 +73,9 @@ if [ $b_tree = $t_tree ]; then
>>  else
>>       # use the ui diff command when the pager is active
>>       diff_command=diff
>> +     if $(git config --bool diff.mnemonicprefix); then
>> +             diff_command="$diff_command --src-prefix=b/ --dst-prefix=$dst_prefix"
>> +     fi
> Do I assume right, that diff.mnemonicprefix is topgitish only?   Maybe
> it should go then into a topgit namespace?

No. it is from git. From the manual:

       diff.mnemonicprefix
           If set, git diff uses a prefix pair that is different from the
           standard "a/" and "b/" depending on what is being compared. When
           this configuration is in effect, reverse diff output also swaps the
           order of the prefixes:

           git diff
               compares the (i)ndex and the (w)ork tree;

           git diff HEAD
               compares a (c)ommit and the (w)ork tree;

           git diff --cached
               compares a (c)ommit and the (i)ndex;

           git diff HEAD:file1 file2
               compares an (o)bject and a (w)ork tree entity;

           git diff --no-index a b
               compares two non-git things (1) and (2).

And it is only a diff ui option too. I thought to take c/ for the
committed case for us too, but I have also no strong opinion about t/
either.

>
> Hmm, nice idea, the only thing about it I don't like ad hoc is that b/
> is already used by default and so it might be confusing.  OTOH you need
> to enabled it in the config, ...  Hmm, will think about it.
>
> Uwe

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

* Re: [TopGit PATCH 09/10] [RFC] tg-patch: use ui diff when pager is active
  2010-10-09 20:43                 ` [TopGit PATCH 09/10] [RFC] tg-patch: use ui diff when pager is active Uwe Kleine-König
@ 2010-10-10  8:04                   ` Bert Wesarg
  0 siblings, 0 replies; 16+ messages in thread
From: Bert Wesarg @ 2010-10-10  8:04 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: git, pasky, martin f krafft

2010/10/9 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> Hi Bert,
>
>
> On Fri, Oct 08, 2010 at 09:58:07AM +0200, Bert Wesarg wrote:
>> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
>
> can you tell me the motivation for this patch again?  It should go into
> the commit log, too.

My motivation is, that diff-tree should be used to generate patches
meant for submission (or non-human consumption). But for pure human
inspection some 'eye-candy' effects could take considerations. Like
color, renames, mnemonicprefix, or noprefix. External diff driver or
word-diff. All these are in effect by using the diff command, when
configured in your git config file. diff-tree does not honor these
configure options but its possible to give them as command line
options too. Selecting the plumbing or ui diff driver is best done
automatically, in my opinion, and the active pager is my best bet that
a human will consume the output. I will probably add an overwrite
command switch (to enable ui mode even without an active pager, I
sometimes pipe the output for inspection into my editor) shortly.

I don't know if this is suitable for the commit log. If so I will try
to fit it in.

Bert

>
> Thanks
> Uwe
>
>> ---
>>  tg-patch.sh |    7 ++++++-
>>  1 files changed, 6 insertions(+), 1 deletions(-)
>>
>> diff --git a/tg-patch.sh b/tg-patch.sh
>> index 9def6e5..dcce672 100644 tg-patch.sh
>> --- a/tg-patch.sh
>> +++ b/tg-patch.sh
>> @@ -70,7 +70,12 @@ t_tree=$(pretty_tree "$name" $head_from)
>>  if [ $b_tree = $t_tree ]; then
>>       echo "No changes."
>>  else
>> -     git diff-tree -p --stat $b_tree $t_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
>>  fi
>>
>>  echo '-- '
>> --
>> 1.7.1.1067.g5aeb7
>>
>>
>
> --
> Pengutronix e.K.                           | Uwe Kleine-König            |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>

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

end of thread, other threads:[~2010-10-10  8:05 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-08  7:57 [TopGit PATCH 01/10] cat_file: take -i/-w parameters Bert Wesarg
2010-10-08  7:58 ` [TopGit PATCH 02/10] pretty_tree: globalize and respect -i/-w options Bert Wesarg
2010-10-08  7:58   ` [TopGit PATCH 03/10] branch_empty: use pretty_tree and therefore respect -i/-w Bert Wesarg
2010-10-08  7:58     ` [TopGit PATCH 04/10] tg-path: use pretty_tree and diff-tree to generate the patch Bert Wesarg
2010-10-08  7:58       ` [TopGit PATCH 05/10] list_deps: accept -i/-w Bert Wesarg
2010-10-08  7:58         ` [TopGit PATCH 06/10] tg-summary: " Bert Wesarg
2010-10-08  7:58           ` [TopGit PATCH 07/10] tg-files: list files changed by the topic branch Bert Wesarg
2010-10-08  7:58             ` [TopGit PATCH 08/10] tg-prev/tg-next: commands to explore dependencies Bert Wesarg
2010-10-08  7:58               ` [TopGit PATCH 09/10] [RFC] tg-patch: use ui diff when pager is active Bert Wesarg
2010-10-08  7:58                 ` [TopGit PATCH 10/10] [RFC] tg-patch: simulate mnemonic prefixes Bert Wesarg
2010-10-09 20:46                   ` Uwe Kleine-König
2010-10-09 21:03                     ` Bert Wesarg
2010-10-09 20:43                 ` [TopGit PATCH 09/10] [RFC] tg-patch: use ui diff when pager is active Uwe Kleine-König
2010-10-10  8:04                   ` Bert Wesarg
2010-10-09 20:32 ` [TopGit PATCH 01/10] cat_file: take -i/-w parameters Uwe Kleine-König
2010-10-09 20:57   ` Bert Wesarg

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