* contrib/git-normal-to-bare.sh
@ 2013-05-27 4:00 Zenaan Harkness
2013-05-27 9:02 ` contrib/git-normal-to-bare.sh Matthieu Moy
2013-05-29 2:52 ` contrib/git-normal-to-bare.sh Felipe Contreras
0 siblings, 2 replies; 7+ messages in thread
From: Zenaan Harkness @ 2013-05-27 4:00 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 295 bytes --]
This question comes up every now and then - how to convert from normal
to bare, or vice versa.
This is just a start to a basic script to go one way. Needs more tests
etc, but it's enough to get newbies (like me) off to a reasonable
start.
PLEASE CC me, as I am not subscribed.
Thanks,
Zenaan
[-- Attachment #2: git-normal-to-bare.sh --]
[-- Type: application/x-sh, Size: 654 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* contrib/git-normal-to-bare.sh
@ 2013-05-27 4:54 Zenaan Harkness
2013-05-28 20:07 ` contrib/git-normal-to-bare.sh Junio C Hamano
0 siblings, 1 reply; 7+ messages in thread
From: Zenaan Harkness @ 2013-05-27 4:54 UTC (permalink / raw)
To: git
I needed this quite a bit in the last few days, basic script but
serves my need. I think it would be useful for other beginners if in
$git/contrib/ source dir.
Just a start to a basic script. Needs more tests etc, but it's enough
to get newbies (like me) off to a reasonable start. Handles multiple
input dirs.
PLEASE CC me, as I am not subscribed.
(some SMTP server rejected attachment, so pasting below instead)
Thanks,
Zenaan
#!/bin/bash
# Change one or more normal repos into bare repos:
# See also https://git.wiki.kernel.org/index.php/GitFaq#How_do_I_make_existing_non-bare_repository_bare.3F
for i in "$@"; do
echo; echo "----------------------"
echo Processing $i
repo="$i"
repo="`basename $i`"
tmp_repo="${repo}.git"
# Insert here: may be exit if any spaces in repo fqn
# Insert here: check for non-existent repo/.git dir
# Insert here: check that we are not inside the repo
# Insert here: add exit/do-nothing if fail to mv dirs etc
mv $repo/.git $tmp_repo
git --git-dir=$tmp_repo config core.bare true
mv $repo ${repo}.bak
mv $tmp_repo $repo
done
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: contrib/git-normal-to-bare.sh
2013-05-27 4:00 contrib/git-normal-to-bare.sh Zenaan Harkness
@ 2013-05-27 9:02 ` Matthieu Moy
2013-05-27 9:43 ` contrib/git-normal-to-bare.sh Zenaan Harkness
2013-05-29 2:52 ` contrib/git-normal-to-bare.sh Felipe Contreras
1 sibling, 1 reply; 7+ messages in thread
From: Matthieu Moy @ 2013-05-27 9:02 UTC (permalink / raw)
To: Zenaan Harkness; +Cc: git
Zenaan Harkness <zen@freedbms.net> writes:
> rm -rf $repo
The user would appreciate if you check that there are no uncommited
changes and no untracked files (at least no untracked and not ignored
files) before running this.
Also, it's "$repo", not just $repo, or you'll get surprising behavior if
$repo contain spaces.
The safe way would actually be stg like:
rm -fr -- "$repo"
in case $repo starts with a dash.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: contrib/git-normal-to-bare.sh
2013-05-27 9:02 ` contrib/git-normal-to-bare.sh Matthieu Moy
@ 2013-05-27 9:43 ` Zenaan Harkness
2013-05-27 9:52 ` contrib/git-normal-to-bare.sh Fredrik Gustafsson
0 siblings, 1 reply; 7+ messages in thread
From: Zenaan Harkness @ 2013-05-27 9:43 UTC (permalink / raw)
To: git
On 5/27/13, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:
> Zenaan Harkness <zen@freedbms.net> writes:
>
>> rm -rf $repo
>
> The user would appreciate if you check that there are no uncommited
> changes and no untracked files (at least no untracked and not ignored
> files) before running this.
>
> Also, it's "$repo", not just $repo, or you'll get surprising behavior if
> $repo contain spaces.
>
> The safe way would actually be stg like:
>
> rm -fr -- "$repo"
Thanks.
In my later email, I changed it to mv - should have highlighted there
was a change. I got bitten, on a small repo thankfully, where a perms
or ownership problem caused the whole repo to disappear. So mv it is
:)
BTW, I've subscribed for a little while now...
Thanks again
Zenaan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: contrib/git-normal-to-bare.sh
2013-05-27 9:43 ` contrib/git-normal-to-bare.sh Zenaan Harkness
@ 2013-05-27 9:52 ` Fredrik Gustafsson
0 siblings, 0 replies; 7+ messages in thread
From: Fredrik Gustafsson @ 2013-05-27 9:52 UTC (permalink / raw)
To: Zenaan Harkness; +Cc: git
On Mon, May 27, 2013 at 07:43:13PM +1000, Zenaan Harkness wrote:
> In my later email, I changed it to mv - should have highlighted there
> was a change. I got bitten, on a small repo thankfully, where a perms
> or ownership problem caused the whole repo to disappear. So mv it is
> :)
Do you really need bash for that script or will it do with sh? I think
sh is preferred.
Also a mv instead of a rm will require a lot of disc space if you have a
big repository.
--
Med vänliga hälsningar
Fredrik Gustafsson
tel: 0733-608274
e-post: iveqy@iveqy.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: contrib/git-normal-to-bare.sh
2013-05-27 4:54 contrib/git-normal-to-bare.sh Zenaan Harkness
@ 2013-05-28 20:07 ` Junio C Hamano
0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2013-05-28 20:07 UTC (permalink / raw)
To: Zenaan Harkness; +Cc: git
Zenaan Harkness <zen@freedbms.net> writes:
> I needed this quite a bit in the last few days, basic script but
> serves my need. I think it would be useful for other beginners if in
> $git/contrib/ source dir.
>
> Just a start to a basic script. Needs more tests etc, but it's enough
> to get newbies (like me) off to a reasonable start. Handles multiple
> input dirs.
>
> PLEASE CC me, as I am not subscribed.
>
> (some SMTP server rejected attachment, so pasting below instead)
>
> Thanks,
> Zenaan
>
>
> #!/bin/bash
I do not think you need (nor used) any bash-ism in this script.
Saying "#!/bin/sh" here is cleaner.
>
> # Change one or more normal repos into bare repos:
> # See also https://git.wiki.kernel.org/index.php/GitFaq#How_do_I_make_existing_non-bare_repository_bare.3F
>
> for i in "$@"; do
for i
do
You do not have to say 'in "$@"'; it is implied.
> echo; echo "----------------------"
> echo Processing $i
Forgot to dq?
>
> repo="$i"
> repo="`basename $i`"
> tmp_repo="${repo}.git"
> # Insert here: may be exit if any spaces in repo fqn
> # Insert here: check for non-existent repo/.git dir
> # Insert here: check that we are not inside the repo
> # Insert here: add exit/do-nothing if fail to mv dirs etc
>
> mv $repo/.git $tmp_repo
Forgot to dq? i.e.
mv "$repo/.git" "$tmp_repo"
The same for all the variable references in the remainder of the
script.
More importantly, "mv" would fail if $repo is given as a full
pathname elsewhere in the filesystem that is different from your
current directory where you create $tmp_repo.
> git --git-dir=$tmp_repo config core.bare true
> mv $repo ${repo}.bak
> mv $tmp_repo $repo
> done
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: contrib/git-normal-to-bare.sh
2013-05-27 4:00 contrib/git-normal-to-bare.sh Zenaan Harkness
2013-05-27 9:02 ` contrib/git-normal-to-bare.sh Matthieu Moy
@ 2013-05-29 2:52 ` Felipe Contreras
1 sibling, 0 replies; 7+ messages in thread
From: Felipe Contreras @ 2013-05-29 2:52 UTC (permalink / raw)
To: Zenaan Harkness, git
Zenaan Harkness wrote:
> This question comes up every now and then - how to convert from normal
> to bare, or vice versa.
>
> This is just a start to a basic script to go one way. Needs more tests
> etc, but it's enough to get newbies (like me) off to a reasonable
> start.
>
> PLEASE CC me, as I am not subscribed.
You do not need to ask to be CC'ed. Any mailing list properly configued would
not munge the Reply-To header, so anybody replying to this mail would reply to
you.
Git is a properly configured mailing list, just like all the mailing list in
vger.kernel.org.
Cheers.
--
Felipe Contreras
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-05-29 2:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-27 4:00 contrib/git-normal-to-bare.sh Zenaan Harkness
2013-05-27 9:02 ` contrib/git-normal-to-bare.sh Matthieu Moy
2013-05-27 9:43 ` contrib/git-normal-to-bare.sh Zenaan Harkness
2013-05-27 9:52 ` contrib/git-normal-to-bare.sh Fredrik Gustafsson
2013-05-29 2:52 ` contrib/git-normal-to-bare.sh Felipe Contreras
-- strict thread matches above, loose matches on Subject: below --
2013-05-27 4:54 contrib/git-normal-to-bare.sh Zenaan Harkness
2013-05-28 20:07 ` contrib/git-normal-to-bare.sh Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).