git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: git@vger.kernel.org
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	"Shawn O. Pearce" <spearce@spearce.org>,
	Petr Baudis <pasky@suse.cz>, Andreas Gruenbacher <agruen@suse.de>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] Document and test the new % shotcut for the tracked branch
Date: Fri, 20 Mar 2009 11:04:31 +0100	[thread overview]
Message-ID: <1237543471-27248-1-git-send-email-git@drmicha.warpmail.net> (raw)
In-Reply-To: <alpine.DEB.1.00.0903201027450.10279@pacific.mpi-cbg.de>

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
Johannes Schindelin venit, vidit, dixit 20.03.2009 10:29:
> 
> Often, it is quite interesting to inspect the branch tracked by a given
> branch.  This patch introduces a nice notation to get at the tracked
> branch: 'BEL<branch>' can be used to access that tracked branch.
> 
> A special shortcut 'BEL' refers to the branch tracked by the current branch.
> 
> Suggested by Pasky and Shawn.
> 
> This patch extends the function introduced to handle the nth-last branch
> (via the {-<n>} notation); therefore that function name was renamed to
> something more general.
> 
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>

I guess you beat me to it then, which is fine.

But haven't you seen my note about the failing test either? The code below
tests with branches which track local branches. merge and remote is set
for the branch in question ("tracking"), it's just that remote is ".".
It seems that the remote.c code does not set up merge info for these
branches.

<Goes to figure out how to enter BEL...>

 Documentation/git-rev-parse.txt |    3 ++
 t/t1506-rev-parse-track.sh      |   60 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 0 deletions(-)
 create mode 100755 t/t1506-rev-parse-track.sh

diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 5ed2bc8..dafcfe8 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -215,6 +215,9 @@ when you run 'git-merge'.
 * The special construct '@\{-<n>\}' means the <n>th branch checked out
   before the current one.
 
+* A prefix '%', optionally followed by a branchname '<branch>', means the
+  branch tracked by '<branch>'. '<branch>' defaults to the current branch.
+
 * A suffix '{caret}' to a revision parameter means the first parent of
   that commit object.  '{caret}<n>' means the <n>th parent (i.e.
   'rev{caret}'
diff --git a/t/t1506-rev-parse-track.sh b/t/t1506-rev-parse-track.sh
new file mode 100755
index 0000000..1ca1dd6
--- /dev/null
+++ b/t/t1506-rev-parse-track.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+test_description='test % syntax'
+
+. ./test-lib.sh
+
+
+make_commit () {
+	echo "$1" > "$1" &&
+	git add "$1" &&
+	git commit -m "$1"
+}
+
+
+test_expect_success 'setup' '
+
+	make_commit 1 &&
+	git branch tracked &&
+	make_commit 2 &&
+	git checkout tracked &&
+	make_commit 3 &&
+	git checkout --track -b tracking tracked
+	make_commit 4 &&
+	git checkout master
+
+'
+
+# tracking tracks tracked
+# master does not track anything
+# all three point at different commits
+
+test_rev_equivalent () {
+
+	git rev-parse "$1" > expect &&
+	git rev-parse "$2" > output &&
+	test_cmp expect output
+
+}
+
+test_expect_success '%trackingbranch works' '
+	test_rev_equivalent tracked %tracking
+'
+
+test_expect_success '% works in tracking branch' '
+	git checkout tracking &&
+	test_rev_equivalent tracked %
+'
+
+test_expect_success '%nontrackingbranch fails' '
+	test_must_fail git rev-parse %tracked
+'
+
+test_expect_success '% fails in non-tracking branch' '
+	git checkout tracked &&
+	test_must_fail git rev-parse %
+'
+
+test_done
+
+
-- 
1.6.2.149.g6462

  parent reply	other threads:[~2009-03-20 10:08 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200903181448.50706.agruen@suse.de>
2009-03-18 18:26 ` Git {log,diff} against tracked branch? Petr Baudis
2009-03-18 21:12   ` [PATCH] Introduce %<branch> as shortcut to the tracked branch Johannes Schindelin
2009-03-18 21:41     ` Andreas Gruenbacher
2009-03-18 21:46     ` [PATCH v2] " Johannes Schindelin
2009-03-18 21:58       ` Andreas Gruenbacher
2009-03-18 22:43         ` Johannes Schindelin
2009-03-18 22:34       ` Junio C Hamano
2009-03-18 22:46         ` Johannes Schindelin
2009-03-19 14:52           ` Michael J Gruber
2009-03-19 15:17             ` Michael J Gruber
2009-03-20  0:23           ` Johannes Schindelin
2009-03-20  0:38             ` ref name troubles, was " Johannes Schindelin
2009-03-20  0:40               ` Shawn O. Pearce
2009-03-20  0:44                 ` Shawn O. Pearce
2009-03-20  5:59                   ` Sverre Rabbelier
2009-03-20  9:29                   ` [PATCH v3] Introduce BEL<branch> " Johannes Schindelin
2009-03-20  9:42                     ` Wincent Colaiuta
2009-03-20  9:54                       ` Johannes Schindelin
2009-03-20 12:33                         ` Santi Béjar
2009-03-20 12:45                           ` Andreas Gruenbacher
2009-03-20 13:05                             ` Matthieu Moy
2009-03-20 12:46                           ` Johannes Schindelin
2009-03-20 12:53                             ` Mikael Magnusson
2009-03-20 14:00                               ` Johannes Schindelin
2009-03-20 10:04                     ` Michael J Gruber [this message]
2009-03-20 10:31                       ` [PATCH] Document and test the new % shotcut for " Johannes Schindelin
2009-03-20 10:38                         ` Michael J Gruber
2009-03-20 11:16                         ` Petr Baudis
2009-03-20 11:48                           ` Johannes Schindelin
2009-03-22 17:40                             ` Petr Baudis
2009-03-20 14:15                         ` Michael J Gruber
2009-03-20 16:17                     ` [PATCH v4] Introduce %<branch> as shortcut to " Johannes Schindelin
2009-03-20 17:03                       ` Junio C Hamano
2009-03-20 17:32                         ` Johannes Schindelin
2009-03-20 18:02                         ` Junio C Hamano
2009-03-20 19:36                           ` Jeff King
2009-03-20 20:28                             ` Julian Phillips
2009-03-20 20:50                               ` Jeff King
2009-03-20 23:08                         ` Julian Phillips
2009-03-20 23:20                           ` Sverre Rabbelier
2009-03-20 23:41                             ` Julian Phillips
2009-03-20 23:45                               ` Sverre Rabbelier
2009-03-21  0:35                           ` Andreas Gruenbacher
2009-03-21  1:10                             ` Miles Bader
2009-03-21 13:24                             ` Julian Phillips
2009-03-21 13:28                               ` Julian Phillips
2009-03-20 17:08                       ` Björn Steinbrink
2009-03-20  6:05                 ` ref name troubles, was Re: [PATCH v2] " Jeff King
2009-03-20  6:57                   ` Junio C Hamano
2009-03-20  9:30                     ` Johannes Schindelin
2009-03-20 11:12                       ` Petr Baudis
2009-03-20 11:46                         ` Johannes Schindelin
2009-03-20 11:50                           ` Petr Baudis
2009-03-20 11:57                             ` Johannes Schindelin
2009-03-20 14:31                               ` Michael J Gruber
2009-03-20 15:01                                 ` Johannes Schindelin
2009-03-20 15:12                                   ` Michael J Gruber
2009-03-20 16:47                         ` Junio C Hamano
2009-03-20 19:34                           ` Daniel Barkalow
2009-03-20 21:48                             ` Johannes Schindelin
2009-03-21 21:00                 ` Junio C Hamano

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=1237543471-27248-1-git-send-email-git@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=agruen@suse.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pasky@suse.cz \
    --cc=spearce@spearce.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).