Re: Adapting scripts to work in current (not top) directory
- From
Petr Baudis <pasky@ucw.cz>
- Date
- May 13, 2005, 13:53 UTC
- Message-ID
- <20050513135359.GA28138@pasky.ji.cz>
- In-Reply-To
- <200505131459.08891.snake@penza-gsm.ru>
Dear diary, on Fri, May 13, 2005 at 12:59:08PM CEST, I got a letter
> I have opted for current directory and not root. Explanation is later this > mail. New variant:
Yes, that's fine.
Show 20 quoted lines
> =========================
> --- /home/snake/scm/cogito/cg-Xlib 2005-05-12 08:47:29.000000000 +0400
> +++ cg-Xlib 2005-05-13 13:40:58.000000000 +0400
> @@ -8,7 +8,17 @@
>
> _cg_cmd=${0##*/}
>
> -_git=${GIT_DIR:-.git}
> +repopath=`pwd`
> +while ((1)) ; do {
> + [ -d "$repopath/.git" ] && break
> + [ "$repopath" == "/" ] && {
> + repopath=`pwd`;
> + break;
> + };
> + repopath=`dirname $repopath`
> +}; done
> +
> +_git=${GIT_DIR:-$repopath/.git}
> _git_objects=${GIT_OBJECT_DIRECTORY:-$_git/objects}Looks basically fine.
Show 7 quoted lines
> ========================= > Here is a problem: > Because of git backend only some of the commands should be enabled to work > from current directory. F.e. cg-init should not scan upper directories for > ".git" but should instead stick to current directory. In the script above > this workarounded as choosing current directory instead of root but this will > broke if we trying to initialise repo in a subdirectory of another repo.
I'd set some flag like $reposubdir if .git was found in some of the parent directories. Then test that in the relevant commands.
Show 10 quoted lines
> So I have analysed list of cogito commands to find out which ones should be > adopted to use "find repo" behaivoir: > > "+" means "definitely yes" > "-" means "definitely no" > "?" means "not sure" > "." means "not matter" > > + cg-add > ? cg-admin-lsobj
Sure.
> - cg-admin-uncommit > ? cg-branch-add > ? cg-branch-ls
Sure (both).
> - cg-cancel > - cg-clone > - cg-commit
This one should, committing only the subdirectory content.
> + cg-diff > - cg-export
Perhaps it could export just the subdirectory?
> . cg-help > - cg-init > + cg-log > + cg-ls
(Listing the appropriate subdir.)
> - cg-merge > + cg-mkpatch > ? cg-patch
This one should, using the appropriate -p level.
> - cg-pull > - cg-restore
This one should, restoring only the subdirectory.
Show 5 quoted lines
> + cg-rm > - cg-seek > + cg-status > - cg-tag > ? cg-tag-ls
Why not...
> - cg-update > . cg-version
-- Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor