git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonas Fonseca <fonseca@diku.dk>
To: Petr Baudis <pasky@ucw.cz>, git@vger.kernel.org
Subject: [PATCH] cg-object-id: cleanup id verifying
Date: Wed, 7 Dec 2005 22:39:29 +0100	[thread overview]
Message-ID: <20051207213929.GB25890@diku.dk> (raw)

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>

---
commit 36c0d9fae209ab7fa889333e8eebef22e7f0f55c
tree 364122ed83e2b920b0f0f5fe18c608a22aea6d07
parent 964e5ec2dd0ff3b073fbb9f3ad6f11c640a96a04
author Jonas Fonseca <fonseca@diku.dk> Wed, 07 Dec 2005 08:11:43 +0100
committer Jonas Fonseca <fonseca@antimatter.localdomain> Wed, 07 Dec 2005 08:11:43 +0100

 cg-object-id |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/cg-object-id b/cg-object-id
index c7efa8a..56d9f91 100755
--- a/cg-object-id
+++ b/cg-object-id
@@ -50,6 +50,7 @@ normalize_id()
 	revid="$(git-rev-parse --verify "$id^0" 2>/dev/null)"
 	if [ "$revid" ]; then
 		id="$revid"
+		valid=1
 
 	# Short id's must be lower case and at least 4 digits.
 	elif [[ "$id" == [0-9a-f][0-9a-f][0-9a-f][0-9a-f]* ]]; then
@@ -60,8 +61,8 @@ normalize_id()
 		idmatch=($_git_objects/$idpref/$idpost*)
 
 		if [ ${#idmatch[*]} -eq 1 ] && [ -r "$idmatch" ]; then
-			exid=$idpref${idmatch#$_git_objects/$idpref/}
-			[ ${#exid} -eq 40 ] && [ "$(git-rev-parse --revs-only "$exid")" ] && id="$exid"
+			id=$idpref${idmatch#$_git_objects/$idpref/}
+			[ ${#id} -eq 40 ] && [ "$(git-rev-parse --revs-only "$id")" ] && valid=1
 		elif [ ${#idmatch[*]} -gt 1 ]; then
 			echo "Ambiguous id: $id" >&2
 			echo "${idmatch[@]}" >&2
@@ -69,13 +70,12 @@ normalize_id()
 		fi
 	fi
 
-	valid=; [ ${#id} -eq 40 ] && [ "$(git-rev-parse --revs-only "$id")" ] && valid=1
-	if ([ "$id" ] && [ "$id" != " " ]) && [ ! "$valid" ]; then
+	if [ "$id" != " " ] && [ ! "$valid" ]; then
 		reqsecs=$(date --date="$id" +'%s' 2>/dev/null)
 
 		if [ "$reqsecs" ]; then
 			id=$(git-rev-list --min-age=$reqsecs --max-count=1 HEAD)
-			valid=; [ ${#id} -eq 40 ] && [ "$(git-rev-parse --revs-only "$id")" ] && valid=1
+			[ ${#id} -eq 40 ] && [ "$(git-rev-parse --revs-only "$id")" ] && valid=1
 		fi
 	fi
 

-- 
Jonas Fonseca

                 reply	other threads:[~2005-12-07 21:39 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=20051207213929.GB25890@diku.dk \
    --to=fonseca@diku.dk \
    --cc=git@vger.kernel.org \
    --cc=pasky@ucw.cz \
    /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).