index.js
function readPackedRef(gitFolder, refName) {
	var packedRefs, i, each, match

	try {
		packedRefs = fs.readFileSync(path.join(gitFolder, 'packed-refs'), 'utf8').split(/\r?\n/)
	} catch (e) {
		return ''
	}

	for (i = 0; i < packedRefs.length; i++) {
		each = packedRefs[i].trim()

		// Look for lines like:
		// 1d6f5f98a254578e19b5eb163077170d45448c26 refs/heads/master
		match = each.match(/^(.{40}) (.*)$/)
		if (match && match[2] === refName && isSHA1(match[1])) {
			return match[1]
		}
	}
	return ''
}
function readPackedRef(gitFolder, refName) {
	var packedRefs, i, each, match

	try {
		packedRefs = fs.readFileSync(path.join(gitFolder, 'packed-refs'), 'utf8').split(/\r?\n/)
	} catch (e) {
		return ''
	}

	for (i = 0; i < packedRefs.length; i++) {
		each = packedRefs[i].trim()

		// Look for lines like:
		// 1d6f5f98a254578e19b5eb163077170d45448c26 refs/heads/master
		match = each.match(/^(.{40}) (.*)$/)
		if (match && match[2] === refName && isSHA1(match[1])) {
			return match[1]
		}
	}
	return ''
}
function readPackedRef ( gitFolder , refName ) { var packedRefs , i , each , match try { packedRefs = fs . readFileSync ( path . join ( gitFolder , 'packed-refs' ) , 'utf8' ) . split ( / \r?\n / ) } catch ( e ) { return '' } for ( i = 0 ; i < packedRefs . length ; i ++ ) { each = packedRefs [ i ] . trim ( ) // Look for lines like: // 1d6f5f98a254578e19b5eb163077170d45448c26 refs/heads/master match = each . match ( / ^(.{40}) (.*)$ / ) if ( match && match [ 2 ] === refName && isSHA1 ( match [ 1 ] ) ) { return match [ 1 ] } } return '' }
Return the commit name for the given ref name from packed-refs file
@param {string} gitFolder
@param {string} refName
@returns {string} - '' if not found
Return the commit name for the given ref name from packed - refs file