* diff/Checking out by date specification
@ 2008-06-30 2:24 Toby Corkindale
2008-06-30 3:27 ` Jeff King
0 siblings, 1 reply; 6+ messages in thread
From: Toby Corkindale @ 2008-06-30 2:24 UTC (permalink / raw)
To: git
Hi,
`man git-rev-parse` seems to indicate that one can look at the state of
the repository by date (absolute or relative), and use this for diff or
checkout, etc.
It includes examples such as "{yesterday}" and "{1979-02-26 18:30:00}".
I'm struggling to get this to work in real life with cloned
repositories, as I receive an error that the log only goes back to
whenever I cloned the repository.
Is there a way to make this operate upon the remote log?
Eg:
$ git clone git://git.kernel.org/pub/scm/git/git.git
$ cd git
$ git diff "@{yesterday}"
warning: Log for '' only goes back to Mon, 30 Jun 2008 12:22:52 +1000.
fatal: bad object @{yesterday}
Cheers,
Toby
--
Toby Corkindale
Software developer
w: www.rea-group.com
REA Group refers to realestate.com.au Ltd (ASX:REA)
Warning - This e-mail transmission may contain confidential information.
If you have received this transmission in error, please notify us
immediately on (61 3) 9897 1121 or by reply email to the sender. You
must destroy the e-mail immediately and not use, copy, distribute or
disclose the contents.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: diff/Checking out by date specification 2008-06-30 2:24 diff/Checking out by date specification Toby Corkindale @ 2008-06-30 3:27 ` Jeff King 2008-06-30 4:38 ` Toby Corkindale 0 siblings, 1 reply; 6+ messages in thread From: Jeff King @ 2008-06-30 3:27 UTC (permalink / raw) To: Toby Corkindale; +Cc: Junio C Hamano, git On Mon, Jun 30, 2008 at 12:24:03PM +1000, Toby Corkindale wrote: > `man git-rev-parse` seems to indicate that one can look at the state of > the repository by date (absolute or relative), and use this for diff or > checkout, etc. > It includes examples such as "{yesterday}" and "{1979-02-26 18:30:00}". It's a little bit more complex than that. The branch@{time} syntax means "what was in _my_ branch at that time". And if you just cloned, your branch doesn't go back very far. If you want to say "find commits that happened before time T", you want --until or --since (or their aliases --before and --after). Would the documentation patch below have helped with the confusion? -- >8 -- doc/rev-parse: clarify reflog vs --until for specifying revisions The rev-parse manpage introduces the branch@{date} syntax, and mentions the reflog specifically. However, new users may not be familiar with the distinction between the reflog and the commit date, so let's help them out with a "you may be interested in --until" pointer. Signed-off-by: Jeff King <peff@peff.net> --- Documentation/git-rev-parse.txt | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt index 9e273bc..59e95ad 100644 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@ -184,7 +184,10 @@ blobs contained in a commit. second ago\}' or '\{1979-02-26 18:30:00\}') to specify the value of the ref at a prior point in time. This suffix may only be used immediately following a ref name and the ref must have an - existing log ($GIT_DIR/logs/<ref>). + existing log ($GIT_DIR/logs/<ref>). Note that this looks up the state + of your *local* ref at a given time; e.g., what was in your local + `master` branch last week. If you want to look at commits made during + certain times, see `--since` and `--until`. * A ref followed by the suffix '@' with an ordinal specification enclosed in a brace pair (e.g. '\{1\}', '\{15\}') to specify -- 1.5.6.1.202.g3a23.dirty ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: diff/Checking out by date specification 2008-06-30 3:27 ` Jeff King @ 2008-06-30 4:38 ` Toby Corkindale 2008-06-30 5:09 ` Daniel Barkalow 2008-06-30 5:21 ` Jeff King 0 siblings, 2 replies; 6+ messages in thread From: Toby Corkindale @ 2008-06-30 4:38 UTC (permalink / raw) To: Jeff King; +Cc: Junio C Hamano, git Jeff King wrote: > On Mon, Jun 30, 2008 at 12:24:03PM +1000, Toby Corkindale wrote: > >> `man git-rev-parse` seems to indicate that one can look at the state of >> the repository by date (absolute or relative), and use this for diff or >> checkout, etc. >> It includes examples such as "{yesterday}" and "{1979-02-26 18:30:00}". > > It's a little bit more complex than that. The branch@{time} syntax means > "what was in _my_ branch at that time". And if you just cloned, your > branch doesn't go back very far. > > If you want to say "find commits that happened before time T", you want > --until or --since (or their aliases --before and --after). > > Would the documentation patch below have helped with the confusion? Ah, I see. Thanks, yes, that would have made the issue clearer. I think it would be good if you could give a couple of examples, such as: How would I go about checking out the code at the state it was in at, say, 2008-01-01? Or how one can get a diff between 2008-01-01 and 2008-01-08? (I note that "git-diff --until=2008-01-08 --since=2008-01-01" fails, as does "git-checkout --until=2008-01-08") thanks for the quick response! -Toby > > -- >8 -- > doc/rev-parse: clarify reflog vs --until for specifying revisions > > The rev-parse manpage introduces the branch@{date} syntax, > and mentions the reflog specifically. However, new users may > not be familiar with the distinction between the reflog and > the commit date, so let's help them out with a "you may be > interested in --until" pointer. > > Signed-off-by: Jeff King <peff@peff.net> > --- > Documentation/git-rev-parse.txt | 5 ++++- > 1 files changed, 4 insertions(+), 1 deletions(-) > > diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt > index 9e273bc..59e95ad 100644 > --- a/Documentation/git-rev-parse.txt > +++ b/Documentation/git-rev-parse.txt > @@ -184,7 +184,10 @@ blobs contained in a commit. > second ago\}' or '\{1979-02-26 18:30:00\}') to specify the value > of the ref at a prior point in time. This suffix may only be > used immediately following a ref name and the ref must have an > - existing log ($GIT_DIR/logs/<ref>). > + existing log ($GIT_DIR/logs/<ref>). Note that this looks up the state > + of your *local* ref at a given time; e.g., what was in your local > + `master` branch last week. If you want to look at commits made during > + certain times, see `--since` and `--until`. > > * A ref followed by the suffix '@' with an ordinal specification > enclosed in a brace pair (e.g. '\{1\}', '\{15\}') to specify -- Toby Corkindale Software developer w: www.rea-group.com REA Group refers to realestate.com.au Ltd (ASX:REA) Warning - This e-mail transmission may contain confidential information. If you have received this transmission in error, please notify us immediately on (61 3) 9897 1121 or by reply email to the sender. You must destroy the e-mail immediately and not use, copy, distribute or disclose the contents. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: diff/Checking out by date specification 2008-06-30 4:38 ` Toby Corkindale @ 2008-06-30 5:09 ` Daniel Barkalow 2008-06-30 5:21 ` Jeff King 1 sibling, 0 replies; 6+ messages in thread From: Daniel Barkalow @ 2008-06-30 5:09 UTC (permalink / raw) To: Toby Corkindale; +Cc: Jeff King, Junio C Hamano, git On Mon, 30 Jun 2008, Toby Corkindale wrote: > Jeff King wrote: > > On Mon, Jun 30, 2008 at 12:24:03PM +1000, Toby Corkindale wrote: > > > > > `man git-rev-parse` seems to indicate that one can look at the state of > > > the repository by date (absolute or relative), and use this for diff or > > > checkout, etc. > > > It includes examples such as "{yesterday}" and "{1979-02-26 18:30:00}". > > > > It's a little bit more complex than that. The branch@{time} syntax means > > "what was in _my_ branch at that time". And if you just cloned, your > > branch doesn't go back very far. > > > > If you want to say "find commits that happened before time T", you want > > --until or --since (or their aliases --before and --after). > > > > Would the documentation patch below have helped with the confusion? > > Ah, I see. > Thanks, yes, that would have made the issue clearer. > > I think it would be good if you could give a couple of examples, such as: > How would I go about checking out the code at the state it was in at, say, > 2008-01-01? > Or how one can get a diff between 2008-01-01 and 2008-01-08? That's not well-defined, except in a particular location. It's pretty likely that there were some changes that were made by different people late in 2007, and languished in their local repositories, and were never merged with each other until after some further changes had been made and the holiday was over. So there isn't a single state of the code as of 2008-01-01 to compare against. The usual case for wanting the diff between 2008-01-01 and 2008-01-08 is that you encountered some version on each of those dates, and you want to know what the difference is between them, and reflogs work for that, but it's also possible that what you want is the states that were somewhere else at that point, and I don't think we have a good solution for that currently unless you can run git commands there to look at the reflog for that location. But, in general, with a distributed system like git, you'll do better to look at the history graph around that time with gitk and find the states you're actually interested in by other features or a combination of features. -Daniel *This .sig left intentionally blank* ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: diff/Checking out by date specification 2008-06-30 4:38 ` Toby Corkindale 2008-06-30 5:09 ` Daniel Barkalow @ 2008-06-30 5:21 ` Jeff King 2008-06-30 5:26 ` Jeff King 1 sibling, 1 reply; 6+ messages in thread From: Jeff King @ 2008-06-30 5:21 UTC (permalink / raw) To: Toby Corkindale; +Cc: Junio C Hamano, git On Mon, Jun 30, 2008 at 02:38:17PM +1000, Toby Corkindale wrote: > I think it would be good if you could give a couple of examples, such as: > How would I go about checking out the code at the state it was in at, > say, 2008-01-01? > Or how one can get a diff between 2008-01-01 and 2008-01-08? > > (I note that "git-diff --until=2008-01-08 --since=2008-01-01" fails, as > does "git-checkout --until=2008-01-08") That is a little bit trickier, since there is a not a convenient syntax for selecting a particular revision by commit time. So you _can_ do this: git diff \ `git rev-list -1 --until=2008-01-01 HEAD` \ `git rev-list -1 --until=2008-01-08 HEAD` But that isn't quite what you want either. Remember that history can follow many branches simultaneously. So what we are saying with "--until" here is "show me all the commits that happened before this time", and then we use "-1" to say "pick the first one." So you are really picking two points in time that are close to what you want, and then diffing the two states. Depending on what you want to do, that may be enough. But more likely, you are interested in the actual shape of history, so looking at the individual commits with something like "gitk --since=2008-01-01 --until=2008-01-08" is probably going to be more instructive. -Peff ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: diff/Checking out by date specification 2008-06-30 5:21 ` Jeff King @ 2008-06-30 5:26 ` Jeff King 0 siblings, 0 replies; 6+ messages in thread From: Jeff King @ 2008-06-30 5:26 UTC (permalink / raw) To: Toby Corkindale; +Cc: Junio C Hamano, git On Mon, Jun 30, 2008 at 01:21:05AM -0400, Jeff King wrote: > Depending on what you want to do, that may be enough. But more likely, > you are interested in the actual shape of history, so looking at the > individual commits with something like "gitk --since=2008-01-01 > --until=2008-01-08" is probably going to be more instructive. Side note: what you may have _really_ wanted was "what is the difference between what was in Junio's 'master' branch on those dates". I.e., looking at the sequence of states at the tip of some "official" git repo. In that case, you could get the answer you want by looking in Junio's reflog. However, that information is not generally available through git. There is no support for downloading reflogs, and most people don't have reflogs enabled on their published bare repos. If Junio enabled reflogs on pushing to his bare repo, then you could manually download them into your .git/logs/ hierarchy and pretend that that was your history of your refs. -Peff ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-06-30 5:27 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-06-30 2:24 diff/Checking out by date specification Toby Corkindale 2008-06-30 3:27 ` Jeff King 2008-06-30 4:38 ` Toby Corkindale 2008-06-30 5:09 ` Daniel Barkalow 2008-06-30 5:21 ` Jeff King 2008-06-30 5:26 ` Jeff King
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).