From: Jeff King <peff@peff.net>
To: Johannes Schindelin <johannes.schindelin@gmx.de>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] push: Learn to set up branch tracking with '--track'
Date: Thu, 29 Jan 2009 18:17:15 -0500 [thread overview]
Message-ID: <20090129231715.GA17399@coredump.intra.peff.net> (raw)
In-Reply-To: <20090129223308.GB12871@coredump.intra.peff.net>
On Thu, Jan 29, 2009 at 05:33:08PM -0500, Jeff King wrote:
> So I think this patch is going about it the wrong way. Instead of
> parsing the refspec, I think you actually want to look at what we _do_
> push (or at least try to push -- probably even uptodate refs should also
> have tracking established), and use that. Then you will have wildcards
> expanded, --all handled, etc. And I suspect all you have to do is
> iterate over the result of match_refs (which we call later), which
> should be even easier (because you don't have to parse the refspecs
> yourself). But I haven't looked carefully.
Something like the patch below (which is obviously missing all of the
infrastructure for doing this optionally, but is meant to illustrate
what I'm talking about).
The downside of this is that it only works for the git protocol
transport, making dumb push even more of a second class citizen (it
looks like this is already the case for updating tracking refs). But I
think this is the right place to do it, since we have detailed
information on the matched refs. If other transports want to do the same
thing, we should abstract setup_tracking (and update_tracking_ref while
we're at it) and call them from those transports.
---
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index d65d019..23b326a 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -247,6 +247,31 @@ static void update_tracking_ref(struct remote *remote, struct ref *ref)
}
}
+static void setup_tracking(const char *remote, struct ref *ref)
+{
+ const char *name;
+ struct strbuf key = STRBUF_INIT;
+
+ if (ref->status != REF_STATUS_OK && ref->status != REF_STATUS_UPTODATE)
+ return;
+ if (!ref->peer_ref)
+ return;
+
+ name = ref->peer_ref->name;
+ if (prefixcmp(name, "refs/heads/"))
+ return;
+ name += 11;
+
+ strbuf_addf(&key, "branch.%s.remote", name);
+ git_config_set(key.buf, remote);
+
+ strbuf_reset(&key);
+ strbuf_addf(&key, "branch.%s.merge", name);
+ git_config_set(key.buf, ref->name);
+
+ strbuf_release(&key);
+}
+
static const char *prettify_ref(const struct ref *ref)
{
const char *name = ref->name;
@@ -523,6 +548,10 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
for (ref = remote_refs; ref; ref = ref->next)
update_tracking_ref(remote, ref);
}
+ if (/* args.track && */ !args.dry_run) {
+ for (ref = remote_refs; ref; ref = ref->next)
+ setup_tracking(remote ? remote->name : dest, ref);
+ }
if (!refs_pushed(remote_refs))
fprintf(stderr, "Everything up-to-date\n");
next prev parent reply other threads:[~2009-01-29 23:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1233236267u.git.johannes.schindelin@gmx.de>
2009-01-29 13:38 ` [PATCH] push: Learn to set up branch tracking with '--track' Johannes Schindelin
2009-01-29 13:51 ` Sverre Rabbelier
2009-01-29 14:05 ` Johannes Schindelin
2009-01-29 14:02 ` Johannes Schindelin
2009-01-29 22:33 ` Jeff King
2009-01-29 23:17 ` Jeff King [this message]
2009-01-30 0:28 ` Johannes Schindelin
2009-01-30 5:09 ` Jeff King
2009-01-30 15:58 ` Johannes Schindelin
2009-01-30 16:22 ` Jeff King
2009-01-30 17:05 ` Johannes Schindelin
2009-02-02 13:16 ` Jeff King
2009-02-02 13:52 ` Johannes Schindelin
2009-02-06 14:10 ` Jeff King
2009-02-06 14:54 ` 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=20090129231715.GA17399@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
/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).