{"thread":{"id":"7174","subject":"[GUILT][RFC] Autotagging","startedAt":"2007-03-10T04:46:21Z","lastAt":"2007-03-10T04:46:23Z","messageCount":3,"participants":["Josef 'Jeff' Sipek"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"36723","messageId":"11735019831915-git-send-email-jsipek@cs.sunysb.edu","threadId":"7174","inReplyTo":null,"subject":"[GUILT][RFC] Autotagging","fromName":"Josef 'Jeff' Sipek","fromEmail":"jsipek@cs.sunysb.edu","sentAt":"2007-03-10T04:46:21Z","receivedAt":"2007-03-10T04:46:21Z","isPatch":false,"sender":{"key":"jsipek@cs.sunysb.edu","avatar":null},"body":"Greetings all!\n\nRecently, it has been brought to my attention that it would be nice to be\nable to refer to the top/bottom/base of the patch stack in Guilt by a name\ninstead of fishing around the log for the hash. I quickly coded up the\nfollowing solution (which I call \"autotagging\"), which creates unannotated\ntags for the top (topmost applied patch), bottom (first applied patch), and\nbase (parent of bottom) in with this naming scheme:\n\n\t${branch}_top\n\t${branch}_bottom\n\t${branch}_base\n\nThe branch name is necessary as each branch has its own series of patches,\nand potentially different history to begin with.\n\nOf course, I included an option to disable this feature (see patch 2) - just\nset guilt.autotag=0 in your git config.\n\nBefore I merge this into Guilt master, I was hoping for some feedback. Just\nin case I completely missed something obvious, or perhaps there is a better\nway to name the branches :)\n\nThanks,\n\nJosef \"Jeff\" Sipek.\n"},{"id":"36725","messageId":"11735019831879-git-send-email-jsipek@cs.sunysb.edu","threadId":"7174","inReplyTo":"11735019831915-git-send-email-jsipek@cs.sunysb.edu","subject":"[PATCH 1/2] Automatically create unannotated tags for top, bottom, and base of the stack","fromName":"Josef 'Jeff' Sipek","fromEmail":"jsipek@cs.sunysb.edu","sentAt":"2007-03-10T04:46:22Z","receivedAt":"2007-03-10T04:46:22Z","isPatch":true,"sender":{"key":"jsipek@cs.sunysb.edu","avatar":null},"body":"On every push or pop operation (refresh is a pop followed by a push), update\nthe stack top (${branch}_top), stack bottom (${branch}_bottom), and stack\nbase (${branch}_base) tags.\n\nTop:\tTopmost applied patch/commit\nBottom:\tBottommost applied patch/commit\nBase:\tCommit on top of which the bottom most patch is applied\n\nHaving these three tags, one can easily get the log/diff/other information\nonly for commits that are (or are not!) part of the patch stack.\n\nSigned-off-by: Josef 'Jeff' Sipek <jsipek@cs.sunysb.edu>\n---\n guilt |   34 ++++++++++++++++++++++++++++++++--\n 1 files changed, 32 insertions(+), 2 deletions(-)\n\ndiff --git a/guilt b/guilt\nindex 43e7842..3dbe4b6 100755\n--- a/guilt\n+++ b/guilt\n@@ -277,6 +277,33 @@ function pop_many_patches\n \tmv \"$applied.tmp\" \"$applied\"\n \n \tcd - 2>&1 >/dev/null\n+\n+\t# update references to top, bottom, and base\n+\tupdate_stack_tags\n+}\n+\n+# usage: update_stack_tags\n+function update_stack_tags\n+{\n+\tif [ `wc -l < $applied` -gt 0 ]; then\n+\t\t# there are patches applied, therefore we must get the top,\n+\t\t# bottom and base hashes, and update the tags\n+\n+\t\tlocal top_hash=`git-rev-parse HEAD`\n+\t\tlocal bottom_hash=`head -1 < $applied | cut -d: -f1`\n+\t\tlocal base_hash=`git-rev-parse $bottom_hash^`\n+\n+\t\techo $top_hash > \"$GIT_DIR/refs/tags/${branch}_top\"\n+\t\techo $bottom_hash > \"$GIT_DIR/refs/tags/${branch}_bottom\"\n+\t\techo $base_hash > \"$GIT_DIR/refs/tags/${branch}_base\"\n+\telse\n+\t\t# there are no patches applied, therefore we must remove the\n+\t\t# tags to old top, bottom, and base\n+\n+\t\trm -f \"$GIT_DIR/refs/tags/${branch}_top\"\n+\t\trm -f \"$GIT_DIR/refs/tags/${branch}_bottom\"\n+\t\trm -f \"$GIT_DIR/refs/tags/${branch}_base\"\n+\tfi\n }\n \n # usage: push_patch patchname [bail_action]\n@@ -349,6 +376,11 @@ function push_patch\n \t# mark patch as applied\n \techo \"$commitish:$pname\" >> $applied\n \n+\tcd - 2>&1 >/dev/null\n+\n+\t# update references to top, bottom, and base of the stack\n+\tupdate_stack_tags\n+\n \t# restore original GIT_AUTHOR_{NAME,EMAIL}\n \tif [ ! -z \"$author_str\" ]; then\n \t\tif [ ! -z \"$backup_author_name\" ]; then\n@@ -376,8 +408,6 @@ function push_patch\n \n \trm -f /tmp/guilt.msg.$$ /tmp/guilt.log.$$\n \n-\tcd - 2>&1 >/dev/null\n-\n \treturn $bail\n }\n \n-- \n1.5.0.3.268.g3dda\n"},{"id":"36724","messageId":"11735019832141-git-send-email-jsipek@cs.sunysb.edu","threadId":"7174","inReplyTo":"11735019831915-git-send-email-jsipek@cs.sunysb.edu","subject":"[PATCH 2/2] Autotag: Read guilt.autotag config var and tag commits only if this feature is enabled","fromName":"Josef 'Jeff' Sipek","fromEmail":"jsipek@cs.sunysb.edu","sentAt":"2007-03-10T04:46:23Z","receivedAt":"2007-03-10T04:46:23Z","isPatch":true,"sender":{"key":"jsipek@cs.sunysb.edu","avatar":null},"body":"Some users may not want to have guilt automatically tag the top, bottom, and\nbase of the stack. Allow them to disable such functionality by setting\nguilt.autotag=0 in their git config file.\n\nguilt-init now accepts a new parameter '-n' to automatically set\nguilt.autotag=0 in the current repository.\n\nSigned-off-by: Josef 'Jeff' Sipek <jsipek@cs.sunysb.edu>\n---\n Documentation/guilt-init.txt |    8 +++++++-\n guilt                        |   15 +++++++++++++++\n guilt-init                   |   15 ++++++++++++---\n 3 files changed, 34 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/guilt-init.txt b/Documentation/guilt-init.txt\nindex e643668..a245c6e 100644\n--- a/Documentation/guilt-init.txt\n+++ b/Documentation/guilt-init.txt\n@@ -8,12 +8,18 @@ guilt-init - Initialize guilt for use in a git repository\n \n SYNOPSIS\n --------\n-'guilt-init' \n+'guilt-init [-n]' \n \n DESCRIPTION\n -----------\n Initialize a git repository for use with guilt\n \n+OPTIONS\n+-------\n+-n::\n+\tDo not automatically create stack top, bottom, and base tags (sets\n+\tguilt.autotag config variable to 0).\n+\n EXAMPLES\n --------\n First, get a repository to work on. Here's one that we'll use as an example:\ndiff --git a/guilt b/guilt\nindex 3dbe4b6..e7c22d2 100755\n--- a/guilt\n+++ b/guilt\n@@ -285,6 +285,11 @@ function pop_many_patches\n # usage: update_stack_tags\n function update_stack_tags\n {\n+\t# bail if autotagging is not enabled\n+\tif [ $autotag -eq 0 ]; then\n+\t\treturn 0\n+\tfi\n+\n \tif [ `wc -l < $applied` -gt 0 ]; then\n \t\t# there are patches applied, therefore we must get the top,\n \t\t# bottom and base hashes, and update the tags\n@@ -480,12 +485,22 @@ function munge_hash_range\n \tfi\n }\n \n+#\n # Some constants\n+#\n \n # used for: git-apply -C <val>\n guilt_push_diff_context=1\n \n #\n+# Parse any part of .git/config that belongs to us\n+#\n+\n+# autotag?\n+autotag=`git-config guilt.autotag`\n+[ -z \"$autotag\" ] && autotag=1\n+\n+#\n # The following gets run every time this file is source'd\n #\n \ndiff --git a/guilt-init b/guilt-init\nindex 1277998..feacf95 100755\n--- a/guilt-init\n+++ b/guilt-init\n@@ -5,11 +5,19 @@\n \n DO_NOT_CHECK_BRANCH_EXISTENCE=1\n \n+USAGE=\"[-n]\"\n . guilt\n \n-if [ $# -ne 0 ]; then\n-\tusage\n-fi\n+autotag=1\n+\n+while case $# in 0) break ;; esac; do\n+\tif [ \"$1\" = \"-n\" ]; then\n+\t\tautotag=0\n+\t\tshift\n+\telse\n+\t\tusage\n+\tfi\n+done\n \n if [ -d \"$GUILT_DIR/$branch\" ]; then\n \tdie \"Branch $branch appears to be already initialized (GIT_DIR=$GIT_DIR)\"\n@@ -20,3 +28,4 @@ mkdir $GUILT_DIR/$branch\n touch $GUILT_DIR/$branch/series\n touch $GUILT_DIR/$branch/status\n \n+git-config --int --replace-all guilt.autotag $autotag\n-- \n1.5.0.3.268.g3dda\n"}]}