* [PATCH] git push: Interpret $GIT_DIR/branches in a Cogito compatible way
@ 2008-11-10 21:47 Martin Koegler
2008-11-10 23:25 ` Junio C Hamano
2008-11-11 8:45 ` Mike Ralphson
0 siblings, 2 replies; 5+ messages in thread
From: Martin Koegler @ 2008-11-10 21:47 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Martin Koegler
Current git versions ignore everything after # (called <head> in the
following) when pushing. Older versions (before cf818348f1ab57),
interpret #<head> as part of the URL, which make git bail out.
Ignoring the <head> part for push (fetch respects them) is unlogical.
As branches origin from Cogito, it is the best to correct this by
using the behaviour of cg-push:
push HEAD to remote refs/heads/<head>
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
Documentation/urls-remotes.txt | 19 +++++++++++----
remote.c | 11 ++++++++
t/t5516-fetch-push.sh | 50 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+), 5 deletions(-)
diff --git a/Documentation/urls-remotes.txt b/Documentation/urls-remotes.txt
index 504ae8a..d9e284c 100644
--- a/Documentation/urls-remotes.txt
+++ b/Documentation/urls-remotes.txt
@@ -68,13 +68,22 @@ This file should have the following format:
------------
`<url>` is required; `#<head>` is optional.
-When you do not provide a refspec on the command line,
-git will use the following refspec, where `<head>` defaults to `master`,
-and `<repository>` is the name of this file
-you provided in the command line.
+
+Depending on the operation, git will use one of the following
+refsprecs, if you don't provide one on the command line.
+`<branch>` is the name of this file in `$GIT_DIR/branches` and
+`<head>` defaults to `master`.
+
+git fetch uses:
+
+------------
+ refs/heads/<head>:refs/heads/<branch>
+------------
+
+git push uses:
------------
- refs/heads/<head>:<repository>
+ HEAD:refs/heads/<head>
------------
diff --git a/remote.c b/remote.c
index e530a21..660b2ce 100644
--- a/remote.c
+++ b/remote.c
@@ -297,6 +297,17 @@ static void read_branches_file(struct remote *remote)
}
add_url_alias(remote, p);
add_fetch_refspec(remote, strbuf_detach(&branch, 0));
+ /*
+ * Cogito compatible push: push current HEAD to remote #branch
+ * (master if missing)
+ */
+ strbuf_init(&branch, 0);
+ strbuf_addstr(&branch, "HEAD");
+ if (frag)
+ strbuf_addf(&branch, ":refs/heads/%s", frag);
+ else
+ strbuf_addstr(&branch, ":refs/heads/master");
+ add_push_refspec(remote, strbuf_detach(&branch, 0));
remote->fetch_tags = 1; /* always auto-follow */
}
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index a6532cb..4426df9 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -523,4 +523,54 @@ test_expect_success 'allow push to HEAD of non-bare repository (config)' '
! grep "warning.*this may cause confusion" stderr
'
+test_expect_success 'fetch with branches' '
+ mk_empty &&
+ git branch second $the_first_commit &&
+ git checkout second &&
+ echo ".." > testrepo/.git/branches/branch1 &&
+ (cd testrepo &&
+ git fetch branch1 &&
+ r=$(git show-ref -s --verify refs/heads/branch1) &&
+ test "z$r" = "z$the_commit" &&
+ test 1 = $(git for-each-ref refs/heads | wc -l)
+ ) &&
+ git checkout master
+'
+
+test_expect_success 'fetch with branches containing #' '
+ mk_empty &&
+ echo "..#second" > testrepo/.git/branches/branch2 &&
+ (cd testrepo &&
+ git fetch branch2 &&
+ r=$(git show-ref -s --verify refs/heads/branch2) &&
+ test "z$r" = "z$the_first_commit" &&
+ test 1 = $(git for-each-ref refs/heads | wc -l)
+ ) &&
+ git checkout master
+'
+
+test_expect_success 'push with branches' '
+ mk_empty &&
+ git checkout second &&
+ echo "testrepo" > .git/branches/branch1 &&
+ git push branch1 &&
+ (cd testrepo &&
+ r=$(git show-ref -s --verify refs/heads/master) &&
+ test "z$r" = "z$the_first_commit" &&
+ test 1 = $(git for-each-ref refs/heads | wc -l)
+ )
+'
+
+test_expect_success 'push with branches containing #' '
+ mk_empty &&
+ echo "testrepo#branch3" > .git/branches/branch2 &&
+ git push branch2 &&
+ (cd testrepo &&
+ r=$(git show-ref -s --verify refs/heads/branch3) &&
+ test "z$r" = "z$the_first_commit" &&
+ test 1 = $(git for-each-ref refs/heads | wc -l)
+ ) &&
+ git checkout master
+'
+
test_done
--
1.5.6.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] git push: Interpret $GIT_DIR/branches in a Cogito compatible way
2008-11-10 21:47 [PATCH] git push: Interpret $GIT_DIR/branches in a Cogito compatible way Martin Koegler
@ 2008-11-10 23:25 ` Junio C Hamano
2008-11-11 8:37 ` Martin Koegler
2008-11-11 8:45 ` Mike Ralphson
1 sibling, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2008-11-10 23:25 UTC (permalink / raw)
To: Martin Koegler; +Cc: git
Martin Koegler <mkoegler@auto.tuwien.ac.at> writes:
> Current git versions ignore everything after # (called <head> in the
> following) when pushing. Older versions (before cf818348f1ab57),
> interpret #<head> as part of the URL, which make git bail out.
>
> Ignoring the <head> part for push (fetch respects them) is unlogical.
> As branches origin from Cogito, it is the best to correct this by
> using the behaviour of cg-push:
>
> push HEAD to remote refs/heads/<head>
>
> Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
This message was addressed to me, but is it meant for inclusion?
I do not recall seeing an agreement on what the desired behaviour should
be from (ex-)Cogito users, if this change of behaviour hurts real world
usage of existing git users, andr if so how we ease this change in to the
release.
While I'd personally agree matching with whatever cg-push used to do might
make the most sense in the end, I am not sure changing of behaviour
abruptly like this is a good idea.
I am also not so sure url#branch is illogical; I'd suggest dropping that
line from the commit log message in any case.
> +
> +Depending on the operation, git will use one of the following
> +refsprecs, if you don't provide one on the command line.
> +`<branch>` is the name of this file in `$GIT_DIR/branches` and
> +`<head>` defaults to `master`.
> +
> +git fetch uses:
> +
> +------------
> + refs/heads/<head>:refs/heads/<branch>
> +------------
> +
> +git push uses:
>
> ------------
> - refs/heads/<head>:<repository>
> + HEAD:refs/heads/<head>
> ------------
Why isn't this "refs/heads/<head>:refs/heads/<head>", by the way?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] git push: Interpret $GIT_DIR/branches in a Cogito compatible way
2008-11-10 23:25 ` Junio C Hamano
@ 2008-11-11 8:37 ` Martin Koegler
2008-11-11 17:25 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Martin Koegler @ 2008-11-11 8:37 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Mon, Nov 10, 2008 at 03:25:09PM -0800, Junio C Hamano wrote:
> Martin Koegler <mkoegler@auto.tuwien.ac.at> writes:
> > Current git versions ignore everything after # (called <head> in the
> > following) when pushing. Older versions (before cf818348f1ab57),
> > interpret #<head> as part of the URL, which make git bail out.
> >
> > Ignoring the <head> part for push (fetch respects them) is unlogical.
> > As branches origin from Cogito, it is the best to correct this by
> > using the behaviour of cg-push:
> >
> > push HEAD to remote refs/heads/<head>
> >
> > Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
>
> This message was addressed to me, but is it meant for inclusion?
>
> I do not recall seeing an agreement on what the desired behaviour should
> be from (ex-)Cogito users, if this change of behaviour hurts real world
> usage of existing git users, andr if so how we ease this change in to the
> release.
Nobody else seemd to be interessted in this topic, so its difficult to
start a discussion.
I would suggest to queue it in pu for some time and wait for other
feedback.
> While I'd personally agree matching with whatever cg-push used to do might
> make the most sense in the end, I am not sure changing of behaviour
> abruptly like this is a good idea.
I'm open for any suggestion, how to make this change smoothly. I
think, that doing such a behaviour change should be OK for 1.6.1 or
1.6.2:
Until v1.5.4 (9 month ago), git-push with # was totally broken. Daniel
Barkalow fixed the fetch case in v1.5.4. As a side effect, git-push no
longer fails, but ignores everything after #. So in my option, the
current behaviour was created by chance.
> I am also not so sure url#branch is illogical; I'd suggest dropping that
> line from the commit log message in any case.
OK, I'll drop it in the next version.
> > +git push uses:
> >
> > ------------
> > - refs/heads/<head>:<repository>
> > + HEAD:refs/heads/<head>
> > ------------
>
> Why isn't this "refs/heads/<head>:refs/heads/<head>", by the way?
1) It's Cogito behaviour (cg-push(2)):
| It will push your commits on the current branch (or as specified
| by the -r option) to the remote repository, provided that your
| commits follow the last commit in the remote repository.
2) In my options, it's more flexible
If you want to push to <head>, you must create a local branch called
<head>. If you want to fetch from the remote too, you must choose a
name != <head> for the branches file, as you normaly don't want to
fetch into a local branch. Pushing to <head> in multiple remote
repositories is also more difficult, if they are used for diffent
things, as they are based on one local branch.
=> It's a way to seperate the remote head names from the local ones.
mfg Martin Kögler
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] git push: Interpret $GIT_DIR/branches in a Cogito compatible way
2008-11-10 21:47 [PATCH] git push: Interpret $GIT_DIR/branches in a Cogito compatible way Martin Koegler
2008-11-10 23:25 ` Junio C Hamano
@ 2008-11-11 8:45 ` Mike Ralphson
1 sibling, 0 replies; 5+ messages in thread
From: Mike Ralphson @ 2008-11-11 8:45 UTC (permalink / raw)
To: Martin Koegler; +Cc: Junio C Hamano, git
2008/11/10 Martin Koegler <mkoegler@auto.tuwien.ac.at>:
> +Depending on the operation, git will use one of the following
> +refsprecs, if you don't provide one on the command line.
s/refsprecs,/refspecs/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] git push: Interpret $GIT_DIR/branches in a Cogito compatible way
2008-11-11 8:37 ` Martin Koegler
@ 2008-11-11 17:25 ` Junio C Hamano
0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2008-11-11 17:25 UTC (permalink / raw)
To: Martin Koegler; +Cc: git
mkoegler@auto.tuwien.ac.at (Martin Koegler) writes:
> Nobody else seemd to be interessted in this topic, so its difficult to
> start a discussion.
>
> I would suggest to queue it in pu for some time and wait for other
> feedback.
>
>> While I'd personally agree matching with whatever cg-push used to do might
>> make the most sense in the end, I am not sure changing of behaviour
>> abruptly like this is a good idea.
>
> I'm open for any suggestion, how to make this change smoothly. I
> think, that doing such a behaviour change should be OK for 1.6.1 or
> 1.6.2:
>
> Until v1.5.4 (9 month ago), git-push with # was totally broken. Daniel
> Barkalow fixed the fetch case in v1.5.4. As a side effect, git-push no
> longer fails, but ignores everything after #. So in my option, the
> current behaviour was created by chance.
>
>> I am also not so sure url#branch is illogical; I'd suggest dropping that
>> line from the commit log message in any case.
>
> OK, I'll drop it in the next version.
Thanks for detailed explanation of the background.
Everything you said makes sense. You convinced me that this is just a
bugfix that does not warrant a deprecation notice nor waiting for a flag
day release. I'm even inclined to say that we should apply this
eventually to 'maint' (which means we'd fork a topic branch from maint,
merge that first to next and then to master and eventually to maint to be
included in 1.6.0.X, while the change will go to 1.6.1 as well).
Does the patch apply to 'maint' right now?
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-11-11 17:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-10 21:47 [PATCH] git push: Interpret $GIT_DIR/branches in a Cogito compatible way Martin Koegler
2008-11-10 23:25 ` Junio C Hamano
2008-11-11 8:37 ` Martin Koegler
2008-11-11 17:25 ` Junio C Hamano
2008-11-11 8:45 ` Mike Ralphson
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).