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

Re: Fwd: Possibly nicer pathspec syntax?

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 8, 2017, 02:42 UTC
Message-ID
<xmqqefz9xv0x.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<alpine.LFD.2.20.1702071739060.17609@i7.lan>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 7 quoted lines
> So here's an RFC patch, and I'm quoting the above part of my thinking 
> because it's what the patch does, but it turns out that it's probably not 
> what we want, and I suspect the "." behavior (as opposed to "no filtering 
> at all") is actually better.
> ...
>
> Comments?
 1. I think some commands limit their operands to cwd and some work
    on the whole tree when given no pathspec.  I think the "no
    positive?  then let's give you everything except these you
    excluded" should base the definition of "everything" to that.
    IOW, "cd t && git grep -e foo" shows everything in t/ directory,
    so the default you would add would be "." for "grep"; "cd t &&
    git diff HEAD~100 HEAD" would show everything, so you would give
    ":(top)." for "diff".
 2. I am not sure what ctype.c change is about.  Care to elaborate?
 3. I think our recent trend is to wean ourselves away from "an
    empty element in pathspec means all paths match", and I think we
    even have accepted a patch to emit a warning.  Doesn't the
    warning trigger for the new code below?
Show 15 quoted lines
> -	if (nr_exclude == n)
> -		die(_("There is nothing to exclude from by :(exclude) patterns.\n"
> -		      "Perhaps you forgot to add either ':/' or '.' ?"));
> -
> +	/*
> +	 * If everything is an exclude pattern, add one positive pattern
> +	 * that matches everyting. We allocated an extra one for this.
> +	 */
> +	if (nr_exclude == n) {
> +		init_pathspec_item(item + n, 0, "", 0, "");
> +		pathspec->nr++;
> +	}
>  
>  	if (pathspec->magic & PATHSPEC_MAXDEPTH) {
>  		if (flags & PATHSPEC_KEEP_ORDER)
Previous: Linus TorvaldsNext: Linus Torvalds
Message 4 of 17 in “Fwd: Possibly nicer pathspec syntax?”
  1. Linus TorvaldsFeb 7, 2017
  2. Junio C HamanoFeb 8, 2017
  3. Linus TorvaldsFeb 8, 2017
  4. Junio C HamanoFeb 8, 2017
  5. Linus TorvaldsFeb 8, 2017
  6. Junio C HamanoFeb 8, 2017
  7. Linus TorvaldsFeb 8, 2017
  8. Junio C HamanoFeb 8, 2017
  9. Linus TorvaldsFeb 8, 2017
  10. Duy NguyenFeb 8, 2017
  11. Junio C HamanoFeb 8, 2017
  12. Junio C HamanoFeb 8, 2017
  13. Duy NguyenFeb 9, 2017
  14. Duy NguyenFeb 9, 2017
  15. Mike HommeyFeb 8, 2017
  16. Linus TorvaldsFeb 8, 2017
  17. Mike HommeyFeb 8, 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.