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

Re: [PATCH] git-diff-*: Allow "--name-only -z" as alias for "--name-only-z"

From
Junio C Hamano <junkio@cox.net>
Date
Jul 14, 2005, 23:11 UTC
Message-ID
<7vmzop56fo.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20050714223622.GZ9915@kiste.smurf.noris.de>
Matthias Urlichs <smurf@smurf.noris.de> writes:
> Exactly the same thing as vice versa.
> Or, even more exactly, my patch *makes* that happen. ;-)
Ah, I was not being careful enough.  Sorry.

That said, I have been hating that diff options parsing for quite a while, and I've been thinking about cleaning it up along the lines I'll outline here, but have not done anything about it. Care to help me out?

 - In diff.h introduce these new stuff:
     struct diff_opts {
     int output_format;
     int detect_rename;
     ...
     };
     void diff_opts_init(struct diff_opts *);
     int diff_opts_parse(const char *, struct diff_opts *);
     int diff_opts_final(struct diff_opts *);
 - In diff-* brothers:
   - replace individual diff option variables with a single
     "static struct diff_opts diff_opts";
   - change the argument parsing code to do the following:
     diff_opts_init(&diff_opts);
     for each arg {
         /* common options to diff brothers are handled by
          * diff_opts_parse()
          */
         switch (diff_opts_parse(arg, &diff_opts)) {
         case 1: /* was a diff option and was parsed successfully */
         	continue;
         case -1: /* error */
                usage(diff_*_usage);
         }
         if (!strcmp())
              ... parsing of other options
     }
     if (diff_opts_final(&diff_opts))
         /* defaulting to HUMAN format when nothing specified,
          * complaining if find-copies-harder is specified but
          * -C was not, etc. is done in diff_opts_final().
          *
          * The complex if() chains that checks if we are in
          * name or in raw mode and switch output_format around
          * properly is what I missed in your patch, but I think
          * you can lose that by recording z-ness of the output
          * independently from the output format in diff_opts_parse()
          * and combining diff-raw vs diff-name and z vs non-z
          * in diff_opts_final().  That would make the code much
          * simpler.
          */
         usage(diff_*_usage);
 - In diff.h and diff.c, replace individual option parameters
   for the following functions to a single pointer to struct
   diff_opts:
     diff_setup(), diffcore_std(), diffcore_std_no_resolve(), diff_flush().  

We probably can make diff_scoreopt_parse() function static to diff.c once this is done.

We may want to rip out the independeant pickaxe, orderfile and filter support for diff-helper while we are at it, making it truly just a "diff-raw to diff-patch" converter.

Hmm?
Previous: Matthias UrlichsNext: Matthias Urlichs
Message 4 of 7 in “git-diff-*: Allow "--name-only -z" as alias for "--name-only-z"”
  1. git-diff-*: Allow "--name-only -z" as alias for "--name-only-z"Matthias Urlichs, Jul 14, 2005
  2. Junio C HamanoJul 14, 2005
  3. Matthias UrlichsJul 14, 2005
  4. Junio C HamanoJul 14, 2005
  5. Matthias UrlichsJul 14, 2005
  6. Linus TorvaldsJul 15, 2005
  7. Junio C HamanoJul 15, 2005

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.