summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d0740d9)
raw | patch | inline | side by side (parent: d0740d9)
author | Shawn Pearce <spearce@spearce.org> | |
Fri, 19 May 2006 07:29:43 +0000 (03:29 -0400) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 19 May 2006 22:02:55 +0000 (15:02 -0700) |
Its ambiguous to parse "master@2006-05-17 18:30:foo" when foo is
meant as a file name and ":30" is meant as 30 minutes past 6 pm.
Therefore all date specifications in a sha1 expression must now
appear within brackets and the ':' splitter used for the path name
in a sha1 expression ignores ':' appearing within brackets.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
meant as a file name and ":30" is meant as 30 minutes past 6 pm.
Therefore all date specifications in a sha1 expression must now
appear within brackets and the ':' splitter used for the path name
in a sha1 expression ignores ':' appearing within brackets.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Documentation/git-rev-parse.txt | patch | blob | history | |
sha1_name.c | patch | blob | history | |
t/t1400-update-ref.sh | patch | blob | history |
index df308c3f5fa14c6fe0a9b7b5725ab49471eb8c74..b8946943673d988e997b1b50148d0734dd762414 100644 (file)
happen to have both heads/master and tags/master, you can
explicitly say 'heads/master' to tell git which one you mean.
-* A suffix '@' followed by a date specification such as 'yesterday'
- (24 hours ago) or '1 month 2 weeks 3 days 1 hour 1 second ago'
- 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>).
+* A suffix '@' followed by a date specification enclosed in a brace
+ pair (e.g. '\{yesterday\}', '\{1 month 2 weeks 3 days 1 hour 1
+ 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>).
* A suffix '{caret}' to a revision parameter means the first parent of
that commit object. '{caret}<n>' means the <n>th parent (i.e.
diff --git a/sha1_name.c b/sha1_name.c
index 4376cb3928d068b27618b4d41d3903f536582419..fbbde1cf7d388527c88720a511532d93aa769cc0 100644 (file)
--- a/sha1_name.c
+++ b/sha1_name.c
static const char *warning = "warning: refname '%.*s' is ambiguous.\n";
const char **p, *pathname;
char *real_path = NULL;
- int refs_found = 0, at_mark;
+ int refs_found = 0, am;
unsigned long at_time = (unsigned long)-1;
unsigned char *this_result;
unsigned char sha1_from_ref[20];
if (len == 40 && !get_sha1_hex(str, sha1))
return 0;
- /* At a given period of time? "@2 hours ago" */
- for (at_mark = 1; at_mark < len; at_mark++) {
- if (str[at_mark] == '@') {
- int date_len = len - at_mark - 1;
+ /* At a given period of time? "@{2 hours ago}" */
+ for (am = 1; am < len - 1; am++) {
+ if (str[am] == '@' && str[am+1] == '{' && str[len-1] == '}') {
+ int date_len = len - am - 3;
char *date_spec = xmalloc(date_len + 1);
- strncpy(date_spec, str + at_mark + 1, date_len);
+ strncpy(date_spec, str + am + 2, date_len);
date_spec[date_len] = 0;
at_time = approxidate(date_spec);
free(date_spec);
- len = at_mark;
+ len = am;
break;
}
}
*/
int get_sha1(const char *name, unsigned char *sha1)
{
- int ret;
+ int ret, bracket_depth;
unsigned unused;
int namelen = strlen(name);
const char *cp;
}
return -1;
}
- cp = strchr(name, ':');
- if (cp) {
+ for (cp = name, bracket_depth = 0; *cp; cp++) {
+ if (*cp == '{')
+ bracket_depth++;
+ else if (bracket_depth && *cp == '}')
+ bracket_depth--;
+ else if (!bracket_depth && *cp == ':')
+ break;
+ }
+ if (*cp == ':') {
unsigned char tree_sha1[20];
if (!get_sha1_1(name, cp-name, tree_sha1))
return get_tree_entry(tree_sha1, cp+1, sha1,
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index 7858d86b93d728712bc6700f575e45c0d9568485..f6b076bafd54ee069129560aba6c8e60a55c26c3 100755 (executable)
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
gd="Thu, 26 May 2005 18:33:00 -0500"
ld="Thu, 26 May 2005 18:43:00 -0500"
test_expect_success \
- 'Query "master@May 25 2005" (before history)' \
+ 'Query "master@{May 25 2005}" (before history)' \
'rm -f o e
- git-rev-parse --verify "master@May 25 2005" >o 2>e &&
+ git-rev-parse --verify "master@{May 25 2005}" >o 2>e &&
test $C = $(cat o) &&
test "warning: Log .git/logs/$m only goes back to $ed." = "$(cat e)"'
test_expect_success \
- "Query master@2005-05-25 (before history)" \
+ "Query master@{2005-05-25} (before history)" \
'rm -f o e
- git-rev-parse --verify master@2005-05-25 >o 2>e &&
+ git-rev-parse --verify master@{2005-05-25} >o 2>e &&
test $C = $(cat o) &&
echo test "warning: Log .git/logs/$m only goes back to $ed." = "$(cat e)"'
test_expect_success \
- 'Query "master@May 26 2005 23:31:59" (1 second before history)' \
+ 'Query "master@{May 26 2005 23:31:59}" (1 second before history)' \
'rm -f o e
- git-rev-parse --verify "master@May 26 2005 23:31:59" >o 2>e &&
+ git-rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&
test $C = $(cat o) &&
test "warning: Log .git/logs/$m only goes back to $ed." = "$(cat e)"'
test_expect_success \
- 'Query "master@May 26 2005 23:32:00" (exactly history start)' \
+ 'Query "master@{May 26 2005 23:32:00}" (exactly history start)' \
'rm -f o e
- git-rev-parse --verify "master@May 26 2005 23:32:00" >o 2>e &&
+ git-rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
test $A = $(cat o) &&
test "" = "$(cat e)"'
test_expect_success \
- 'Query "master@2005-05-26 23:33:01" (middle of history with gap)' \
+ 'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' \
'rm -f o e
- git-rev-parse --verify "master@2005-05-26 23:33:01" >o 2>e &&
+ git-rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e &&
test $B = $(cat o) &&
test "warning: Log .git/logs/$m has gap after $gd." = "$(cat e)"'
test_expect_success \
- 'Query "master@2005-05-26 23:33:01" (middle of history)' \
+ 'Query "master@{2005-05-26 23:38:00}" (middle of history)' \
'rm -f o e
- git-rev-parse --verify "master@2005-05-26 23:38:00" >o 2>e &&
+ git-rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e &&
test $Z = $(cat o) &&
test "" = "$(cat e)"'
test_expect_success \
- 'Query "master@2005-05-26 23:43:00" (exact end of history)' \
+ 'Query "master@{2005-05-26 23:43:00}" (exact end of history)' \
'rm -f o e
- git-rev-parse --verify "master@2005-05-26 23:43:00" >o 2>e &&
+ git-rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e &&
test $E = $(cat o) &&
test "" = "$(cat e)"'
test_expect_success \
- 'Query "master@2005-05-28" (past end of history)' \
+ 'Query "master@{2005-05-28}" (past end of history)' \
'rm -f o e
- git-rev-parse --verify "master@2005-05-28" >o 2>e &&
+ git-rev-parse --verify "master@{2005-05-28}" >o 2>e &&
test $D = $(cat o) &&
test "warning: Log .git/logs/$m unexpectedly ended on $ld." = "$(cat e)"'
+
+rm -f .git/$m .git/logs/$m expect
+
+test_expect_success \
+ 'creating initial files' \
+ 'cp ../../COPYING COPYING &&
+ git-add COPYING &&
+ GIT_COMMITTER_DATE="2005-05-26 23:30" git-commit -m add -a &&
+ cp ../../Makefile COPYING &&
+ GIT_COMMITTER_DATE="2005-05-26 23:41" git-commit -m change -a'
+
+test_expect_success \
+ 'git-cat-file blob master:COPYING (expect Makefile)' \
+ 'git-cat-file blob master:COPYING | diff - ../../Makefile'
+test_expect_success \
+ 'git-cat-file blob master@{2005-05-26 23:30}:COPYING (expect COPYING)' \
+ 'git-cat-file blob "master@{2005-05-26 23:30}:COPYING" \
+ | diff - ../../COPYING'
+test_expect_success \
+ 'git-cat-file blob master@{2005-05-26 23:42}:COPYING (expect Makefile)' \
+ 'git-cat-file blob "master@{2005-05-26 23:42}:COPYING" \
+ | diff - ../../Makefile'
+
test_done