Re: [PATCH] repack: find -> /usr/bin/find, as for cygwin
- From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
- Date
- Mar 19, 2011, 15:50 UTC
- Message-ID
- <4D84D0C0.7080808@lsrfire.ath.cx>
- In-Reply-To
- <AANLkTimPbz2s=Maafhqg-7wOk_TT4fFSh7AQ-3rWY0A3@mail.gmail.com>
Am 19.03.2011 13:18, schrieb Nguyen Thai Ngoc Duy:
Show 11 quoted lines
> On Sat, Mar 19, 2011 at 7:08 PM, ryenus ◇<ryenus@gmail.com> wrote:
>> - for e in `cd "$PACKDIR"&& find . -type f -name '*.pack' \
>> + for e in `cd "$PACKDIR"&& /usr/bin/find . -type f
>
> I'd rather have something like in test-lib.sh (with conditions)
>
> find() {
> /usr/bin/find "$@"
> }
>
> Even better, rewrite this script to C.That's a good idea, but it's a lot more involved than the original patch.
Do we need to support pack files in subdirectories of $PACKDIR? If not -- and I don't immediately see why, except that the current code does with its find call -- then the following patch might be a quick bandaid. Untested, please be careful.
René
git-repack.sh | 19 ++++++++++--------- 1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/git-repack.sh b/git-repack.sh index 624feec..4e49079 100755 --- a/git-repack.sh +++ b/git-repack.sh @@ -64,15 +64,16 @@ case ",$all_into_one," in ,t,) args= existing= if [ -d "$PACKDIR" ]; then - for e in `cd "$PACKDIR" && find . -type f -name '*.pack' \ - | sed -e 's/^\.\///' -e 's/\.pack$//'` - do - if [ -e "$PACKDIR/$e.keep" ]; then - : keep - else - existing="$existing $e" - fi - done + existing=$( + cd "$PACKDIR" && + for e in *.pack + do + if test -f "$e" -a ! -e "${e%.pack}.keep" + then + echo "${e%.pack}" + fi + done + ) if test -n "$existing" -a -n "$unpack_unreachable" -a \ -n "$remove_redundant" then