{"thread":{"id":"43246","subject":"Re: [PATCH 3/3] git-fetch: allow glob pattern in refspec","startedAt":"2006-11-23T07:24:05Z","lastAt":"2006-11-27T18:14:21Z","messageCount":3,"participants":["Michael Loeffler","Andy Parkins","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"294487","messageId":"7vzmaik4mi.fsf@assigned-by-dhcp.cox.net","threadId":"43246","inReplyTo":null,"subject":"[PATCH 3/3] git-fetch: allow glob pattern in refspec","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-11-23T07:24:05Z","receivedAt":"2006-11-23T07:24:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This adds Andy's refspec glob.  You can have a single line:\n\n\tPull: refs/heads/*:refs/remotes/origin/*\n\nin your \".git/remotes/origin\" and say \"git fetch\" to retrieve\nall refs under heads/ at the remote side to remotes/origin/ in\nthe local repository.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n * Andy, I think this does the same thing as you wanted to do,\n   but is cleaner implementation-wise and also at the concept\n   level, to pretend as if the user listed the expanded form in\n   the configuration.  I deliberately decided not to apply the\n   wildcard expansion on refspecs that came from command line,\n   but if we wanted to we can move the expand_refs_wildcard call\n   a few lines down to make it also apply to them.\n\n git-parse-remote.sh |   35 +++++++++++++++++++++++++++++++++++\n 1 files changed, 35 insertions(+), 0 deletions(-)\n\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex c325ef7..e281b7c 100755\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -90,6 +90,39 @@ get_remote_default_refs_for_push () {\n \tesac\n }\n \n+# Called from canon_refs_list_for_fetch -d \"$remote\", which\n+# is called from get_remote_default_refs_for_fetch to grok\n+# refspecs that are retrieved from the configuration, but not\n+# from get_remote_refs_for_fetch when it deals with refspecs\n+# supplied on the command line.  $ls_remote_result has the list\n+# of refs available at remote.\n+expand_refs_wildcard () {\n+\tfor ref\n+\tdo\n+\t\t# a non glob pattern is given back as-is.\n+\t\texpr \"z$ref\" : 'zrefs/.*/\\*:refs/.*/\\*$' >/dev/null || {\n+\t\t\techo \"$ref\"\n+\t\t\tcontinue\n+\t\t}\n+\t\tfrom=`expr \"z$ref\" : 'z\\(refs/.*/\\)\\*:refs/.*/\\*$'`\n+\t\tto=`expr \"z$ref\" : 'zrefs/.*/\\*:\\(refs/.*/\\)\\*$'`\n+\t\techo \"$ls_remote_result\" |\n+\t\t(\n+\t\t\tIFS='\t'\n+\t\t\twhile read sha1 name\n+\t\t\tdo\n+\t\t\t\tmapped=${name#\"$from\"}\n+\t\t\t\tif test \"z$name\" != \"z${name#'^{}'}\" ||\n+\t\t\t\t\ttest \"z$name\" = \"z$mapped\"\n+\t\t\t\tthen\n+\t\t\t\t\tcontinue\n+\t\t\t\tfi\n+\t\t\t\techo \"${name}:${to}${mapped}\"\n+\t\t\tdone\n+\t\t)\n+\tdone\n+}\n+\n # Subroutine to canonicalize remote:local notation.\n canon_refs_list_for_fetch () {\n \t# If called from get_remote_default_refs_for_fetch\n@@ -107,6 +140,8 @@ canon_refs_list_for_fetch () {\n \t\t\tmerge_branches=$(git-repo-config \\\n \t\t\t    --get-all \"branch.${curr_branch}.merge\")\n \t\tfi\n+\t\tset x $(expand_refs_wildcard \"$@\")\n+\t\tshift\n \tfi\n \tfor ref\n \tdo\n-- \n1.4.4.1.g77614\n\n"},{"id":"294371","messageId":"200611230855.04124.andyparkins@gmail.com","threadId":"43246","inReplyTo":"7vzmaik4mi.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 3/3] git-fetch: allow glob pattern in refspec","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-11-23T08:55:02Z","receivedAt":"2006-11-23T08:55:02Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"On Thursday 2006 November 23 07:24, Junio C Hamano wrote:\n\n>  * Andy, I think this does the same thing as you wanted to do,\n>    but is cleaner implementation-wise and also at the concept\n\nIt certainly is.  Looking at your implementation I see that I was worrying \nunnecessarily about passing extra globals/parameters to git-parse-remote.  \nYour version is much better than mine; and I see that noone else calls \nget_remote_refs_for_fetch anyway.\n\n>    level, to pretend as if the user listed the expanded form in\n>    the configuration.  I deliberately decided not to apply the\n>    wildcard expansion on refspecs that came from command line,\n>    but if we wanted to we can move the expand_refs_wildcard call\n>    a few lines down to make it also apply to them.\n\nThat's probably the most sensible method.  Using globs on the command line \ncould get people into trouble if they accidentally hit a shell expansion.\n\n\nAndy\n-- \nDr Andy Parkins, M Eng (hons), MIEE\n"},{"id":"294129","messageId":"1164651262.13153.31.camel@ibook.zvpunry.de","threadId":"43246","inReplyTo":"7vzmaik4mi.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 3/3] git-fetch: allow glob pattern in refspec","fromName":"Michael Loeffler","fromEmail":"miloeffler@googlemail.com","sentAt":"2006-11-27T18:14:21Z","receivedAt":"2006-11-27T18:14:21Z","isPatch":true,"sender":{"key":"miloeffler@googlemail.com","avatar":null},"body":"hi,\n\nAm Mittwoch, den 22.11.2006, 23:24 -0800 schrieb Junio C Hamano: \n> This adds Andy's refspec glob.  You can have a single line:\n> \n> \tPull: refs/heads/*:refs/remotes/origin/*\nHow about using extended regex for this, something like this:\nPull: refs/heads/master:refs/remotes/origin/master\nPull: refs/tags/v(.*):refs/tags/origin/v\\1\n\n... \n> +expand_refs_wildcard () {\n> +\tfor ref\n> +\tdo\n...\nHow about using something like:\necho \"$ls_remote_result\" | sed -n -r -e \"s:$ref: p\"\n\nUsing $ref as a part of the sed expression is not a good idea (.* should\nnot match past the ':'), but something like this maybe. What do you\nthink?\n\nbye\n"}]}