git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Support :/quuxery in rebase (early preview)
@ 2013-06-13 18:15 Ramkumar Ramachandra
  2013-06-13 18:16 ` [PATCH 1/3] t/rebase: add failing tests for a peculiar revision Ramkumar Ramachandra
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ramkumar Ramachandra @ 2013-06-13 18:15 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

Hi,

So this is a series to make git rebase [-i] :/quuxery possible.  It is
an early preview, because I have not tested that :/quuxery works as
the <onto>, <upstream>, and <branch>.

Thanks.

Ramkumar Ramachandra (3):
  t/rebase: add failing tests for a peculiar revision
  sh-setup: add new peel_committish() helper
  rebase: use peel_committish() where appropriate

 git-rebase.sh                 |  6 +++---
 git-sh-setup.sh               | 13 +++++++++++++
 t/t3400-rebase.sh             |  8 ++++++++
 t/t3404-rebase-interactive.sh |  8 ++++++++
 4 files changed, 32 insertions(+), 3 deletions(-)

-- 
1.8.3.1.381.g31c8856.dirty

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] t/rebase: add failing tests for a peculiar revision
  2013-06-13 18:15 [PATCH 0/3] Support :/quuxery in rebase (early preview) Ramkumar Ramachandra
@ 2013-06-13 18:16 ` Ramkumar Ramachandra
  2013-06-13 18:16 ` [PATCH 2/3] sh-setup: add new peel_committish() helper Ramkumar Ramachandra
  2013-06-13 18:16 ` [PATCH 3/3] rebase: use peel_committish() where appropriate Ramkumar Ramachandra
  2 siblings, 0 replies; 4+ messages in thread
From: Ramkumar Ramachandra @ 2013-06-13 18:16 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

The following commands fail, even if :/quuxery resolves to a perfectly
valid commit:

  $ git rebase :/quuxery
  $ git rebase -i :/quuxery

This is because rebase [-i] attempts to rev-parse ${REV}^0 to verify
that the given revision resolves to a commit.  Add tests to document
these failures.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 t/t3400-rebase.sh             | 8 ++++++++
 t/t3404-rebase-interactive.sh | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index b58fa1a..890f159 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -88,6 +88,14 @@ test_expect_success 'rebase fast-forward to master' '
 	test_i18ngrep "Fast-forwarded HEAD to my-topic-branch" out
 '
 
+test_expect_failure 'rebase against revision specified as :/quuxery' '
+	git checkout my-topic-branch^ &&
+	sha1=$(git rev-parse ":/Add B") &&
+	git rebase $sha1 &&
+	git checkout my-topic-branch^ &&
+	git rebase ":/Add B"
+'
+
 test_expect_success 'the rebase operation should not have destroyed author information' '
 	! (git log | grep "Author:" | grep "<>")
 '
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 79e8d3c..ca4ee92 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -947,4 +947,12 @@ test_expect_success 'rebase -i respects core.commentchar' '
 	test B = $(git cat-file commit HEAD^ | sed -ne \$p)
 '
 
+test_expect_failure 'rebase -i against revision specified as :/quuxery' '
+	git checkout branch1 &&
+	sha1=$(git rev-parse ":/J") &&
+	git rebase $sha1 &&
+	git checkout branch1 &&
+	git rebase ":/J"
+'
+
 test_done
-- 
1.8.3.1.381.g31c8856.dirty

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] sh-setup: add new peel_committish() helper
  2013-06-13 18:15 [PATCH 0/3] Support :/quuxery in rebase (early preview) Ramkumar Ramachandra
  2013-06-13 18:16 ` [PATCH 1/3] t/rebase: add failing tests for a peculiar revision Ramkumar Ramachandra
@ 2013-06-13 18:16 ` Ramkumar Ramachandra
  2013-06-13 18:16 ` [PATCH 3/3] rebase: use peel_committish() where appropriate Ramkumar Ramachandra
  2 siblings, 0 replies; 4+ messages in thread
From: Ramkumar Ramachandra @ 2013-06-13 18:16 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

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 | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 2f78359..6ae19a6 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -313,3 +313,16 @@ then
 	}
 	: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
 fi
+
+peel_committish () {
+	test $# -gt 1 && quiet="--quiet" || quiet=""
+	case "$1" in
+	:/*)
+		peeltmp=$(git rev-parse --verify $quiet "$1") &&
+		git rev-parse --verify "${peeltmp}^0"
+		;;
+	*)
+		git rev-parse --verify "${1}^0"
+		;;
+	esac
+}
-- 
1.8.3.1.381.g31c8856.dirty

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] rebase: use peel_committish() where appropriate
  2013-06-13 18:15 [PATCH 0/3] Support :/quuxery in rebase (early preview) Ramkumar Ramachandra
  2013-06-13 18:16 ` [PATCH 1/3] t/rebase: add failing tests for a peculiar revision Ramkumar Ramachandra
  2013-06-13 18:16 ` [PATCH 2/3] sh-setup: add new peel_committish() helper Ramkumar Ramachandra
@ 2013-06-13 18:16 ` Ramkumar Ramachandra
  2 siblings, 0 replies; 4+ messages in thread
From: Ramkumar Ramachandra @ 2013-06-13 18:16 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

The failing tests in t/rebase and t/rebase-interactive pass as a result.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 git-rebase.sh                 | 6 +++---
 t/t3400-rebase.sh             | 2 +-
 t/t3404-rebase-interactive.sh | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/git-rebase.sh b/git-rebase.sh
index d0c11a9..28e8d47 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -434,7 +434,7 @@ then
 		shift
 		;;
 	esac
-	upstream=`git rev-parse --verify "${upstream_name}^0"` ||
+	upstream=$(peel_committish "${upstream_name}") ||
 	die "$(eval_gettext "invalid upstream \$upstream_name")"
 	upstream_arg="$upstream_name"
 else
@@ -470,7 +470,7 @@ case "$onto_name" in
 	fi
 	;;
 *)
-	onto=$(git rev-parse --verify "${onto_name}^0") ||
+	onto=$(peel_committish "$onto_name") ||
 	die "$(eval_gettext "Does not point to a valid commit: \$onto_name")"
 	;;
 esac
@@ -490,7 +490,7 @@ case "$#" in
 	   orig_head=$(git rev-parse -q --verify "refs/heads/$1")
 	then
 		head_name="refs/heads/$1"
-	elif orig_head=$(git rev-parse -q --verify "$1")
+	elif orig_head=$(peel_committish "$1" quiet)
 	then
 		head_name="detached HEAD"
 	else
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 890f159..272f0f5 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -88,7 +88,7 @@ test_expect_success 'rebase fast-forward to master' '
 	test_i18ngrep "Fast-forwarded HEAD to my-topic-branch" out
 '
 
-test_expect_failure 'rebase against revision specified as :/quuxery' '
+test_expect_success 'rebase against revision specified as :/quuxery' '
 	git checkout my-topic-branch^ &&
 	sha1=$(git rev-parse ":/Add B") &&
 	git rebase $sha1 &&
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index ca4ee92..c9a5d56 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -947,7 +947,7 @@ test_expect_success 'rebase -i respects core.commentchar' '
 	test B = $(git cat-file commit HEAD^ | sed -ne \$p)
 '
 
-test_expect_failure 'rebase -i against revision specified as :/quuxery' '
+test_expect_success 'rebase -i against revision specified as :/quuxery' '
 	git checkout branch1 &&
 	sha1=$(git rev-parse ":/J") &&
 	git rebase $sha1 &&
-- 
1.8.3.1.381.g31c8856.dirty

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-06-13 18:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-13 18:15 [PATCH 0/3] Support :/quuxery in rebase (early preview) Ramkumar Ramachandra
2013-06-13 18:16 ` [PATCH 1/3] t/rebase: add failing tests for a peculiar revision Ramkumar Ramachandra
2013-06-13 18:16 ` [PATCH 2/3] sh-setup: add new peel_committish() helper Ramkumar Ramachandra
2013-06-13 18:16 ` [PATCH 3/3] rebase: use peel_committish() where appropriate Ramkumar Ramachandra

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).