From: Steffen Prohaska <prohaska@zib.de>
To: git@vger.kernel.org
Cc: Steffen Prohaska <prohaska@zib.de>
Subject: [PATCH 04/10] push: add "git push HEAD" shorthand for 'push current branch to default repo'
Date: Sun, 28 Oct 2007 18:46:15 +0100 [thread overview]
Message-ID: <11935935812185-git-send-email-prohaska@zib.de> (raw)
In-Reply-To: <1193593581486-git-send-email-prohaska@zib.de>
Sometimes it is handy to push only the current branch to the
default remote repository. For example, if you created a branch
using the '--track' option git knows that the current branch
is linked to a specific remote. But up to now you needed to say
"git push <defaultremote> <thisbranch>", which was quite
annoying. You could have said "git push" but then _all_ branches
would have been pushed to the default remote.
This commit introduces "git push HEAD", which resolves HEAD to
the current branch and pushes only the current branch to its
default remote.
Setups that have a remote named HEAD will break. But such a setup
if unlikely to exist; and is not very sensible anyway.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
Documentation/git-push.txt | 6 +++++-
builtin-push.c | 2 ++
t/t5516-fetch-push.sh | 12 ++++++++++++
3 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 67b354b..236898f 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -10,7 +10,7 @@ SYNOPSIS
--------
[verse]
'git-push' [--all] [--dry-run] [--create] [--tags] [--receive-pack=<git-receive-pack>]
- [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]
+ [--repo=all] [-f | --force] [-v] [HEAD | <repository> <refspec>...]
DESCRIPTION
-----------
@@ -25,6 +25,10 @@ documentation for gitlink:git-receive-pack[1].
OPTIONS
-------
+HEAD::
+ Tells push to push the current branch to the default
+ remote repository.
+
<repository>::
The "remote" repository that is destination of a push
operation. See the section <<URLS,GIT URLS>> below.
diff --git a/builtin-push.c b/builtin-push.c
index 2e3c8c6..7c08e19 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -102,6 +102,8 @@ int cmd_push(int argc, const char **argv, const char *prefix)
const char *arg = argv[i];
if (arg[0] != '-') {
+ if (!strcmp("HEAD", arg))
+ break;
repo = arg;
i++;
break;
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 8becaf8..2650e36 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -291,6 +291,18 @@ test_expect_success 'push with HEAD' '
'
+test_expect_success 'push HEAD' '
+
+ mk_test heads/track &&
+ git remote add test testrepo &&
+ git fetch test &&
+ git checkout -b track test/track &&
+ git reset --hard master &&
+ git push HEAD &&
+ check_push_result $the_commit heads/track
+
+'
+
test_expect_success 'push with HEAD (--create)' '
mk_test &&
--
1.5.3.4.439.ge8b49
next prev parent reply other threads:[~2007-10-28 17:51 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-28 17:46 [PATCH 0/10 v3] improve refspec handling in push Steffen Prohaska
2007-10-28 17:46 ` [PATCH 01/10] push: change push to fail if short refname does not exist Steffen Prohaska
2007-10-28 17:46 ` [PATCH 02/10] push: teach push new flag --create Steffen Prohaska
2007-10-28 17:46 ` [PATCH 03/10] push: support pushing HEAD to real branch name Steffen Prohaska
2007-10-28 17:46 ` Steffen Prohaska [this message]
2007-10-28 17:46 ` [PATCH 05/10] rename ref_matches_abbrev() to ref_abbrev_matches_full_with_fetch_rules() Steffen Prohaska
2007-10-28 17:46 ` [PATCH 06/10] add ref_abbrev_matches_full_with_rev_parse_rules() comparing abbrev with full ref name Steffen Prohaska
2007-10-28 17:46 ` [PATCH 07/10] push: use same rules as git-rev-parse to resolve refspecs Steffen Prohaska
2007-10-28 17:46 ` [PATCH 08/10] push: teach push to accept --verbose option Steffen Prohaska
2007-10-28 17:46 ` [PATCH 09/10] push: teach push to pass --verbose option to transport layer Steffen Prohaska
2007-10-28 17:46 ` [PATCH 10/10] push: teach push to be quiet if local ref is strict subset of remote ref Steffen Prohaska
2007-10-30 8:29 ` Junio C Hamano
2007-10-30 10:15 ` Steffen Prohaska
2007-10-30 10:26 ` Andreas Ericsson
2007-10-30 10:53 ` Steffen Prohaska
2007-10-30 19:19 ` Junio C Hamano
2007-10-31 7:53 ` Steffen Prohaska
2007-10-31 8:45 ` Junio C Hamano
[not found] ` <B3C76DB8-076D-4C43-AC28-99119A05325C@z ib.de>
2007-10-31 9:14 ` Junio C Hamano
2007-10-31 10:50 ` Steffen Prohaska
2007-10-31 18:51 ` Junio C Hamano
2007-10-31 21:09 ` Steffen Prohaska
2007-10-31 21:31 ` Junio C Hamano
2007-11-01 7:03 ` Steffen Prohaska
2007-11-01 9:11 ` Andreas Ericsson
2007-11-01 16:43 ` Steffen Prohaska
2007-11-01 20:18 ` Junio C Hamano
2007-11-02 7:21 ` Steffen Prohaska
2007-11-02 7:52 ` Junio C Hamano
2007-11-02 10:03 ` Steffen Prohaska
2007-11-02 10:44 ` Junio C Hamano
2007-11-02 11:40 ` Steffen Prohaska
2007-11-02 10:03 ` Andreas Ericsson
2007-11-02 13:24 ` Tom Prince
2007-11-02 13:52 ` Andreas Ericsson
2007-11-02 14:49 ` Steffen Prohaska
2007-11-02 19:42 ` Junio C Hamano
2007-11-02 20:19 ` Junio C Hamano
2007-11-01 8:18 ` Andreas Ericsson
2007-11-01 8:36 ` Steffen Prohaska
2007-11-01 9:29 ` Andreas Ericsson
2007-11-02 8:18 ` Wincent Colaiuta
2007-11-02 12:14 ` Johannes Schindelin
2007-11-02 12:48 ` Steffen Prohaska
2007-11-02 13:11 ` Wincent Colaiuta
2007-10-30 18:00 ` Daniel Barkalow
2007-10-30 8:28 ` [PATCH 07/10] push: use same rules as git-rev-parse to resolve refspecs Junio C Hamano
2007-10-30 8:49 ` Steffen Prohaska
2007-10-30 8:28 ` [PATCH 04/10] push: add "git push HEAD" shorthand for 'push current branch to default repo' Junio C Hamano
2007-10-30 8:28 ` [PATCH 03/10] push: support pushing HEAD to real branch name Junio C Hamano
2007-10-30 8:29 ` [PATCH 01/10] push: change push to fail if short refname does not exist Junio C Hamano
2007-10-30 8:56 ` Steffen Prohaska
2007-10-30 9:22 ` 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=11935935812185-git-send-email-prohaska@zib.de \
--to=prohaska@zib.de \
--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).