git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 2/3] sh-setup: add new peel_committish() helper
Date: Fri, 14 Jun 2013 18:47:51 +0530	[thread overview]
Message-ID: <1371215872-9796-3-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1371215872-9796-1-git-send-email-artagnon@gmail.com>

The normal way to check whether a certain revision resolves to a valid
commit is:

  $ git rev-parse --verify $REV^0

Unfortunately, this does not work when $REV is of the type :/quuxery.
Write a helper to work around this limitation.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 git-sh-setup.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 2f78359..7a964ad 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -313,3 +313,15 @@ then
 	}
 	: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
 fi
+
+peel_committish () {
+	case "$1" in
+	:/*)
+		peeltmp=$(git rev-parse --verify "$1") &&
+		git rev-parse --verify "${peeltmp}^0"
+		;;
+	*)
+		git rev-parse --verify "${1}^0"
+		;;
+	esac
+}
-- 
1.8.3.1.381.g12ca056.dirty

  parent reply	other threads:[~2013-06-14 13:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-14 13:17 [PATCH 0/3] Get rebase to work with :/foomery committish Ramkumar Ramachandra
2013-06-14 13:17 ` [PATCH 1/3] t/rebase: add failing tests for a peculiar revision Ramkumar Ramachandra
2013-06-14 13:17 ` Ramkumar Ramachandra [this message]
2013-06-14 16:05   ` [PATCH 2/3] sh-setup: add new peel_committish() helper Philip Oakley
2013-06-14 16:18     ` Ramkumar Ramachandra
2013-06-14 16:44       ` Philip Oakley
2013-06-14 13:17 ` [PATCH 3/3] rebase: use peel_committish() where appropriate Ramkumar Ramachandra
2013-06-14 16:56   ` Junio C Hamano
2013-06-15 13:47     ` Ramkumar Ramachandra
2013-06-17  2:52       ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2013-06-13 18:15 [PATCH 0/3] Support :/quuxery in rebase (early preview) Ramkumar Ramachandra
2013-06-13 18:16 ` [PATCH 2/3] sh-setup: add new peel_committish() helper Ramkumar Ramachandra

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1371215872-9796-3-git-send-email-artagnon@gmail.com \
    --to=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).