From: Senorsen <senorsen.zhang@gmail.com>
To: git@vger.kernel.org
Cc: Senorsen <senorsen.zhang@gmail.com>
Subject: [PATCH] diff: handle "-" as abbreviation of '@{-1}'
Date: Sat, 12 Mar 2016 10:11:50 +0800 [thread overview]
Message-ID: <1457748710-79370-1-git-send-email-senorsen.zhang@gmail.com> (raw)
Currently it just replace "-" in argv[] into "@{-1}".
For example,
git diff -
equals to
git diff @{-1}
Signed-off-by: Senorsen <senorsen.zhang@gmail.com>
---
Notes:
Hello everyone, I'm Zhang Sen, a college student from Zhejiang University
in China, and this is a patch for the microproject of GSoC 2016. I'm
looking forward to contributing to Git and participating in GSoC 2016.
I have learnt some rules and guides from the documents, and carefully
wrote this small patch, according to other code from git.
Thanks a lot!
builtin/diff.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/builtin/diff.c b/builtin/diff.c
index 52c98a9..c110141 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -389,6 +389,11 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
}
}
+ for (i = 0; i < argc; i++) {
+ if (!strcmp(argv[i], "-"))
+ argv[i] = "@{-1}";
+ }
+
for (i = 0; i < rev.pending.nr; i++) {
struct object_array_entry *entry = &rev.pending.objects[i];
struct object *obj = entry->item;
--
2.7.0
next reply other threads:[~2016-03-12 2:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-12 2:11 Senorsen [this message]
2016-03-12 2:48 ` [PATCH] diff: handle "-" as abbreviation of '@{-1}' Javier Domingo Cansino
2016-03-14 9:17 ` Michael J Gruber
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=1457748710-79370-1-git-send-email-senorsen.zhang@gmail.com \
--to=senorsen.zhang@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).