{"thread":{"id":"1877","subject":"[PATCH 7/8] cogito: Fix cg-tag to use cg-object-id","startedAt":"2005-09-20T02:27:42Z","lastAt":"2005-09-20T02:27:42Z","messageCount":1,"participants":["Pavel Roskin"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"8953","messageId":"1127183262.31115.38.camel@dv","threadId":"1877","inReplyTo":null,"subject":"[PATCH 7/8] cogito: Fix cg-tag to use cg-object-id","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2005-09-20T02:27:42Z","receivedAt":"2005-09-20T02:27:42Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Fix cg-tag to use cg-object-id\n\nAdd new option -n (normalize only) to cg-object-id.  Mark all options\nas mutually exclusive and check it.  Call 'cg-object-id -n' from cg-tag.\n\ndiff --git a/cg-object-id b/cg-object-id\n--- a/cg-object-id\n+++ b/cg-object-id\n@@ -8,10 +8,13 @@\n # If the ID is not provided, HEAD is used.  The default behavior is to\n # show the commit ID.\n #\n # OPTIONS\n # -------\n+# -n::\n+#\tNormalize only - don't check the object type.\n+#\n # -p::\n #\tGet ID of parent commit(s) to a given revision or HEAD.\n #\tNOTE: Multiple SHA1s separated by newlines will be returned for\n #\tcommits with multiple parents.\n #\n@@ -19,11 +22,11 @@\n #\tGet ID of tree associated with given commit or HEAD.\n #\n # OBJECT_ID::\n #\tAn ID resolving to a commit.\n \n-USAGE=\"cg-object-id [-p] [-t] [OBJECT_ID]\"\n+USAGE=\"cg-object-id [-n | -p | -t] [OBJECT_ID]\"\n \n . ${COGITO_LIB}cg-Xlib\n \n \n # Normalize argument.  The normalized SHA1 ID is put to $normid.\n@@ -95,12 +98,15 @@ normalize_id()\n \n \n \n show_parent=\n show_tree=\n+normalize_only=\n while optparse; do\n-\tif optparse -p; then\n+\tif optparse -n; then\n+\t\tnormalize_only=1\n+\telif optparse -p; then\n \t\tshow_parent=1\n \telif optparse -t; then\n \t\tshow_tree=1\n \telse\n \t\toptfail\n@@ -111,17 +117,22 @@ done\n case $_cg_cmd in\n \t*parent*) show_parent=1;;\n \t*tree*) show_tree=1;;\n esac\n \n-if [ \"$show_parent\" -a \"$show_tree\" ]; then\n-\techo \"Cannot show parent and tree ID at the same time.\" >&2\n-\texit 1\n-fi\n+case \"$show_parent$show_tree$normalize_only\" in\n+\t11*)\tusage;;\n+esac\n \n id=\"${ARGS[0]}\"\n normalize_id \"$id\"\n+\n+if [ \"$normalize_only\" ]; then\n+\techo $normid\n+\texit 0\n+fi\n+\n [ \"$type\" ] || type=$(git-cat-file -t \"$normid\")\n \n if [ -z \"$show_tree\" ]; then\n \tif [ \"$type\" != \"commit\" ]; then\n \t\techo \"Invalid commit id: $normid\" >&2\ndiff --git a/cg-tag b/cg-tag\n--- a/cg-tag\n+++ b/cg-tag\n@@ -45,12 +45,12 @@ done\n name=\"${ARGS[0]}\"\n id=\"${ARGS[1]}\"\n \n [ \"$name\" ] || usage\n \n-id=$(. ${COGITO_LIB}cg-Xnormid \"$id\") || exit 1\n-type=${id#* }; [ \"$type\" ] || type=$(git-cat-file -t \"$id\")\n+id=$(cg-object-id -n \"$id\") || exit 1\n+type=$(git-cat-file -t \"$id\")\n id=${id% *}\n \n (echo $name | egrep -qv '[^a-zA-Z0-9_.@!:-]') || \\\n \tdie \"name contains invalid characters\"\n \n\n-- \nRegards,\nPavel Roskin\n"}]}