Skip to content

Commit

Permalink
remote-helpers: add extra safety checks
Browse files Browse the repository at this point in the history
Suggested-by: Roman Ovchinnikov <coolthecold@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Felipe Contreras authored and Junio C Hamano committed Dec 9, 2013
1 parent 257ec84 commit 0c0ebc1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
14 changes: 10 additions & 4 deletions contrib/remote-helpers/git-remote-bzr
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,16 @@ def main(args):
global branches, peers
global transports

marks = None
is_tmp = False
gitdir = os.environ.get('GIT_DIR', None)

if len(args) < 3:
die('Not enough arguments.')

if not gitdir:
die('GIT_DIR not set')

alias = args[1]
url = args[2]

Expand All @@ -891,19 +901,15 @@ def main(args):
blob_marks = {}
parsed_refs = {}
files_cache = {}
marks = None
branches = {}
peers = {}
transports = []

if alias[5:] == url:
is_tmp = True
alias = hashlib.sha1(alias).hexdigest()
else:
is_tmp = False

prefix = 'refs/bzr/%s' % alias
gitdir = os.environ['GIT_DIR']
dirname = os.path.join(gitdir, 'bzr', alias)

if not is_tmp:
Expand Down
14 changes: 10 additions & 4 deletions contrib/remote-helpers/git-remote-hg
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,16 @@ def main(args):
global dry_run
global notes, alias

marks = None
is_tmp = False
gitdir = os.environ.get('GIT_DIR', None)

if len(args) < 3:
die('Not enough arguments.')

if not gitdir:
die('GIT_DIR not set')

alias = args[1]
url = args[2]
peer = None
Expand All @@ -1184,16 +1194,12 @@ def main(args):
if alias[4:] == url:
is_tmp = True
alias = hashlib.sha1(alias).hexdigest()
else:
is_tmp = False

gitdir = os.environ['GIT_DIR']
dirname = os.path.join(gitdir, 'hg', alias)
branches = {}
bmarks = {}
blob_marks = {}
parsed_refs = {}
marks = None
parsed_tags = {}
filenodes = {}
fake_bmark = None
Expand Down

0 comments on commit 0c0ebc1

Please sign in to comment.