From: Felipe Contreras <felipe.contreras@gmail.com>
To: Tomo Krajina <tkrajina@gmail.com>, git@vger.kernel.org
Cc: felipe.contreras@gmail.com, Tomo Krajina <tkrajina@gmail.com>
Subject: RE: [PATCH] push: Allow @ shortcut with git-push
Date: Sat, 07 Dec 2013 03:45:41 -0600 [thread overview]
Message-ID: <52a2ee45b8644_29836d5e9877@nysa.notmuch> (raw)
In-Reply-To: <1386310392-26882-1-git-send-email-tkrajina@gmail.com>
Tomo Krajina wrote:
> Until now, HEAD could be used with git-push to push the current
> branch. Now @ is a shortcut to HEAD, but it didn't work when
> pushing branches. It fails with:
>
> fatal: remote part of refspec is not a valid name in @
>
> Reinterpret all branch names from argv in order for @ to be used
> when pushing branches.
>
> Signed-off-by: Tomo Krajina <tkrajina@gmail.com>
> ---
> builtin/push.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/builtin/push.c b/builtin/push.c
> index 7b1b66c..51c0200 100644
> --- a/builtin/push.c
> +++ b/builtin/push.c
> @@ -494,7 +494,20 @@ int cmd_push(int argc, const char **argv, const char *prefix)
>
> if (argc > 0) {
> repo = argv[0];
> - set_refspecs(argv + 1, argc - 1);
> +
> + char *refs[argc - 1];
> + int i;
> + for(i = 1; i < argc; i++) {
> + refs[i - 1] = argv[i];
> +
> + struct strbuf buf = STRBUF_INIT;
> + interpret_branch_name(argv[i], strlen(argv[i]), &buf);
> +
> + if(buf.buf && strlen(buf.buf) > 0)
> + refs[i - 1] = buf.buf;
> + }
> +
> + set_refspecs(refs, argc - 1);
> }
>
> rc = do_push(repo, flags);
> --
I don't think this is the right way to go. There are many places where HEAD
cannot be replaced with @, or @{u}, or any of such syntaxes.
We might want to do this kind of replacement in many other places, but we would
need to make sure it makes sense.
Moreover, in order for this patch to be considered you need to add tests.
Cheers.
--
Felipe Contreras
prev parent reply other threads:[~2013-12-07 9:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-06 6:13 [PATCH] push: Allow @ shortcut with git-push Tomo Krajina
2013-12-07 9:45 ` Felipe Contreras [this message]
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=52a2ee45b8644_29836d5e9877@nysa.notmuch \
--to=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=tkrajina@gmail.com \
/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).