From: "Rudolf Polzer" <divVerent@alientrap.org>
To: git@vger.kernel.org
Subject: Re: [PATCH] git push --track
Date: Wed, 13 Jan 2010 16:55:20 +0100 [thread overview]
Message-ID: <op.u6haiiiog402ra@nb-04> (raw)
In-Reply-To: 20100113154310.GA7348@Knoppix
On Wed, 13 Jan 2010 16:43:10 +0100, Ilari Liusvaara
<ilari.liusvaara@elisanet.fi> wrote:
> On Wed, Jan 13, 2010 at 04:12:49PM +0100, Rudolf Polzer wrote:
>> Hi,
>>
>> I'd like a feature to automatically "transform" a non-tracking local
>> branch into a tracking branch on push. A patch to do that is
>> attached.
>
> The patches should be sent inline, together with commit messages
> (unless you are asked to resend as attachment because of whitespace
> mangling). Attached patches are very hard to comment on.
>
>> Are there any chances for this getting added to official git - or an
>> alternate convenient way convert a local to a tracking branch?
>
> This is missing sign-off. It can't be included without it.
Of course, but I assume the sign-off would not be by me, but by some of
the git developers, and would depend on whether they actually want this
feature.
> Also couple comments:
>
> - Some lines look way too long (~160 chars, should be max 80 unles
> it would linebreak error message).
Yes, also I got told that I used the wrong braces style... well, fixed
that.
> - Should the tracking be set up even if only part of ref update suceeded
> (for those that succeeded), not requiring all to succeed?
Good point, but I simply see no clean way to set it up for the succeeded
refs. Would be a nice idea for improvement of this.
> - Is --track the best name for this?
I am assuming this, because this is what git-checkout and git-branch use
for the same thing.
As I am absolutely not sure if with Opera I can include the file as is, I
also provided it on http://nopaste.linux-dev.org/?6248 this time.
Best regards,
Rudolf
From 123598516c7d4e1f83591e8dae64e2c76dc87c90 Mon Sep 17 00:00:00 2001
From: Rudolf Polzer <divVerent@alientrap.org>
Date: Wed, 13 Jan 2010 16:42:04 +0100
Subject: [PATCH 1/2] Add a feature "git push --track" to automatically
make the pushed branches tracking
---
builtin-push.c | 33 +++++++++++++++++++++++++++++++++
transport.h | 1 +
2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/builtin-push.c b/builtin-push.c
index 28a26e7..e5b66a3 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -7,6 +7,7 @@
#include "builtin.h"
#include "remote.h"
#include "transport.h"
+#include "branch.h"
#include "parse-options.h"
static const char * const push_usage[] = {
@@ -115,6 +116,36 @@ static int push_with_options(struct transport
*transport, int flags)
fprintf(stderr, "Pushing to %s\n", transport->url);
err = transport_push(transport, refspec_nr, refspec, flags,
&nonfastforward);
+ if (err == 0 && flags & TRANSPORT_PUSH_TRACK) {
+ struct ref *remote_refs =
+ transport->get_refs_list(transport, 1);
+ struct ref *local_refs = get_local_heads();
+ int match_flags = 0;
+ if (flags & TRANSPORT_PUSH_ALL)
+ match_flags |= MATCH_REFS_ALL;
+ if (flags & TRANSPORT_PUSH_MIRROR)
+ match_flags |= MATCH_REFS_MIRROR;
+ if(!(flags & TRANSPORT_PUSH_DRY_RUN))
+ if(!match_refs(local_refs, &remote_refs, refspec_nr, refspec,
+ match_flags)) {
+ struct ref *next = remote_refs;
+ while(next) {
+ if(next->peer_ref && *next->peer_ref->name &&
+ *next->name &&
+ next->peer_ref->new_sha1 &&
+ !is_null_sha1(next->peer_ref->new_sha1))
+ {
+ if (!prefixcmp(next->peer_ref->name,
+ "refs/heads/"))
+ install_branch_config(BRANCH_CONFIG_VERBOSE,
+ next->peer_ref->name + 11,
+ transport->remote->name,
+ next->name);
+ }
+ next = next->next;
+ }
+ }
+ }
if (err != 0)
error("failed to push some refs to '%s'", transport->url);
@@ -218,6 +249,8 @@ int cmd_push(int argc, const char **argv, const char
*prefix)
OPT_BOOLEAN( 0 , "thin", &thin, "use thin pack"),
OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", "receive
pack program"),
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack
program"),
+ OPT_BIT('t', "track", &flags, "set up tracking mode (see git-pull(1))",
+ TRANSPORT_PUSH_TRACK),
OPT_END()
};
diff --git a/transport.h b/transport.h
index 9e74406..8a9c776 100644
--- a/transport.h
+++ b/transport.h
@@ -74,6 +74,7 @@ struct transport {
#define TRANSPORT_PUSH_VERBOSE 16
#define TRANSPORT_PUSH_PORCELAIN 32
#define TRANSPORT_PUSH_QUIET 64
+#define TRANSPORT_PUSH_TRACK 128
/* Returns a transport suitable for the url */
struct transport *transport_get(struct remote *, const char *);
--
1.6.3.3
From bbdd185ac43fb789f35d0177697486457af87fd0 Mon Sep 17 00:00:00 2001
From: Rudolf Polzer <divVerent@alientrap.org>
Date: Wed, 13 Jan 2010 16:47:24 +0100
Subject: [PATCH 2/2] tracking into Docs
---
Documentation/git-push.txt | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index e3eb1e8..ebaa67b 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -82,6 +82,14 @@ nor in any Push line of the corresponding remotes
file---see below).
if the configuration option `remote.<remote>.mirror` is
set.
+-t::
+--track::
+ When pushing, set up "upstream" configuration. See
+ "--track" in linkgit:git-branch[1] for details. All
+ refspecs that have a branch as source ref will be turned
+ into tracking branches if they are not already, and in any case
+ adjusted to track the given remote and ref on the remote side.
+
-n::
--dry-run::
Do everything except actually send the updates.
--
1.6.3.3
next prev parent reply other threads:[~2010-01-13 15:55 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-13 15:12 [PATCH] git push --track Rudolf Polzer
2010-01-13 15:43 ` Ilari Liusvaara
2010-01-13 15:55 ` Rudolf Polzer [this message]
2010-01-13 16:27 ` Ilari Liusvaara
2010-01-13 16:37 ` Matthieu Moy
2010-01-14 5:21 ` Tay Ray Chuan
2010-01-14 7:00 ` Rudolf Polzer
2010-01-14 23:13 ` Junio C Hamano
2010-01-14 7:16 ` Jeff King
2010-01-15 5:47 ` Junio C Hamano
2010-01-15 14:00 ` Rudolf Polzer
2010-01-15 15:45 ` Miles Bader
2010-01-15 18:16 ` Junio C Hamano
2010-01-14 0:28 ` Miles Bader
2010-01-14 0:25 ` Miles Bader
2010-01-14 0:33 ` Johannes Schindelin
2010-01-14 0:36 ` Miles Bader
2010-01-14 0:46 ` Miles Bader
2010-01-14 7:01 ` Rudolf Polzer
2010-01-14 13:44 ` Martin Langhoff
2010-01-14 14:16 ` Johannes Schindelin
2010-01-14 14:25 ` Matthieu Moy
2010-01-14 14:35 ` Martin Langhoff
2010-01-14 15:27 ` Andreas Krey
2010-01-14 1:27 ` Tay Ray Chuan
2010-01-14 1:35 ` Miles Bader
2010-01-14 1:37 ` Tay Ray Chuan
2010-01-14 1:49 ` Miles Bader
2010-01-14 1:58 ` Tay Ray Chuan
2010-01-14 7:03 ` Rudolf Polzer
2010-01-14 23:46 ` Junio C Hamano
2010-01-15 0:30 ` Miles Bader
2010-01-15 18:18 ` Junio C Hamano
2010-01-15 18:54 ` Miles Bader
2010-01-15 13:26 ` Matthieu Moy
2010-01-14 6:41 ` Nanako Shiraishi
2010-01-14 7:08 ` Rudolf Polzer
2010-01-14 10:31 ` Johannes Schindelin
2010-01-14 22:27 ` Nanako Shiraishi
2010-01-14 23:50 ` Junio C Hamano
2010-01-15 13:44 ` Rudolf Polzer
2010-01-15 14:09 ` Johannes Schindelin
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=op.u6haiiiog402ra@nb-04 \
--to=divverent@alientrap.org \
--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).