Revision f3a2fffe06d13b216cbc18acba5a46b8a00ae326 authored by Jeff King on 30 May 2017, 05:11:23 UTC, committed by Junio C Hamano on 30 May 2017, 05:39:47 UTC
If the user provides "-h" on the command line, then our
parse_options() invocation will show a usage message and
quit. But if "-h" is the only argument, the git wrapper
behaves specially: it ignores our RUN_SETUP flag and calls
cmd_am() without having done repository setup at all.  This
is due to 99caeed05 (Let 'git <command> -h' show usage
without a git dir, 2009-11-09).

Before cmd_am() calls parse_options(), though, it runs a few
other setup functions. One of these is am_state_init(),
which uses git_pathdup() to set up the default rebase-apply
path. But calling git_pathdup() when we haven't done
repository setup will fall back to using ".git". That's
mostly harmless (since we won't use the value anyway), but
is forbidden since b1ef400eec ("setup_git_env: avoid blind
fall-back to ".git"", 2016-10-20), and we now BUG().

We can't easily move that setup to after the parse_options()
call; the point is to set up defaults that are overwritten
by the option parsing. Instead, we'll detect the "-h" case
early and show the usage then. This matches the behavior of
other builtins which have a similar setup-ordering issue
(e.g., git-branch).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent b06d364
History
File Mode Size
.gitignore -rw-r--r-- 7 bytes
README -rw-r--r-- 10.6 KB
TEAMS -rw-r--r-- 2.1 KB
bg.po -rw-r--r-- 611.3 KB
ca.po -rw-r--r-- 469.1 KB
de.po -rw-r--r-- 483.0 KB
fr.po -rw-r--r-- 503.5 KB
git.pot -rw-r--r-- 303.3 KB
is.po -rw-r--r-- 3.3 KB
it.po -rw-r--r-- 128.2 KB
ko.po -rw-r--r-- 484.2 KB
pt_PT.po -rw-r--r-- 482.9 KB
ru.po -rw-r--r-- 526.1 KB
sv.po -rw-r--r-- 487.8 KB
vi.po -rw-r--r-- 539.5 KB
zh_CN.po -rw-r--r-- 449.6 KB

README

back to top