From: Pavel Roskin <proski@gnu.org>
To: git <git@vger.kernel.org>
Subject: [PATCH 7/8] cogito: Fix cg-tag to use cg-object-id
Date: Mon, 19 Sep 2005 22:27:42 -0400 [thread overview]
Message-ID: <1127183262.31115.38.camel@dv> (raw)
Fix cg-tag to use cg-object-id
Add new option -n (normalize only) to cg-object-id. Mark all options
as mutually exclusive and check it. Call 'cg-object-id -n' from cg-tag.
diff --git a/cg-object-id b/cg-object-id
--- a/cg-object-id
+++ b/cg-object-id
@@ -8,10 +8,13 @@
# If the ID is not provided, HEAD is used. The default behavior is to
# show the commit ID.
#
# OPTIONS
# -------
+# -n::
+# Normalize only - don't check the object type.
+#
# -p::
# Get ID of parent commit(s) to a given revision or HEAD.
# NOTE: Multiple SHA1s separated by newlines will be returned for
# commits with multiple parents.
#
@@ -19,11 +22,11 @@
# Get ID of tree associated with given commit or HEAD.
#
# OBJECT_ID::
# An ID resolving to a commit.
-USAGE="cg-object-id [-p] [-t] [OBJECT_ID]"
+USAGE="cg-object-id [-n | -p | -t] [OBJECT_ID]"
. ${COGITO_LIB}cg-Xlib
# Normalize argument. The normalized SHA1 ID is put to $normid.
@@ -95,12 +98,15 @@ normalize_id()
show_parent=
show_tree=
+normalize_only=
while optparse; do
- if optparse -p; then
+ if optparse -n; then
+ normalize_only=1
+ elif optparse -p; then
show_parent=1
elif optparse -t; then
show_tree=1
else
optfail
@@ -111,17 +117,22 @@ done
case $_cg_cmd in
*parent*) show_parent=1;;
*tree*) show_tree=1;;
esac
-if [ "$show_parent" -a "$show_tree" ]; then
- echo "Cannot show parent and tree ID at the same time." >&2
- exit 1
-fi
+case "$show_parent$show_tree$normalize_only" in
+ 11*) usage;;
+esac
id="${ARGS[0]}"
normalize_id "$id"
+
+if [ "$normalize_only" ]; then
+ echo $normid
+ exit 0
+fi
+
[ "$type" ] || type=$(git-cat-file -t "$normid")
if [ -z "$show_tree" ]; then
if [ "$type" != "commit" ]; then
echo "Invalid commit id: $normid" >&2
diff --git a/cg-tag b/cg-tag
--- a/cg-tag
+++ b/cg-tag
@@ -45,12 +45,12 @@ done
name="${ARGS[0]}"
id="${ARGS[1]}"
[ "$name" ] || usage
-id=$(. ${COGITO_LIB}cg-Xnormid "$id") || exit 1
-type=${id#* }; [ "$type" ] || type=$(git-cat-file -t "$id")
+id=$(cg-object-id -n "$id") || exit 1
+type=$(git-cat-file -t "$id")
id=${id% *}
(echo $name | egrep -qv '[^a-zA-Z0-9_.@!:-]') || \
die "name contains invalid characters"
--
Regards,
Pavel Roskin
reply other threads:[~2005-09-20 2:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1127183262.31115.38.camel@dv \
--to=proski@gnu.org \
--cc=git@vger.kernel.org \
/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).