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

Re: [PATCH 8/8] t0012: test "-h" with builtins

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 1, 2017, 04:17 UTC
Message-ID
<xmqqinkg734c.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170530152756.vs777v6unaxg6otb@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 7 quoted lines
> Anyway, the problem is sk/dash-is-previous, specifically fc5684b47
> (revision.c: args starting with "-" might be a revision, 2017-02-25). It
> looks like the revision parser used to just bail on "-h", because
> revision.c would say "I don't recognize this" and then cmd_rev_list()
> would similarly say "I don't recognize this" and call usage(). But now
> we actually try to read it as a ref, which obviously requires being
> inside a repository.
Heh, I found another ;-)  

95e98cd9 ("revision.c: use refs_for_each*() instead of for_each_*_submodule()", 2017-04-19), which is in the middle of Duy's nd/prune-in-worktree series, does this:

#0  die (err=0x6128f8 "BUG: setup_git_env called without repository") at usage.c:114
#1  0x00000000004f9467 in setup_git_env () at environment.c:172
#2  0x00000000004f966c in get_git_dir () at environment.c:214
#3  0x000000000055113b in get_main_ref_store () at refs.c:1544
#4  0x0000000000570ee0 in handle_revision_pseudo_opt (submodule=0x0, 
    revs=0x7fffffffd6a0, argc=1, argv=0x7fffffffe180, flags=0x7fffffffc59c)
    at revision.c:2110
#5  0x00000000005716f5 in setup_revisions (argc=2, argv=0x7fffffffe178, 
    revs=0x7fffffffd6a0, opt=0x0) at revision.c:2254
#6  0x000000000043074a in cmd_diff_files (argc=2, argv=0x7fffffffe178, prefix=0x0)
    at builtin/diff-files.c:29
#7  0x0000000000405907 in run_builtin (p=0x87ba00 <commands+672>, argc=2, 
    argv=0x7fffffffe178) at git.c:376
#8  0x0000000000405bb5 in handle_builtin (argc=2, argv=0x7fffffffe178) at git.c:584
#9  0x0000000000405e04 in cmd_main (argc=2, argv=0x7fffffffe178) at git.c:683
#10 0x00000000004a3364 in main (argc=2, argv=0x7fffffffe178) at common-main.c:43

when jk/consistent-h is merged into it and then "git diff-files -h" is run.

I guess anything that calls setup_revisions() from the "git cmd -h" bypass need to be prepared with that

  check_help_option(argc, argv, usage, options);

thing. Which is a bit sad, but I tend to agree with you that restructuring to make usage[] of everybody available to git.c is probably too noisy for the benefit it would give us.

Previous: Junio C HamanoNext: Jeff King
Message 29 of 38 in “[Bug] setup_git_env called without repository”
  1. Zero KingMay 29, 2017
  2. Ævar Arnfjörð BjarmasonMay 29, 2017
  3. Jeff KingMay 29, 2017
  4. 0/8 consistent "-h" handling in builtinsJeff King, May 30, 2017
  5. 1/8 am: handle "-h" argument earlierJeff King, May 30, 2017
  6. Junio C HamanoMay 30, 2017
  7. 2/8 credential: handle invalid arguments earlierJeff King, May 30, 2017
  8. 3/8 upload-archive: handle "-h" option earlyJeff King, May 30, 2017
  9. 4/8 remote-{ext,fd}: print usage message on invalid argumentsJeff King, May 30, 2017
  10. 5/8 submodule--helper: show usage for "-h"Jeff King, May 30, 2017
  11. 6/8 version: convert to parse-optionsJeff King, May 30, 2017
  12. version: move --build-options to a test helperÆvar Arnfjörð Bjarmason, May 30, 2017
  13. Jeff KingMay 30, 2017
  14. Johannes SchindelinMay 31, 2017
  15. Jeff KingMay 31, 2017
  16. Johannes SchindelinMay 31, 2017
  17. Ævar Arnfjörð BjarmasonMay 31, 2017
  18. Jeff KingMay 31, 2017
  19. 7/8 git: add hidden --list-builtins optionJeff King, May 30, 2017
  20. 8/8 t0012: test "-h" with builtinsJeff King, May 30, 2017
  21. Junio C HamanoMay 30, 2017
  22. Jeff KingMay 30, 2017
  23. Junio C HamanoMay 30, 2017
  24. Jeff KingMay 30, 2017
  25. Junio C HamanoMay 30, 2017
  26. Jeff KingMay 30, 2017
  27. Jeff KingMay 30, 2017
  28. Junio C HamanoMay 30, 2017
  29. Junio C HamanoJun 1, 2017
  30. Jeff KingJun 1, 2017
  31. Junio C HamanoJun 1, 2017
  32. Junio C HamanoJun 1, 2017
  33. Jeff KingJun 1, 2017
  34. Junio C HamanoJun 1, 2017
  35. Jeff KingJun 1, 2017
  36. Jonathan NiederJun 13, 2017
  37. Jeff KingJun 14, 2017
  38. Junio C HamanoMay 30, 2017

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.