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

Re: [PATCH 4/4] builtin/show: do not prune by pathspec

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 4, 2011, 21:49 UTC
Message-ID
<7v1v1h8z5k.fsf@alter.siamese.dyndns.org>
In-Reply-To
<6509d23c538dfabd4fac8870d29a69b1dd11a516.1301649372.git.git@drmicha.warpmail.net>
Michael J Gruber <git@drmicha.warpmail.net> writes:
Show 10 quoted lines
> diff --git a/builtin/log.c b/builtin/log.c
> index 916019c..474a76d 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -420,6 +420,8 @@ int cmd_show(int argc, const char **argv, const char *prefix)
>  	opt.def = "HEAD";
>  	opt.tweak = show_rev_tweak_rev;
>  	cmd_log_init(argc, argv, prefix, &rev, &opt);
> +	if (rev.no_walk)
> +		rev.prune = 0;
This is not your fault, but I am somewhat disgusted by the reason why
    $ git show master..next [ -- Documentation ]

works by "walking" the history. It takes completely different codepath from "git log" with the same set of arguments.

 * first log_init() grabs '^master' and 'next' into the rev.pending object
   array;
 * we pop '^master' first, make it the only object in the rev.pending
   object array, and let cmd_log_walk() call prepare_revision_walk() on it
   to limit the list.  Since we don't have any positive ref, we get
   nothing;
 * then we pop 'next', make it again _the only_ object in the rev.pending
   object array; prepare_revision_walk() on the same codepath now limits
   the list to exclude what is reachable from 'master', only because we
   have processed '^master'.

Yikes. In other words, the reason the current code works is only by accident.

This is a tangent, but we _might_ want to (perhaps at git 2.0) update the revision parsing machinery so that we can clear the object flags more easily and have

    $ git log A..B C..D [ -- pathspec ]

compute the union of (commits reachable from B but not from A) and (commits reachable from D but not from C). I say we _might_ because we would still want to compute what the current code computes in some cases, and we may be able to express it as "^A ^C B D", but I am not sure if we want to go that route and end up with a general set operation (with unions and intersections, perhaps even using parentheses to express precedence).

More general set operation is certainly doable, and at that point it probably does not matter that we cannot stream the output as we are doing something complex (IOW, we would be revs->limited, giving up the latency), but I don't know if it is useful in the first place to support such general case. Because the most complex set operations that I run every day is

    $ git log ^master $topic1 $topic2 $topic3... -- $pathspec

and I don't recall cases in which I wished A..B C..D showed commits within A..B that are reachable from C.

Previous: Michael J GruberNext: Michael J Gruber
Message 27 of 29 in “Usability improvement request: git show revision -- file”
  1. Piotr KrukowieckiMar 31, 2011
  2. Michael J GruberMar 31, 2011
  3. 1/3 t1506: factor out test for "Did you mean..."Michael J Gruber, Mar 31, 2011
  4. 2/3 sha1_name: Suggest commit:./file for path in subdirMichael J Gruber, Mar 31, 2011
  5. Junio C HamanoMar 31, 2011
  6. Michael J GruberApr 1, 2011
  7. Junio C HamanoApr 1, 2011
  8. 3/3 builtin/show.c: do not prune by pathspecMichael J Gruber, Mar 31, 2011
  9. Johannes SixtMar 31, 2011
  10. Michael J GruberMar 31, 2011
  11. Johannes SixtMar 31, 2011
  12. Michael J GruberMar 31, 2011
  13. Nguyen Thai Ngoc DuyMar 31, 2011
  14. Michael J GruberMar 31, 2011
  15. Nguyen Thai Ngoc DuyMar 31, 2011
  16. Michael J GruberMar 31, 2011
  17. Junio C HamanoMar 31, 2011
  18. Michael J GruberApr 1, 2011
  19. 0/4 reflog, show and command line overridesMichael J Gruber, Apr 1, 2011
  20. 1/4 builtin/log.c: separate default and setup of cmd_log_init()Michael J Gruber, Apr 1, 2011
  21. 2/4 t/t1411: test reflog with formatsMichael J Gruber, Apr 1, 2011
  22. 3/4 reflog: fix overriding of command line optionsMichael J Gruber, Apr 1, 2011
  23. 4/4 builtin/show: do not prune by pathspecMichael J Gruber, Apr 1, 2011
  24. Junio C HamanoApr 1, 2011
  25. Junio C HamanoApr 1, 2011
  26. Michael J GruberApr 3, 2011
  27. Junio C HamanoApr 4, 2011
  28. Michael J GruberApr 5, 2011
  29. Piotr KrukowieckiMar 31, 2011

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.