* [PATCH] git-parse-remote: Support dummy remote `.' in branch.<name>.remote
@ 2007-03-09 15:53 Paolo Bonzini
2007-03-10 0:17 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2007-03-09 15:53 UTC (permalink / raw)
To: git, Andy Parkins
This patch adds support for a dummy remote `.' to avoid having to declare
a fake remote like
[remote "local"]
url = .
fetch = refs/heads/*:refs/heads/*
A configuration variable is provided, "branch.forcelocalupdates", which
fakes the fetch line to read "+refs/heads/*:refs/heads/*".
A subsequent patch, which will be submitted after this and the
--track/--no-track patch goes in, will add support for the `.'
remote in `git-branch --track'.
It is important to notice that the `.' remote only works in
branch.<name>.remote by design.
Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
---
Documentation/config.txt | 10 ++++++++++
git-parse-remote.sh | 15 ++++++++++++++-
t/t5520-pull.sh | 13 +++++++++++++
3 files changed, 37 insertions(+), 1 deletion(-)
Andy Parkins wrote:
> I think what you want is something that I would like too. If you specify "."
> to a git-pull it means to use the local repository not a remote. It would be
> great if one could have:
>
> [remote "origin"]
> url = git://git.kernel.org/pub/scm/git/git.git
> fetch = refs/heads/master:refs/remotes/origin/master
> [branch "master"]
> remote = .
> merge = refs/remotes/origin/master
>
> That way a "git pull" on master wouldn't need to make a remote connection in
> order to do a merge (which is the way I like it). However, I remember there
> was a reason this wouldn't work, but I don't remember what it was :-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 5408dd6..0e72c3e 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -272,6 +272,16 @@ branch.<name>.merge::
`git fetch`) to lookup the default branch for merging. Without
this option, `git pull` defaults to merge the first refspec fetched.
Specify multiple values to get an octopus merge.
+ If you wish to setup `git pull` so that it merges into <name> from
+ another branch in the local repository, you can point
+ branch.<name>.merge to the desired branch, and use the special setting
+ `.` (a period) for branch.<name>.remote.
+
+branch.forcelocalupdates::
+ If set to true, merges from the local repository (i.e. when
+ branch.<name>.remote is the special setting `.`) are performed
+ even if they do not result in a fast forward update. The default
+ is true.
color.branch::
A boolean to enable/disable color in the output of
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 99e7184..60c4b08 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -9,6 +9,9 @@ get_data_source () {
*/*)
echo ''
;;
+ .)
+ echo builtin
+ ;;
*)
if test "$(git-config --get "remote.$1.url")"
then
@@ -31,6 +34,9 @@ get_remote_url () {
'')
echo "$1"
;;
+ builtin)
+ echo "$1"
+ ;;
config)
git-config --get "remote.$1.url"
;;
@@ -57,7 +63,7 @@ get_default_remote () {
get_remote_default_refs_for_push () {
data_source=$(get_data_source "$1")
case "$data_source" in
- '' | branches)
+ '' | branches | builtin)
;; # no default push mapping, just send matching refs.
config)
git-config --get-all "remote.$1.push" ;;
@@ -128,6 +134,13 @@ get_remote_default_refs_for_fetch () {
case "$data_source" in
'')
set explicit "HEAD:" ;;
+ builtin)
+ if test $(git-config --bool "branch.forcelocalupdates" || echo true) = true
+ then
+ set $(expand_refs_wildcard . +refs/heads/*:refs/heads/*)
+ else
+ set $(expand_refs_wildcard . refs/heads/*:refs/heads/*)
+ fi ;;
config)
set $(expand_refs_wildcard "$1" \
$(git-config --get-all "remote.$1.fetch")) ;;
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 7eb3783..c424e5b 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -29,5 +29,18 @@ test_expect_success 'checking the results' '
diff file cloned/file
'
+test_expect_success 'test . as a remote' '
+
+ git branch copy master &&
+ git config branch.copy.remote . &&
+ git config branch.copy.merge refs/heads/master &&
+ echo updated >file &&
+ git commit -a -m updated &&
+ git checkout copy &&
+ test `cat file` = file &&
+ git pull &&
+ test `cat file` = updated
+'
+
test_done
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] git-parse-remote: Support dummy remote `.' in branch.<name>.remote
2007-03-09 15:53 [PATCH] git-parse-remote: Support dummy remote `.' in branch.<name>.remote Paolo Bonzini
@ 2007-03-10 0:17 ` Junio C Hamano
2007-03-12 8:38 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2007-03-10 0:17 UTC (permalink / raw)
To: bonzini; +Cc: git, Andy Parkins
Paolo Bonzini <paolo.bonzini@lu.unisi.ch> writes:
> This patch adds support for a dummy remote `.' to avoid having to declare
> a fake remote like
>
> [remote "local"]
> url = .
> fetch = refs/heads/*:refs/heads/*
For one thing, I do not think it would help Andy's original
example of reusing what we already have in refs/remotes
hierarchy if you faked it with refs/heads/*:refs/heads/*
wildcard like the above.
Why not
[remote "local"]
url = .
fetch = refs/heads/*
or even
[remote "local"]
url = .
fetch = refs/*
except that we currently do not have non-storing globbing
pattern defined?
I am actually Ok with the idea of built-in ".", but I really do
not like it to even pretend storing the fetched results in local
branches. If you stop thinking in terms of "tracking fetch"
that stores the result in some local branch, you do not have to
have branch.forcelocalupdates.
By the way, I do not understand the semantics of that
configuration variable at all.
> +branch.forcelocalupdates::
> + If set to true, merges from the local repository (i.e. when
> + branch.<name>.remote is the special setting `.`) are performed
> + even if they do not result in a fast forward update. The default
> + is true.
Really, when does fetching from refs/heads/<blah> into refs/heads/<blah>
result in anything but "already up-to-date"?
I think you can get rid of this ridiculous "we obtain
refs/heads/master from ourselves and store it in the same branch
of ours". The only thing you want here is to leave FETCH_HEAD
in a state that is usable by git-pull. Wouldn't that be much
cleaner?
> @@ -128,6 +134,13 @@ get_remote_default_refs_for_fetch () {
> case "$data_source" in
> '')
> set explicit "HEAD:" ;;
> + builtin)
> + if test $(git-config --bool "branch.forcelocalupdates" || echo true) = true
> + then
> + set $(expand_refs_wildcard . +refs/heads/*:refs/heads/*)
> + else
> + set $(expand_refs_wildcard . refs/heads/*:refs/heads/*)
> + fi ;;
> config)
> set $(expand_refs_wildcard "$1" \
> $(git-config --get-all "remote.$1.fetch")) ;;
Especially this above hunk is not something I'd like to see so
the patch won't be applied as-is in this round, but just for
future reference...
The --bool option makes sure the git-config command either says
"true", "false" or silently exit with non-zero, in which case
you would let echo say "true". In that sense, it is not a
problem in this particular patch, but in general it makes me
worried when I see somebody feeds $() without quoting to test as
its argument.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] git-parse-remote: Support dummy remote `.' in branch.<name>.remote
2007-03-10 0:17 ` Junio C Hamano
@ 2007-03-12 8:38 ` Paolo Bonzini
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2007-03-12 8:38 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Andy Parkins
> By the way, I do not understand the semantics of that
> configuration variable at all.
I think I seriously misunderstood something -- I cannot even
recall what -- when I wrote that. In fact, the only thing I
want to work, is the scenario for which I wrote the testcase.
I'll ponder your comments on FETCH_HEAD and see if I can write
the patch in a better way.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-03-12 8:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-09 15:53 [PATCH] git-parse-remote: Support dummy remote `.' in branch.<name>.remote Paolo Bonzini
2007-03-10 0:17 ` Junio C Hamano
2007-03-12 8:38 ` Paolo Bonzini
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).