Lines Matching +full:force +full:- +full:mode

2 # SPDX-License-Identifier: GPL-2.0
6 echo "Usage: $(basename "$0") [--selftest] [--force] <commit-id> [commit-subject]"
7 …echo "Resolves a short git commit ID to its full SHA-1 hash, particularly useful for fixing refere…
10 echo " --selftest Run self-tests"
11 echo " --force Try to find commit by subject if ID lookup fails"
12 echo " commit-id Short git commit ID to resolve"
13 echo " commit-subject Optional commit subject to help resolve between multiple matches"
24 escaped_subject=$(echo "$escaped_subject" | sed 's/[:-]/\\&/g')
31 local force=0
32 if [ "$1" = "--force" ]; then
33 force=1
52 readarray -t matches < <(git rev-parse --disambiguate="$commit_id" 2>/dev/null)
55 if [ ${#matches[@]} -eq 1 ]; then
60 # If no matches and not in force mode, return failure
61 if [ ${#matches[@]} -eq 0 ] && [ $force -eq 0 ]; then
66 if [ -n "$subject" ]; then
71 # In force mode with no ID matches, use git log --grep directly
72 if [ ${#matches[@]} -eq 0 ] && [ $force -eq 1 ]; then
75 match=$(git log --format="%H %s" --grep="$grep_pattern" --perl-regexp -10 | \
76 while read -r hash subject; do
77 if echo "$subject" | grep -qP "$grep_pattern"; then
82 if [ -n "$match" ]; then
89 if git log -1 --format="%s" "$match" | grep -qP "$grep_pattern"; then
108 '12345678' # Non-existent commit
110 …'--force 99999999 ("net/tls: Fix skb memory leak when running kTLS traffic")' # Force mode with n…
111 '83be ("firmware: ... auto-update: fix poll_complete() ... errors")' # Wildcard test
112 …'--force 999999999999 ("firmware: ... auto-update: fix poll_complete() ... errors")' # Force mode…
121 "" # Expect empty output for non-existent commit
123 "ffef737fd0372ca462b5be3e7a592a8929a82752" # Should find commit by subject in force mode
125 "83beece5aff75879bdfc6df8ba84ea88fd93050e" # Force mode wildcard test
134 1 # Expect failure for non-existent commit
136 0 # Should succeed in force mode
138 0 # Should succeed with force mode and wildcard
143 echo "Running self-tests..."
147 result=$(git_resolve_commit ${test_cases[$i]}) # Removed quotes to allow --force to be parsed
164 if [ $failed -eq 0 ]; then
174 if [ "$1" = "--selftest" ]; then
179 # Handle --force flag
180 force=""
181 if [ "$1" = "--force" ]; then
182 force="--force"
187 if [ $# -eq 0 ]; then
191 # Skip validation in force mode
192 if [ -z "$force" ]; then
194 if [ "$(git rev-parse --disambiguate="$1" 2>/dev/null | wc -l)" -eq 0 ]; then
200 git_resolve_commit $force "$@"