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

Re: [PATCH] add a diff-files command

From
Junio C Hamano <junkio@cox.net>
Date
Apr 27, 2005, 21:49 UTC
Message-ID
<7vr7gvevpv.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.62.0504271701080.14033@localhost.localdomain>
>>>>> "NP" == Nicolas Pitre <nico@cam.org> writes:

NP> It also has the ability to accept exclude file patterns with -x and even NP> a file containing a list of patterns to exclude with -X. This is NP> especially useful to use the famous dontdiff file when looking for NP> uncommitted files in a compiled kernel tree.

I think show-diff with path restriction (if restriction is simple), or piping its output to grep or filterdiff (otherwise), would be enough to do what you do here, so personally I doubt this new command is even useful that much.

That said, I have a couple of comments. Other than these I do not see anything majorly wrong (although I haven't even compiled it yet ;-).

NP> +static const char *diff_files_usage = "diff-files [-a] [-c] [-d] [-o] [-p | -z]" NP> + " [-x <pattern>] [-X <file>] [paths...]"; NP> +

If you are trying to do something similar to show-files by these -[acdo] flags, matching these flags in both commands would be less confusing to the users and script writers. Either make diff-files take fully spelled --others etc. that show-files takes, or submit a patch for show-files to match these shorter ones as well. I personally prefer the latter.

NP> +/* NP> + * Read a directory tree. We currently ignore anything but NP> + * directories and regular files. That's because git doesn't NP> + * handle them at all yet. Maybe that will change some day. NP> + * NP> + * Also, we currently ignore all names starting with a dot. NP> + * That likely will not change. NP> + */

For that logic, instead of doing de->d_name[0] == '.' and things yourself, I'd rather see you lift verify_path() function from update-cache.c into common library and call it. Then if the "likely will not change" part needs to be updated, you do not have to worry about it; updates to verify_path() would take care of it for you.

Previous: Nicolas PitreNext: Nicolas Pitre
Message 2 of 6 in “add a diff-files command”
  1. add a diff-files commandNicolas Pitre, Apr 27, 2005
  2. Junio C HamanoApr 27, 2005
  3. Nicolas PitreApr 28, 2005
  4. Junio C HamanoApr 28, 2005
  5. Nicolas PitreApr 28, 2005
  6. Junio C HamanoApr 28, 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.