{"thread":{"id":"22850","subject":"[PATCH] tg-push: Filter out plain SHA1s from being pushed.","startedAt":"2010-02-27T22:09:08Z","lastAt":"2010-02-28T13:57:41Z","messageCount":3,"participants":["Thomas Schwinge","Uwe Kleine-König"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"135860","messageId":"1267308548-10136-1-git-send-email-thomas@schwinge.name","threadId":"22850","inReplyTo":null,"subject":"[PATCH] tg-push: Filter out plain SHA1s from being pushed.","fromName":"Thomas Schwinge","fromEmail":"thomas@schwinge.name","sentAt":"2010-02-27T22:09:08Z","receivedAt":"2010-02-27T22:09:08Z","isPatch":true,"sender":{"key":"thomas@schwinge.name","avatar":"https://gravatar.com/avatar/52ddb7ca4856f40a2eb23eac2f499178ff17dcc372d055c6c41ab2ecc4d19ae8?d=mp&s=160"},"body":"Otherwise, problems arise when branches depend (via .topdeps) on SHA1s:\n\n    $ tg push -r tmp t/____longjmp_chk_cleanup_linux_x86_64\n    fatal: 77c84aeb81808c3109665949448dba59965c391e cannot be resolved to branch.\n    fatal: The remote end hung up unexpectedly\n---\n\nHello!\n\nI was facing the following problem:\n\n    thomas@dirichlet:~/tmp/source/glibc/git/glibc.hurd $ bash -v -x /usr/bin/tg push -r tmp t/____longjmp_chk_cleanup_linux_x86_64\n    [...]\n    ++ read _dep\n    ++ missing_deps=\n    ++ rm /tmp/tg-depsfile.nCfywI\n    ++ return 0\n    ++ xargs git push tmp\n    ++ sort -u /tmp/tg-push-listfile.sZeHIr\n    fatal: 77c84aeb81808c3109665949448dba59965c391e cannot be resolved to branch.\n    fatal: The remote end hung up unexpectedly\n    rm -f \"/tmp/tg-push-listfile.sZeHIr\"\n    + rm -f /tmp/tg-push-listfile.sZeHIr\n\nThat's the actual problem:\n\n    thomas@dirichlet:~/tmp/source/glibc/git/glibc.hurd $ git push tmp 77c84aeb81808c3109665949448dba59965c391e\n    fatal: 77c84aeb81808c3109665949448dba59965c391e cannot be resolved to branch.\n    fatal: The remote end hung up unexpectedly\n\n... which is due to:\n\n    $ git show t/____longjmp_chk_cleanup_linux_x86_64:.topdeps\n    77c84aeb81808c3109665949448dba59965c391e\n\nAll other parts (at least those I tested / got to use so far) work just\nfine when passing SHA1s.\n\nHere is a patch to make this work for tg push, too.\n\n    thomas@dirichlet:~/tmp/source/glibc/git/glibc.hurd $ tg push -r tmp t/____longjmp_chk_cleanup_linux_x86_64\n    Counting objects: 196207, done.\n    Compressing objects: 100% (32953/32953), done.\n    Writing objects: 100% (196207/196207), 66.45 MiB | 4047 KiB/s, done.\n    Total 196207 (delta 163379), reused 191592 (delta 159243)\n    To /media/Stalin/tmp/glibc\n     * [new branch]      t/____longjmp_chk_cleanup_linux_x86_64 -> t/____longjmp_chk_cleanup_linux_x86_64\n     * [new branch]      refs/top-bases/t/____longjmp_chk_cleanup_linux_x86_64 -> refs/top-bases/t/____longjmp_chk_cleanup_linux_x86_64\n\n\n tg-push.sh |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/tg-push.sh b/tg-push.sh\nindex cd208a0..28cad81 100644\n--- a/tg-push.sh\n+++ b/tg-push.sh\n@@ -71,6 +71,9 @@ for name in $branches; do\n \t$recurse_deps && [ -n \"$_dep_is_tgish\" ] &&\n \t\tno_remotes=1 recurse_deps push_branch \"$name\"\n \n+\t# filter out plain SHA1s\n \t# remove multiple occurrences of the same branch\n-\tsort -u \"$_listfile\" | xargs git push $dry_run \"$remote\"\n+\tgrep -vE '^[0-9a-f]{40}$' < \"$_listfile\" \\\n+\t\t| sort -u \\\n+\t\t\t| xargs git push $dry_run \"$remote\"\n done\n-- \n1.6.0.4\n"},{"id":"135871","messageId":"20100228101807.GB13987@pengutronix.de","threadId":"22850","inReplyTo":"1267308548-10136-1-git-send-email-thomas@schwinge.name","subject":"Re: [PATCH] tg-push: Filter out plain SHA1s from being pushed.","fromName":"Uwe Kleine-König","fromEmail":"u.kleine-koenig@pengutronix.de","sentAt":"2010-02-28T10:18:07Z","receivedAt":"2010-02-28T10:18:07Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello,\n\nOn Sat, Feb 27, 2010 at 11:09:08PM +0100, Thomas Schwinge wrote:\n> Otherwise, problems arise when branches depend (via .topdeps) on SHA1s:\n> \n>     $ tg push -r tmp t/____longjmp_chk_cleanup_linux_x86_64\n>     fatal: 77c84aeb81808c3109665949448dba59965c391e cannot be resolved to branch.\n>     fatal: The remote end hung up unexpectedly\n> ---\n> \n> Hello!\n> \n> I was facing the following problem:\n> \n>     thomas@dirichlet:~/tmp/source/glibc/git/glibc.hurd $ bash -v -x /usr/bin/tg push -r tmp t/____longjmp_chk_cleanup_linux_x86_64\n>     [...]\n>     ++ read _dep\n>     ++ missing_deps=\n>     ++ rm /tmp/tg-depsfile.nCfywI\n>     ++ return 0\n>     ++ xargs git push tmp\n>     ++ sort -u /tmp/tg-push-listfile.sZeHIr\n>     fatal: 77c84aeb81808c3109665949448dba59965c391e cannot be resolved to branch.\n>     fatal: The remote end hung up unexpectedly\n>     rm -f \"/tmp/tg-push-listfile.sZeHIr\"\n>     + rm -f /tmp/tg-push-listfile.sZeHIr\n> \n> That's the actual problem:\n> \n>     thomas@dirichlet:~/tmp/source/glibc/git/glibc.hurd $ git push tmp 77c84aeb81808c3109665949448dba59965c391e\n>     fatal: 77c84aeb81808c3109665949448dba59965c391e cannot be resolved to branch.\n>     fatal: The remote end hung up unexpectedly\n> \n> ... which is due to:\n> \n>     $ git show t/____longjmp_chk_cleanup_linux_x86_64:.topdeps\n>     77c84aeb81808c3109665949448dba59965c391e\n> \n> All other parts (at least those I tested / got to use so far) work just\n> fine when passing SHA1s.\n> \n> Here is a patch to make this work for tg push, too.\n> \n>     thomas@dirichlet:~/tmp/source/glibc/git/glibc.hurd $ tg push -r tmp t/____longjmp_chk_cleanup_linux_x86_64\n>     Counting objects: 196207, done.\n>     Compressing objects: 100% (32953/32953), done.\n>     Writing objects: 100% (196207/196207), 66.45 MiB | 4047 KiB/s, done.\n>     Total 196207 (delta 163379), reused 191592 (delta 159243)\n>     To /media/Stalin/tmp/glibc\n>      * [new branch]      t/____longjmp_chk_cleanup_linux_x86_64 -> t/____longjmp_chk_cleanup_linux_x86_64\n>      * [new branch]      refs/top-bases/t/____longjmp_chk_cleanup_linux_x86_64 -> refs/top-bases/t/____longjmp_chk_cleanup_linux_x86_64\n> \n> \n>  tg-push.sh |    5 ++++-\n>  1 files changed, 4 insertions(+), 1 deletions(-)\n> \n> diff --git a/tg-push.sh b/tg-push.sh\n> index cd208a0..28cad81 100644\n> --- a/tg-push.sh\n> +++ b/tg-push.sh\n> @@ -71,6 +71,9 @@ for name in $branches; do\n>  \t$recurse_deps && [ -n \"$_dep_is_tgish\" ] &&\n>  \t\tno_remotes=1 recurse_deps push_branch \"$name\"\n>  \n> +\t# filter out plain SHA1s\n>  \t# remove multiple occurrences of the same branch\n> -\tsort -u \"$_listfile\" | xargs git push $dry_run \"$remote\"\n> +\tgrep -vE '^[0-9a-f]{40}$' < \"$_listfile\" \\\n> +\t\t| sort -u \\\n> +\t\t\t| xargs git push $dry_run \"$remote\"\n>  done\nprobably this is good enough.  Still I wonder if there is a better way\nto detect if a given rev is a sha1 or a branch.\n\ntest \"$(git rev-parse \"$rev\")\" = \"$rev\"\n\ncomes to mind.  Anybody who gives names to branches that match\n^[0-9a-f]{40}$ has other problems probably.\n\nI think I will take it anyhow (and fix up the broken indention).\n\nBest regards\nUwe\n\n-- \nPengutronix e.K.                           | Uwe Kleine-König            |\nIndustrial Linux Solutions                 | http://www.pengutronix.de/  |\n"},{"id":"299170","messageId":"1267365461-29801-1-git-send-email-thomas@schwinge.name","threadId":"22850","inReplyTo":"20100228101807.GB13987@pengutronix.de","subject":"[PATCH] tg-push: Filter out plain SHA1s from being pushed.","fromName":"Thomas Schwinge","fromEmail":"thomas@schwinge.name","sentAt":"2010-02-28T13:57:41Z","receivedAt":"2010-02-28T13:57:41Z","isPatch":true,"sender":{"key":"thomas@schwinge.name","avatar":"https://gravatar.com/avatar/52ddb7ca4856f40a2eb23eac2f499178ff17dcc372d055c6c41ab2ecc4d19ae8?d=mp&s=160"},"body":"Otherwise, problems arise when branches depend (via .topdeps) on SHA1s:\n\n    $ tg push -r tmp t/____longjmp_chk_cleanup_linux_x86_64\n    fatal: 77c84aeb81808c3109665949448dba59965c391e cannot be resolved to branch.\n    fatal: The remote end hung up unexpectedly\n\nSigned-off-by: Thomas Schwinge <thomas@schwinge.name>\n\n---\n\nHello!\n\nI was facing the following problem:\n\n    thomas@dirichlet:~/tmp/source/glibc/git/glibc.hurd $ bash -v -x /usr/bin/tg push -r tmp t/____longjmp_chk_cleanup_linux_x86_64\n    [...]\n    ++ read _dep\n    ++ missing_deps=\n    ++ rm /tmp/tg-depsfile.nCfywI\n    ++ return 0\n    ++ xargs git push tmp\n    ++ sort -u /tmp/tg-push-listfile.sZeHIr\n    fatal: 77c84aeb81808c3109665949448dba59965c391e cannot be resolved to branch.\n    fatal: The remote end hung up unexpectedly\n    rm -f \"/tmp/tg-push-listfile.sZeHIr\"\n    + rm -f /tmp/tg-push-listfile.sZeHIr\n\nThat's the actual problem:\n\n    thomas@dirichlet:~/tmp/source/glibc/git/glibc.hurd $ git push tmp 77c84aeb81808c3109665949448dba59965c391e\n    fatal: 77c84aeb81808c3109665949448dba59965c391e cannot be resolved to branch.\n    fatal: The remote end hung up unexpectedly\n\n... which is due to:\n\n    $ git show t/____longjmp_chk_cleanup_linux_x86_64:.topdeps\n    77c84aeb81808c3109665949448dba59965c391e\n\nAll other parts (at least those I tested / got to use so far) work just\nfine when passing SHA1s.\n\nHere is a patch to make this work for tg push, too.\n\n    thomas@dirichlet:~/tmp/source/glibc/git/glibc.hurd $ tg push -r tmp t/____longjmp_chk_cleanup_linux_x86_64\n    Counting objects: 196207, done.\n    Compressing objects: 100% (32953/32953), done.\n    Writing objects: 100% (196207/196207), 66.45 MiB | 4047 KiB/s, done.\n    Total 196207 (delta 163379), reused 191592 (delta 159243)\n    To /media/Stalin/tmp/glibc\n     * [new branch]      t/____longjmp_chk_cleanup_linux_x86_64 -> t/____longjmp_chk_cleanup_linux_x86_64\n     * [new branch]      refs/top-bases/t/____longjmp_chk_cleanup_linux_x86_64 -> refs/top-bases/t/____longjmp_chk_cleanup_linux_x86_64\n\n tg-push.sh |    3 +++\n tg.sh      |    7 +++++++\n 2 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/tg-push.sh b/tg-push.sh\nindex cd208a0..089f885 100644\n--- a/tg-push.sh\n+++ b/tg-push.sh\n@@ -53,6 +53,9 @@ push_branch()\n \t# if so desired omit non tgish deps\n \t$tgish_deps_only && [ -z \"$_dep_is_tgish\" ] && return 0\n \n+\t# filter out plain SHA1s\n+\tis_sha1 \"$_dep\" && return 0\n+\n \techo \"$_dep\" >> \"$_listfile\"\n \t[ -z \"$_dep_is_tgish\" ] ||\n \t\techo \"top-bases/$_dep\" >> \"$_listfile\"\ndiff --git a/tg.sh b/tg.sh\nindex 1f6d3da..91c374a 100644\n--- a/tg.sh\n+++ b/tg.sh\n@@ -126,6 +126,13 @@ branch_annihilated()\n \ttest \"$(git rev-parse \"$mb^{tree}\")\" = \"$(git rev-parse \"$_name^{tree}\")\";\n }\n \n+# is_sha1 REF\n+# Whether REF is a SHA1 (compared to a symbolic name).\n+is_sha1()\n+{\n+\t[ \"$(git rev-parse \"$1\")\" = \"$1\" ]\n+}\n+\n # recurse_deps CMD NAME [BRANCHPATH...]\n # Recursively eval CMD on all dependencies of NAME.\n # CMD can refer to $_name for queried branch name,\n-- \ntg: (341a371..) t/tg_push_no_SHA1 (depends on: master)\n"}]}