git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] Automatically create unannotated tags for top, bottom, and base of the stack

From
JSJosef 'Jeff' Sipek <jsipek@cs.sunysb.edu>
Date
Mar 10, 2007, 04:46 UTC
Message-ID
<11735019831879-git-send-email-jsipek@cs.sunysb.edu>
In-Reply-To
<11735019831915-git-send-email-jsipek@cs.sunysb.edu>

On every push or pop operation (refresh is a pop followed by a push), update the stack top (${branch}_top), stack bottom (${branch}_bottom), and stack base (${branch}_base) tags.

Top: Topmost applied patch/commit Bottom: Bottommost applied patch/commit Base: Commit on top of which the bottom most patch is applied

Having these three tags, one can easily get the log/diff/other information only for commits that are (or are not!) part of the patch stack.

Signed-off-by: Josef 'Jeff' Sipek <jsipek@cs.sunysb.edu>
---
 guilt |   34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/guilt b/guilt
index 43e7842..3dbe4b6 100755
--- a/guilt
+++ b/guilt
@@ -277,6 +277,33 @@ function pop_many_patches
 	mv "$applied.tmp" "$applied"
 
 	cd - 2>&1 >/dev/null
+
+	# update references to top, bottom, and base
+	update_stack_tags
+}
+
+# usage: update_stack_tags
+function update_stack_tags
+{
+	if [ `wc -l < $applied` -gt 0 ]; then
+		# there are patches applied, therefore we must get the top,
+		# bottom and base hashes, and update the tags
+
+		local top_hash=`git-rev-parse HEAD`
+		local bottom_hash=`head -1 < $applied | cut -d: -f1`
+		local base_hash=`git-rev-parse $bottom_hash^`
+
+		echo $top_hash > "$GIT_DIR/refs/tags/${branch}_top"
+		echo $bottom_hash > "$GIT_DIR/refs/tags/${branch}_bottom"
+		echo $base_hash > "$GIT_DIR/refs/tags/${branch}_base"
+	else
+		# there are no patches applied, therefore we must remove the
+		# tags to old top, bottom, and base
+
+		rm -f "$GIT_DIR/refs/tags/${branch}_top"
+		rm -f "$GIT_DIR/refs/tags/${branch}_bottom"
+		rm -f "$GIT_DIR/refs/tags/${branch}_base"
+	fi
 }
 
 # usage: push_patch patchname [bail_action]
@@ -349,6 +376,11 @@ function push_patch
 	# mark patch as applied
 	echo "$commitish:$pname" >> $applied
 
+	cd - 2>&1 >/dev/null
+
+	# update references to top, bottom, and base of the stack
+	update_stack_tags
+
 	# restore original GIT_AUTHOR_{NAME,EMAIL}
 	if [ ! -z "$author_str" ]; then
 		if [ ! -z "$backup_author_name" ]; then
@@ -376,8 +408,6 @@ function push_patch
 
 	rm -f /tmp/guilt.msg.$$ /tmp/guilt.log.$$
 
-	cd - 2>&1 >/dev/null
-
 	return $bail
 }
 
-- 
1.5.0.3.268.g3dda
Previous: Josef 'Jeff' SipekNext: Josef 'Jeff' Sipek
Message 2 of 3 in “[GUILT][RFC] Autotagging”
  1. Josef 'Jeff' SipekMar 10, 2007
  2. 1/2 Automatically create unannotated tags for top, bottom, and base of the stackJosef 'Jeff' Sipek, Mar 10, 2007
  3. 2/2 Autotag: Read guilt.autotag config var and tag commits only if this feature is enabledJosef 'Jeff' Sipek, Mar 10, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.