{"thread":{"id":"33945","subject":"contrib/git-normal-to-bare.sh","startedAt":"2013-05-27T04:54:35Z","lastAt":"2013-05-28T20:07:44Z","messageCount":2,"participants":["Zenaan Harkness","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"218589","messageId":"CAOsGNST8X+crMQz1ynJQxctCMUnBw3T3K5HiMH8B_GFP63yX1w@mail.gmail.com","threadId":"33945","inReplyTo":null,"subject":"contrib/git-normal-to-bare.sh","fromName":"Zenaan Harkness","fromEmail":"zen@freedbms.net","sentAt":"2013-05-27T04:54:35Z","receivedAt":"2013-05-27T04:54:35Z","isPatch":false,"sender":{"key":"zen@freedbms.net","avatar":null},"body":"I needed this quite a bit in the last few days, basic script but\nserves my need. I think it would be useful for other beginners if in\n$git/contrib/ source dir.\n\nJust a start to a basic script. Needs more tests etc, but it's enough\nto get newbies (like me) off to a reasonable start. Handles multiple\ninput dirs.\n\nPLEASE CC me, as I am not subscribed.\n\n(some SMTP server rejected attachment, so pasting below instead)\n\nThanks,\nZenaan\n\n\n#!/bin/bash\n\n# Change one or more normal repos into bare repos:\n# See also https://git.wiki.kernel.org/index.php/GitFaq#How_do_I_make_existing_non-bare_repository_bare.3F\n\nfor i in \"$@\"; do\n   echo; echo \"----------------------\"\n   echo Processing $i\n\n   repo=\"$i\"\n   repo=\"`basename $i`\"\n   tmp_repo=\"${repo}.git\"\n\n   # Insert here: may be exit if any spaces in repo fqn\n   # Insert here: check for non-existent repo/.git dir\n   # Insert here: check that we are not inside the repo\n   # Insert here: add exit/do-nothing if fail to mv dirs etc\n\n   mv $repo/.git $tmp_repo\n   git --git-dir=$tmp_repo config core.bare true\n   mv $repo ${repo}.bak\n   mv $tmp_repo $repo\ndone\n"},{"id":"218699","messageId":"7v1u8qzx4f.fsf@alter.siamese.dyndns.org","threadId":"33945","inReplyTo":"CAOsGNST8X+crMQz1ynJQxctCMUnBw3T3K5HiMH8B_GFP63yX1w@mail.gmail.com","subject":"Re: contrib/git-normal-to-bare.sh","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-05-28T20:07:44Z","receivedAt":"2013-05-28T20:07:44Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Zenaan Harkness <zen@freedbms.net> writes:\n\n> I needed this quite a bit in the last few days, basic script but\n> serves my need. I think it would be useful for other beginners if in\n> $git/contrib/ source dir.\n>\n> Just a start to a basic script. Needs more tests etc, but it's enough\n> to get newbies (like me) off to a reasonable start. Handles multiple\n> input dirs.\n>\n> PLEASE CC me, as I am not subscribed.\n>\n> (some SMTP server rejected attachment, so pasting below instead)\n>\n> Thanks,\n> Zenaan\n>\n>\n> #!/bin/bash\n\nI do not think you need (nor used) any bash-ism in this script.\nSaying \"#!/bin/sh\" here is cleaner.\n\n>\n> # Change one or more normal repos into bare repos:\n> # See also https://git.wiki.kernel.org/index.php/GitFaq#How_do_I_make_existing_non-bare_repository_bare.3F\n>\n> for i in \"$@\"; do\n\n\tfor i\n        do\n\nYou do not have to say 'in \"$@\"'; it is implied.\n\n>    echo; echo \"----------------------\"\n>    echo Processing $i\n\nForgot to dq?\n\n>\n>    repo=\"$i\"\n>    repo=\"`basename $i`\"\n>    tmp_repo=\"${repo}.git\"\n>    # Insert here: may be exit if any spaces in repo fqn\n>    # Insert here: check for non-existent repo/.git dir\n>    # Insert here: check that we are not inside the repo\n>    # Insert here: add exit/do-nothing if fail to mv dirs etc\n>\n>    mv $repo/.git $tmp_repo\n\nForgot to dq?  i.e.\n\n\tmv \"$repo/.git\" \"$tmp_repo\"\n\nThe same for all the variable references in the remainder of the\nscript.\n\nMore importantly, \"mv\" would fail if $repo is given as a full\npathname elsewhere in the filesystem that is different from your\ncurrent directory where you create $tmp_repo.\n\n>    git --git-dir=$tmp_repo config core.bare true\n>    mv $repo ${repo}.bak\n>    mv $tmp_repo $repo\n> done\n"}]}