git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yann Dirson <ydirson@altern.org>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: GIT list <git@vger.kernel.org>
Subject: [PATCH 2/5] Add contrib/stg-whatchanged: look at what would be changed by refreshing.
Date: Fri, 05 Jan 2007 00:46:47 +0100	[thread overview]
Message-ID: <20070104234647.13580.50428.stgit@gandelf.nowhere.earth> (raw)
In-Reply-To: <20070104233934.13580.17744.stgit@gandelf.nowhere.earth>


This script outputs a "metadiff" (diff of diffs, ie. diff between 2
versions of a single patch).  This is somewhat a proof of concept, and some
work is indeed needed in the way to present the results.  Consider
filtering the output at least through colordiff.

I have 2 uses for this script:
- when simply editing a patch, provides a 3rd way to check what I've done
  before refreshing (in addition to "stg diff" and "stg diff -r //bottom")
- most usefully, when resolving conflicts caused by a push, to ease
  checking of the merge result.

Signed-off-by: Yann Dirson <ydirson@altern.org>
---

 contrib/stg-whatchanged |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/contrib/stg-whatchanged b/contrib/stg-whatchanged
new file mode 100755
index 0000000..978749c
--- /dev/null
+++ b/contrib/stg-whatchanged
@@ -0,0 +1,37 @@
+#!/bin/bash
+set -e
+
+# stg-whatchanged - show a metadiff for the patch being modified,
+# especially when resolving a merge.
+
+# Copyright (c) 2006-2007 Yann Dirson <ydirson@altern.org>
+# Subject to the GNU GPL, version 2.
+
+# FIXME:
+# - should only exclude hunk headers differing only in line offsets
+# - diff coloring should show changes in context lines differently than
+#   changes in contents
+# - filter on ^index lines is a bit wide
+# - we should be able to ask diff to force a new hunk on "^@@ " to better
+#   handle them
+# - we should always show the hunk header for any changes within a hunk
+
+# default to unified diff
+if [ "$#" = 0 ]; then
+    set -- -u
+fi
+
+# Merges via "push" leave top=bottom so we must look at old patch
+# in this case (unlike, eg., "pick --fold")
+patchdir="$(git-rev-parse --git-dir)/patches/$(stg branch)/$(stg top)"
+if [ $(cat "$patchdir/bottom") = $(cat "$patchdir/top") ];
+then
+    current_cmd="stg-show-old"
+else
+    current_cmd="stg show"
+fi
+
+colordiff "$@" \
+    -I '^index [0-9a-b]*..[0-9a-b]*' \
+    -I '^@@ .* @@' \
+    <($current_cmd) <(stg diff -r//bottom) | less -RFX

  parent reply	other threads:[~2007-01-04 23:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-04 23:39 [PATCH 0/5] My set of stgit companion scripts Yann Dirson
2007-01-04 23:46 ` [PATCH 1/5] Add contrib/stg-show-old: show old version of a patch Yann Dirson
2007-01-04 23:46 ` Yann Dirson [this message]
2007-01-04 23:46 ` [PATCH 3/5] Add contrib/stg-fold-files-from: pick selected changes from a patch above current one Yann Dirson
2007-01-04 23:46 ` [PATCH 4/5] Add contrib/stg-swallow: completely merge an unapplied patch into " Yann Dirson
2007-01-04 23:47 ` [PATCH 5/5] Add contrib/stg-cvs: helper script to manage a mixed cvs/stgit working copy Yann Dirson
2007-01-09 10:21 ` [PATCH 0/5] My set of stgit companion scripts Catalin Marinas
2007-01-09 22:26   ` Yann Dirson

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=20070104234647.13580.50428.stgit@gandelf.nowhere.earth \
    --to=ydirson@altern.org \
    --cc=catalin.marinas@gmail.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 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).