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

Re: How do get a specific version of a particular file?

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Feb 28, 2007, 00:22 UTC
Message-ID
<Pine.LNX.4.64.0702271605290.12485@woody.linux-foundation.org>
In-Reply-To
<7vfy8rb2do.fsf@assigned-by-dhcp.cox.net>
On Tue, 27 Feb 2007, Junio C Hamano wrote:
Show 19 quoted lines
> merlyn@stonehenge.com (Randal L. Schwartz) writes:
> 
> >>>>>> "Theodore" == Theodore Tso <tytso@mit.edu> writes:
> >
> > Theodore> And I'm still not sure why
> >
> > Theodore> 	git show v1.5.0..v1.5.0.1 
> >
> > Theodore> doesn't throw an error, and why it prints what it does...
> >
> > Wait, that doesn't throw an error?
> >
> > (tries it)
> >
> > OK, how is that different from git-diff ?
> 
> I do not think there is any difference.  "show" is about
> multiple points, not ranges.  "diff" is about multiple
> (typically two) points, and not ranges.

Well, I do think Ted has a good point. Having negative refs makes no sense for the "no-walk" case (aka "git show").

So when we do
	git show v1.4.4..v1.5.0

that's an illogical thing to do, since "git show" is defined to be a non-revision-walking action, which means the range operator be pointless and wrong. The fact that we happily accept it (and then _only_ show v1.5.0, which is the positive end of the range) is quite arguably not very logical.

We should complain, and say that you can only do "no_walk" with positive refs. Negative object refs really don't make any sense unless you walk the obejct list (or you're "git diff" and know about ranges explicitly).

Something like this (although I don't know if my message is necessarily the best possible one).

		Linus
---
diff --git a/revision.c b/revision.c
index 4cf697e..b84c066 100644
--- a/revision.c
+++ b/revision.c
@@ -116,6 +116,8 @@ void mark_parents_uninteresting(struct commit *commit)
 
 void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)
 {
+	if (revs->no_walk && (obj->flags & UNINTERESTING))
+		die("object ranges do not make sense when not walking revisions");
 	add_object_array(obj, name, &revs->pending);
 	if (revs->reflog_info && obj->type == OBJ_COMMIT)
 		add_reflog_for_walk(revs->reflog_info,
Previous: Junio C HamanoNext: Junio C Hamano
Message 12 of 32 in “How do get a specific version of a particular file?”
  1. Theodore Ts'oFeb 27, 2007
  2. Christian MICHONFeb 27, 2007
  3. Peter BaumannFeb 27, 2007
  4. Alex RiesenFeb 27, 2007
  5. Alex RiesenFeb 27, 2007
  6. Johannes SchindelinFeb 27, 2007
  7. Theodore TsoFeb 27, 2007
  8. Johannes SchindelinFeb 27, 2007
  9. Theodore TsoFeb 27, 2007
  10. Randal L. SchwartzFeb 27, 2007
  11. Junio C HamanoFeb 27, 2007
  12. Linus TorvaldsFeb 28, 2007
  13. Junio C HamanoFeb 28, 2007
  14. Johannes SchindelinFeb 28, 2007
  15. Linus TorvaldsFeb 28, 2007
  16. Nicolas PitreFeb 28, 2007
  17. Linus TorvaldsFeb 28, 2007
  18. Nicolas PitreFeb 28, 2007
  19. Theodore TsoFeb 28, 2007
  20. Junio C HamanoFeb 28, 2007
  21. Theodore TsoFeb 28, 2007
  22. Junio C HamanoFeb 28, 2007
  23. Nicolas PitreFeb 28, 2007
  24. Johannes SchindelinFeb 28, 2007
  25. Linus TorvaldsFeb 28, 2007
  26. Junio C HamanoFeb 28, 2007
  27. Johannes SchindelinFeb 28, 2007
  28. Fix git-show man page formatting in the EXAMPLES sectionTheodore Tso, Feb 27, 2007
  29. Linus TorvaldsFeb 27, 2007
  30. Bill LearFeb 27, 2007
  31. Theodore TsoFeb 27, 2007
  32. Linus TorvaldsFeb 27, 2007

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.