git push --track
PATCH 1/1 git push --track
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.
Usage:
git branch mybranch
git checkout mybranch
...
git push --track origin mybranch:mybranch
will not just perform the push, but also write a block
[branch "mybranch"]
remote = origin
merge = refs/heads/mybranch
to the git configuration so the branch becomes tracking.
This should be a simpler alternative to the otherwise usual procedure
git push origin mybranch:mybranch
git config branch.mybranch.remote origin
git config branch.mybranch.merge refs/heads/mybranch
Are there any chances for this getting added to official git - or an alternate convenient way convert a local to a tracking branch?
Best regards,
Rudolf
builtin-push.c +30 -0
@@ -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,33 @@ 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 +246,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() };
transport.h +1 -0
@@ -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 *);
Quoted 5 lines · Rudolf Polzer
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.
Quoted 2 lines
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.
Also couple comments:
- Some lines look way too long (~160 chars, should be max 80 unles it would linebreak error message).
- Should the tracking be set up even if only part of ref update suceeded (for those that succeeded), not requiring all to succeed?
- Is --track the best name for this?
-Ilari
Quoted 7 lines · Ilari Liusvaara
Quoted 5 lines · Rudolf Polzer
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.
Quoted 8 lines
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.
Quoted 2 lines
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.
Quoted 4 lines
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.
Quoted 2 lines
- 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.
Quoted 1 line
- 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 <[email protected]>
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(-)
builtin-push.c +31 -0
@@ -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()
};
transport.h +1 -0
@@ -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 *);
Signature · 11 lines
1.6.3.3 From bbdd185ac43fb789f35d0177697486457af87fd0 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer <[email protected]> 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(-)
Documentation/git-push.txt +8 -0
@@ -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.
Signature · 1 line
1.6.3.3
Quoted 10 lines · Rudolf Polzer
Quoted 3 lines · Ilari Liusvaara
Quoted 2 lines · Rudolf Polzer
Hi,
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.
It would need sign-off by you. Even if you took the code from somewhere (and then it would need theirs as well) and passed it along.
Quoted 5 lines
Quoted 2 lines
- 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.
Ah, that is only known in transport_push and what it calls (and transport_push is last point to insert common functionality)...
Review
Quoted 11 lines
(quoted diff) +2
-0@@ -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),(quoted diff) +0
-0OPT_END() };
Linewrap damage.
-Ilari
Quoted 3 lines · Rudolf Polzer
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.
Read Documentation/SubmittingPatches in Git's source to make sure you understand what Signed-off-by: means for the Git project.
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Quoted 5 lines · Rudolf Polzer
Quoted 2 lines
- 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.
I don't think it's that hard. In fact, I did a preliminary patch for it about a year ago:
http://article.gmane.org/gmane.comp.version-control.git/107750
That patch was held up because there were a lot of cleanups needed in transport.c before it would make sense (read the whole thread for details). I think most of those cleanups have happened in the meantime, so it would be pretty straightforward to use the same setup_tracking() function and just call it from the right spot in transport.c. But I haven't actually looked at this topic since the above-referenced thread.
-Peff
Quoted 8 lines · Rudolf Polzer
Quoted 2 lines · Ilari Liusvaara
- 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.
You didn't, although you tried to "hide" one level, which is even worse.
If you see overlong lines in patch text, it often is that the added codepath is too deeply nested, and it often becomes much easier to understand if you split it into a separate smaller helper function.
For example, if you have
if (A) {
if (B) {
do something #1
if (C) {
do something #2
while (D) {
if (E) {
do something #3
}
}
}
}
}it often is much easier to read if you did:
if (A) helper(...)
and wrote a helper that is
helper()
{
if (!B)
return
do something #1
if (!C)
return
do something #2
while (D) {
if (!E)
continue
do something #3
}
}Quoted 2 lines
Quoted 2 lines
- Should the tracking be set up even if only part of ref update suceeded (for those that succeeded), not requiring all to succeed?
I think giving configuration to the ones that succeeded, while not doing so for the ones that failed, would be the best.
Quoted 1 line
Quoted 1 line
- Is --track the best name for this?
Most probably not. "git branch --track" was already a mistake, whose damage can be seen in the first message in this thread. I originally read "this converts a local branch to a tracking branch", and went "Huh??? --- Is this patch running 'mv refs/heads/frotz refs/remotes/origin/frotz'? What's fun about it???"
builtin-push.c static int push_with_options(struct transport · line 120
Quoted 6 lines
builtin-push.c +1
-0@@ -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 ) {
Style:
- Have SP between syntactic keyword and open parenthesis.
- Never place an opening brace, except the one that begins a function body, on its own line;
Also the overlong line is merely a symptom that you are putting too much stuff in this function. The whole addition should probably be a helper function.
builtin-push.c static int push_with_options(struct transport *transport, int flags) · line 122
Quoted 8 lines
builtin-push.c +4
-0@@ -115,6 +116,33 @@ 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 );
You have already pushed by calling transport_push() before you got "err" back. Do you need to make a second, separate call to ls-remote here and if so why?
I have a feeling that it is more appropriate to have the additional code in transport_push(), which gets ls-remote information, runs match_refs() and finally calls transport->push_refs(). I think the extra branch configuration would fit better inside the if block immediately after all that happens, i.e.
if (!(flags & TRANSPORT_PUSH_DRY_RUN)) {
struct ref *ref;
for (ref = remote_refs; ref; ref = ref->next)
update_tracking_ref(transport->remote, ref, verbose);
+ if (flags & TRANSPORT_PUSH_RECONFIGURE_FORK)
+ configure_forked_branch(...);
}in transport.c
Review static int push_with_options(struct transport *transport, int flags) · line 124
Quoted 2 lines
(quoted diff) +2
-0+ if(!(flags & TRANSPORT_PUSH_DRY_RUN)) + if(!match_refs(local_refs, &remote_refs, refspec_nr, refspec, match_flags))
Yuck; hiding the fact that you have an over-nested logic is not a way to fix it.
Quoted 14 lines · Junio C Hamano
I have a feeling that it is more appropriate to have the additional code in
transport_push(), which gets ls-remote information, runsmatch_refs()and finally callstransport->push_refs(). I think the extra branch configuration would fit better inside the if block immediately after all that happens, i.e.if (!(flags & TRANSPORT_PUSH_DRY_RUN)) { struct ref *ref; for (ref = remote_refs; ref; ref = ref->next) update_tracking_ref(transport->remote, ref, verbose);(quoted diff) +2
-0+ if (flags & TRANSPORT_PUSH_RECONFIGURE_FORK) + configure_forked_branch(...);}
Quoted 1 line
in
transport.c
I thought about this place when making my patch, but didn't put it there because this function is not called in the rsync protocol (which defines transport->push). So I instead did the logical step and went into the caller of that function. Functionality-wise, it also isn't really a "transport" function but part of pushing.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if(!(flags & TRANSPORT_PUSH_DRY_RUN)) + if(!match_refs(local_refs, &remote_refs, refspec_nr, refspec, match_flags))Yuck; hiding the fact that you have an over-nested logic is not a way to fix it.
This was accidental.
But well. Why bother with this, if this feature was rejected before already anyway.
Rudolf
Quoted 15 lines · Rudolf Polzer
Quoted 14 lines · Junio C Hamano
I have a feeling that it is more appropriate to have the additional code in
transport_push(), which gets ls-remote information, runsmatch_refs()and finally callstransport->push_refs(). I think the extra branch configuration would fit better inside the if block immediately after all that happens, i.e.if (!(flags & TRANSPORT_PUSH_DRY_RUN)) { struct ref *ref; for (ref = remote_refs; ref; ref = ref->next) update_tracking_ref(transport->remote, ref, verbose);(quoted diff) +2
-0+ if (flags & TRANSPORT_PUSH_RECONFIGURE_FORK) + configure_forked_branch(...);}
Quoted 5 lines
Quoted 1 line
in
transport.cI thought about this place when making my patch, but didn't put it there because this function is not called in the rsync protocol (which defines
transport->push).
That's not a very good reasoning. Instead of punishing well behaved transport that defines push_ref, punish _only_ the transports that does not define it (see the paragraph at the end of this message).
Quoted 2 lines
But well. Why bother with this, if this feature was rejected before already anyway.
Read the thread Nana quoted for you again; I nor anybody ever _rejected_ the ultimate goal, even though I said that the justifications were not sufficiently convincing for the previous implementation attempts.
I think Ilari's patch is done right and can be extended by anybody who cares about rsync transport to call an extra ls-remote in the "does this one lack push_ref but know how to push" codepath.
Quoted 2 lines · Rudolf Polzer
But well. Why bother with this, if this feature was rejected before already anyway.
It's a good feature and people obviously want it, so it's worth trying.
Sometimes it takes a few tries to get a feature added...
-Miles
Signature · 3 lines
`...the Soviet Union was sliding in to an economic collapse so comprehensive that in the end its factories produced not goods but bads: finished products less valuable than the raw materials they were made from.' [The Economist]
Hi,
generally, it would be better if you could add some tests for this.
If I'm not wrong, the place to put it would be t5516-fetch-push.sh.
Quoted 2 lines · Rudolf Polzer
On Wed, 13 Jan 2010 16:43:10 +0100, Ilari Liusvaara <[email protected]> wrote:
please don't drop people from the Cc list - especially when you're replying to somebody!
Quoted 5 lines
From
123598516c7d4e1f83591e8dae64e2c76dc87c90Mon Sep 17 00:00:00 2001
From: Rudolf Polzer <[email protected]>
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
Each patch should be sent out in its own mail. (As Matthieu has recommended, you should check out Documentation/SubmittingPatches.)
Quoted 9 lines
static const char * const push_usage[] = {
builtin-push.c +3
-0@@ -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);
builtin-push.c static int push_with_options(struct transport · line 132
Quoted 10 lines
builtin-push.c +9
-0+ 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)) {
It would be better if you can move this to transport.c::transport_push(). It repeats what's already there, so you don't have to configure match_flags, nor call match_refs, etc.
builtin-push.c static int push_with_options(struct transport *transport, int flags) · line 145
Quoted 4 lines
builtin-push.c +3
-0+ struct ref *next = remote_refs; + while(next) { + next = next->next;
In most places, this is done like this:
struct ref* ref;
for (ref = remote_refs; ref; ref = ref->next) {
...
}Signature · 2 lines
Cheers, Ray Chuan
Quoted 5 lines · Tay Ray Chuan
Hi,
generally, it would be better if you could add some tests for this.
If I'm not wrong, the place to put it would be
t5516-fetch-push.sh.
Can add that, but it seems like it won't go in anyway from the discussion here, so it's probably not worth working on it. Sad.
Quoted 6 lines · Rudolf Polzer
Quoted 2 lines
On Wed, 13 Jan 2010 16:43:10 +0100, Ilari Liusvaara <[email protected]> wrote:
please don't drop people from the Cc list - especially when you're replying to somebody!
I did not drop anyone, but simply replied from my newsreader. I really don't want to subscribe to a mailing list and then get hundreds of emails a day.
Quoted 8 lines
Quoted 5 lines
From
123598516c7d4e1f83591e8dae64e2c76dc87c90Mon Sep 17 00:00:00 2001
From: Rudolf Polzer <[email protected]>
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 trackingEach patch should be sent out in its own mail. (As Matthieu has recommended, you should check out
Documentation/SubmittingPatches.)
So, using a newsreader is not accepted practice? Why is the mailing list on a newsgroup then?
Quoted 15 lines
Quoted 15 lines
static const char * const push_usage[] = {
builtin-push.c +9
-0@@ -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;
Quoted 8 lines
builtin-push.c static int push_with_options(struct transport *transport, int flags) · line 130
Quoted 4 lines
builtin-push.c +3
-0+ if(!(flags & TRANSPORT_PUSH_DRY_RUN)) + if(!match_refs(local_refs, &remote_refs, refspec_nr, refspec, + match_flags)) {It would be better if you can move this to
transport.c::transport_push(). It repeats what's already there, so you don't have to configurematch_flags, nor callmatch_refs, etc.
Then I have to duplicate it in the rsync specific push code too. Otherwise, agreed.
Quoted 11 lines
builtin-push.c static int push_with_options(struct transport *transport, int flags) · line 145
Quoted 4 lines
builtin-push.c +3
-0+ struct ref *next = remote_refs; + while(next) { + next = next->next;In most places, this is done like this:
struct ref* ref; for (ref = remote_refs; ref; ref = ref->next) { ... }
Sure, could do that too, I got this loop from the loop that frees a ref list.
Best regards,
Rudolf
Quoted 5 lines · Rudolf Polzer
Quoted 2 lines
Each patch should be sent out in its own mail. (As Matthieu has recommended, you should check out
Documentation/SubmittingPatches.)So, using a newsreader is not accepted practice? Why is the mailing list on a newsgroup then?
I do read this list in a newsreader. When I say "reply" or "follow-up", the response is sent out to the list via e-mail. Your newsreader should be configurable in a similar way, I think.
Quoted 1 line · Ilari Liusvaara
- Is --track the best name for this?
I think "--track" is absolutely the right name for this option -- it's the option name used for "set up tracking" option in other commands, and it's just very natural (when I've thought about implementing a similar functionality myself, I also chose the name "--track").
-Miles
Signature · 3 lines
Youth, n. The Period of Possibility, when Archimedes finds a fulcrum, Cassandra has a following and seven cities compete for the honor of endowing a living Homer.
Quoting Rudolf Polzer <[email protected]>
Quoted 2 lines
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.
How well does this take earlier discussions on the same topic into account? For example, did you study the design discussion in
http://thread.gmane.org/gmane.comp.version-control.git/135325/focus=135390
Signature · 2 lines
Nanako Shiraishi http://ivory.ap.teacup.com/nanako3/
Quoted 7 lines · Nanako Shiraishi
Quoting Rudolf Polzer <[email protected]>
Quoted 2 lines
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.
How well does this take earlier discussions on the same topic into account? For example, did you study the design discussion in
http://thread.gmane.org/gmane.comp.version-control.git/135325/focus=135390
I don't really think this has much to do with the other. git branch --will-track still means one needs to know it at branch setup time, and git pull --remember still means one needs to type way more stuff than with a simple push --track.
But well, given the discussion here I see the feature is essentially rejected, and already was rejected a previous time. Will probably forget about this and make a shell script that does for ME what I want.
Best regards,
Rudolf
Hi,
Quoted 7 lines · Nanako Shiraishi
Quoting Rudolf Polzer <[email protected]>
Quoted 2 lines
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.
How well does this take earlier discussions on the same topic into account? For example, did you study the design discussion in
http://thread.gmane.org/gmane.comp.version-control.git/135325/focus=135390
Thank you for looking up that reference.
Do you remember what the outcome was? (Peff mentioned that there was some talk about putting this code into transport.c and some needed restructurings, but I do not remember the details, and I did not have time to follow the development of that file in the recent months.)
Ciao,
Dscho
Quoting Johannes Schindelin <[email protected]>
Quoted 7 lines · Nanako Shiraishi
Quoted 6 lines
Quoting Rudolf Polzer <[email protected]>
Quoted 2 lines
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.
Quoted 6 lines
Quoted 2 lines
How well does this take earlier discussions on the same topic into account? For example, did you study the design discussion in
http://thread.gmane.org/gmane.comp.version-control.git/135325/focus=135390Thank you for looking up that reference.
Do you remember what the outcome was?
I summarized it when I reminded Junio on this topic last time and it is in the same discussion thread: http://thread.gmane.org/gmane.comp.version-control.git/135325/focus=136216
Here is an extended version.
'git branch --will-track origin/topic topic origin/master' was proposed as a way to fork a topic branch at origin's master. Later 'git pull' will merge topic from origin to topic.
This is bad in two ways. It will force users to decide when the branch is created. It will not allow users to configure branch.topic.rebase variable.
'git push --track' was suggested as a way to let users delay that decision.
'git branch --configure' to update the same information for an existing branch was suggested as an alternative UI. An added benefit is that this approach will allow the same option to be used when creating a branch.
'git pull --remember' that remembers the options used from the command line was suggested as a solution in addition to 'git branch --reconfigure'. Users can postpone the decision even more than 'git push --track', and it naturally supports setting branch.topic.rebase with 'git pull --rebase --remember'. It also has two additional benefits. 'push --track' configures what happens when you 'pull' (counter-intuitive), but 'pull --remember' makes 'pull' to change the setting used by 'pull' (much more natural). Also it does not add the confusing word 'track' to the interface (for a more detailed discussion on 'track', see http://article.gmane.org/gmane.comp.version-control.git/136785).
Signature · 2 lines
Nanako Shiraishi http://ivory.ap.teacup.com/nanako3/
Quoted 6 lines · Nanako Shiraishi
'git push --track' was suggested as a way to let users delay that decision.
'git branch --configure' to update the same information for an existing branch was suggested as an alternative UI. An added benefit is that this approach will allow the same option to be used when creating a branch.
Quoted 9 lines
'git pull --remember' that remembers the options used from the command line was suggested as a solution in addition to 'git branch --reconfigure'. Users can postpone the decision even more than 'git push --track', and it naturally supports setting branch.topic.rebase with 'git pull --rebase --remember'. It also has two additional benefits. 'push --track' configures what happens when you 'pull' (counter-intuitive), but 'pull --remember' makes 'pull' to change the setting used by 'pull' (much more natural). Also it does not add the confusing word 'track' to the interface (for a more detailed discussion on 'track', see http://article.gmane.org/gmane.comp.version-control.git/136785).
Still requires you to specify the remote and the branch name twice.
So the workflow would be:
git push origin localbranch:remotebranch
...
git pull --remember origin remotebranch:localbranch
instead of
git push --track origin localbranch:remotebranch
...
git pull
The one thing I want to avoid, is specifying the "origin localbranch:remotebranch" stuff twice.
Doesn't make git pull --remember a bad idea, it's good in many other cases. But in my specific use case, git push --track is the most useful one.
Rudolf
Hi,
Quoted 7 lines · Rudolf Polzer
Quoted 6 lines · Nanako Shiraishi
'git push --track' was suggested as a way to let users delay that decision.
'git branch --configure' to update the same information for an existing branch was suggested as an alternative UI. An added benefit is that this approach will allow the same option to be used when creating a branch.
Quoted 9 lines
Quoted 9 lines
'git pull --remember' that remembers the options used from the command line was suggested as a solution in addition to 'git branch --reconfigure'. Users can postpone the decision even more than 'git push --track', and it naturally supports setting branch.topic.rebase with 'git pull --rebase --remember'. It also has two additional benefits. 'push --track' configures what happens when you 'pull' (counter-intuitive), but 'pull --remember' makes 'pull' to change the setting used by 'pull' (much more natural). Also it does not add the confusing word 'track' to the interface (for a more detailed discussion on 'track', see http://article.gmane.org/gmane.comp.version-control.git/136785).
Thanks for the very nice summary!
Quoted 14 lines
Still requires you to specify the remote and the branch name twice.
So the workflow would be:
git push origin localbranch:remotebranch
...
git pull --remember origin remotebranch:localbranchinstead of
git push --track origin localbranch:remotebranch
...
git pull
Quoted 6 lines
The one thing I want to avoid, is specifying the "origin localbranch:remotebranch" stuff twice.
Doesn't make git pull --remember a bad idea, it's good in many other cases. But in my specific use case, git push --track is the most useful one.
The thing is: done right, the three can share the major part of the code.
Ciao,
Dscho
Quoted 1 line · Nanako Shiraishi
I summarized it when I reminded Junio on this topic last time and it is in the same discussion thread: http://thread.gmane.org/gmane.comp.version-control.git/135325/focus=136216
Please wrap your lines for readability.
Quoted 1 line
'git pull --remember' that remembers...
Although I admit I was the one who suggested it, and I think that it is the most natural way to do this from the end user's point of view, from the implementation point of view, it is the most difficult one in its current form. "git pull" does not interpret refspecs and delegates all the hard work to "git fetch".
Quoted 2 lines · Rudolf Polzer
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.
Yay!!
I've wanted this for a long time, but discussions about it always seem to end up petering out...
Quoted 4 lines
git branch mybranch
git checkout mybranch
...
git push --track origin mybranch:mybranch
Does it default to the current branch so you can just say "git push --track origin"?
I hope this can be added to the distro...
Thanks,
-Miles
Signature · 2 lines
Opposition, n. In politics the party that prevents the Goverment from running amok by hamstringing it.
Quoted 9 lines · Miles Bader
Quoted 2 lines · Rudolf Polzer
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.
Yay!!
I've wanted this for a long time, but discussions about it always seem to end up petering out...
Quoted 6 lines
Quoted 4 lines
git branch mybranch
git checkout mybranch
...
git push --track origin mybranch:mybranchDoes it default to the current branch so you can just say "git push --track origin"?
It does the very same decisions as push. Basically, it is "whatever got pushed, mark as tracking".
Best regards,
Rudolf
Quoted 1 line · Miles Bader
Yay!!
Yay too!
Quoted 3 lines
Quoted 1 line
git push --track origin mybranch:mybranch
Does it default to the current branch so you can just say "git push --track origin"?
<wishlist>Can we take this further and say
git push --make-a-new-repo-and-track-it --shared
git+ssh://foo.bar/var/git/mynewthing.git master:master
...?
</wishlist>
Of course it'd only work if you have full ssh access, unless the git server learns a new command to mkdir (in sane and approved locations).
cheers,
m
Signature · 5 lines
[email protected] [email protected] -- School Server Architect - ask interesting questions - don't get distracted with shiny stuff - working code first - http://wiki.laptop.org/go/User:Martinlanghoff
Hi,
Quoted 8 lines · Martin Langhoff
<wishlist>Can we take this further and say
git push --make-a-new-repo-and-track-it --shared
git+ssh://foo.bar/var/git/mynewthing.git master:master...?
</wishlist>
You mean just like http pushing?
Quoted 2 lines
Of course it'd only work if you have full ssh access, unless the git server learns a new command to mkdir (in sane and approved locations).
You mean a new "init" command a la "git --git-dir=bla.git init", which _does_ mkdir the directory.
Ciao,
Dscho
Quoted 5 lines · Johannes Schindelin
Quoted 2 lines
Of course it'd only work if you have full ssh access, unless the git server learns a new command to mkdir (in sane and approved locations).
You mean a new "init" command a la "git --git-dir=bla.git init", which _does_ mkdir the directory.
I think he meant
git --git-dir=git+ssh://foo.bar/var/git/mynewthing.git init
which doesn't.
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Quoted 5 lines · Matthieu Moy
Quoted 3 lines · Johannes Schindelin
Quoted 2 lines
Of course it'd only work if you have full ssh access, unless the git server learns a new command to mkdir (in sane and approved locations).
Quoted 8 lines
Quoted 2 lines
You mean a new "init" command a la "git --git-dir=bla.git init", which _does_ mkdir the directory.
I think he meant
git --git-dir=git+ssh://foo.bar/var/git/mynewthing.git initwhich doesn't.
But 'ssh foo.bar git --git-dir=/var/git/mynewthing.git init' likely would.
Probably missing a --bare somewhere; and I think that repo creation potentially needs too many things (like custom hook or access rights setup) to be done via git push. Especially since you really only need to create an empty repo, and only if you didn't clone from the push target in the first place.
Andreas
Quoted 3 lines · Matthieu Moy
I think he meant
git --git-dir=git+ssh://foo.bar/var/git/mynewthing.git init
exacto. And push --track, all in one cmd.
Zooper easy for users.
m
Signature · 5 lines
[email protected] [email protected] -- School Server Architect - ask interesting questions - don't get distracted with shiny stuff - working code first - http://wiki.laptop.org/go/User:Martinlanghoff
BTW, I was _just_ going to post a message saying "whatever happened to push --track", but then decided to check the list once more, and saw your message...!
-Miles
Signature · 1 line
Dawn, n. When men of reason go to bed.
Hi,
Quoted 8 lines · Miles Bader
Quoted 2 lines · Rudolf Polzer
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.
Yay!!
I've wanted this for a long time, but discussions about it always seem to end up petering out...
That is not fair. I came up with a patch already years ago. You could always have applied it to your own source, maybe after tweaking. And then maybe lobbying for it.
Ciao,
Dscho
Quoted 6 lines · Johannes Schindelin
Quoted 2 lines
I've wanted this for a long time, but discussions about it always seem to end up petering out...
That is not fair. I came up with a patch already years ago. You could always have applied it to your own source, maybe after tweaking. And then maybe lobbying for it.
Ah, sorry, I didn't mean anything against your patch, I just didn't know about it.
I don't track this list as well as I could....
[Do you have a pointer to your patch?]
Thanks,
-Miles
Signature · 1 line
Do not taunt Happy Fun Ball.
Hi,
Quoted 20 lines · Rudolf Polzer
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.
Usage:
git branch mybranch
git checkout mybranch
...
git push --track origin mybranch:mybranchwill not just perform the push, but also write a block
[branch "mybranch"]
remote = origin
merge = refs/heads/mybranchto the git configuration so the branch becomes tracking.
Quoted 8 lines
This should be a simpler alternative to the otherwise usual procedure
git push origin mybranch:mybranch
git config branch.mybranch.remote origin
git config branch.mybranch.merge refs/heads/mybranchAre there any chances for this getting added to official git - or an alternate convenient way convert a local to a tracking branch?
before I put up my comments on the patch, I wonder if git-push is the best place to add this feature, as git-push usually deals with "pushing" data to another repo.
I think git-branch would be a better place to do this.
Signature · 2 lines
Cheers, Ray Chuan
Quoted 5 lines · Tay Ray Chuan
before I put up my comments on the patch, I wonder if git-push is the best place to add this feature, as git-push usually deals with "pushing" data to another repo.
I think git-branch would be a better place to do this.
I think git-branch can already do this: after pushing, you can do git branch -f --track origin/mybranch.
But the goal of this is to postponing the decision to track to the push time, and adding as little as possible extra commands/options to do this.
Quoted 5 lines · Rudolf Polzer
Quoted 4 lines · Tay Ray Chuan
before I put up my comments on the patch, I wonder if git-push is the best place to add this feature, as git-push usually deals with "pushing" data to another repo.
Quoted 7 lines
Quoted 1 line
I think git-branch would be a better place to do this.
I think git-branch can already do this: after pushing, you can do git branch -f --track origin/mybranch.
But the goal of this is to postponing the decision to track to the push time, and adding as little as possible extra commands/options to do this.
Thinking about this again (when was the last time we discussed it?), I like the "git branch -f" suggestion (modulo one small nit).
Yes, "push --track" lets you postpone the decision; branching, working on it, pushing it out _and_ _then_ using your "branch -f" trick will let you postpone the decision even further. And it doesn't add --track to the UI.
The small nit is that "branch -f --track me origin/me" will happily overwrite "me", even when your "me" is not up to date with "origin/me", losing commits.
Perhaps we could teach "branch --track me origin/me" (i.e. no "-f") not to barf even when "me" exists, as long as "me" is a subset of "origin/me", and treat it as a request to re-configure the upstream information for the existing branch "me" and at the same time fast-forward it to "origin/me"?
Quoted 3 lines · Junio C Hamano
Yes, "push --track" lets you postpone the decision; branching, working on it, pushing it out _and_ _then_ using your "branch -f" trick will let you postpone the decision even further.
Nonetheless, "push --track" is by far the most natural UI for the most common case, I think.
Quoted 1 line
And it doesn't add --track to the UI.
That's not a positive...
None of this is _necessary_, it's to make git more convenient.
Halfway-measures seem like "oh the user can just use this branch command" seem like, well, halfway measures. Sure, it would be nice to have a branch command _too_, just to make it easier for branch maintenance, but it's not what's really wanted.
-Miles
Signature · 2 lines
Faith, n. Belief without evidence in what is told by one who speaks without knowledge, of things without parallel.
Quoted 3 lines · Miles Bader
Quoted 1 line
And it doesn't add --track to the UI.
That's not a positive...
Oh, that is definitely a *HUGE* plus. I wouldn't go so far as to say that the word --track was a mistake. But the thing is, unfortunately it has already been contaminated by people using it in two completely different ways and ended up confusing new people. Some use it to mean "this branch forked off of and builds on top of", and others use it to mean "this ref holds a copy for reference purposes".
Quoted 10 lines · Junio C Hamano
Quoted 3 lines
Quoted 1 line
And it doesn't add --track to the UI.
That's not a positive...
Oh, that is definitely a *HUGE* plus. I wouldn't go so far as to say that the word --track was a mistake. But the thing is, unfortunately it has already been contaminated by people using it in two completely different ways and ended up confusing new people. Some use it to mean "this branch forked off of and builds on top of", and others use it to mean "this ref holds a copy for reference purposes".
Then the right thing to do is to rename existing uses of --track so that they're not confusing. Much-wanted functionality should not be rejected simply because of an earlier mistake which is essentially orthogonal to it, and which can be corrected easily enough.
So let's just say we're discussing the semantics, and it will use another option name, which will be then retrofitted to other similar uses for consistency (as should surely be done regardless of what happens with this command):
git push --GRUBBLENUT
-Miles
Signature · 1 line
Do not taunt Happy Fun Ball.
Quoted 3 lines · Junio C Hamano
The small nit is that "branch -f --track me origin/me" will happily overwrite "me", even when your "me" is not up to date with "origin/me", losing commits.
And another issue is:
$ git branch -f --track my-branch origin/my-branch fatal: Cannot force update the current branch. $ git branch --track my-branch origin/my-branch fatal: A branch named 'my-branch' already exists.
Actually, I just can't find a natural set of commands doing:
1. create a branch (git checkout -b)
2. work on it
3. send it upstream (git push)
4. set the upstream as tracking (???)
with the current version of Git. I just do 4. with $EDITOR .git/config ...
Quoted 5 lines
Perhaps we could teach "branch --track me origin/me" (i.e. no "-f") not to barf even when "me" exists, as long as "me" is a subset of "origin/me", and treat it as a request to re-configure the upstream information for the existing branch "me" and at the same time fast-forward it to "origin/me"?
+1, and in addition, allow doing this on the checkout branch if it doesn't actually change the reference (i.e. touch .git/config, not .git/refs/...).
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Quoted 5 lines · Tay Ray Chuan
before I put up my comments on the patch, I wonder if git-push is the best place to add this feature, as git-push usually deals with "pushing" data to another repo.
I think git-branch would be a better place to do this.
No. I think push is absolutely the right place to do it.
I very often create local branches and only later decide that I'd also like to push them to a remote -- but just as often, or more often, I never do so. It would be extremely annoying if I had to make that decision at branch-time.
-Miles
Signature · 2 lines
Pray, v. To ask that the laws of the universe be annulled in behalf of a single petitioner confessedly unworthy.
Hi,
Quoted 5 lines · Miles Bader
Quoted 4 lines · Tay Ray Chuan
before I put up my comments on the patch, I wonder if git-push is the best place to add this feature, as git-push usually deals with "pushing" data to another repo.
Quoted 8 lines
Quoted 1 line
I think git-branch would be a better place to do this.
No. I think push is absolutely the right place to do it.
I very often create local branches and only later decide that I'd also like to push them to a remote -- but just as often, or more often, I never do so. It would be extremely annoying if I had to make that decision at branch-time.
I'm not saying that the feature should belong to git-branch and so you have to make this decision at branch time - I'm saying that since this has got to do with modifying branches (sort of), it should be in there.
Signature · 2 lines
Cheers, Ray Chuan
Quoted 9 lines · Tay Ray Chuan
Quoted 4 lines
I very often create local branches and only later decide that I'd also like to push them to a remote -- but just as often, or more often, I never do so. It would be extremely annoying if I had to make that decision at branch-time.
I'm not saying that the feature should belong to git-branch and so you have to make this decision at branch time - I'm saying that since this has got to do with modifying branches (sort of), it should be in there.
I, and it appears other people, want to make this association at push-time -- that's almost always when I make the decision "I'd like to track this" -- so the most convenient and intuitive thing would be to have a --track option to push.
Of course there could _also_ be some sort of branch sub-command (or another command) to setup or change tracking state without pushing. But "push --track" is more important for normal usage I think.
-miles
Signature · 1 line
Do not taunt Happy Fun Ball.
Quoted 8 lines · Miles Bader
I, and it appears other people, want to make this association at push-time -- that's almost always when I make the decision "I'd like to track this" -- so the most convenient and intuitive thing would be to have a --track option to push.
Of course there could _also_ be some sort of branch sub-command (or another command) to setup or change tracking state without pushing. But "push --track" is more important for normal usage I think.
Ok, I see your point.
Signature · 2 lines
Cheers, Ray Chuan