Skip to content

Commit a3f08f1

Browse files
authored
Merge pull request #59 from comelz/no-detached-head-message
Pass advice.detachedHead=false to Git to mute "detached HEAD" messages
2 parents 6041759 + 2e04bc3 commit a3f08f1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

quark/subproject.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def checkout(self):
343343
fork(['git', 'init'])
344344
fork(['git', 'remote', 'add', 'origin', self.url.geturl()])
345345
fork(['git', 'fetch', '--depth', '1', 'origin', self.noremote_ref()])
346-
fork(['git', 'checkout', self.ref, '--'])
346+
fork(['git', '-c', 'advice.detachedHead=false', 'checkout', self.ref, '--'])
347347
else:
348348
# Regular case
349349
extra_opts = []
@@ -361,7 +361,7 @@ def checkout(self):
361361
# Find out a sensible local branch name (needed for origin/HEAD)
362362
local_branch = self.symbolic_full_name(self.ref).split('/origin/', 1)[1]
363363
opts = [ local_branch ]
364-
fork(['git', 'checkout'] + opts + ['--'])
364+
fork(['git', '-c', 'advice.detachedHead=false', 'checkout'] + opts + ['--'])
365365

366366
def update(self, clean=False, fix_remotes=False):
367367
def actualUpdate():
@@ -405,12 +405,12 @@ def actualUpdate():
405405
try:
406406
# Try to check it out; in the common case (nothing
407407
# changed) this should be a no-op
408-
fork(['git', 'checkout', remote_commit, '--'])
408+
fork(['git', '-c', 'advice.detachedHead=false', 'checkout', remote_commit, '--'])
409409
except CalledProcessError:
410410
# Probably we don't have the commit; fetch it
411411
fork(['git', 'fetch', '--depth', '1', 'origin', remote_commit])
412412
# Try again
413-
fork(['git', 'checkout', remote_commit, '--'])
413+
fork(['git', '-c', 'advice.detachedHead=false', 'checkout', remote_commit, '--'])
414414
else:
415415
fork(['git', 'fetch'])
416416
# If we want to go on a branch, try to find a local branch that tracks it
@@ -431,7 +431,7 @@ def actualUpdate():
431431
if remote_fullref == local_fulltrackref:
432432
try:
433433
# Checkout and fast-forward
434-
fork(['git', 'checkout', local_ref, '--'])
434+
fork(['git', '-c', 'advice.detachedHead=false', 'checkout', local_ref, '--'])
435435
fork(['git', 'merge', '--ff-only', self.ref, '--'])
436436
# Final sanity check
437437
if log_check_output(['git', 'rev-parse', self.ref, '--']) != log_check_output(['git', 'rev-parse', local_ref, '--']):
@@ -440,7 +440,7 @@ def actualUpdate():
440440
except CalledProcessError:
441441
logger.warning("Couldn't fast-forward local branch, fallback to detached head mode...")
442442
# General case: plain checkout of the origin ref (going in detached HEAD)
443-
fork(['git', 'checkout', self.ref, '--'])
443+
fork(['git', '-c', 'advice.detachedHead=false', 'checkout', self.ref, '--'])
444444

445445
if not exists(self.directory):
446446
self.checkout()

0 commit comments

Comments
 (0)