scripts/setlocalversion
Source file repositories/reference/linux-study-clean/scripts/setlocalversion
File Facts
- System
- Linux kernel
- Corpus path
scripts/setlocalversion- Extension
[no extension]- Size
- 5322 bytes
- Lines
- 213
- Domain
- Support Tooling And Documentation
- Bucket
- scripts
- Inferred role
- Support Tooling And Documentation: scripts
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function try_tag
Annotated Snippet
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# This scripts adds local version information from the version
# control system git.
#
# If something goes wrong, send a mail the kernel build mailinglist
# (see MAINTAINERS) and CC Nico Schottelius
# <nico-linuxsetlocalversion -at- schottelius.org>.
#
#
set -e
usage() {
echo "Usage: $0 [--no-local] [srctree]" >&2
exit 1
}
no_local=false
if test "$1" = "--no-local"; then
no_local=true
shift
fi
srctree=.
if test $# -gt 0; then
srctree=$1
shift
fi
if test $# -gt 0 -o ! -d "$srctree"; then
usage
fi
try_tag() {
tag="$1"
# Is $tag an annotated tag?
if [ "$(git cat-file -t "$tag" 2> /dev/null)" != tag ]; then
return
fi
# Is it an ancestor of HEAD, and if so, how many commits are in $tag..HEAD?
# shellcheck disable=SC2046 # word splitting is the point here
set -- $(git rev-list --count --left-right "$tag"...HEAD 2> /dev/null)
# $1 is 0 if and only if $tag is an ancestor of HEAD. Use
# string comparison, because $1 is empty if the 'git rev-list'
# command somehow failed.
if [ "$1" != 0 ]; then
return
fi
# $2 is the number of commits in the range $tag..HEAD, possibly 0.
count="$2"
}
scm_version()
{
local short=false
local no_dirty=false
local tag
while [ $# -gt 0 ];
do
case "$1" in
--short)
short=true;;
--no-dirty)
no_dirty=true;;
Annotation
- Detected declarations: `function try_tag`.
- Atlas domain: Support Tooling And Documentation / scripts.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.