git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git-repack made my pack 317x larger...

From
BSBenjamin Sergeant <bsergean@gmail.com>
Date
Jun 15, 2007, 15:10 UTC
Message-ID
<1621f9fa0706150810m1d1bc31ua485db72f6e0bca1@mail.gmail.com>
In-Reply-To
<20070615145433.22970.qmail@science.horizon.com>
> (I might complan a little less if git-repack would take -adlf rather
> than insisting on -a -d -l -f.  Is that a deliberate choice or has just
> nobody stepped up to revamp the option parsing?)
getopt is our friend, indeed.
(http://www.hmug.org/man/1/getopt.php)
The following code fragment shows how one might process the arguments for
     a command that can take the options -a and -b, and the option -o, which
     requires an argument.
           args=`getopt abo: $*`
           # you should not use `getopt abo: "$@"` since that would parse
           # the arguments differently from what the set command below does.
           if [ $? != 0 ]
           then
                   echo 'Usage: ...'
                   exit 2
           fi
           set -- $args
           # You cannot use the set command with a backquoted getopt directly,
           # since the exit code from getopt would be shadowed by those of set,
           # which is zero by definition.
           for i
           do
                   case "$i"
                   in
                           -a|-b)
                                   echo flag $i set; sflags="${i#-}$sflags";
                                   shift;;
                           -o)
                                   echo oarg is "'"$2"'"; oarg="$2"; shift;
                                   shift;;
                           --)
                                   shift; break;;
                   esac
           done
           echo single-char flags: "'"$sflags"'"
           echo oarg is "'"$oarg"'"
     This code will accept any of the following as equivalent:
           cmd -aoarg file file
           cmd -a -o arg file file
           cmd -oarg -a file file
           cmd -a -oarg -- file file
Previous: linux@horizon.comNext: Nicolas Pitre
Message 4 of 5 in “git-repack made my pack 317x larger...”
  1. linux@horizon.comJun 15, 2007
  2. Nicolas PitreJun 15, 2007
  3. linux@horizon.comJun 15, 2007
  4. Benjamin SergeantJun 15, 2007
  5. Nicolas PitreJun 15, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.