All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Add git-clean command
Date: Wed, 05 Apr 2006 02:00:44 -0400	[thread overview]
Message-ID: <1144216844.3793.10.camel@dv> (raw)
In-Reply-To: <7vzmj2b3w3.fsf@assigned-by-dhcp.cox.net>

On Mon, 2006-04-03 at 17:06 -0700, Junio C Hamano wrote:
> > diff --git a/git-clean.sh b/git-clean.sh
> >...
> > +for arg in "$@"; do
> 
> 	for arg
>         do
>         	...

I checked other git shell scripts and copied the "while" construct from
one of them - if it's good for other commands, it's good for git-clean.

> > +	if [ "$arg" = "-d" ]; then
> 
> 	case "$arg" in -d)...
> 
> > +excl1=
> > +excl2=
> > +if [ -z "$noexclude" ]; then
> > +	excl1="--exclude-per-directory=.gitignore"
> > +	if [ -f "$GIT_DIR/info/exclude" ]; then
> > +		excl2="--exclude-from=$GIT_DIR/info/exclude"
> > +	fi
> > +fi
> > +
> > +git-ls-files --others --directory "$excl1" "$excl2" |
> > +while read -r file; do
> > ...
> 
> The $noexclude case passes two empty strings to git-ls-files,
> which may happen to be harmless with the current implementation,
> but does not feel quite right.

Good catch.  This is needed since $GIT_DIR can contain spaces.  I
believe ${excl2:+"$excl2"} would do the trick.

> Maybe better to read ls-files -z to be really pathname safe, I
> dunno.

I think "xargs -0" has its own problems (argument length limitations),
and the other solution is to use perl.  While at that, I'd rather
rewrite the whole script in Perl, or maybe in even C.

I think this should eventually happen to all git scripts, but I have no
intention to do it right now unless you really want me to.

> > +		$echo1 "Removing $file"
> > +		[ "$cleandirhard" ] && chmod -R 700 "$file"
> 
> I am not quite sure this chmod -R is a good idea.  If we are
> trying really hard would we need to also make sure we can rmdir
> the "$file" by chmod'ing its parent directory?  But once we
> start doing that where would we stop?

OK, I was undecided on that.  I'm dropping this option.

-- 
Regards,
Pavel Roskin

  parent reply	other threads:[~2006-04-05  6:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-03 22:18 [PATCH] Add git-clean command Pavel Roskin
2006-04-04  0:06 ` Junio C Hamano
2006-04-04 10:58   ` Sam Ravnborg
2006-04-04 15:52     ` Pavel Roskin
2006-04-05 16:02       ` unchecked uses of strdup Jim Meyering
2006-04-06 14:11         ` Alex Riesen
2006-04-05  6:00   ` Pavel Roskin [this message]
2006-04-04  8:20 ` [PATCH] Add git-clean command Martin Waitz
2006-04-04  9:08   ` Junio C Hamano
2006-04-04  9:17   ` Alex Riesen
2006-04-04 15:32     ` Pavel Roskin
  -- strict thread matches above, loose matches on Subject: below --
2006-04-05  6:00 Pavel Roskin
2006-04-05  6:25 ` Jakub Narebski
2006-04-03 21:59 Pavel Roskin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1144216844.3793.10.camel@dv \
    --to=proski@gnu.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.