git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Lesh <eclesh@ucla.edu>
To: jsipek@cs.sunysb.edu
Cc: git@vger.kernel.org, Eric Lesh <eclesh@ucla.edu>
Subject: [GUILT PATCH 3/5] guilt-select: Select guards to apply when pushing patches
Date: Mon, 30 Jul 2007 20:11:19 -0700	[thread overview]
Message-ID: <11858514811245-git-send-email-eclesh@ucla.edu> (raw)
In-Reply-To: <1185851481190-git-send-email-eclesh@ucla.edu>

guilt-select chooses guards that alter which patches will be applied
with a guilt-push.  The selected guards are stored in
.git/patches/$branch/guards.

Signed-off-by: Eric Lesh <eclesh@ucla.edu>
---
 Documentation/guilt-select.txt |   47 ++++++++++++++++++++++++++++++++++++
 Documentation/guilt.txt        |    5 +++-
 guilt                          |    1 +
 guilt-select                   |   52 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 104 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/guilt-select.txt
 create mode 100755 guilt-select

diff --git a/Documentation/guilt-select.txt b/Documentation/guilt-select.txt
new file mode 100644
index 0000000..12f19b4
--- /dev/null
+++ b/Documentation/guilt-select.txt
@@ -0,0 +1,47 @@
+guilt-select(1)
+===============
+
+NAME
+----
+guilt-select - Select guards to apply when pushing patches
+
+SYNOPSIS
+--------
+include::usage-guilt-select.txt[]
+
+DESCRIPTION
+-----------
+Select guards to apply when pushing patches.
+
+Guards are selected without the + or - prefix.  Patches are applied in
+the following way:
+
+* An unguarded patch is always applied.
+
+* A patch with a positive guard is applied *only* if the guard is
+selected with guilt-select.
+
+* A patch with a negative guard is applied *unless* the guard is
+selected with guilt-select.
+
+OPTIONS
+-------
+-n|--none::
+        Remove all selected guards
+--pop::
+        Pop back to the first guarded patch
+--reapply::
+        Pop back to first guarded patch, select a new guard, and
+        push
+-s|--series::
+        List all guards listed in the series file
+
+Author
+------
+Written by Eric Lesh <eclesh@ucla.edu>
+
+Documentation
+-------------
+Documentation by Eric Lesh <eclesh@ucla.edu>
+
+include::footer.txt[]
diff --git a/Documentation/guilt.txt b/Documentation/guilt.txt
index 31dbc0e..11c2ca9 100644
--- a/Documentation/guilt.txt
+++ b/Documentation/guilt.txt
@@ -33,7 +33,10 @@ PATCHES DIRECTORY
 In Guilt, all the patches are stored in .git/patches/$branch/, where $branch
 is the name of the branch being worked on. This means that one can have a
 independent series of patches for each branch present in the repository.
-Each of these per-branch directories contains 2 special files:
+Each of these per-branch directories contains 3 special files:
+
+guards: This file contains any guards that should be applied to the
+series when pushing. It is only present when guards are selected.
 
 series: This file contains a list of all the patch filenames relative to the
 per-branch patch directory. Empty and commented out lines are ignored.
diff --git a/guilt b/guilt
index 6af590c..b289026 100755
--- a/guilt
+++ b/guilt
@@ -666,6 +666,7 @@ fi
 # very useful files
 series="$GUILT_DIR/$branch/series"
 applied="$GUILT_DIR/$branch/status"
+guards_file="$GUILT_DIR/$branch/guards"
 
 # determine an editor to use for anything interactive (fall back to vi)
 editor="vi"
diff --git a/guilt-select b/guilt-select
new file mode 100755
index 0000000..378ca98
--- /dev/null
+++ b/guilt-select
@@ -0,0 +1,52 @@
+#!/bin/sh
+#
+# Copyright (c) Eric Lesh, 2007
+#
+
+USAGE="[-n|--none|-s|--series|[--pop|--reapply] <guards...>]"
+. `dirname $0`/guilt
+
+select_guards()
+{
+	for x in "$@"; do
+		if [ $(printf %s "$x" | grep -e "^[+-]") ]; then
+			die "'$x' cannot begin with + or -."
+		fi
+	done
+	echo "$@" | sed -e 's/ /\n/g' | sort | uniq > "$guards_file"
+}
+
+if [ $# == 0 ]; then
+	if [ -s "$guards_file" ]; then
+		cat "$guards_file"
+	else
+		echo >&2 "No guards applied"
+	fi
+	exit 0
+fi
+
+case $1 in
+	-n|--none)
+		rm -f "$guards_file"
+		;;
+	--pop)
+		guilt-pop -a
+		shift
+		select_guards "$@"
+		;;
+	--reapply)
+		top=`get_top`
+		guilt-pop -a
+		shift
+		select_guards "$@"
+		guilt-push "$top"
+		;;
+	-s|--series)
+		(get_series | while read patch; do
+			get_guards "$patch"
+		done) | sed -e 's/ /\n/g' | sort | uniq
+		;;
+	*)
+		select_guards "$@"
+		;;
+esac
-- 
1.5.2

  parent reply	other threads:[~2007-07-31  3:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-31  3:11 [GUILT PATCH v2 0/5] Add guards to guilt Eric Lesh
2007-07-31  3:11 ` [GUILT PATCH 1/5] get_series: Remove comments from end of series lines Eric Lesh
2007-07-31  3:50   ` Josef Sipek
2007-07-31  3:11 ` [GUILT PATCH 2/5] guilt-guard: Assign guards to patches in series Eric Lesh
2007-07-31  4:05   ` Josef Sipek
2007-08-09  7:34     ` Eric Lesh
2007-08-09  8:17       ` David Kastrup
2007-08-09  8:22         ` Thomas Adam
2007-08-09  8:43           ` David Kastrup
2007-08-09  8:53           ` Eric Lesh
2007-08-09  9:01         ` Eric Lesh
2007-08-09 13:47       ` Josef Sipek
2007-07-31  3:11 ` Eric Lesh [this message]
2007-07-31  3:11 ` [GUILT PATCH 4/5] get_series: return guarded patches only Eric Lesh
2007-07-31  3:11 ` [GUILT PATCH 5/5] Guards test suite Eric Lesh
2007-07-31  3:42 ` [GUILT PATCH v2 0/5] Add guards to guilt Josef Sipek

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=11858514811245-git-send-email-eclesh@ucla.edu \
    --to=eclesh@ucla.edu \
    --cc=git@vger.kernel.org \
    --cc=jsipek@cs.sunysb.edu \
    /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).