All of lore.kernel.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: git@vger.kernel.org
Subject: [PATCH cogito] "cg-whatsnew" command
Date: Sat, 14 May 2005 11:58:04 +0100	[thread overview]
Message-ID: <tnx64xm5b2b.fsf@arm.com> (raw)

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

             reply	other threads:[~2005-05-14 10:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-14 10:58 Catalin Marinas [this message]
2005-05-14 11:09 ` [PATCH cogito] "cg-whatsnew" command 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tnx64xm5b2b.fsf@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.