From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ramkumar Ramachandra Subject: [PATCH 4/6] remote.c: introduce a way to have different remotes for fetch/push Date: Wed, 20 Mar 2013 18:14:59 +0530 Message-ID: <1363783501-27981-5-git-send-email-artagnon@gmail.com> References: <1363783501-27981-1-git-send-email-artagnon@gmail.com> Cc: Junio C Hamano , Jeff King , Eric Sunshine , Jonathan Nieder To: Git List X-From: git-owner@vger.kernel.org Wed Mar 20 13:44:42 2013 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UIINi-0001sM-6M for gcvg-git-2@plane.gmane.org; Wed, 20 Mar 2013 13:44:38 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932933Ab3CTMoJ (ORCPT ); Wed, 20 Mar 2013 08:44:09 -0400 Received: from mail-pb0-f43.google.com ([209.85.160.43]:45416 "EHLO mail-pb0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932496Ab3CTMoI (ORCPT ); Wed, 20 Mar 2013 08:44:08 -0400 Received: by mail-pb0-f43.google.com with SMTP id md12so1336606pbc.30 for ; Wed, 20 Mar 2013 05:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=ND8e5xU22c2G/4v2sRHW/+SVTc0fTkLA/gCzuPuZGOc=; b=d2DgXJRbiMEsjAf23zf/rdvWWy3Br5pK88b0HktjSj1NyW6TgLqsYBat2gwV27Ms41 +J17JknRaJmOjCMAo/zvZwwfZZsJLyA2Yka8JVTQHwbfNROnGmN6+8LyQe/7D0uKdSX7 2vFuXKi4doUwMCbkosUWHKNvy1RBs/NBmLuZcWqO0bYb7ShMPiilYBkjCqpxvs29TfVO AkW2sqdLwkCxkxdAODV4EC8pepzQ5Ru2Z/X68jMYBJHHfJPuyaUdoV+Vvntq3lMjPBGX OFZYb8KB8+WQ9JF7oDyuFySgWsah/BSopG7SJBhp5jIhHk/IFBoTOU6yMQo+18K5Pk+V niLw== X-Received: by 10.68.222.163 with SMTP id qn3mr8703336pbc.77.1363783447353; Wed, 20 Mar 2013 05:44:07 -0700 (PDT) Received: from luneth.maa.corp.collab.net ([182.71.239.158]) by mx.google.com with ESMTPS id y13sm2031559pbv.0.2013.03.20.05.44.04 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Mar 2013 05:44:06 -0700 (PDT) X-Mailer: git-send-email 1.8.2 In-Reply-To: <1363783501-27981-1-git-send-email-artagnon@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Currently, do_push() in push.c calls remote_get(), which gets the configured remote for fetching and pushing. Replace this call with a call to pushremote_get() instead, a new function that will return the remote configured specifically for pushing. This function tries to work with the string pushremote_name, before falling back to the codepath of remote_get(). This patch has no visible impact, but serves to enable future patches to introduce configuration variables to set this variable. Signed-off-by: Ramkumar Ramachandra --- builtin/push.c | 2 +- remote.c | 25 +++++++++++++++++++++---- remote.h | 1 + 3 files changed, 23 insertions(+), 5 deletions(-) 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 45b69d6..cf7a65d 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; @@ -669,17 +670,21 @@ static int valid_remote_nick(const char *name) return !strchr(name, '/'); /* no slash */ } -struct remote *remote_get(const char *name) +static struct remote *remote_get_1(const char *name, const char *pushremote_name) { struct remote *ret; int name_given = 0; - read_config(); if (name) name_given = 1; else { - name = default_remote_name; - name_given = explicit_default_remote_name; + 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); @@ -698,6 +703,18 @@ struct remote *remote_get(const char *name) return ret; } +struct remote *remote_get(const char *name) +{ + read_config(); + return remote_get_1(name, NULL); +} + +struct remote *pushremote_get(const char *name) +{ + read_config(); + return remote_get_1(name, pushremote_name); +} + int remote_is_configured(const char *name) { int i; diff --git a/remote.h b/remote.h index 251d8fd..99a437f 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); -- 1.8.2