From: Kenny Lee Sin Cheong <kenny.lee28@gmail.com>
To: git@vger.kernel.org
Cc: Kenny Lee Sin Cheong <kenny.lee28@gmail.com>
Subject: [PATCH 2/2] Add revision range support on "-" and "@{-1}"
Date: Mon, 16 Mar 2015 11:11:43 -0400 [thread overview]
Message-ID: <1426518703-15785-3-git-send-email-kenny.lee28@gmail.com> (raw)
In-Reply-To: <1426518703-15785-1-git-send-email-kenny.lee28@gmail.com>
Currently it is not be possible to do something like "git checkout
master && git checkout next && git log -.." to see what master has on
top of master.
Allows use of the revision range such as <rev>..- or -..<rev> to see
what HEAD has on top of <rev> or vice versa, respectively.
Also allows use of symmetric differences such as <rev>...- and -...<rev>
This is written on top of Junio's "Just For Fun" patch ($Gmane/265260).
Signed-off-by: Kenny Lee Sin Cheong <kenny.lee28@gmail.com>
---
revision.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/revision.c b/revision.c
index 7778bbd..a79b443 100644
--- a/revision.c
+++ b/revision.c
@@ -1490,6 +1490,7 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
int symmetric = *next == '.';
unsigned int flags_exclude = flags ^ (UNINTERESTING | BOTTOM);
static const char head_by_default[] = "HEAD";
+ static const char prev_rev[] = "@{-1}";
unsigned int a_flags;
*dotdot = 0;
@@ -1499,6 +1500,13 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
next = head_by_default;
if (dotdot == arg)
this = head_by_default;
+ /* Allows -..<rev> and <rev>..- */
+ if (!strcmp(this, "-")) {
+ this = prev_rev;
+ }
+ if (!strcmp(next, "-")) {
+ next = prev_rev;
+ }
if (this == head_by_default && next == head_by_default &&
!symmetric) {
/*
@@ -2198,7 +2206,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
read_from_stdin = 0;
for (left = i = 1; i < argc; i++) {
const char *arg = argv[i];
- if (arg[0] == '-' && arg[1]) {
+ if (arg[0] == '-' && !strstr(arg, "..")) {
int opts;
opts = handle_revision_pseudo_opt(submodule,
@@ -2220,6 +2228,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
continue;
}
+
opts = handle_revision_opt(revs, argc - i, argv + i, &left, argv);
if (opts > 0) {
i += opts - 1;
@@ -2229,7 +2238,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
exit(128);
continue;
}
-
+ if (strstr(arg, "..")) {
+ handle_revision_arg(arg, revs, flags, revarg_opt);
+ continue;
+ }
if (handle_revision_arg(arg, revs, flags, revarg_opt)) {
int j;
--
2.3.2.225.gebdc58a
next prev parent reply other threads:[~2015-03-16 15:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-16 15:11 [PATCH/RFC 0/2][GSoC] revision.c: Allow "-" as stand-in for "@{-1}" everywhere a branch is allowed Kenny Lee Sin Cheong
2015-03-16 15:11 ` [PATCH 1/2] "-" and "@{-1}" on various programs Kenny Lee Sin Cheong
2015-03-16 15:11 ` Kenny Lee Sin Cheong [this message]
2015-03-16 18:22 ` [PATCH 2/2] Add revision range support on "-" and "@{-1}" Junio C Hamano
2015-03-17 6:49 ` Junio C Hamano
2015-03-17 21:25 ` Kenny Lee Sin Cheong
2015-03-17 22:16 ` Junio C Hamano
2015-03-24 0:09 ` Kenny Lee Sin Cheong
2015-03-25 22:24 ` 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=1426518703-15785-3-git-send-email-kenny.lee28@gmail.com \
--to=kenny.lee28@gmail.com \
--cc=git@vger.kernel.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).