{"thread":{"id":"19514","subject":"[TopGit PATCH] tg-push: prevent multiple occurences of branches","startedAt":"2009-05-26T21:37:00Z","lastAt":"2009-05-27T07:40:34Z","messageCount":3,"participants":["Bert Wesarg","Uwe Kleine-König"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"114746","messageId":"1243373820-13442-1-git-send-email-bert.wesarg@googlemail.com","threadId":"19514","inReplyTo":null,"subject":"[TopGit PATCH] tg-push: prevent multiple occurences of branches","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2009-05-26T21:37:00Z","receivedAt":"2009-05-26T21:37:00Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"So, I finally tried tg-push and got a lot of warnings and errors:\n\nwarning, no base found top-bases/master\nwarning, no base found top-bases/master\nwarning, no base found top-bases/master\nwarning, no base found top-bases/master\nwarning, no base found top-bases/master\nwarning, no base found top-bases/master\nwarning, no base found top-bases/master\nwarning, no base found top-bases/master\nwarning, no base found top-bases/master\nwarning, no base found top-bases/master\nwarning, no base found top-bases/master\n\n\nerror: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\nerror: failed to lock refs/heads/master\nerror: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\nerror: failed to lock refs/heads/master\nerror: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\nerror: failed to lock refs/heads/master\nerror: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\nerror: failed to lock refs/heads/master\nerror: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\nerror: failed to lock refs/heads/master\nerror: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\nerror: failed to lock refs/heads/master\nerror: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\nerror: failed to lock refs/heads/master\nerror: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\nerror: failed to lock refs/heads/master\nerror: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\nerror: failed to lock refs/heads/master\nerror: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\nerror: failed to lock refs/heads/master\nerror: Ref refs/heads/bw/log is at a16df35cc7009b36f6f71717ae3d9a3dc29987da but expected 0000000000000000000000000000000000000000\nerror: failed to lock refs/heads/bw/log\nerror: Ref refs/top-bases/bw/log is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\nerror: failed to lock refs/top-bases/bw/log\n\n ! [remote rejected] master -> master (failed to lock)\n ! [remote rejected] master -> master (failed to lock)\n ! [remote rejected] master -> master (failed to lock)\n ! [remote rejected] master -> master (failed to lock)\n ! [remote rejected] master -> master (failed to lock)\n ! [remote rejected] master -> master (failed to lock)\n ! [remote rejected] master -> master (failed to lock)\n ! [remote rejected] master -> master (failed to lock)\n ! [remote rejected] master -> master (failed to lock)\n ! [remote rejected] master -> master (failed to lock)\n ! [remote rejected] bw/log -> bw/log (failed to lock)\n ! [remote rejected] refs/top-bases/bw/log -> refs/top-bases/bw/log (failed to lock)\n\nAlso the result was ok this output is defintive not ok.\n\nTo prevent multiple occurences of the same branchname we maintain these in a\nfile.\n\nIn push_branch ref_exists was called, which is redundant because _dep_is_tgish\ntells us exactly this.\n\nRegards,\nBert\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n\n---\n tg-push.sh |   48 +++++++++++++++++++++++++++++-------------------\n 1 files changed, 29 insertions(+), 19 deletions(-)\n\ndiff --git a/tg-push.sh b/tg-push.sh\nindex 8d09a02..c813927 100644\n--- a/tg-push.sh\n+++ b/tg-push.sh\n@@ -45,31 +45,41 @@ for name in $branches; do\n \tref_exists \"$name\" || die \"detached HEAD? Can't push $name\"\n done\n \n+_listfile=\"$(mktemp -t tg-push-listfile.XXXXXX)\"\n+trap \"rm -f \\\"$_listfile\\\"\" 0\n+\n+# prevent multiple occurrences of the same branch\n+add_to_list()\n+{\n+\tfgrep -qx \"$1\" \"$_listfile\" ||\n+\t\techo \"$1\" >> \"$_listfile\"\n+}\n+\n push_branch()\n {\n \t# if so desired omit non tgish deps\n \t$tgish_deps_only && [ -z \"$_dep_is_tgish\" ] && return 0\n \n-\techo \"$_dep\"\n-\tlocal base=\"top-bases/$_dep\"\n-\tif ref_exists \"$base\"; then\n-\t\techo \"top-bases/$_dep\"\n-\telse\n-\t\techo \"warning, no base found $base\" 1>&2\n-\tfi\n+\tadd_to_list \"$_dep\"\n+\t[ -z \"$_dep_is_tgish\" ] ||\n+\t\tadd_to_list \"top-bases/$_dep\"\n }\n \n for name in $branches; do\n-\tlist=\"$(\n-\t\t# deps\n-\t\tif $recurse_deps; then\n-\t\t\tno_remotes=1 recurse_deps push_branch \"$name\"\n-\t\tfi\n-\t\t# current branch\n-\t\t_dep=\"$name\"\n-\t\t_dep_is_tgish=1\n-\t\tpush_branch \"$name\"\n-\t)\"\n-\techo \"pushing:\"; echo $list\n-\tgit push $dry_run \"$remote\" $list\n+\t# current branch\n+\t# re-use push_branch, which expects some pre-defined variables\n+\t_dep=\"$name\"\n+\t_dep_is_tgish=1\n+\tref_exists \"top-bases/$_dep\" ||\n+\t\t_dep_is_tgish=\n+\tpush_branch \"$name\"\n+\n+\t# deps\n+\t$recurse_deps &&\n+\t\tno_remotes=1 recurse_deps push_branch \"$name\"\n+\n+\tcat \"$_listfile\" |\n+\t\tsed '1{ s/^/Pushing: /; n; }; s/^/         /;'\n+\n+\tcat \"$_listfile\" | xargs git push $dry_run \"$remote\"\n done\n-- \ntg: (b725fc9..) bw/push-fixes (depends on: master)\n"},{"id":"114778","messageId":"20090527072100.GA13559@pengutronix.de","threadId":"19514","inReplyTo":"1243373820-13442-1-git-send-email-bert.wesarg@googlemail.com","subject":"Re: [TopGit PATCH] tg-push: prevent multiple occurences of branches","fromName":"Uwe Kleine-König","fromEmail":"u.kleine-koenig@pengutronix.de","sentAt":"2009-05-27T07:21:00Z","receivedAt":"2009-05-27T07:21:00Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hi Bert,\n\nOn Tue, May 26, 2009 at 11:37:00PM +0200, Bert Wesarg wrote:\n> So, I finally tried tg-push and got a lot of warnings and errors:\n> \n> warning, no base found top-bases/master\n> warning, no base found top-bases/master\n> warning, no base found top-bases/master\n> warning, no base found top-bases/master\n> warning, no base found top-bases/master\n> warning, no base found top-bases/master\n> warning, no base found top-bases/master\n> warning, no base found top-bases/master\n> warning, no base found top-bases/master\n> warning, no base found top-bases/master\n> warning, no base found top-bases/master\n> \n> \n> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n> error: failed to lock refs/heads/master\n> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n> error: failed to lock refs/heads/master\n> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n> error: failed to lock refs/heads/master\n> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n> error: failed to lock refs/heads/master\n> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n> error: failed to lock refs/heads/master\n> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n> error: failed to lock refs/heads/master\n> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n> error: failed to lock refs/heads/master\n> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n> error: failed to lock refs/heads/master\n> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n> error: failed to lock refs/heads/master\n> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n> error: failed to lock refs/heads/master\n> error: Ref refs/heads/bw/log is at a16df35cc7009b36f6f71717ae3d9a3dc29987da but expected 0000000000000000000000000000000000000000\n> error: failed to lock refs/heads/bw/log\n> error: Ref refs/top-bases/bw/log is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n> error: failed to lock refs/top-bases/bw/log\n> \n>  ! [remote rejected] master -> master (failed to lock)\n>  ! [remote rejected] master -> master (failed to lock)\n>  ! [remote rejected] master -> master (failed to lock)\n>  ! [remote rejected] master -> master (failed to lock)\n>  ! [remote rejected] master -> master (failed to lock)\n>  ! [remote rejected] master -> master (failed to lock)\n>  ! [remote rejected] master -> master (failed to lock)\n>  ! [remote rejected] master -> master (failed to lock)\n>  ! [remote rejected] master -> master (failed to lock)\n>  ! [remote rejected] master -> master (failed to lock)\n>  ! [remote rejected] bw/log -> bw/log (failed to lock)\n>  ! [remote rejected] refs/top-bases/bw/log -> refs/top-bases/bw/log (failed to lock)\nhhm, does this happen because\n\n\tgit push $remote master master master master\n\ntries to lock master four times?  I'd think this is something that needs\nfixing in git-core.\n \n> Also the result was ok this output is defintive not ok.\n> \n> To prevent multiple occurences of the same branchname we maintain these in a\n> file.\n> \n> In push_branch ref_exists was called, which is redundant because _dep_is_tgish\n> tells us exactly this.\n... what about breaking this out?\n\n> ---\n>  tg-push.sh |   48 +++++++++++++++++++++++++++++-------------------\n>  1 files changed, 29 insertions(+), 19 deletions(-)\n> \n> diff --git a/tg-push.sh b/tg-push.sh\n> index 8d09a02..c813927 100644\n> --- a/tg-push.sh\n> +++ b/tg-push.sh\n> @@ -45,31 +45,41 @@ for name in $branches; do\n>  \tref_exists \"$name\" || die \"detached HEAD? Can't push $name\"\n>  done\n>  \n> +_listfile=\"$(mktemp -t tg-push-listfile.XXXXXX)\"\n> +trap \"rm -f \\\"$_listfile\\\"\" 0\n> +\n> +# prevent multiple occurrences of the same branch\n> +add_to_list()\n> +{\n> +\tfgrep -qx \"$1\" \"$_listfile\" ||\n> +\t\techo \"$1\" >> \"$_listfile\"\n> +}\nThis has complexity O(n**2) for n calls (I think).  Just writing then to\nthe list and doing sort -u afterwards only has O(n log n) (for a\nreasonable implementation of sort).\n\n>  push_branch()\n>  {\n>  \t# if so desired omit non tgish deps\n>  \t$tgish_deps_only && [ -z \"$_dep_is_tgish\" ] && return 0\n>  \n> -\techo \"$_dep\"\nwhat about $tgish_deps_only?\n> -\tlocal base=\"top-bases/$_dep\"\n> -\tif ref_exists \"$base\"; then\n> -\t\techo \"top-bases/$_dep\"\n> -\telse\n> -\t\techo \"warning, no base found $base\" 1>&2\n> -\tfi\n> +\tadd_to_list \"$_dep\"\n> +\t[ -z \"$_dep_is_tgish\" ] ||\n> +\t\tadd_to_list \"top-bases/$_dep\"\n\nBest regards\nUwe\n\n-- \nPengutronix e.K.                              | Uwe Kleine-König            |\nIndustrial Linux Solutions                    | http://www.pengutronix.de/  |\n"},{"id":"114780","messageId":"36ca99e90905270040x2ac8e739j99411d61e8ef2689@mail.gmail.com","threadId":"19514","inReplyTo":"20090527072100.GA13559@pengutronix.de","subject":"Re: [TopGit PATCH] tg-push: prevent multiple occurences of branches","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2009-05-27T07:40:34Z","receivedAt":"2009-05-27T07:40:34Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"2009/5/27 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:\n> Hi Bert,\nMoin Uwe,\n\n>\n> On Tue, May 26, 2009 at 11:37:00PM +0200, Bert Wesarg wrote:\n>> So, I finally tried tg-push and got a lot of warnings and errors:\n>>\n>> warning, no base found top-bases/master\n>> warning, no base found top-bases/master\n>> warning, no base found top-bases/master\n>> warning, no base found top-bases/master\n>> warning, no base found top-bases/master\n>> warning, no base found top-bases/master\n>> warning, no base found top-bases/master\n>> warning, no base found top-bases/master\n>> warning, no base found top-bases/master\n>> warning, no base found top-bases/master\n>> warning, no base found top-bases/master\n>>\n>>\n>> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n>> error: failed to lock refs/heads/master\n>> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n>> error: failed to lock refs/heads/master\n>> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n>> error: failed to lock refs/heads/master\n>> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n>> error: failed to lock refs/heads/master\n>> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n>> error: failed to lock refs/heads/master\n>> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n>> error: failed to lock refs/heads/master\n>> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n>> error: failed to lock refs/heads/master\n>> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n>> error: failed to lock refs/heads/master\n>> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n>> error: failed to lock refs/heads/master\n>> error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n>> error: failed to lock refs/heads/master\n>> error: Ref refs/heads/bw/log is at a16df35cc7009b36f6f71717ae3d9a3dc29987da but expected 0000000000000000000000000000000000000000\n>> error: failed to lock refs/heads/bw/log\n>> error: Ref refs/top-bases/bw/log is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000\n>> error: failed to lock refs/top-bases/bw/log\n>>\n>>  ! [remote rejected] master -> master (failed to lock)\n>>  ! [remote rejected] master -> master (failed to lock)\n>>  ! [remote rejected] master -> master (failed to lock)\n>>  ! [remote rejected] master -> master (failed to lock)\n>>  ! [remote rejected] master -> master (failed to lock)\n>>  ! [remote rejected] master -> master (failed to lock)\n>>  ! [remote rejected] master -> master (failed to lock)\n>>  ! [remote rejected] master -> master (failed to lock)\n>>  ! [remote rejected] master -> master (failed to lock)\n>>  ! [remote rejected] master -> master (failed to lock)\n>>  ! [remote rejected] bw/log -> bw/log (failed to lock)\n>>  ! [remote rejected] refs/top-bases/bw/log -> refs/top-bases/bw/log (failed to lock)\n> hhm, does this happen because\n>\n>        git push $remote master master master master\nExactly.\n\n>\n> tries to lock master four times?  I'd think this is something that needs\n> fixing in git-core.\nCc'd Junio. And Junio, you can stop reading now.\n\n>\n>> Also the result was ok this output is defintive not ok.\n>>\n>> To prevent multiple occurences of the same branchname we maintain these in a\n>> file.\n>>\n>> In push_branch ref_exists was called, which is redundant because _dep_is_tgish\n>> tells us exactly this.\n> ... what about breaking this out?\nBy your command.\n\n>\n>> ---\n>>  tg-push.sh |   48 +++++++++++++++++++++++++++++-------------------\n>>  1 files changed, 29 insertions(+), 19 deletions(-)\n>>\n>> diff --git a/tg-push.sh b/tg-push.sh\n>> index 8d09a02..c813927 100644\n>> --- a/tg-push.sh\n>> +++ b/tg-push.sh\n>> @@ -45,31 +45,41 @@ for name in $branches; do\n>>       ref_exists \"$name\" || die \"detached HEAD? Can't push $name\"\n>>  done\n>>\n>> +_listfile=\"$(mktemp -t tg-push-listfile.XXXXXX)\"\n>> +trap \"rm -f \\\"$_listfile\\\"\" 0\n>> +\n>> +# prevent multiple occurrences of the same branch\n>> +add_to_list()\n>> +{\n>> +     fgrep -qx \"$1\" \"$_listfile\" ||\n>> +             echo \"$1\" >> \"$_listfile\"\n>> +}\n> This has complexity O(n**2) for n calls (I think).  Just writing then to\n> the list and doing sort -u afterwards only has O(n log n) (for a\n> reasonable implementation of sort).\nAhh, that takes a while, but yes. I thought I need to sort each time I\nput a new branch in this file.\n\n>\n>>  push_branch()\n>>  {\n>>       # if so desired omit non tgish deps\n>>       $tgish_deps_only && [ -z \"$_dep_is_tgish\" ] && return 0\n>>\n>> -     echo \"$_dep\"\n> what about $tgish_deps_only?\nHmm, I think I have not changed the semantics here. I replace this\nline with 'add_to_list \"$_dep\"'.\n\n>> -     local base=\"top-bases/$_dep\"\n>> -     if ref_exists \"$base\"; then\n>> -             echo \"top-bases/$_dep\"\n>> -     else\n>> -             echo \"warning, no base found $base\" 1>&2\n>> -     fi\n>> +     add_to_list \"$_dep\"\n>> +     [ -z \"$_dep_is_tgish\" ] ||\n>> +             add_to_list \"top-bases/$_dep\"\n>\nBert\n\n> Best regards\n> Uwe\n"}]}