threads / patch / 9207

patch, 4 partsFix stg-whatchanged to deal with conflicts already solved.

Subject: [StGIT PATCH 1/4] Fix stg-whatchanged to deal with conflicts already solved.

## tl;dr

5 messages between Jul 24, 2007 and Jul 24, 2007. Diffs are folded; open one to read it.

replies: 4people: 1as markdown or json

Yann Dirson· Jul 24, 2007, 18:57 UTC · lore

[StGIT PATCH 0/4] stg-whatchanged improvements

The following series fixes a case where contrib/stg-whatchanged did not work as expected, and makes it use contrib/stg-mdiff instead of reimplementing the same logic. Especially since stg-whatchanged had already gained metadiff-related improvements that stg-mdiff did not had :)

-- 
Yann Dirson    <ydirson@altern.org> |
Debian-related: <dirson@debian.org> |   Support Debian GNU/Linux:
                                    |  Freedom, Power, Stability, Gratis
     http://ydirson.free.fr/        | Check <http://www.debian.org/>
Yann Dirson· Jul 24, 2007, 18:57 UTC · re: Yann Dirson · lore
From: Yann Dirson <yann.dirson@sagem.com>

The most reliable way I found to decide if we were in the process of solving a conflict, including when all conflicted files have already been marked resolved, is to check the latest patchlog entry.

Signed-off-by: Yann Dirson <ydirson@altern.org>
---
 contrib/stg-whatchanged |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
Show changes to contrib/stg-whatchanged +4 −6
diff --git a/contrib/stg-whatchanged b/contrib/stg-whatchanged
index a416e97..231f4f5 100755
--- a/contrib/stg-whatchanged
+++ b/contrib/stg-whatchanged
@@ -24,12 +24,10 @@ 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)/patches/$(stg top)"
-if [ -s "$(git-rev-parse --git-dir)/conflicts" ];
-then
-    current_cmd="stg show //top.old"
-else
-    current_cmd="stg show"
-fi
+case $(stg log | head -n1) in
+    *push\(c\)*) current_cmd="stg show //top.old" ;;
+    *) current_cmd="stg show" ;;
+esac
 
 colordiff "$@" \
     -I '^index [0-9a-b]*..[0-9a-b]*' \
Yann Dirson· Jul 24, 2007, 18:57 UTC · re: Yann Dirson · lore

[StGIT PATCH 2/4] Add range comparison support to stg-mdiff.

From: Yann Dirson <yann.dirson@sagem.com>
We can now compare arbitrary deltas, not just single commits.
Signed-off-by: Yann Dirson <ydirson@altern.org>
---
 contrib/stg-mdiff |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
Show changes to contrib/stg-mdiff +11 −2
diff --git a/contrib/stg-mdiff b/contrib/stg-mdiff
index cd0c678..9bb324a 100755
--- a/contrib/stg-mdiff
+++ b/contrib/stg-mdiff
@@ -12,7 +12,7 @@ set -e
 
 usage()
 {
-    echo "Usage: $(basename $0) <patch1> <patch2>"
+    echo "Usage: $(basename $0) <from1>..[<to1>]|<patch1> <from2>..[<to2>]|<patch2>"
     exit 1
 }
 
@@ -20,4 +20,13 @@ if [ "$#" != 2 ]; then
     usage
 fi
 
-colordiff -u <(stg show "$1") <(stg show "$2") | less -RFX
+case "$1" in
+*..*) cmd1="stg diff" ;;
+*)    cmd1="stg show" ;;
+esac
+case "$2" in
+*..*) cmd2="stg diff" ;;
+*)    cmd2="stg show" ;;
+esac
+
+colordiff -u <($cmd1 "$1") <($cmd2 "$2") | less -RFX
Yann Dirson· Jul 24, 2007, 18:57 UTC · re: Yann Dirson · lore

[StGIT PATCH 3/4] Add to stg-mdiff the ability to pass options to underlying diff opts.

From: Yann Dirson <yann.dirson@sagem.com>

So we now have -O, similar to the existing option in stg diff, to pass flags to git-diff when computing the 2 diffs to compare (-M, -C and -w come to mind as being potentially useful here), and -o can be used to tune the invocation of diff on those 2 diffs.

Note that -o is only there temporarily, and will disappear when a more sophisticated process than plain diff will be used.

Signed-off-by: Yann Dirson <ydirson@altern.org>
---
 contrib/stg-mdiff |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)
Show changes to contrib/stg-mdiff +23 −6
diff --git a/contrib/stg-mdiff b/contrib/stg-mdiff
index 9bb324a..61cba9e 100755
--- a/contrib/stg-mdiff
+++ b/contrib/stg-mdiff
@@ -12,21 +12,38 @@ set -e
 
 usage()
 {
-    echo "Usage: $(basename $0) <from1>..[<to1>]|<patch1> <from2>..[<to2>]|<patch2>"
+    echo "Usage: [-o <diff-flags>] [-O <gitdiff-flags>] $(basename $0) <from1>..[<to1>]|<patch1> <from2>..[<to2>]|<patch2>"
     exit 1
 }
 
+diffopts=
+subdiffopts=
+while [ "$#" -gt 0 ]; do
+    case "$1" in
+	-o) diffopts="$2"; shift ;;
+	-O) subdiffopts="-O $2"; shift ;;
+	-*) usage ;;
+	*) break ;;
+    esac
+    shift
+done
+
 if [ "$#" != 2 ]; then
     usage
 fi
 
+if [ -z "$diffopts" ]; then
+    diffopts="-u"
+fi
+
 case "$1" in
-*..*) cmd1="stg diff" ;;
-*)    cmd1="stg show" ;;
+*..*) cmd1="stg diff $subdiffopts -r" ;;
+*)    cmd1="stg show $subdiffopts" ;;
 esac
 case "$2" in
-*..*) cmd2="stg diff" ;;
-*)    cmd2="stg show" ;;
+*..*) cmd2="stg diff $subdiffopts -r" ;;
+*)    cmd2="stg show $subdiffopts" ;;
 esac
 
-colordiff -u <($cmd1 "$1") <($cmd2 "$2") | less -RFX
+colordiff $diffopts \
+    <($cmd1 "$1") <($cmd2 "$2") | less -RFX
Yann Dirson· Jul 24, 2007, 18:57 UTC · re: Yann Dirson · lore

[StGIT PATCH 4/4] Port stg-whatchanged improvements to stg-mdiff and have the former use the latter.

From: Yann Dirson <yann.dirson@sagem.com>
Signed-off-by: Yann Dirson <ydirson@altern.org>
---
 contrib/stg-mdiff       |    2 ++
 contrib/stg-whatchanged |   10 ++++------
 2 files changed, 6 insertions(+), 6 deletions(-)
Show changes to 2 files +6 −6

contrib/stg-mdiff, contrib/stg-whatchanged

diff --git a/contrib/stg-mdiff b/contrib/stg-mdiff
index 61cba9e..74d7f77 100755
--- a/contrib/stg-mdiff
+++ b/contrib/stg-mdiff
@@ -46,4 +46,6 @@ case "$2" in
 esac
 
 colordiff $diffopts \
+    -I '^index [0-9a-b]*..[0-9a-b]*' \
+    -I '^@@ .* @@' \
     <($cmd1 "$1") <($cmd2 "$2") | less -RFX
diff --git a/contrib/stg-whatchanged b/contrib/stg-whatchanged
index 231f4f5..afeda2c 100755
--- a/contrib/stg-whatchanged
+++ b/contrib/stg-whatchanged
@@ -25,11 +25,9 @@ fi
 # in this case (unlike, eg., "pick --fold")
 patchdir="$(git-rev-parse --git-dir)/patches/$(stg branch)/patches/$(stg top)"
 case $(stg log | head -n1) in
-    *push\(c\)*) current_cmd="stg show //top.old" ;;
-    *) current_cmd="stg show" ;;
+    *push\(c\)*) former="//top.old" ;;
+    *) former="//top" ;;
 esac
 
-colordiff "$@" \
-    -I '^index [0-9a-b]*..[0-9a-b]*' \
-    -I '^@@ .* @@' \
-    <($current_cmd) <(stg diff -r//bottom) | less -RFX
+stg-mdiff -o "$*" \
+    $former //bottom..

← back to recent threads