summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-02-04 06:14:40 (GMT)
committerJunio C Hamano <junkio@cox.net>2007-02-04 07:05:34 (GMT)
commitd77ee72662a821d66ae218056f0103eb24d8d4b4 (patch)
treee22abdbd11735a0669362f934ae723d233c87e2b /sha1_name.c
parenteb8381c88518b10d683a29deea1d43ed671f14ec (diff)
parent8d0fc48f27304ac1bc7abf802ec53fe66fedb15a (diff)
downloadgit-d77ee72662a821d66ae218056f0103eb24d8d4b4.zip
git-d77ee72662a821d66ae218056f0103eb24d8d4b4.tar.gz
git-d77ee72662a821d66ae218056f0103eb24d8d4b4.tar.bz2
Merge branch 'master' into np/dreflog
This is to resolve conflicts early in preparation for possible inclusion of "reflog on detached HEAD" series by Nico, as having it in 1.5.0 would really help us remove confusion between detached and attached states. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 9dfb3ac..de8caf8 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -279,7 +279,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
/* basic@{time or number} format to query ref-log */
reflog_len = at = 0;
if (str[len-1] == '}') {
- for (at = 1; at < len - 1; at++) {
+ for (at = 0; at < len - 1; at++) {
if (str[at] == '@' && str[at+1] == '{') {
reflog_len = (len-1) - (at+2);
len = at;
@@ -289,10 +289,14 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
}
/* Accept only unambiguous ref paths. */
- if (ambiguous_path(str, len))
+ if (len && ambiguous_path(str, len))
return -1;
- refs_found = dwim_ref(str, len, sha1, &real_ref);
+ if (!len && reflog_len) {
+ /* allow "@{...}" to mean the current branch reflog */
+ refs_found = dwim_ref("HEAD", 4, sha1, &real_ref);
+ } else
+ refs_found = dwim_ref(str, len, sha1, &real_ref);
if (!refs_found)
return -1;
@@ -301,12 +305,27 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
fprintf(stderr, warning, len, str);
if (reflog_len) {
- /* Is it asking for N-th entry, or approxidate? */
int nth, i;
unsigned long at_time;
unsigned long co_time;
int co_tz, co_cnt;
+ /*
+ * We'll have an independent reflog for "HEAD" eventually
+ * which won't be a synonym for the current branch reflog.
+ * In the mean time prevent people from getting used to
+ * such a synonym until the work is completed.
+ */
+ if (len && !strncmp("HEAD", str, len) &&
+ !strncmp(real_ref, "refs/", 5)) {
+ error("reflog for HEAD has not been implemented yet\n"
+ "Maybe you could try %s%s instead, "
+ "or just %s for current branch..",
+ strchr(real_ref+5, '/')+1, str+len, str+len);
+ exit(-1);
+ }
+
+ /* Is it asking for N-th entry, or approxidate? */
for (i = nth = 0; 0 <= nth && i < reflog_len; i++) {
char ch = str[at+2+i];
if ('0' <= ch && ch <= '9')