git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <chriscool@tuxfamily.org>
To: Junio Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: [PATCH 1/2] Add [-s|--hash] option to Linus' show-ref.
Date: Sun, 17 Sep 2006 06:20:24 +0200	[thread overview]
Message-ID: <20060917062024.c476e07d.chriscool@tuxfamily.org> (raw)

With this option only the sha1 hash of the ref should
be printed.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 builtin-show-ref.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/builtin-show-ref.c b/builtin-show-ref.c
index 161b236..577d934 100644
--- a/builtin-show-ref.c
+++ b/builtin-show-ref.c
@@ -3,9 +3,10 @@ #include "refs.h"
 #include "object.h"
 #include "tag.h"
 
-static const char show_ref_usage[] = "git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--deref] [--tags] [--heads] [--] [pattern*]";
+static const char show_ref_usage[] = "git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--deref] [-s|--hash] [--tags] [--heads] [--] [pattern*]";
 
-static int deref_tags = 0, show_head = 0, tags_only = 0, heads_only = 0, found_match = 0, verify = 0, quiet = 0;
+static int deref_tags = 0, show_head = 0, tags_only = 0, heads_only = 0,
+	found_match = 0, verify = 0, quiet = 0, hash_only = 0;
 static const char **pattern;
 
 static int show_ref(const char *refname, const unsigned char *sha1)
@@ -50,7 +51,10 @@ match:
 	}
 	if (quiet)
 		return 0;
-	printf("%s %s\n", sha1_to_hex(sha1), refname);
+	if (hash_only)
+		printf("%s\n", sha1_to_hex(sha1));
+	else
+		printf("%s %s\n", sha1_to_hex(sha1), refname);
 	if (deref_tags && obj->type == OBJ_TAG) {
 		obj = deref_tag(obj, refname, 0);
 		printf("%s %s^{}\n", sha1_to_hex(obj->sha1), refname);
@@ -86,6 +90,10 @@ int cmd_show_ref(int argc, const char **
 			deref_tags = 1;
 			continue;
 		}
+		if (!strcmp(arg, "-s") || !strcmp(arg, "--hash")) {
+			hash_only = 1;
+			continue;
+		}
 		if (!strcmp(arg, "--verify")) {
 			verify = 1;
 			continue;
-- 
1.4.2.1.gea00f-dirty

             reply	other threads:[~2006-09-17  4:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-17  4:20 Christian Couder [this message]
2006-09-17  4:32 ` [PATCH 2/2] Use Linus' show ref in "git-branch.sh" Christian Couder
2006-09-17  7:15 ` [PATCH 1/2] Add [-s|--hash] option to Linus' show-ref Jakub Narebski
2006-09-17 11:32   ` Christian Couder

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=20060917062024.c476e07d.chriscool@tuxfamily.org \
    --to=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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).