git-fetch: Support the local remote "."
PATCH 2/3 git-fetch: Support the local remote "."
To this end, git-parse-remote is grown with a new kind of remote, `builtin'. This returns all the local branches in get_remote_default_refs_for_fetch. This is equivalent to having a fake remote as:
[remote "local"]
url = .
fetch = refs/*
Based on a patch from Paolo Bonzini.
--- Documentation/config.txt | 4 ++++ git-parse-remote.sh | 12 +++++++++++- t/t5515-fetch-merge-logic.sh | 2 ++ t/t5515/fetch.br-. | 6 ++++++ t/t5515/fetch.br-.-merge | 6 ++++++ t/t5515/fetch.br-.-merge_. | 6 ++++++ t/t5515/fetch.br-.-octopus | 6 ++++++ t/t5515/fetch.br-.-octopus_. | 6 ++++++ t/t5515/fetch.br-._. | 6 ++++++ t/t5515/fetch.br-unconfig_. | 5 +++++ t/t5515/fetch.master_. | 5 +++++ t/t5520-pull.sh | 13 +++++++++++++ 12 files changed, 76 insertions(+), 1 deletions(-) create mode 100644 t/t5515/fetch.br-. create mode 100644 t/t5515/fetch.br-.-merge create mode 100644 t/t5515/fetch.br-.-merge_. create mode 100644 t/t5515/fetch.br-.-octopus create mode 100644 t/t5515/fetch.br-.-octopus_. create mode 100644 t/t5515/fetch.br-._.
Documentation/config.txt +4 -0
@@ -272,6 +272,10 @@ 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. color.branch:: A boolean to enable/disable color in the output of
git-parse-remote.sh +11 -1
@@ -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,10 @@ get_remote_default_refs_for_fetch () { case "$data_source" in '') set explicit "HEAD:" ;; + builtin) + set glob $(for name in $(git-show-ref | + sed -n 's,.*[ ]refs/,refs/,p') + do echo "$name:" ; done);; config) set $(expand_refs_wildcard "$1" \ $(git-config --get-all "remote.$1.fetch")) ;;
t/t5515-fetch-merge-logic.sh +2 -0
@@ -78,6 +78,8 @@ test_expect_success setup ' echo "../.git#one" > .git/branches/branches-one && remotes="$remotes branches-one" && + remotes="$remotes ." && + for remote in $remotes ; do git config branch.br-$remote.remote $remote && git config branch.br-$remote-merge.remote $remote &&
t/t5515/fetch.br-. new file +6 -0
@@ -0,0 +1,6 @@ +# br-. +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/HEAD' of . +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge remote branch 'origin/master' of . +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge remote branch 'origin/one' of . +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/three' of . +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge remote branch 'origin/two' of .
t/t5515/fetch.br-.-merge new file +6 -0
@@ -0,0 +1,6 @@ +# br-.-merge +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/HEAD' of . +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge remote branch 'origin/master' of . +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge remote branch 'origin/one' of . +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/three' of . +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge remote branch 'origin/two' of .
t/t5515/fetch.br-.-merge_. new file +6 -0
@@ -0,0 +1,6 @@ +# br-.-merge . +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/HEAD' of . +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge remote branch 'origin/master' of . +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge remote branch 'origin/one' of . +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/three' of . +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge remote branch 'origin/two' of .
t/t5515/fetch.br-.-octopus new file +6 -0
@@ -0,0 +1,6 @@ +# br-.-octopus +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/HEAD' of . +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge remote branch 'origin/master' of . +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge remote branch 'origin/one' of . +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/three' of . +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge remote branch 'origin/two' of .
t/t5515/fetch.br-.-octopus_. new file +6 -0
@@ -0,0 +1,6 @@ +# br-.-octopus . +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/HEAD' of . +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge remote branch 'origin/master' of . +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge remote branch 'origin/one' of . +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/three' of . +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge remote branch 'origin/two' of .
t/t5515/fetch.br-._. new file +6 -0
@@ -0,0 +1,6 @@ +# br-. . +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/HEAD' of . +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge remote branch 'origin/master' of . +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge remote branch 'origin/one' of . +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/three' of . +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge remote branch 'origin/two' of .
t/t5515/fetch.br-unconfig_. +5 -0
@@ -1 +1,6 @@ # br-unconfig . +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/HEAD' of . +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge remote branch 'origin/master' of . +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge remote branch 'origin/one' of . +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/three' of . +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge remote branch 'origin/two' of .
t/t5515/fetch.master_. +5 -0
@@ -1 +1,6 @@ # master . +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/HEAD' of . +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge remote branch 'origin/master' of . +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge remote branch 'origin/one' of . +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge remote branch 'origin/three' of . +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge remote branch 'origin/two' of .
t/t5520-pull.sh +13 -0
@@ -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
Signature · 1 line
1.5.0.3.1021.g5897
Quoted 10 lines · Santi Béjar
To this end, git-parse-remote is grown with a new kind of remote, `builtin'. This returns all the local branches in
get_remote_default_refs_for_fetch. This is equivalent to having a fake remote as:[remote "local"]
url = .
fetch = refs/*Based on a patch from Paolo Bonzini.
Can you please compare the times to do "git fetch ."? The reason to touch git-fetch.sh was an optimization that Junio requested.
I found my 2nd submission to be 20% faster than the first.
Paolo
Quoted 10 lines · Paolo Bonzini
Quoted 9 lines · Santi Béjar
To this end, git-parse-remote is grown with a new kind of remote, `builtin'. This returns all the local branches in
get_remote_default_refs_for_fetch. This is equivalent to having a fake remote as:[remote "local"]
url = .
fetch = refs/*
Quoted 9 lines
Quoted 1 line
Based on a patch from Paolo Bonzini.
Can you please compare the times to do "git fetch ."? The reason to touch
git-fetch.shwas an optimization that Junio requested.I found my 2nd submission to be 20% faster than the first.
Paolo
Yes. But this optimization is independent of this patch, as it already exists without this (but it gets worse with this patch).
Also, I think, the split in fetch_main should be base on transport and not on the definition of the remote.
Santi