git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH cogito] "cg-whatsnew" command
@ 2005-05-14 10:58 Catalin Marinas
  2005-05-14 11:09 ` Petr Baudis
  0 siblings, 1 reply; 8+ messages in thread
From: Catalin Marinas @ 2005-05-14 10:58 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 212 bytes --]

This patch adds a simple command that shows the unmerged changes on a
branch. I find it quite useful to be able to see the diff or the log
before merging (gnuarch has something similar with "missing").

Catalin


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-cg-whatsnew --]
[-- Type: text/x-patch, Size: 3243 bytes --]

Added the "cg-whatsnew" command

The command shows the unmerged changes on a branch (defaulting to 
"origin") as either a diff, log or patch.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

---
commit e396c64c7f84c45a1360d34bcb6092b62183df7d
tree c143a31ed694000b705c5019bb10ec3b3f911344
parent fa6e9eb368e949e78c4e66217461cf624b52b0a2
author Catalin Marinas <cmarinas@pc1117.cambridge.arm.com> Sat, 14 May 2005 11:47:52 +0100
committer Catalin Marinas <cmarinas@pc1117.cambridge.arm.com> Sat, 14 May 2005 11:47:52 +0100

 Makefile    |    3 +-
 cg-help     |    1 
 cg-whatsnew |   63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+), 1 deletion(-)

Index: Makefile
===================================================================
--- de641904363cd3759f132ee7c0dfaf8a2ee58388/Makefile  (mode:100644)
+++ c143a31ed694000b705c5019bb10ec3b3f911344/Makefile  (mode:100644)
@@ -49,7 +49,8 @@
 SCRIPT=	commit-id tree-id parent-id cg-add cg-admin-lsobj cg-admin-uncommit \
 	cg-branch-add cg-branch-ls cg-cancel cg-clone cg-commit cg-diff \
 	cg-export cg-help cg-init cg-log cg-ls cg-merge cg-mkpatch cg-patch \
-	cg-pull cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update
+	cg-pull cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update \
+	cg-whatsnew
 
 LIB_SCRIPT=cg-Xlib cg-Xdiffdo cg-Xmergefile
 
Index: cg-help
===================================================================
--- de641904363cd3759f132ee7c0dfaf8a2ee58388/cg-help  (mode:100755)
+++ c143a31ed694000b705c5019bb10ec3b3f911344/cg-help  (mode:100755)
@@ -44,6 +44,7 @@
 	cg-tag-ls
 	cg-update	[BNAME]
 	cg-version
+	cg-whatsnew	[-n] [-l | -m] [BNAME]
 
 Advanced (low-level or dangerous) commands:
 	cg-admin-lsobj	[OBJTYPE]
Index: cg-whatsnew
===================================================================
--- /dev/null  (tree:de641904363cd3759f132ee7c0dfaf8a2ee58388)
+++ c143a31ed694000b705c5019bb10ec3b3f911344/cg-whatsnew  (mode:100755)
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+#
+# Shows the unmerged changes on a branch
+# Copyright (c) Catalin Marinas, 2005
+#
+# Takes a parameter identifying the branch (defaulting to "origin").
+# Optional "-n" parameter specifies not to pull the changes from the branch.
+#
+# By default, shows the unmerged diff of the branch.
+# Optional "-l" parameter specifies to show the log instead of the diff
+# Optional "-m" parameter specifies to show the mkpatch instead of the diff
+
+. ${COGITO_LIB:-/home/cmarinas/lib/cogito/}cg-Xlib
+
+head=$(commit-id)
+show_cmd=cg-diff
+
+do_not_pull=
+if [ "$1" = "-n" ]; then
+	shift
+	do_not_pull=1
+fi
+
+while [ "$1" ]; do
+	case "$1" in
+	-n)
+		do_not_pull=1
+		shift
+		;;
+	-l)
+		show_cmd=cg-log
+		shift
+		;;
+	-m)
+		show_cmd=cg-mkpatch
+		shift
+		;;
+	-*)
+		die "Unknown option: $1"
+		;;
+	*)
+		break
+		;;
+	esac
+done
+
+if [ "$1" ]; then
+	branchname="$1"
+else
+	branchname=origin
+fi
+
+[ "$do_not_pull" ] || cg-pull $branchname
+
+branch=$(commit-id "$branchname") || exit 1
+base=$(git-merge-base "$head" "$branch")
+[ "$base" ] || die "Unable to determine the merge base"
+
+if [ "$base" = "$branch" ]; then
+	echo "Branch already fully merged" >&2
+else
+	$show_cmd -r $base:$branch
+fi

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

* Re: [PATCH cogito] "cg-whatsnew" command
  2005-05-14 10:58 [PATCH cogito] "cg-whatsnew" command Catalin Marinas
@ 2005-05-14 11:09 ` Petr Baudis
  2005-05-15  8:29   ` Catalin Marinas
  0 siblings, 1 reply; 8+ messages in thread
From: Petr Baudis @ 2005-05-14 11:09 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

Dear diary, on Sat, May 14, 2005 at 12:58:04PM CEST, I got a letter
where Catalin Marinas <catalin.marinas@arm.com> told me that...
> This patch adds a simple command that shows the unmerged changes on a
> branch. I find it quite useful to be able to see the diff or the log
> before merging (gnuarch has something similar with "missing").

I'd prefer this to be functionality builtin to cg-log and cg-mkpatch.
Perhaps some

	cg-log -m $branch2 [$branch1]

to show stuff in branch2 not yet merged to branch1.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

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

* Re: [PATCH cogito] "cg-whatsnew" command
  2005-05-14 11:09 ` Petr Baudis
@ 2005-05-15  8:29   ` Catalin Marinas
  2005-05-15 17:36     ` Matthias Urlichs
  0 siblings, 1 reply; 8+ messages in thread
From: Catalin Marinas @ 2005-05-15  8:29 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 693 bytes --]

Petr Baudis <pasky@ucw.cz> wrote:
> Dear diary, on Sat, May 14, 2005 at 12:58:04PM CEST, I got a letter
> where Catalin Marinas <catalin.marinas@arm.com> told me that...
>> This patch adds a simple command that shows the unmerged changes on a
>> branch. I find it quite useful to be able to see the diff or the log
>> before merging (gnuarch has something similar with "missing").
>
> I'd prefer this to be functionality builtin to cg-log and cg-mkpatch.
> Perhaps some
>
> 	cg-log -m $branch2 [$branch1]
>
> to show stuff in branch2 not yet merged to branch1.

See the attached patch. Let me know if you want it implemented
differently. I also added the "-m" option to cg-diff.

-- 
Catalin


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-m-option --]
[-- Type: text/x-patch, Size: 4489 bytes --]

"-m" option added to cg-diff, cg-log and cg-mkpatch

This option takes two optional parameters, branch2 and branch1, and shows
the changes in branch2 not yet merged to branch1. Branch2 defaults to
origin and branch1 to HEAD.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

---
commit 1a9bf2d3a0478344ae4019ac0725426627c32658
tree 3e889a5c03d7df9f82d7a649e02fef2ebdbb9f75
parent fa6e9eb368e949e78c4e66217461cf624b52b0a2
author Catalin Marinas <cmarinas@pc1117.cambridge.arm.com> Sun, 15 May 2005 09:25:49 +0100
committer Catalin Marinas <cmarinas@pc1117.cambridge.arm.com> Sun, 15 May 2005 09:25:49 +0100

 cg-diff    |   19 +++++++++++++++++++
 cg-help    |    6 +++---
 cg-log     |   19 +++++++++++++++++++
 cg-mkpatch |   19 +++++++++++++++++++
 4 files changed, 60 insertions(+), 3 deletions(-)

Index: cg-diff
===================================================================
--- de641904363cd3759f132ee7c0dfaf8a2ee58388/cg-diff  (mode:100755)
+++ 3e889a5c03d7df9f82d7a649e02fef2ebdbb9f75/cg-diff  (mode:100755)
@@ -14,6 +14,9 @@
 # -p instead of one ID denotes a parent commit to the specified ID
 # (which must not be a tree, obviously).
 #
+# -m [branch2] [branch1] shows the changes in branch2 (defaulting to
+# origin) not yet merged to branch1 (defaulting to HEAD)
+#
 # Outputs a diff converting the first tree to the second one.
 
 . ${COGITO_LIB}cg-Xlib
@@ -31,6 +34,22 @@
 	parent=1
 fi
 
+if [ "$1" = "-m" ]; then
+	branch=HEAD
+	id2=origin
+	shift
+	if [ "$1" ]; then
+		id2=$1
+		shift
+	fi
+	if [ "$1" ]; then
+		branch=$1
+		shift
+	fi
+	id1=$(git-merge-base "$branch" "$id2")
+	[ "$id1" ] || die "Unable to determine the merge base"
+fi
+
 if [ "$1" = "-r" ]; then
 	shift
 	id1=$(echo "$1": | cut -d : -f 1)
Index: cg-help
===================================================================
--- de641904363cd3759f132ee7c0dfaf8a2ee58388/cg-help  (mode:100755)
+++ 3e889a5c03d7df9f82d7a649e02fef2ebdbb9f75/cg-help  (mode:100755)
@@ -26,14 +26,14 @@
 	cg-cancel
 	cg-clone	[-s] SOURCE_LOC [DESTDIR]
 	cg-commit	[-m"Commit message"]... [-e | -E] [FILE]... < log message
-	cg-diff		[-p] [-r FROM_ID[:TO_ID]] [FILE]...
+	cg-diff		[-p] [-r FROM_ID[:TO_ID]] [-m [BNAME] [BNAME]] [FILE]...
 	cg-export	DEST [TREE_ID]
 	cg-help		[COMMAND]
 	cg-init
-	cg-log		[-c] [-f] [-r FROM_ID[:TO_ID]] [FILE]...
+	cg-log		[-c] [-f] [-r FROM_ID[:TO_ID]] ] [-m [BNAME] [BNAME]] [FILE]...
 	cg-ls		[TREE_ID]
 	cg-merge	[-c] [-b BASE_ID] FROM_ID
-	cg-mkpatch	[-s] [-r FROM_ID[:TO_ID]]
+	cg-mkpatch	[-s] [-r FROM_ID[:TO_ID]]] [-m [BNAME] [BNAME]]
 	cg-patch			< patch on stdin
 	cg-pull		[BNAME]
 	cg-restore	[FILE]...
Index: cg-log
===================================================================
--- de641904363cd3759f132ee7c0dfaf8a2ee58388/cg-log  (mode:100755)
+++ 3e889a5c03d7df9f82d7a649e02fef2ebdbb9f75/cg-log  (mode:100755)
@@ -22,6 +22,9 @@
 # (HEAD by default), or id1:id2 representing an (id1;id2] range
 # of commits to show.
 #
+# -m [branch2] [branch1] shows the changes in branch2 (defaulting to
+# origin) not yet merged to branch1 (defaulting to HEAD)
+#
 # The rest of arguments are took as filenames; cg-log then displays
 # only changes in those files.
 
@@ -94,6 +97,22 @@
 
 log_start=
 log_end=
+if [ "$1" = "-m" ]; then
+	branch=HEAD
+	log_end=origin
+	shift
+	if [ "$1" ]; then
+		log_end=$1
+		shift
+	fi
+	if [ "$1" ]; then
+		branch=$1
+		shift
+	fi
+	log_start=$(git-merge-base "$branch" "$log_end")
+	[ "$log_start" ] || die "Unable to determine the merge base"
+fi
+
 if [ "$1" = "-r" ]; then
 	shift
 	log_start="$1"
Index: cg-mkpatch
===================================================================
--- de641904363cd3759f132ee7c0dfaf8a2ee58388/cg-mkpatch  (mode:100755)
+++ 3e889a5c03d7df9f82d7a649e02fef2ebdbb9f75/cg-mkpatch  (mode:100755)
@@ -9,6 +9,9 @@
 #
 # Takes an -r followed with ID defaulting to HEAD, or id1:id2, forming
 # a range (id1;id2]. (Use "id1:" to take just everything from id1 to HEAD.)
+#
+# -m [branch2] [branch1] shows the changes in branch2 (defaulting to
+# origin) not yet merged to branch1 (defaulting to HEAD)
 
 . ${COGITO_LIB}cg-Xlib
 
@@ -65,6 +68,22 @@
 
 log_start=
 log_end=
+if [ "$1" = "-m" ]; then
+	branch=HEAD
+	log_end=origin
+	shift
+	if [ "$1" ]; then
+		log_end=$1
+		shift
+	fi
+	if [ "$1" ]; then
+		branch=$1
+		shift
+	fi
+	log_start=$(git-merge-base "$branch" "$log_end")
+	[ "$log_start" ] || die "Unable to determine the merge base"
+fi
+
 if [ "$1" = "-r" ]; then
 	shift
 	log_start="$1"

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

* Re: [PATCH cogito] "cg-whatsnew" command
  2005-05-15  8:29   ` Catalin Marinas
@ 2005-05-15 17:36     ` Matthias Urlichs
  2005-05-16  8:33       ` Catalin Marinas
  0 siblings, 1 reply; 8+ messages in thread
From: Matthias Urlichs @ 2005-05-15 17:36 UTC (permalink / raw)
  To: git

Hi, Catalin Marinas wrote:

> +	cg-diff		[-p] [-r FROM_ID[:TO_ID]] [-m [BNAME] [BNAME]] [FILE]...

That should be

[-m [BNAME [BNAME]]]

though I'd suggest something more mnemonic than two BNAMEs.

-- 
Matthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de



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

* Re: [PATCH cogito] "cg-whatsnew" command
  2005-05-15 17:36     ` Matthias Urlichs
@ 2005-05-16  8:33       ` Catalin Marinas
  2005-05-18 22:30         ` Petr Baudis
  0 siblings, 1 reply; 8+ messages in thread
From: Catalin Marinas @ 2005-05-16  8:33 UTC (permalink / raw)
  To: Matthias Urlichs; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 283 bytes --]

Matthias Urlichs <smurf@smurf.noris.de> wrote:
>> +	cg-diff		[-p] [-r FROM_ID[:TO_ID]] [-m [BNAME] [BNAME]] [FILE]...
>
> That should be
>
> [-m [BNAME [BNAME]]]

You are right.

> though I'd suggest something more mnemonic than two BNAMEs.

Another try, see attached.

-- 
Catalin


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-m-option --]
[-- Type: text/x-patch, Size: 4529 bytes --]

"-m" option added to cg-diff, cg-log and cg-mkpatch

This option takes two optional parameters, branch2 and branch1, and shows
the changes in branch2 not yet merged to branch1. Branch2 defaults to
origin and branch1 to HEAD.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

---
commit 54c787f373557940617bca2c206c731d04c7e07b
tree d46bb25bdadb369e6cbf28ca25ffaeb4b41f7381
parent fa6e9eb368e949e78c4e66217461cf624b52b0a2
author Catalin Marinas <cmarinas@pc1117.cambridge.arm.com> Mon, 16 May 2005 09:30:08 +0100
committer Catalin Marinas <cmarinas@pc1117.cambridge.arm.com> Mon, 16 May 2005 09:30:08 +0100

 cg-diff    |   19 +++++++++++++++++++
 cg-help    |    8 +++++---
 cg-log     |   19 +++++++++++++++++++
 cg-mkpatch |   19 +++++++++++++++++++
 4 files changed, 62 insertions(+), 3 deletions(-)

Index: cg-diff
===================================================================
--- de641904363cd3759f132ee7c0dfaf8a2ee58388/cg-diff  (mode:100755)
+++ d46bb25bdadb369e6cbf28ca25ffaeb4b41f7381/cg-diff  (mode:100755)
@@ -14,6 +14,9 @@
 # -p instead of one ID denotes a parent commit to the specified ID
 # (which must not be a tree, obviously).
 #
+# -m [branch2] [branch1] shows the changes in branch2 (defaulting to
+# origin) not yet merged to branch1 (defaulting to HEAD)
+#
 # Outputs a diff converting the first tree to the second one.
 
 . ${COGITO_LIB}cg-Xlib
@@ -31,6 +34,22 @@
 	parent=1
 fi
 
+if [ "$1" = "-m" ]; then
+	branch=HEAD
+	id2=origin
+	shift
+	if [ "$1" ]; then
+		id2=$1
+		shift
+	fi
+	if [ "$1" ]; then
+		branch=$1
+		shift
+	fi
+	id1=$(git-merge-base "$branch" "$id2")
+	[ "$id1" ] || die "Unable to determine the merge base"
+fi
+
 if [ "$1" = "-r" ]; then
 	shift
 	id1=$(echo "$1": | cut -d : -f 1)
Index: cg-help
===================================================================
--- de641904363cd3759f132ee7c0dfaf8a2ee58388/cg-help  (mode:100755)
+++ d46bb25bdadb369e6cbf28ca25ffaeb4b41f7381/cg-help  (mode:100755)
@@ -26,14 +26,16 @@
 	cg-cancel
 	cg-clone	[-s] SOURCE_LOC [DESTDIR]
 	cg-commit	[-m"Commit message"]... [-e | -E] [FILE]... < log message
-	cg-diff		[-p] [-r FROM_ID[:TO_ID]] [FILE]...
+	cg-diff		[-p] [-r FROM_ID[:TO_ID]] [-m [SRC_BNAME [DST_BNAME]]] \\
+			[FILE]...
 	cg-export	DEST [TREE_ID]
 	cg-help		[COMMAND]
 	cg-init
-	cg-log		[-c] [-f] [-r FROM_ID[:TO_ID]] [FILE]...
+	cg-log		[-c] [-f] [-r FROM_ID[:TO_ID]] ] \\
+			[-m [SRC_BNAME [DST_BNAME]]] [FILE]...
 	cg-ls		[TREE_ID]
 	cg-merge	[-c] [-b BASE_ID] FROM_ID
-	cg-mkpatch	[-s] [-r FROM_ID[:TO_ID]]
+	cg-mkpatch	[-s] [-r FROM_ID[:TO_ID]]] [-m [SRC_BNAME [DST_BNAME]]]
 	cg-patch			< patch on stdin
 	cg-pull		[BNAME]
 	cg-restore	[FILE]...
Index: cg-log
===================================================================
--- de641904363cd3759f132ee7c0dfaf8a2ee58388/cg-log  (mode:100755)
+++ d46bb25bdadb369e6cbf28ca25ffaeb4b41f7381/cg-log  (mode:100755)
@@ -22,6 +22,9 @@
 # (HEAD by default), or id1:id2 representing an (id1;id2] range
 # of commits to show.
 #
+# -m [branch2] [branch1] shows the changes in branch2 (defaulting to
+# origin) not yet merged to branch1 (defaulting to HEAD)
+#
 # The rest of arguments are took as filenames; cg-log then displays
 # only changes in those files.
 
@@ -94,6 +97,22 @@
 
 log_start=
 log_end=
+if [ "$1" = "-m" ]; then
+	branch=HEAD
+	log_end=origin
+	shift
+	if [ "$1" ]; then
+		log_end=$1
+		shift
+	fi
+	if [ "$1" ]; then
+		branch=$1
+		shift
+	fi
+	log_start=$(git-merge-base "$branch" "$log_end")
+	[ "$log_start" ] || die "Unable to determine the merge base"
+fi
+
 if [ "$1" = "-r" ]; then
 	shift
 	log_start="$1"
Index: cg-mkpatch
===================================================================
--- de641904363cd3759f132ee7c0dfaf8a2ee58388/cg-mkpatch  (mode:100755)
+++ d46bb25bdadb369e6cbf28ca25ffaeb4b41f7381/cg-mkpatch  (mode:100755)
@@ -9,6 +9,9 @@
 #
 # Takes an -r followed with ID defaulting to HEAD, or id1:id2, forming
 # a range (id1;id2]. (Use "id1:" to take just everything from id1 to HEAD.)
+#
+# -m [branch2] [branch1] shows the changes in branch2 (defaulting to
+# origin) not yet merged to branch1 (defaulting to HEAD)
 
 . ${COGITO_LIB}cg-Xlib
 
@@ -65,6 +68,22 @@
 
 log_start=
 log_end=
+if [ "$1" = "-m" ]; then
+	branch=HEAD
+	log_end=origin
+	shift
+	if [ "$1" ]; then
+		log_end=$1
+		shift
+	fi
+	if [ "$1" ]; then
+		branch=$1
+		shift
+	fi
+	log_start=$(git-merge-base "$branch" "$log_end")
+	[ "$log_start" ] || die "Unable to determine the merge base"
+fi
+
 if [ "$1" = "-r" ]; then
 	shift
 	log_start="$1"

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

* Re: [PATCH cogito] "cg-whatsnew" command
  2005-05-16  8:33       ` Catalin Marinas
@ 2005-05-18 22:30         ` Petr Baudis
  2005-05-18 23:50           ` Matthias Urlichs
  2005-05-19  8:24           ` Catalin Marinas
  0 siblings, 2 replies; 8+ messages in thread
From: Petr Baudis @ 2005-05-18 22:30 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: Matthias Urlichs, git

Dear diary, on Mon, May 16, 2005 at 10:33:44AM CEST, I got a letter
where Catalin Marinas <catalin.marinas@arm.com> told me that...
> Matthias Urlichs <smurf@smurf.noris.de> wrote:
> >> +	cg-diff		[-p] [-r FROM_ID[:TO_ID]] [-m [BNAME] [BNAME]] [FILE]...
> >
> > That should be
> >
> > [-m [BNAME [BNAME]]]
> 
> You are right.
> 
> > though I'd suggest something more mnemonic than two BNAMEs.
> 
> Another try, see attached.

Unfortunately I can't comment on it well when it's not either in the
body or as text/plain attachment.

I think the -m usage doesn't make much sense now. What about dropping
branch1 and instead using what the user passed as the -r argument?

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

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

* Re: [PATCH cogito] "cg-whatsnew" command
  2005-05-18 22:30         ` Petr Baudis
@ 2005-05-18 23:50           ` Matthias Urlichs
  2005-05-19  8:24           ` Catalin Marinas
  1 sibling, 0 replies; 8+ messages in thread
From: Matthias Urlichs @ 2005-05-18 23:50 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Catalin Marinas, git

Hi,

Petr Baudis:
> Unfortunately I can't comment on it well when it's not either in the
> body or as text/plain attachment.

It was a text/x-patch attachment. What's the problem?
If nothing else: save it, read it in, s/^/> /.  *shrug*

At least, this way there won't be any word-wrapping by
overzealous email programs ...

-- 
Matthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de

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

* Re: [PATCH cogito] "cg-whatsnew" command
  2005-05-18 22:30         ` Petr Baudis
  2005-05-18 23:50           ` Matthias Urlichs
@ 2005-05-19  8:24           ` Catalin Marinas
  1 sibling, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2005-05-19  8:24 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Matthias Urlichs, git

[-- Attachment #1: Type: text/plain, Size: 491 bytes --]

Petr Baudis <pasky@ucw.cz> wrote:
> Unfortunately I can't comment on it well when it's not either in the
> body or as text/plain attachment.

It was attached as text/x-patch.

> I think the -m usage doesn't make much sense now. What about dropping
> branch1 and instead using what the user passed as the -r argument?

See attached (text/plain this time).

It is also possible not to give any argument to -m and use the -r ones
entirely (not implemented in the attached patch).

-- 
Catalin


[-- Attachment #2: patch-m-option --]
[-- Type: text/plain, Size: 3814 bytes --]

"-m" option added to cg-diff, cg-log and cg-mkpatch

This option takes a branch name as an optional parameter and shows the
changes on this branch not yet merged to HEAD or to the first argument
passed to "-r".

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

---
Index: cg-diff
===================================================================
--- ca5fef50fb68a3afbb35e1a48ac622f7a964f021/cg-diff  (mode:100755)
+++ uncommitted/cg-diff  (mode:100755)
@@ -14,6 +14,9 @@
 # -p instead of one ID denotes a parent commit to the specified ID
 # (which must not be a tree, obviously).
 #
+# -m [branch] shows the changes in branch (defaulting to origin)
+# not yet merged to HEAD (or the first argument passed to -r)
+#
 # Outputs a diff converting the first tree to the second one.
 
 . ${COGITO_LIB}cg-Xlib
@@ -49,6 +52,18 @@
 	id1=$(parent-id "$id2" | head -n 1)
 fi
 
+if [ "$1" = "-m" ]; then
+	[ "$id1" = " " ] && id1=HEAD
+	id2=origin
+	shift
+	if [ "$1" ]; then
+		id2=$1
+		shift
+	fi
+	id1=$(git-merge-base "$id1" "$id2")
+	[ "$id1" ] || die "Unable to determine the merge base"
+fi
+
 
 filter=
 if [ "$*" ]; then
Index: cg-help
===================================================================
--- ca5fef50fb68a3afbb35e1a48ac622f7a964f021/cg-help  (mode:100755)
+++ uncommitted/cg-help  (mode:100755)
@@ -26,14 +26,14 @@
 	cg-cancel
 	cg-clone	[-s] SOURCE_LOC [DESTDIR]
 	cg-commit	[-m"Commit message"]... [-e | -E] [FILE]... < log message
-	cg-diff		[-p] [-r FROM_ID[:TO_ID]] [FILE]...
+	cg-diff		[-p] [-r FROM_ID[:TO_ID]] [-m [BNAME]] [FILE]...
 	cg-export	DEST [TREE_ID]
 	cg-help		[COMMAND]
 	cg-init
-	cg-log		[-c] [-f] [-r FROM_ID[:TO_ID]] [FILE]...
+	cg-log		[-c] [-f] [-r FROM_ID[:TO_ID]] [-m [BNAME]] [FILE]...
 	cg-ls		[TREE_ID]
 	cg-merge	[-c] [-b BASE_ID] FROM_ID
-	cg-mkpatch	[-s] [-r FROM_ID[:TO_ID]]
+	cg-mkpatch	[-s] [-r FROM_ID[:TO_ID]] [-m [BNAME]]
 	cg-patch			< patch on stdin
 	cg-pull		[BNAME]
 	cg-restore	[FILE]...
Index: cg-log
===================================================================
--- ca5fef50fb68a3afbb35e1a48ac622f7a964f021/cg-log  (mode:100755)
+++ uncommitted/cg-log  (mode:100755)
@@ -22,6 +22,9 @@
 # (HEAD by default), or id1:id2 representing an (id1;id2] range
 # of commits to show.
 #
+# -m [branch] shows the changes in branch (defaulting to origin)
+# not yet merged to HEAD (or the first argument passed to -r)
+#
 # The rest of arguments are took as filenames; cg-log then displays
 # only changes in those files.
 
@@ -110,6 +113,18 @@
 	shift
 fi
 
+if [ "$1" = "-m" ]; then
+	[ "$log_start" ] || log_start=HEAD
+	log_end=origin
+	shift
+	if [ "$1" ]; then
+		log_end=$1
+		shift
+	fi
+	log_start=$(git-merge-base "$log_start" "$log_end")
+	[ "$log_start" ] || die "Unable to determine the merge base"
+fi
+
 if [ "$log_end" ]; then
 	id1="$(commit-id $log_start)" || exit 1
 	id2="$(commit-id $log_end)" || exit 1
Index: cg-mkpatch
===================================================================
--- ca5fef50fb68a3afbb35e1a48ac622f7a964f021/cg-mkpatch  (mode:100755)
+++ uncommitted/cg-mkpatch  (mode:100755)
@@ -9,6 +9,9 @@
 #
 # Takes an -r followed with ID defaulting to HEAD, or id1:id2, forming
 # a range (id1;id2]. (Use "id1:" to take just everything from id1 to HEAD.)
+#
+# -m [branch] shows the changes in branch (defaulting to origin)
+# not yet merged to HEAD (or the first argument passed to -r)
 
 . ${COGITO_LIB}cg-Xlib
 
@@ -80,6 +83,18 @@
 	shift
 fi
 
+if [ "$1" = "-m" ]; then
+	[ "$log_start" ] || log_start=HEAD
+	log_end=origin
+	shift
+	if [ "$1" ]; then
+		log_end=$1
+		shift
+	fi
+	log_start=$(git-merge-base "$log_start" "$log_end")
+	[ "$log_start" ] || die "Unable to determine the merge base"
+fi
+
 if [ "$log_end" ]; then
 	id1=$(commit-id $log_start) || exit 1
 	id2=$(commit-id $log_end) || exit 1

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

end of thread, other threads:[~2005-05-19  8:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-14 10:58 [PATCH cogito] "cg-whatsnew" command Catalin Marinas
2005-05-14 11:09 ` Petr Baudis
2005-05-15  8:29   ` Catalin Marinas
2005-05-15 17:36     ` Matthias Urlichs
2005-05-16  8:33       ` Catalin Marinas
2005-05-18 22:30         ` Petr Baudis
2005-05-18 23:50           ` Matthias Urlichs
2005-05-19  8:24           ` Catalin Marinas

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 NNTP newsgroup(s).