@@ -128,6 +129,12 @@ be updated. (See linkgit:git-config[1]). + With `--prune` option, prune all the remotes that are updated.+'tracking'::++Returns the tracking branch for the given remote (<name>) and branch+(<branch>). Note that <branch> must exactly match the left hand side of+the refspec of the given remote.+ DISCUSSION ----------
This function is used in "git pull --rebase" to know the tracking branch.
Signed-off-by: Santi Béjar <redacted>
---
git-parse-remote.sh | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
@@ -74,8 +74,6 @@ get_remote_merge_branch () {repo=$1shiftref=$1-# FIXME: It should return the tracking branch-# Currently only works with the default mappingcase"$ref"in+*)ref=$(expr"z$ref":'z+\(.*\)')
I've noticed that having branch.<branch>.merge set with the branch
name, and not with the full ref, cause problems with
--format='%(upstream)' and also with the "branch -av" and "git
status" upstream branch outputs. But git-fetch and git-pull works ok,
so it is a valid setting.
Actually, it is broken in a lot of places. for-each-ref relies on the
same code as "git status", "git checkout", etc, which will all fail to
display tracking info. I believe the same code is also used for updating
tracking branches on push. So I'm not sure if it was ever intended to be
a valid setting.
It wasn't. Some places may accept them gracefully by either being extra
nice or by accident.
And what about the comments in my reply. And in the branch.<name>.merge
docs says: The value is handled like the remote part of a refspec.
In fact I found it trying to implement a patch to get the local tracking
for a given remote and branch. But it only works if you spell the branch with
its full form:
$ git remote tracking origin master # does not work
$ git remote tracking origin refs/heads/master # does work
refs/remotes/origin/master
so I thought it would be better to resolve the %(upstream) first.
So if you know how to resolve this and or the %(upstream) issue, please tell me.
Anyway, here you have the WIP patch to get the tracking branch, I'm not sure
about the UI (or the script interface?), it is also a RFC.
---8<----
Subject: [RFC/PATCH]: Output tracking branch from remote and branch
---
Hi,
as said above it is a RFC, specially for the UI, and also can anyone help
me with the:
$ git remote tracking origin master # does not work
case?
Thanks,
Santi
P.D: This case will be used in the "git pull --rebase remote branch" case.
builtin-remote.c | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
Seems something is wrong in the --cover-letter utf-8 handlin, no?
In this case (the cover letter) it is send-email that handles the
utf-8, but I don't know why it is not working, as there is a test in
t9001-send-email that tests it. I think it worked, I'll try to bisect
if I found a working version.
Santi
This function is used in "git pull --rebase" to know the tracking branch.
Signed-off-by: Santi Béjar <redacted>
---
git-parse-remote.sh | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
+ while true ; do
+ case "$remote" in
+ '' | HEAD ) remote=;;
I forgot to say that I changed the HEAD behavior because the remote
HEAD and the local remote HEAD (origin/HEAD) can point to different
branches, as the local remote HEAD represents your preference for
which is the default remote branch.
Santi
@@ -128,6 +129,12 @@ be updated. (See linkgit:git-config[1]). + With `--prune` option, prune all the remotes that are updated.+'tracking'::++Returns the tracking branch for the given remote (<name>) and branch+(<branch>). Note that <branch> must exactly match the left hand side of+the refspec of the given remote.+
From that description, it is not clear to me if the branch is the _remote_
branch, the branch _on_ the remote, or the local branch.
If it is the remote branch (or the branch on the remote), I wonder how you
deal with ambiguities, as I can easily create hundreds of branches
tracking the same remote branch.
If it is the local branch I wonder why I have to pass the name of the
remote.
Ciao,
Dscho
@@ -128,6 +129,12 @@ be updated. (See linkgit:git-config[1]). + With `--prune` option, prune all the remotes that are updated.+'tracking'::++Returns the tracking branch for the given remote (<name>) and branch+(<branch>). Note that <branch> must exactly match the left hand side of+the refspec of the given remote.+
From that description, it is not clear to me if the branch is the _remote_
branch, the branch _on_ the remote, or the local branch.
OK. s/and branch/and remote branch/
If it is the remote branch (or the branch on the remote), I wonder how you
deal with ambiguities, as I can easily create hundreds of branches
tracking the same remote branch.
AFAICS from remote_find_tracking (and some tests), it picks the first match.
So, additional text could be: In case of multiple matches, it picks
the first one.
Santi
@@ -128,6 +129,12 @@ be updated. (See linkgit:git-config[1]). + With `--prune` option, prune all the remotes that are updated.+'tracking'::++Returns the tracking branch for the given remote (<name>) and branch+(<branch>). Note that <branch> must exactly match the left hand side of+the refspec of the given remote.+
From that description, it is not clear to me if the branch is the _remote_
branch, the branch _on_ the remote, or the local branch.
OK. s/and branch/and remote branch/
quoted
If it is the remote branch (or the branch on the remote), I wonder how you
deal with ambiguities, as I can easily create hundreds of branches
tracking the same remote branch.
AFAICS from remote_find_tracking (and some tests), it picks the first match.
So, additional text could be: In case of multiple matches, it picks
the first one.
Why not have both:
git remote tracking <remote> <remote branch>
would show all local branches that track <remote branch>, and have
<remote> as default remote, while
git remote tracking <local branch>
would show <remote> and <remote branch> if <local branch> is following
remote-tracking branch.
--
Jakub Narebski
Poland
ShadeHawk on #git
@@ -128,6 +129,12 @@ be updated. (See linkgit:git-config[1]). + With `--prune` option, prune all the remotes that are updated.+'tracking'::++Returns the tracking branch for the given remote (<name>) and branch+(<branch>). Note that <branch> must exactly match the left hand side of+the refspec of the given remote.+
From that description, it is not clear to me if the branch is the _remote_
branch, the branch _on_ the remote, or the local branch.
OK. s/and branch/and remote branch/
quoted
If it is the remote branch (or the branch on the remote), I wonder how you
deal with ambiguities, as I can easily create hundreds of branches
tracking the same remote branch.
AFAICS from remote_find_tracking (and some tests), it picks the first match.
So, additional text could be: In case of multiple matches, it picks
the first one.
Why not have both:
It makes sense.
git remote tracking <remote> <remote branch>
would show all local branches that track <remote branch>, and have
<remote> as default remote,
Maybe my description is unclear, but it's not about local branches
which track <branch> on <remote>, it is about the local branch
representation of the remote branch, i.e. not 'master' but
origin/master (git remote tracking origin master in a default clone).
while
git remote tracking <local branch>
would show <remote> and <remote branch> if <local branch> is following
remote-tracking branch.
From: Jakub Narebski <hidden> Date: 2016-06-15 22:46:58
On Thu, 18 June 2009, Santi Béjar wrote:
2009/6/18 Jakub Narebski [off-list ref]:
[cut]
quoted
$ git remote tracking <remote> <remote branch>
would show all local branches that track <remote branch>, and have
<remote> as default remote,
Maybe my description is unclear, but it's not about local branches
which track <branch> on <remote>, it is about the local branch
representation of the remote branch, i.e. not 'master' but
origin/master (git remote tracking origin master in a default clone).
Ah, the problem with the same (or similar) name for two different
things. If we have local branch 'local' set to track branch 'master'
on remote 'origin', we have:
/------- local repository ------\ /- origin -\
/ \ / \
| | | |
'local' --------> 'origin/master' -----------> 'master'
refs/heads/local refs/remotes/origin/master refs/heads/master
branch.local.remote = origin
branch.local.merge = refs/heads/master
remote.origin.fetch = +refs/heads/*:refs/remotes/origin/*
'origin/master' is called remote-TRACKING branch (for 'master' branch
on remote 'origin'). Setting up automerge information for local branch
'local' which _follows_ branch 'master' on remote 'origin' is done
using --TRACK option to git-branch.
Therefore the confusion.
Do I understand correctly that you want for
$ git remote tracking origin master
to return
origin/master
(and perhaps also origin/HEAD?).
--
Jakub Narebski
Poland
$ git remote tracking <remote> <remote branch>
would show all local branches that track <remote branch>, and have
<remote> as default remote,
Maybe my description is unclear, but it's not about local branches
which track <branch> on <remote>, it is about the local branch
representation of the remote branch, i.e. not 'master' but
origin/master (git remote tracking origin master in a default clone).
Ah, the problem with the same (or similar) name for two different
things. If we have local branch 'local' set to track branch 'master'
on remote 'origin', we have:
/------- local repository ------\ /- origin -\
/ \ / \
| | | |
'local' --------> 'origin/master' -----------> 'master'
refs/heads/local refs/remotes/origin/master refs/heads/master
branch.local.remote = origin
branch.local.merge = refs/heads/master
remote.origin.fetch = +refs/heads/*:refs/remotes/origin/*
'origin/master' is called remote-TRACKING branch (for 'master' branch
on remote 'origin'). Setting up automerge information for local branch
'local' which _follows_ branch 'master' on remote 'origin' is done
using --TRACK option to git-branch.
Therefore the confusion.
OK, but I wonder if the documentation for the new command is clear
enough or can be improved.
Do I understand correctly that you want for
$ git remote tracking origin master
to return
origin/master
In this particular case (the above settings) not exactly, as master
does not match exactly the lhs of the refspec. It would be:
$ git remote tracking origin refs/heads/master
refs/remotes/origin/master
(and perhaps also origin/HEAD?).
HEAD is another beast, as the local HEAD symlink is a local config,
that defaults to the remote default branch, but that you can change
with "git remote set-head".
Ops, you are saying to return origin/HEAD for "git remote tracking
origin master", no? I don't think it makes sense, I think of "git
remote tracking" more as a mapping function, it applies the map (the
refspec) to the given argument.
Santi
One thing it just occurred to me is to return the explicit refspec
instead of the tracking branch. So with the default config (after a
clone):
$ git remote tracking origin refs/heads/master
refs/heads/master:refs/remotes/origin/master
this makes a difference in case we want to allow returning all the
matching tracking branch and not the first one with more than one
branch, as:
$ git config remote.origin.fetch --add +refs/heads/*:refs/remote/another/*
$ git remote tracking origin refs/heads/master
refs/heads/master:refs/remotes/origin/master
refs/heads/next:refs/remotes/origin/next
$ git remote tracking origin refs/heads/master refs/heads/next
refs/heads/master:refs/remotes/origin/master
refs/heads/master:refs/remotes/another/master
refs/heads/next:refs/remotes/origin/next
refs/heads/next:refs/remotes/another/next
Thoughts?
Seems something is wrong in the --cover-letter utf-8 handlin, no?
In this case (the cover letter) it is send-email that handles the
utf-8, but I don't know why it is not working, as there is a test in
t9001-send-email that tests it. I think it worked, I'll try to bisect
if I found a working version.
In fact I've been checking some of my cover letter and almost none of
them have the MIME headers. One that have the MIME headers is:
Subject: [PATCHv4 0/4] Show author and/or committer in some cases
Date: Sun, 4 May 2008 18:04:48 +0200
Message-Id: [off-list ref]
X-Mailer: git-send-email 1.5.5.1.224.gadb29
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
But I don't know/remeber what I did differently and I cannot reproduce
it even using the same git-send-email version.
So I don't know what else to look, and in fact I don't know who is
responsible (if any) for these MIME headers in a cover-letter. But
they are added automatically if you use the --compose flag. So maybe
git-send-email could be enhanced so that it adds the MIME headers to
the cover-letter (0000-cover-letter.patch) as if run with --compose.
Santi