git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH cogito] "cg-whatsnew" command

From
CMCatalin Marinas <catalin.marinas@arm.com>
Date
May 14, 2005, 10:58 UTC
Message-ID
<tnx64xm5b2b.fsf@arm.com>

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
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
Next: Petr Baudis
Message 1 of 8 in “"cg-whatsnew" command”
  1. "cg-whatsnew" commandCatalin Marinas, May 14, 2005
  2. Petr BaudisMay 14, 2005
  3. Catalin MarinasMay 15, 2005
  4. Matthias UrlichsMay 15, 2005
  5. Catalin MarinasMay 16, 2005
  6. Petr BaudisMay 18, 2005
  7. Matthias UrlichsMay 18, 2005
  8. Catalin MarinasMay 19, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.