From: Blind <stoycho.sleptsov@gmail.com>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [RFC/PATCH] Introduce branch.<name>.pushremote
Date: Mon, 11 Feb 2013 08:16:50 +0200 [thread overview]
Message-ID: <CAGL0X-rKnWBy-Ff=YmEdqgo8RFb40FXTxvUM5X77YaQvhAGHYg@mail.gmail.com> (raw)
In-Reply-To: <1360307982-20027-1-git-send-email-artagnon@gmail.com>
If I understand correctly,
in your scenario the branches with branch.<name>.pushremote
will be still included in the $git push <remote> --all?
Are you considering some way to exclude a branch from "push --all"
(branch.<name>.push = always, explicit, never... for example)?
Or maybe, if the branch is already marked as special
with branch.<name>.pushremote,
then it could be logical to push it only when is explicitly specified
on the command line (excluded from --all)?
Thanks,
Blind.
2013/2/8 Ramkumar Ramachandra <artagnon@gmail.com>:
> This new configuration variable overrides the remote in
> `branch.<name>.remote` for pushes. It is useful in the typical
> scenario, where the remote I'm pulling from is not the remote I'm
> pushing to. Although `remote.<name>.pushurl` is similar, it does not
> serve the purpose as the URL would lack corresponding remote tracking
> branches.
>
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
> This is a first cut. There's code duplication at the moment, but I'm
> currently trying to figure out which other remote_get() calls to
> replace with pushremote_get(). Comments are welcome.
>
> I will leave it to future patches to do the following things:
> 1. Fix the status output to be more meaningful when pushremote is
> set. At the moment, I'm thinking statuses like [pull: 4 behind,
> push: 3 ahead] will make sense.
> 2. Introduce a remote.pushDefault (peff)
> 3. Introduce a remote.default (peff)
>
> Documentation/config.txt | 6 ++++++
> builtin/push.c | 2 +-
> remote.c | 41 +++++++++++++++++++++++++++++++++++++++++
> remote.h | 2 ++
> 4 files changed, 50 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index 9b11597..0b3b1f8 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -727,6 +727,12 @@ branch.<name>.remote::
> remote to fetch from/push to. It defaults to `origin` if no remote is
> configured. `origin` is also used if you are not on any branch.
>
> +branch.<name>.pushremote::
> + When in branch <name>, it tells 'git push' which remote to
> + push to. It falls back to `branch.<name>.remote`, and
> + defaults to `origin` if no remote is configured. `origin` is
> + also used if you are not on any branch.
> +
> branch.<name>.merge::
> Defines, together with branch.<name>.remote, the upstream branch
> for the given branch. It tells 'git fetch'/'git pull'/'git rebase' which
> diff --git a/builtin/push.c b/builtin/push.c
> index 42b129d..d447a80 100644
> --- a/builtin/push.c
> +++ b/builtin/push.c
> @@ -322,7 +322,7 @@ static int push_with_options(struct transport *transport, int flags)
> static int do_push(const char *repo, int flags)
> {
> int i, errs;
> - struct remote *remote = remote_get(repo);
> + struct remote *remote = pushremote_get(repo);
> const char **url;
> int url_nr;
>
> diff --git a/remote.c b/remote.c
> index e53a6eb..d6fcfc0 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -48,6 +48,7 @@ static int branches_nr;
>
> static struct branch *current_branch;
> static const char *default_remote_name;
> +static const char *pushremote_name;
> static int explicit_default_remote_name;
>
> static struct rewrites rewrites;
> @@ -363,6 +364,12 @@ static int handle_config(const char *key, const char *value, void *cb)
> default_remote_name = branch->remote_name;
> explicit_default_remote_name = 1;
> }
> + } else if (!strcmp(subkey, ".pushremote")) {
> + if (!value)
> + return config_error_nonbool(key);
> + branch->pushremote_name = xstrdup(value);
> + if (branch == current_branch)
> + pushremote_name = branch->pushremote_name;
> } else if (!strcmp(subkey, ".merge")) {
> if (!value)
> return config_error_nonbool(key);
> @@ -700,6 +707,40 @@ struct remote *remote_get(const char *name)
> return ret;
> }
>
> +struct remote *pushremote_get(const char *name)
> +{
> + struct remote *ret;
> + int name_given = 0;
> +
> + read_config();
> + if (name)
> + name_given = 1;
> + else {
> + if (pushremote_name) {
> + name = pushremote_name;
> + name_given = 1;
> + } else {
> + name = default_remote_name;
> + name_given = explicit_default_remote_name;
> + }
> + }
> +
> + ret = make_remote(name, 0);
> + if (valid_remote_nick(name)) {
> + if (!valid_remote(ret))
> + read_remotes_file(ret);
> + if (!valid_remote(ret))
> + read_branches_file(ret);
> + }
> + if (name_given && !valid_remote(ret))
> + add_url_alias(ret, name);
> + if (!valid_remote(ret))
> + return NULL;
> + ret->fetch = parse_fetch_refspec(ret->fetch_refspec_nr, ret->fetch_refspec);
> + ret->push = parse_push_refspec(ret->push_refspec_nr, ret->push_refspec);
> + return ret;
> +}
> +
> int remote_is_configured(const char *name)
> {
> int i;
> diff --git a/remote.h b/remote.h
> index 251d8fd..aa42ff5 100644
> --- a/remote.h
> +++ b/remote.h
> @@ -51,6 +51,7 @@ struct remote {
> };
>
> struct remote *remote_get(const char *name);
> +struct remote *pushremote_get(const char *name);
> int remote_is_configured(const char *name);
>
> typedef int each_remote_fn(struct remote *remote, void *priv);
> @@ -130,6 +131,7 @@ struct branch {
> const char *refname;
>
> const char *remote_name;
> + const char *pushremote_name;
> struct remote *remote;
>
> const char **merge_name;
> --
> 1.8.1.2.545.g2f19ada.dirty
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-02-11 6:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-08 7:19 [RFC/PATCH] Introduce branch.<name>.pushremote Ramkumar Ramachandra
2013-02-08 8:21 ` Junio C Hamano
2013-02-08 9:02 ` [RFC/PATCH] Introduce remote.pushdefault Ramkumar Ramachandra
2013-02-08 20:11 ` Junio C Hamano
2013-02-09 7:50 ` Ramkumar Ramachandra
2013-03-17 0:30 ` Ramkumar Ramachandra
2013-03-17 5:48 ` Jeff King
2013-03-18 9:02 ` Ramkumar Ramachandra
2013-03-17 6:10 ` Junio C Hamano
2013-02-08 20:04 ` [RFC/PATCH] Introduce branch.<name>.pushremote Junio C Hamano
2013-02-09 7:46 ` Ramkumar Ramachandra
2013-02-09 20:00 ` Junio C Hamano
2013-02-10 15:41 ` Ramkumar Ramachandra
2013-02-11 6:16 ` Blind [this message]
2013-02-19 9:27 ` Ramkumar Ramachandra
2013-02-19 11:18 ` Blind
2013-02-19 11:30 ` Ramkumar Ramachandra
2013-02-19 11:51 ` Blind
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='CAGL0X-rKnWBy-Ff=YmEdqgo8RFb40FXTxvUM5X77YaQvhAGHYg@mail.gmail.com' \
--to=stoycho.sleptsov@gmail.com \
--cc=artagnon@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).