git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [StGIT PATCH 0/6] Various contrib/ updates
@ 2007-08-02 20:18 Yann Dirson
  2007-08-02 20:18 ` [StGIT PATCH 1/6] Improve stg-fold-files-from doc Yann Dirson
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Yann Dirson @ 2007-08-02 20:18 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

This series, asside from small fixes, enhance the bash completion to
be aware of file status (notably, makes it much more comfortable to
refresh only selective files), and introduces 2 new contrib scripts:

- whereas stg-fold-files-from was designed to merge in the current
patch changes from several other patches, stg-dispatch makes life
easier to split a given patch into several other ones (ie. making a
split series out of a monolithic patch).

- stg-show is a RFC/proof-of-concept for a redesign of "stg show",
which calls git-show much more transparently.  This allows to harness
the full power of the git-show command-line without duplicating the
logic in stgit.


I already made heavy use of the scripts in the last days, and I rate
them as good candidates for 0.13.1.

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

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

* [StGIT PATCH 1/6] Improve stg-fold-files-from doc.
  2007-08-02 20:18 [StGIT PATCH 0/6] Various contrib/ updates Yann Dirson
@ 2007-08-02 20:18 ` Yann Dirson
  2007-08-02 20:18 ` [StGIT PATCH 2/6] New contrib scripts: stg-dispatch and stg-show Yann Dirson
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Yann Dirson @ 2007-08-02 20:18 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

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

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

 contrib/stg-fold-files-from |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/stg-fold-files-from b/contrib/stg-fold-files-from
index bfb4a1f..53d3d02 100755
--- a/contrib/stg-fold-files-from
+++ b/contrib/stg-fold-files-from
@@ -2,12 +2,12 @@
 set -e
 
 # stg-fold-files-from - picks changes to one file from another patch.
-# Only supports picking from one file, but allows to select any range
+# Only supports picking from one file pattern, but allows to select any range
 # of hunks from the file, using the -# flag to filterdiff.
 # Use together with "filterdiff --annotate" in your diff pager, to
 # identify hunk numbers easily.
 
-# usage: stg-fold-files-from <patch> [-#<n>[-<n>][,<n>]...] <file>
+# usage: stg-fold-files-from <patch> [-#<n>[-<n>][,<n>]...] <file-pattern>
 
 # Copyright (c) 2006-2007 Yann Dirson <ydirson@altern.org>
 # Subject to the GNU GPL, version 2.

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

* [StGIT PATCH 2/6] New contrib scripts: stg-dispatch and stg-show.
  2007-08-02 20:18 [StGIT PATCH 0/6] Various contrib/ updates Yann Dirson
  2007-08-02 20:18 ` [StGIT PATCH 1/6] Improve stg-fold-files-from doc Yann Dirson
@ 2007-08-02 20:18 ` Yann Dirson
  2007-08-02 20:18 ` [StGIT PATCH 3/6] Add -O flag to stg-fold-files-from Yann Dirson
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Yann Dirson @ 2007-08-02 20:18 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

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

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

 contrib/stg-dispatch |   34 ++++++++++++++++++++++++++++++++++
 contrib/stg-show     |   27 +++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/contrib/stg-dispatch b/contrib/stg-dispatch
new file mode 100755
index 0000000..8911946
--- /dev/null
+++ b/contrib/stg-dispatch
@@ -0,0 +1,34 @@
+#!/bin/sh
+set -e
+
+# stg-dispatch - percollates files matching a pattern down to another patch.
+# It does the same job as stg-fold-files-from (and makes use of it to
+# do so), but from the patch containing the changes to migrate,
+# instead of doing so from the target patch.
+
+# usage: stg-dispatch <topatch> [-#<n>[-<n>][,<n>]...] <file-pattern>
+
+# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
+# Subject to the GNU GPL, version 2.
+
+die()
+{
+    echo >&2 "$(basename $0) error: $*"
+    exit 1
+}
+
+TOPATCH="$1"
+shift
+
+stg applied | grep "^$TOPATCH\$" >/dev/null ||
+    die "cannot dispatch to unapplied patch '$TOPATCH'"
+
+CURRENTPATCH=$(stg top)
+
+[ "x$TOPATCH" != "x$CURRENTPATCH" ] ||
+    die "dispatching to current patch ($CURRENTPATCH) makes no sense"
+
+stg goto "$TOPATCH"
+stg-fold-files-from "$CURRENTPATCH" "$@"
+stg refresh
+stg goto "$CURRENTPATCH"
diff --git a/contrib/stg-show b/contrib/stg-show
new file mode 100755
index 0000000..8c61540
--- /dev/null
+++ b/contrib/stg-show
@@ -0,0 +1,27 @@
+#!/bin/bash
+set -e
+
+# stg-show - unlike "stg show", just "git show" with knowledge of stg refs
+
+# Ex:
+# stg-show --color-words -- files
+
+# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
+# Subject to the GNU GPL, version 2.
+
+command=(git show)
+
+# subsitute git id's for stg ones until --
+endofpatches=0
+while [ "$#" -gt 0 ]; do
+    case "$1" in
+	--) endofpatches=1; break ;;
+	-*) command+=("$1"); shift ;;
+	*) command+=( $(stg id "$1" 2>/dev/null || echo "$1") ); shift ;;
+    esac
+done
+
+# append remaining args
+command+=("$@")
+
+eval "${command[@]}"

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

* [StGIT PATCH 3/6] Add -O flag to stg-fold-files-from.
  2007-08-02 20:18 [StGIT PATCH 0/6] Various contrib/ updates Yann Dirson
  2007-08-02 20:18 ` [StGIT PATCH 1/6] Improve stg-fold-files-from doc Yann Dirson
  2007-08-02 20:18 ` [StGIT PATCH 2/6] New contrib scripts: stg-dispatch and stg-show Yann Dirson
@ 2007-08-02 20:18 ` Yann Dirson
  2007-08-02 20:18 ` [StGIT PATCH 4/6] Add a no-act flag to stg-dispatch and stg-fold-file-from Yann Dirson
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Yann Dirson @ 2007-08-02 20:18 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

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

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

 contrib/stg-fold-files-from |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/contrib/stg-fold-files-from b/contrib/stg-fold-files-from
index 53d3d02..806a157 100755
--- a/contrib/stg-fold-files-from
+++ b/contrib/stg-fold-files-from
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 set -e
 
 # stg-fold-files-from - picks changes to one file from another patch.
@@ -6,8 +6,9 @@ set -e
 # of hunks from the file, using the -# flag to filterdiff.
 # Use together with "filterdiff --annotate" in your diff pager, to
 # identify hunk numbers easily.
+# Use "-O -U<n>" to get finer hunk granularity for -#<n>.
 
-# usage: stg-fold-files-from <patch> [-#<n>[-<n>][,<n>]...] <file-pattern>
+# usage: stg-fold-files-from <patch> [-O <stg-show-flags>] [-#<n>[-<n>][,<n>]...] <file-pattern>
 
 # Copyright (c) 2006-2007 Yann Dirson <ydirson@altern.org>
 # Subject to the GNU GPL, version 2.
@@ -18,14 +19,17 @@ shift
 filtercmd=cat
 hunks=
 foldflags=
+showflags=()
 while [ "$#" -gt 0 ]; do
     case "$1" in
-	-\#*) hunks="$1"; shift ;;
-	-t) foldflags="-t"; shift ;;
+	-\#*) hunks="$1" ;;
+	-t) foldflags="-t" ;;
+	-O) showflags+=(-O "$2"); shift ;;
 	-*) { echo >&2 "unknown flag '$1'"; exit 1; } ;;
 	*) break ;;
     esac
+    shift
 done
 [ "$#" = 1 ] || { echo >&2 "supports one file only"; exit 1; }
 
-stg show "$PATCH" | filterdiff -p1 $hunks -i "$1" | stg fold $foldflags
+stg show "${showflags[@]}" "$PATCH" | filterdiff -p1 $hunks -i "$1" | stg fold $foldflags

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

* [StGIT PATCH 4/6] Add a no-act flag to stg-dispatch and stg-fold-file-from.
  2007-08-02 20:18 [StGIT PATCH 0/6] Various contrib/ updates Yann Dirson
                   ` (2 preceding siblings ...)
  2007-08-02 20:18 ` [StGIT PATCH 3/6] Add -O flag to stg-fold-files-from Yann Dirson
@ 2007-08-02 20:18 ` Yann Dirson
  2007-08-02 20:18 ` [StGIT PATCH 5/6] Provide file completion for add/resolved/refresh based on status Yann Dirson
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Yann Dirson @ 2007-08-02 20:18 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

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

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

 contrib/stg-dispatch        |   20 +++++++++++++++-----
 contrib/stg-fold-files-from |   15 +++++++++++++--
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/contrib/stg-dispatch b/contrib/stg-dispatch
index 8911946..e9cfb05 100755
--- a/contrib/stg-dispatch
+++ b/contrib/stg-dispatch
@@ -6,7 +6,7 @@ set -e
 # do so), but from the patch containing the changes to migrate,
 # instead of doing so from the target patch.
 
-# usage: stg-dispatch <topatch> [-#<n>[-<n>][,<n>]...] <file-pattern>
+# usage: stg-dispatch [-n] <topatch> [-#<n>[-<n>][,<n>]...] <file-pattern>
 
 # Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
 # Subject to the GNU GPL, version 2.
@@ -17,6 +17,12 @@ die()
     exit 1
 }
 
+noact=0
+if [ "x$1" = "x-n" ]; then
+    noact=1
+    shift
+fi
+
 TOPATCH="$1"
 shift
 
@@ -28,7 +34,11 @@ CURRENTPATCH=$(stg top)
 [ "x$TOPATCH" != "x$CURRENTPATCH" ] ||
     die "dispatching to current patch ($CURRENTPATCH) makes no sense"
 
-stg goto "$TOPATCH"
-stg-fold-files-from "$CURRENTPATCH" "$@"
-stg refresh
-stg goto "$CURRENTPATCH"
+if [ $noact = 1 ]; then
+    stg-fold-files-from "$CURRENTPATCH" -n "$@"
+else
+    stg goto "$TOPATCH"
+    stg-fold-files-from "$CURRENTPATCH" "$@"
+    stg refresh
+    stg goto "$CURRENTPATCH"
+fi
diff --git a/contrib/stg-fold-files-from b/contrib/stg-fold-files-from
index 806a157..c52abfc 100755
--- a/contrib/stg-fold-files-from
+++ b/contrib/stg-fold-files-from
@@ -8,7 +8,7 @@ set -e
 # identify hunk numbers easily.
 # Use "-O -U<n>" to get finer hunk granularity for -#<n>.
 
-# usage: stg-fold-files-from <patch> [-O <stg-show-flags>] [-#<n>[-<n>][,<n>]...] <file-pattern>
+# usage: stg-fold-files-from <patch> [-n] [-O <stg-show-flags>] [-#<n>[-<n>][,<n>]...] <file-pattern>
 
 # Copyright (c) 2006-2007 Yann Dirson <ydirson@altern.org>
 # Subject to the GNU GPL, version 2.
@@ -20,10 +20,12 @@ filtercmd=cat
 hunks=
 foldflags=
 showflags=()
+noact=0
 while [ "$#" -gt 0 ]; do
     case "$1" in
 	-\#*) hunks="$1" ;;
 	-t) foldflags="-t" ;;
+	-n) noact=1 ;;
 	-O) showflags+=(-O "$2"); shift ;;
 	-*) { echo >&2 "unknown flag '$1'"; exit 1; } ;;
 	*) break ;;
@@ -32,4 +34,13 @@ while [ "$#" -gt 0 ]; do
 done
 [ "$#" = 1 ] || { echo >&2 "supports one file only"; exit 1; }
 
-stg show "${showflags[@]}" "$PATCH" | filterdiff -p1 $hunks -i "$1" | stg fold $foldflags
+getpatch()
+{
+    stg show "${showflags[@]}" "$PATCH" | filterdiff -p1 $hunks -i "$1"
+}
+
+if [ $noact = 1 ]; then
+    getpatch "$1"
+else
+    getpatch "$1" | stg fold $foldflags
+fi

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

* [StGIT PATCH 5/6] Provide file completion for add/resolved/refresh based on status.
  2007-08-02 20:18 [StGIT PATCH 0/6] Various contrib/ updates Yann Dirson
                   ` (3 preceding siblings ...)
  2007-08-02 20:18 ` [StGIT PATCH 4/6] Add a no-act flag to stg-dispatch and stg-fold-file-from Yann Dirson
@ 2007-08-02 20:18 ` Yann Dirson
  2007-08-02 20:18 ` [StGIT PATCH 6/6] Fixed completion function hardcoding .git/ Yann Dirson
  2007-08-20 17:24 ` [StGIT PATCH 0/6] Various contrib/ updates Catalin Marinas
  6 siblings, 0 replies; 8+ messages in thread
From: Yann Dirson @ 2007-08-02 20:18 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

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

 contrib/stgit-completion.bash |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/contrib/stgit-completion.bash b/contrib/stgit-completion.bash
index a843db4..2d0d5f2 100644
--- a/contrib/stgit-completion.bash
+++ b/contrib/stgit-completion.bash
@@ -111,6 +111,30 @@ _all_branches ()
     [ "$g" ] && (cd .git/patches/ && echo *)
 }
 
+_conflicting_files ()
+{
+    local g=$(_gitdir)
+    [ "$g" ] && stg status --conflict
+}
+
+_dirty_files ()
+{
+    local g=$(_gitdir)
+    [ "$g" ] && stg status --modified --new --deleted
+}
+
+_unknown_files ()
+{
+    local g=$(_gitdir)
+    [ "$g" ] && stg status --unknown
+}
+
+_known_files ()
+{
+    local g=$(_gitdir)
+    [ "$g" ] && git ls-files
+}
+
 # List the command options
 _cmd_options ()
 {
@@ -162,6 +186,11 @@ _complete_options ()
     COMPREPLY=($(compgen -W "$options" -- "${COMP_WORDS[COMP_CWORD]}"))
 }
 
+_complete_files ()
+{
+    COMPREPLY=($(compgen -W "$(_cmd_options $1) $2" -- "${COMP_WORDS[COMP_CWORD]}"))
+}
+
 _stg_common ()
 {
     _complete_options "$(_cmd_options $1)"
@@ -223,12 +252,16 @@ _stg ()
         log)    _stg_patches $command _all_patches ;;
         mail)   _stg_patches $command _all_patches ;;
         pick)   _stg_patches $command _unapplied_patches ;;
-        refresh)_stg_patches_options $command _applied_patches "-p --patch" ;;
+#	refresh)_stg_patches_options $command _applied_patches "-p --patch" ;;
+        refresh) _complete_files $command "$(_dirty_files)" ;;
         rename) _stg_patches $command _all_patches ;;
         show)   _stg_patches $command _all_patches ;;
         sync)   _stg_patches $command _applied_patches ;;
         # working-copy commands
         diff)   _stg_patches_options $command _applied_patches "-r --range" ;;
+	resolved) _complete_files $command "$(_conflicting_files)" ;;
+	add)	_complete_files $command "$(_unknown_files)" ;;
+#	rm)	_complete_files $command "$(_known_files)" ;;
 	# commands that usually raher accept branches
 	branch) _complete_branch $command _all_branches ;;
 	rebase) _complete_branch $command _all_branches ;;

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

* [StGIT PATCH 6/6] Fixed completion function hardcoding .git/.
  2007-08-02 20:18 [StGIT PATCH 0/6] Various contrib/ updates Yann Dirson
                   ` (4 preceding siblings ...)
  2007-08-02 20:18 ` [StGIT PATCH 5/6] Provide file completion for add/resolved/refresh based on status Yann Dirson
@ 2007-08-02 20:18 ` Yann Dirson
  2007-08-20 17:24 ` [StGIT PATCH 0/6] Various contrib/ updates Catalin Marinas
  6 siblings, 0 replies; 8+ messages in thread
From: Yann Dirson @ 2007-08-02 20:18 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

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

 contrib/stgit-completion.bash |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/contrib/stgit-completion.bash b/contrib/stgit-completion.bash
index 2d0d5f2..7ae9e6a 100644
--- a/contrib/stgit-completion.bash
+++ b/contrib/stgit-completion.bash
@@ -108,7 +108,7 @@ _all_other_patches ()
 _all_branches ()
 {
     local g=$(_gitdir)
-    [ "$g" ] && (cd .git/patches/ && echo *)
+    [ "$g" ] && (cd $g/patches/ && echo *)
 }
 
 _conflicting_files ()

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

* Re: [StGIT PATCH 0/6] Various contrib/ updates
  2007-08-02 20:18 [StGIT PATCH 0/6] Various contrib/ updates Yann Dirson
                   ` (5 preceding siblings ...)
  2007-08-02 20:18 ` [StGIT PATCH 6/6] Fixed completion function hardcoding .git/ Yann Dirson
@ 2007-08-20 17:24 ` Catalin Marinas
  6 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2007-08-20 17:24 UTC (permalink / raw)
  To: Yann Dirson; +Cc: git

On 02/08/07, Yann Dirson <ydirson@altern.org> wrote:
> This series, asside from small fixes, enhance the bash completion to
> be aware of file status (notably, makes it much more comfortable to
> refresh only selective files), and introduces 2 new contrib scripts:

Thanks.

> I already made heavy use of the scripts in the last days, and I rate
> them as good candidates for 0.13.1.

Should we keep 0.13.1 a bug-fix release only? I.e. not adding the new
contrib scripts.

-- 
Catalin

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

end of thread, other threads:[~2007-08-20 17:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-02 20:18 [StGIT PATCH 0/6] Various contrib/ updates Yann Dirson
2007-08-02 20:18 ` [StGIT PATCH 1/6] Improve stg-fold-files-from doc Yann Dirson
2007-08-02 20:18 ` [StGIT PATCH 2/6] New contrib scripts: stg-dispatch and stg-show Yann Dirson
2007-08-02 20:18 ` [StGIT PATCH 3/6] Add -O flag to stg-fold-files-from Yann Dirson
2007-08-02 20:18 ` [StGIT PATCH 4/6] Add a no-act flag to stg-dispatch and stg-fold-file-from Yann Dirson
2007-08-02 20:18 ` [StGIT PATCH 5/6] Provide file completion for add/resolved/refresh based on status Yann Dirson
2007-08-02 20:18 ` [StGIT PATCH 6/6] Fixed completion function hardcoding .git/ Yann Dirson
2007-08-20 17:24 ` [StGIT PATCH 0/6] Various contrib/ updates 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).