git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH] merge: allow "-" as a short-hand for "previous branch"
Date: Thu, 07 Apr 2011 16:03:14 -0700	[thread overview]
Message-ID: <7vmxk164wd.fsf@alter.siamese.dyndns.org> (raw)

Just like "git checkout -" is a short-hand for "git checkout @{-1}" to
conveniently switch back to the previous branch, "git merge -" is a
short-hand for "git merge @{-1}" to conveniently merge the previous branch.

It will allow me to say:

    $ git checkout -b au/topic
    $ git am -s ./+au-topic.mbox
    $ git checkout pu
    $ git merge -

which is an extremely typical and repetitive operation during my git day.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/merge.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/builtin/merge.c b/builtin/merge.c
index d54e7dd..0bdd19a 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1062,9 +1062,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 	if (!allow_fast_forward && fast_forward_only)
 		die(_("You cannot combine --no-ff with --ff-only."));
 
-	if (!argc && !abort_current_merge && default_to_upstream)
-		argc = setup_with_upstream(&argv);
-
+	if (!abort_current_merge) {
+		if (!argc && default_to_upstream)
+			argc = setup_with_upstream(&argv);
+		else if (argc == 1 && !strcmp(argv[0], "-"))
+			argv[0] = "@{-1}";
+	}
 	if (!argc)
 		usage_with_options(builtin_merge_usage,
 			builtin_merge_options);
-- 
1.7.5.rc1

             reply	other threads:[~2011-04-07 23:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-07 23:03 Junio C Hamano [this message]
2011-04-07 23:13 ` [PATCH] merge: allow "-" as a short-hand for "previous branch" Thomas Adam
2011-04-07 23:26   ` Junio C Hamano
2011-04-08  9:30     ` Michael J Gruber
2011-04-08 18:43       ` 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

  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=7vmxk164wd.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.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.
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).