Skip to content

Commit 46cc3ad

Browse files
felipecpeff
authored andcommitted
remote-hg: fake bookmark when there's none
Or at least no current bookmark. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent 9490bd0 commit 46cc3ad

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

contrib/remote-helpers/git-remote-hg

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import urllib
2626
# git:
2727
# Sensible defaults for git.
2828
# hg bookmarks are exported as git branches, hg branches are prefixed
29-
# with 'branches/'.
29+
# with 'branches/', HEAD is a special case.
3030
#
3131
# hg:
3232
# Emulate hg-git.
@@ -430,12 +430,21 @@ def get_branch_tip(repo, branch):
430430
return heads[0]
431431

432432
def list_head(repo, cur):
433-
global g_head
433+
global g_head, bmarks
434434

435435
head = bookmarks.readcurrent(repo)
436-
if not head:
437-
return
438-
node = repo[head]
436+
if head:
437+
node = repo[head]
438+
else:
439+
# fake bookmark from current branch
440+
head = cur
441+
node = repo['.']
442+
if not node:
443+
return
444+
if head == 'default':
445+
head = 'master'
446+
bmarks[head] = node
447+
439448
print "@refs/heads/%s HEAD" % head
440449
g_head = (head, node)
441450

0 commit comments

Comments
 (0)