Skip to content

Commit fe55851

Browse files
Nicolas PitreJunio C Hamano
authored andcommitted
prevent HEAD reflog to be interpreted as current branch reflog
The work in progress to enable separate reflog for HEAD will make it independent from reflog of any branch HEAD might be pointing to. In the mean time disallow HEAD@{...} until that work is completed. Otherwise people might get used to the current behavior which makes HEAD@{...} an alias for <current_branch>@{...} which won't be the case later. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 08f1675 commit fe55851

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

sha1_name.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,26 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
301301
fprintf(stderr, warning, len, str);
302302

303303
if (reflog_len) {
304-
/* Is it asking for N-th entry, or approxidate? */
305304
int nth, i;
306305
unsigned long at_time;
307306
unsigned long co_time;
308307
int co_tz, co_cnt;
309308

309+
/*
310+
* We'll have an independent reflog for "HEAD" eventually
311+
* which won't be a synonym for the current branch reflog.
312+
* In the mean time prevent people from getting used to
313+
* such a synonym until the work is completed.
314+
*/
315+
if (!strncmp("HEAD", str, len) &&
316+
!strncmp(real_ref, "refs/", 5)) {
317+
error("reflog for HEAD has not been implemented yet\n"
318+
"Maybe you could try %s%s instead.",
319+
strchr(real_ref+5, '/')+1, str + len);
320+
exit(-1);
321+
}
322+
323+
/* Is it asking for N-th entry, or approxidate? */
310324
for (i = nth = 0; 0 <= nth && i < reflog_len; i++) {
311325
char ch = str[at+2+i];
312326
if ('0' <= ch && ch <= '9')

0 commit comments

Comments
 (0)