Thread (24 messages) flat view 24 messages, 7 authors, 4d ago

Re: [PATCH v3] var: support broken-down idents, default key, multiple args, and -z

From: Ben Knoble <hidden>
Date: 2026-09-03 18:22:59

Le 3 sept. 2026 à 14:02, Junio C Hamano [off-list ref] a écrit :

"Andrew Pleeter via GitGitGadget" [off-list ref] writes:
quoted
+    if (!vars.nr)
       usage(var_usage);
I do not know if this is friendly for a tool meant primarily for
scripts.  "git var foo bar" would give information about foo and
bar, "git var foo" would give informmation about foo, and it is
natural "git var" alone would give nothing.
I believe « git var » prints usage and exits 129 today, at least on my 2.55.0.340.g8e2bf96aa5.

Lifting the limitation may be sensible, though I suspect the empty case is likely to indicate a logic error earlier in the script; either way, probably out of scope here for now?
This matters because it is plausible to have a list of vars in a
variable and then run "git var -z $variables | xargs -0 ..." to
process the vars and their values.  If you barf for an empty list,
then they need to see if they have nothing in $variable, which
becomes more than "test -z "$variable" because people often take
advantage of the fact that IFS is ignored to write their accumulator
like so

   variable=" "
   for n in ...
   do
       variable="$variable$n "
   done

   case "$variable" in
   *" "word" "*)
       : has the word
       ;;
   esac

which means that $variable may not be an empty string.  It is easier
for scripts if "git var <variable>..." did not barf when the number
of <variable>s happens to be zero.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help