From patchwork Thu Jan 18 20:43:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Britton Kerin X-Patchwork-Id: 13523213 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8DAD2E827 for ; Thu, 18 Jan 2024 20:43:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705610618; cv=none; b=mTtmKKDiW37OUwlp4OQp2ZO9+AWHPPibqo3j38WiBSD37aTtcvKs+Ue/eJ15X0TcGmHoGIG6tolHmsqiIEoXx1BXK6YKkEKu8PhapkfU14cpKZa+q3n8qoCtNLatIEZSV4tLolxpUI0FmPMZYcnpKM/XTRw4g2xsJLvpHLvUyfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705610618; c=relaxed/simple; bh=2nJOF6bdDiW/oC2MJ95gSL54DMbkImvSqElscwQjl8o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SscOD6bpWWTbeBy1BnKtxg3P2nP7D+tNUJRMBRk+MnsYS6NuZspjgviNx79VmjJ8t63HOdSE+2R1UdPiGgIgqmuplS+cD+JC9AXS8xWey8qfitJ+19soIXyN48vjuE8R6sxoeKjUmVOKo1HHhLIDHO0aCAzNlSmFoo6ifsCzBSs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZiB8KV3v; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZiB8KV3v" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1d5f1e0e32eso137085ad.3 for ; Thu, 18 Jan 2024 12:43:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705610616; x=1706215416; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CgliPEM4acHgcMDbFwUlT9w93z11KYWyH0jcwn+NClI=; b=ZiB8KV3vx4C3retNXzbuAS+Rz8ZfwfjNH1k0jhHSNiNLCZYYq5BRUkpJtReaNxGz5n iTI2AwaWns8qR+GjhC16tvw+gWXdWkaN3OCT1N4K++kjWz1K2AoNuI11TDprzpyRbyd3 8fa1zopiZDToYEoebJrh7M01MVHD5ufOvhxvlSSruz4pdXKV31cZOncKFt5cyuUAiTU7 H5KIBlYhQiL0mUJEvoqs2NQQ09TGuX8BSPMaCSNUKDkCM/lcXYwzx5nawsCt4PQRxJ7j Oh7T6v7PdsyGM7UFDoqPBRj3blIrz+YOawNE5XmHadvY2rRavmyCa8Io2r/o8HxrwEjF zK3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705610616; x=1706215416; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CgliPEM4acHgcMDbFwUlT9w93z11KYWyH0jcwn+NClI=; b=MMcUqelmI9YG1onvtghH2sGJHu30eN7yeH5sFFJkK96y6PG4T3ujp18LUh5wrZld3J ncTGXIe6XGFQlA38Fa6TRL4edigKc7yAnfIu4S50nuBZjFXwwUooJ/2Ui3Q1IsGWermG ZgL1Ue+PkCr8bgiMFZULo4V06zhtLK/QeQX3yJFCArScdBy3d0Sf5fa6XWHalcpVe7t2 FqdOngysEDxCkeMciKWhMkphodL9NPNB9fG46cne8Ad2neeECk+vcPx3780O5/vP/M1z 4+GbwTPbzI81eWtQo8wzlB168RSEXzfreBUWu6U4ZNO4uG0jgrM46+ngqeH9zMBMz4Sr maRQ== X-Gm-Message-State: AOJu0YzZ9RoUQINvnTIq6pdB3vfM/1ejPFORplKdPA7EncfyRwmJiWNu ysNdCq6JipxR2vZofpJYkk8wN6QmCAFn6B2I00CVmgOBdVfTEHjD X-Google-Smtp-Source: AGHT+IG22HPkBjCVoFmqsHU9deEJzldkju9984RjpqHdUbmqfbypcKBE/4OL9HKHqxpH5OLWDfwIiA== X-Received: by 2002:a17:903:1209:b0:1d4:9ac9:eac2 with SMTP id l9-20020a170903120900b001d49ac9eac2mr1480781plh.28.1705610616227; Thu, 18 Jan 2024 12:43:36 -0800 (PST) Received: from brittons-large-Vivobook ([2600:380:7029:85ba:9b09:b597:4ed2:ccfb]) by smtp.gmail.com with ESMTPSA id h17-20020a170902f7d100b001d71ae81cbbsm212959plw.190.2024.01.18.12.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 12:43:34 -0800 (PST) Received: by brittons-large-Vivobook (Postfix, from userid 1000) id 1B511520275; Thu, 18 Jan 2024 11:43:33 -0900 (AKST) From: Britton Leo Kerin To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , Britton Leo Kerin Subject: [PATCH v3 2/5] completion: git-log opts to bisect visualize Date: Thu, 18 Jan 2024 11:43:20 -0900 Message-ID: <20240118204323.1113859-3-britton.kerin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118204323.1113859-1-britton.kerin@gmail.com> References: <03fe3371-2b0f-4590-90ad-166b8fa4cbbb@smtp-relay.sendinblue.com> <20240118204323.1113859-1-britton.kerin@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To do this the majority of _git_log has been factored out into the new __git_complete_log_opts. This is needed because the visualize command accepts git-log options but not rev arguments (they are fixed to the commits under bisection). __git_complete_log_opts has a precondition that COMPREPLY be empty. In a completion context it doesn't seem advisable to implement preconditions as noisy or hard failures, so instead it becomes a no-op on violation. This should be detectable and quick to debug for devels, without ever aggravating a user (besides completion failure). Signed-off-by: Britton Leo Kerin --- contrib/completion/git-completion.bash | 30 +++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 15d22ff7d9..c16aded36c 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1472,6 +1472,16 @@ _git_bisect () ;; esac ;; + visualize) + case "$cur" in + -*) + __git_complete_log_opts + return + ;; + *) + ;; + esac + ;; esac case "$subcommand" in @@ -2074,10 +2084,14 @@ __git_diff_merges_opts="off none on first-parent 1 separate m combined c dense-c __git_log_pretty_formats="oneline short medium full fuller reference email raw format: tformat: mboxrd" __git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default human raw unix auto: format:" -_git_log () + +# Check for only porcelain (i.e. not git-rev-list) option (not argument) +# and selected option argument completions for git-log options and if any +# are found put them in COMPREPLY. COMPREPLY must be empty at the start, +# and will be empty on return if no candidates are found. +__git_complete_log_opts () { - __git_has_doubledash && return - __git_find_repo_path + [ -z "$COMPREPLY" ] || return 1 # Precondition local merge="" if [ -f "$__git_repo_path/MERGE_HEAD" ]; then @@ -2171,6 +2185,16 @@ _git_log () return ;; esac +} + +_git_log () +{ + __git_has_doubledash && return + __git_find_repo_path + + __git_complete_log_opts + [ -z "$COMPREPLY" ] || return + __git_complete_revlist } From patchwork Thu Jan 18 20:43:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Britton Kerin X-Patchwork-Id: 13523214 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 300F42E64E for ; Thu, 18 Jan 2024 20:43:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705610620; cv=none; b=EYXnpnW3ocvYvt2fkJbM78BboS/0zxPrTBxrRX85VOVfbrXNb5J/FdvSEaNvyYgK+4PpVliJPjG2J7V4cz98GymE6XFMGPlZM+am6r4ov+jTrnDRongAglSe3IGa3Bfi6D+AUmJ+nL75CDBukC5WMToonEJ+vjYw62XIasVc+rg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705610620; c=relaxed/simple; bh=hNgCvCXxLlbJhZsgD5zHasyR/ZTu1PQqmR8dgnScSZU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fKQRgiArdN+kqYxfqjcjYUyouslr7EgGuV3JxJEXTAQpFLr1VujDXTwmf0HKlfCLyWDzpxrPcZ2B0oIRUtOETWMaCrspC+dKXLJmjUmEcHFJolU7sdurMoLjyNOhUMM35SCko24O8INGKASLdFb9syAn0z3J7cxCOzGbsPbZWEA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZiAZADJH; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZiAZADJH" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1d71cb97937so170215ad.3 for ; Thu, 18 Jan 2024 12:43:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705610618; x=1706215418; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oCvZbqb0BgzjI2Mi0k98LO28lzNNTVewcUzt0X9Y9CQ=; b=ZiAZADJHU4WjbrrfZSPmLkW3P8BlpltkqcFsBotyZH+26nfot/OId3nZsilz+1t0vo 9hHzBMPb8Ts9pNnm6R3xC//fsonUTWhhUkYAYu/qLzcrD6J3foSrmEXM6Yx5Ql8hBq5D NmuiBupLRTWnKOvJkD1F0vBYrwfY2tmorXCmcF3cJRhlcwsj//alz2O0XIbuIx/EBLL5 mdaLlaNealJkU++C9k8Up6yk2rkSlZiE9dsWEFFvDLgOWwsiLvDZg5tbBCbGy6qIg4Pg G1NsKC+dg+XxcHGbMiOVUgs58E5G9oMkqt9p7xE16AB5GZpKnk9FiwwX+qkL4ONWNFCT u0Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705610618; x=1706215418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oCvZbqb0BgzjI2Mi0k98LO28lzNNTVewcUzt0X9Y9CQ=; b=nyVzyBYnhbDuBv1X1JF62KrQKTHsvM8e6bl1xPCyXxnil4R92UFmpHL3JW39biWyJF hANVv1wa4kAOj5j+H3kF0WSong/aMkduOICXYBRZkWIXh4oblsvaMgPxnHAzmdNFaSey MCaiNaEtykbHGnDLxhe7sC7JR6dDdVl+pGTRBNZAMR47F1c1DHe6MBaa8RS7zA/6G9CC 3fDyoj4Tt1DZWQ9yhLeFZYZOeyMjJUldM56aPgVYPEHglgtQejAm89M5M2EXZBl7bkVA pBNWfZnsRsCWJ4GzcCxujkCOvmaPB64rMDbaoxm9fuyeMRXu6lGWFaoyPTJvjYNG1pvl 4tMw== X-Gm-Message-State: AOJu0Yy2u59+A4qTPnk+0fGMaaWlx6r4Pz174TccP8NZ+Q7Hxi7bf9Md CwrqvlfnjguVoJr1PgCOXanswcyT+Alx7x6HoOBXQeYYg8waqxw4 X-Google-Smtp-Source: AGHT+IG2Tn9ZCiZoXILQSs9GQ8Zg6WyPhQ1MjjpxcT/mtzJnAa1kmYZiHrSxFXNxF9b7oulQ2pNk2A== X-Received: by 2002:a17:903:2343:b0:1d5:907a:41aa with SMTP id c3-20020a170903234300b001d5907a41aamr1443514plh.21.1705610618544; Thu, 18 Jan 2024 12:43:38 -0800 (PST) Received: from brittons-large-Vivobook (mobile-166-176-186-78.mycingular.net. [166.176.186.78]) by smtp.gmail.com with ESMTPSA id jx16-20020a170903139000b001d4e058284esm1793921plb.89.2024.01.18.12.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 12:43:35 -0800 (PST) Received: by brittons-large-Vivobook (Postfix, from userid 1000) id 1DA80520276; Thu, 18 Jan 2024 11:43:33 -0900 (AKST) From: Britton Leo Kerin To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , Britton Leo Kerin Subject: [PATCH v3 3/5] completion: move to maintain define-before-use Date: Thu, 18 Jan 2024 11:43:21 -0900 Message-ID: <20240118204323.1113859-4-britton.kerin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118204323.1113859-1-britton.kerin@gmail.com> References: <03fe3371-2b0f-4590-90ad-166b8fa4cbbb@smtp-relay.sendinblue.com> <20240118204323.1113859-1-britton.kerin@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Britton Leo Kerin --- contrib/completion/git-completion.bash | 269 ++++++++++++------------- 1 file changed, 134 insertions(+), 135 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index c16aded36c..63ca8082a4 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1445,6 +1445,140 @@ _git_archive () __git_complete_file } +# Options that go well for log, shortlog and gitk +__git_log_common_options=" + --not --all + --branches --tags --remotes + --first-parent --merges --no-merges + --max-count= + --max-age= --since= --after= + --min-age= --until= --before= + --min-parents= --max-parents= + --no-min-parents --no-max-parents +" +# Options that go well for log and gitk (not shortlog) +__git_log_gitk_options=" + --dense --sparse --full-history + --simplify-merges --simplify-by-decoration + --left-right --notes --no-notes +" +# Options that go well for log and shortlog (not gitk) +__git_log_shortlog_options=" + --author= --committer= --grep= + --all-match --invert-grep +" +# Options accepted by log and show +__git_log_show_options=" + --diff-merges --diff-merges= --no-diff-merges --dd --remerge-diff +" + +__git_diff_merges_opts="off none on first-parent 1 separate m combined c dense-combined cc remerge r" + +__git_log_pretty_formats="oneline short medium full fuller reference email raw format: tformat: mboxrd" +__git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default human raw unix auto: format:" + +# Check for only porcelain (i.e. not git-rev-list) option (not argument) +# and selected option argument completions for git-log options and if any +# are found put them in COMPREPLY. COMPREPLY must be empty at the start, +# and will be empty on return if no candidates are found. +__git_complete_log_opts () +{ + [ -z "$COMPREPLY" ] || return 1 # Precondition + + local merge="" + if [ -f "$__git_repo_path/MERGE_HEAD" ]; then + merge="--merge" + fi + case "$prev,$cur" in + -L,:*:*) + return # fall back to Bash filename completion + ;; + -L,:*) + __git_complete_symbol --cur="${cur#:}" --sfx=":" + return + ;; + -G,*|-S,*) + __git_complete_symbol + return + ;; + esac + case "$cur" in + --pretty=*|--format=*) + __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) + " "" "${cur#*=}" + return + ;; + --date=*) + __gitcomp "$__git_log_date_formats" "" "${cur##--date=}" + return + ;; + --decorate=*) + __gitcomp "full short no" "" "${cur##--decorate=}" + return + ;; + --diff-algorithm=*) + __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" + return + ;; + --submodule=*) + __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}" + return + ;; + --ws-error-highlight=*) + __gitcomp "$__git_ws_error_highlight_opts" "" "${cur##--ws-error-highlight=}" + return + ;; + --no-walk=*) + __gitcomp "sorted unsorted" "" "${cur##--no-walk=}" + return + ;; + --diff-merges=*) + __gitcomp "$__git_diff_merges_opts" "" "${cur##--diff-merges=}" + return + ;; + --*) + __gitcomp " + $__git_log_common_options + $__git_log_shortlog_options + $__git_log_gitk_options + $__git_log_show_options + --root --topo-order --date-order --reverse + --follow --full-diff + --abbrev-commit --no-abbrev-commit --abbrev= + --relative-date --date= + --pretty= --format= --oneline + --show-signature + --cherry-mark + --cherry-pick + --graph + --decorate --decorate= --no-decorate + --walk-reflogs + --no-walk --no-walk= --do-walk + --parents --children + --expand-tabs --expand-tabs= --no-expand-tabs + $merge + $__git_diff_common_options + " + return + ;; + -L:*:*) + return # fall back to Bash filename completion + ;; + -L:*) + __git_complete_symbol --cur="${cur#-L:}" --sfx=":" + return + ;; + -G*) + __git_complete_symbol --pfx="-G" --cur="${cur#-G}" + return + ;; + -S*) + __git_complete_symbol --pfx="-S" --cur="${cur#-S}" + return + ;; + esac +} + _git_bisect () { __git_has_doubledash && return @@ -2052,141 +2186,6 @@ _git_ls_tree () __git_complete_file } -# Options that go well for log, shortlog and gitk -__git_log_common_options=" - --not --all - --branches --tags --remotes - --first-parent --merges --no-merges - --max-count= - --max-age= --since= --after= - --min-age= --until= --before= - --min-parents= --max-parents= - --no-min-parents --no-max-parents -" -# Options that go well for log and gitk (not shortlog) -__git_log_gitk_options=" - --dense --sparse --full-history - --simplify-merges --simplify-by-decoration - --left-right --notes --no-notes -" -# Options that go well for log and shortlog (not gitk) -__git_log_shortlog_options=" - --author= --committer= --grep= - --all-match --invert-grep -" -# Options accepted by log and show -__git_log_show_options=" - --diff-merges --diff-merges= --no-diff-merges --dd --remerge-diff -" - -__git_diff_merges_opts="off none on first-parent 1 separate m combined c dense-combined cc remerge r" - -__git_log_pretty_formats="oneline short medium full fuller reference email raw format: tformat: mboxrd" -__git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default human raw unix auto: format:" - - -# Check for only porcelain (i.e. not git-rev-list) option (not argument) -# and selected option argument completions for git-log options and if any -# are found put them in COMPREPLY. COMPREPLY must be empty at the start, -# and will be empty on return if no candidates are found. -__git_complete_log_opts () -{ - [ -z "$COMPREPLY" ] || return 1 # Precondition - - local merge="" - if [ -f "$__git_repo_path/MERGE_HEAD" ]; then - merge="--merge" - fi - case "$prev,$cur" in - -L,:*:*) - return # fall back to Bash filename completion - ;; - -L,:*) - __git_complete_symbol --cur="${cur#:}" --sfx=":" - return - ;; - -G,*|-S,*) - __git_complete_symbol - return - ;; - esac - case "$cur" in - --pretty=*|--format=*) - __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) - " "" "${cur#*=}" - return - ;; - --date=*) - __gitcomp "$__git_log_date_formats" "" "${cur##--date=}" - return - ;; - --decorate=*) - __gitcomp "full short no" "" "${cur##--decorate=}" - return - ;; - --diff-algorithm=*) - __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" - return - ;; - --submodule=*) - __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}" - return - ;; - --ws-error-highlight=*) - __gitcomp "$__git_ws_error_highlight_opts" "" "${cur##--ws-error-highlight=}" - return - ;; - --no-walk=*) - __gitcomp "sorted unsorted" "" "${cur##--no-walk=}" - return - ;; - --diff-merges=*) - __gitcomp "$__git_diff_merges_opts" "" "${cur##--diff-merges=}" - return - ;; - --*) - __gitcomp " - $__git_log_common_options - $__git_log_shortlog_options - $__git_log_gitk_options - $__git_log_show_options - --root --topo-order --date-order --reverse - --follow --full-diff - --abbrev-commit --no-abbrev-commit --abbrev= - --relative-date --date= - --pretty= --format= --oneline - --show-signature - --cherry-mark - --cherry-pick - --graph - --decorate --decorate= --no-decorate - --walk-reflogs - --no-walk --no-walk= --do-walk - --parents --children - --expand-tabs --expand-tabs= --no-expand-tabs - $merge - $__git_diff_common_options - " - return - ;; - -L:*:*) - return # fall back to Bash filename completion - ;; - -L:*) - __git_complete_symbol --cur="${cur#-L:}" --sfx=":" - return - ;; - -G*) - __git_complete_symbol --pfx="-G" --cur="${cur#-G}" - return - ;; - -S*) - __git_complete_symbol --pfx="-S" --cur="${cur#-S}" - return - ;; - esac -} - _git_log () { __git_has_doubledash && return From patchwork Thu Jan 18 20:43:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Britton Kerin X-Patchwork-Id: 13523215 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D2723173E for ; Thu, 18 Jan 2024 20:43:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705610620; cv=none; b=M6Rzwm8t1Jx0eiM5uK5RCDyvzxv+WDfNJ/pb3oJ++CQjh6RPtVDsilLAEyBM/hnL3SlUJbIb4UfrSym4rNse9nPjdms767teqUHNokdI44cEWllMUo1ZO+HdU3D5or2pSWcBhZhIDZxVc1GWg+qWkNe9KXqsQ3nlSkJIbmNhJ2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705610620; c=relaxed/simple; bh=BocqwoumdwyeKQkvIRRzGEy8YZRxfZEdOco9Z+UfBqo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ee1kel/5G8eHgRGmtKxU32fLuT4xo1g7j/5abIF9jSkIx6vwQOvx2BvFKZDqAIPJF4zA3OCOcmerS6uSRfeC9Pa2e0nPB8l5PP36rTLg9cVJBWrn40CB3LF+sgQVyH4Lq8VC1Vf4XxnBNf46vSDr6U05TfIYzsHzI5mduArw8Q8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CwifQEAB; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CwifQEAB" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6d9b267007fso111269b3a.3 for ; Thu, 18 Jan 2024 12:43:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705610619; x=1706215419; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cKB8kMLbJRUVzIIG/52sECuQUrlKokgcV/DxC4b/MZU=; b=CwifQEABerJJnCsCUfHyaxQwKNLH7h7uTfqoNyny7ZTKwNI/TYFg5sk4A2PMkr4p42 UjdwWDxNmk77OkgUP6/LS7dNgcROYZPfVNPwnTOTj/lTbOT9QDTx1SKiM/Jf0IkDikeq a6eBp65DwLjMnC/Vnc+5Sx2wHysLSpyfyFk6UFnsTvSS23Ks0kwjMWaRd2S+FoyRlCsJ CmaXWvevQ063V19S4syJ3egnWLnQ5WaLHD397U682xRZbbRU6Q/unDyNzwRTDtgl2SHy +CTX5AFtykdy84ajQgVu+HEybkEfSQqUld5A+rHWwxytEt+tCkGaUsws7e9rvc5fNxTh g0Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705610619; x=1706215419; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cKB8kMLbJRUVzIIG/52sECuQUrlKokgcV/DxC4b/MZU=; b=eHi+ga9DxQ7E0ofIe+sF6rALAATkXvk4TIPO11lqrVvXjhZdSOLoghyTdZ5h2osXep 07ZCJ1uClqzaSX3NmBhCCuu/41p8DsjahNweMeSvUT4zJpxQZDOy0yb6DSVMU23Qsev5 YylpC4UhakzqaB0hSCkF/z+rbJ2xV5ZvNgQeEwlIiN+KPz/ggprPTQTaN9nE+oA9gDxC Y8zEYreaDou2UU4dXrAXG8N0iE25WsobJKAj6caecw7OXDUXFFiWdGfWo5uP3ySP71Xr gwgPw5voObosyy/bcMFguKRqtEpY8YgebiFifeiWKvX1gVkNCj5rZ0g9CVvOKLnXAsvN 102w== X-Gm-Message-State: AOJu0Yzf6/wocb/HP56yfd+Hmm1x1FYy0mjLLKRTz7gZDyHK3lWowNZz GwNDfujIXOMkrAiMKlsUWIanGoWyYNn+WM8nSngwIes5FUeLazZO X-Google-Smtp-Source: AGHT+IGFF76f01wPlqiP93OA4dwXqc+q8PjwycdbkkJB5rKo7qGYNn24TfJ+8QxCtHWFYyQBt9+HWw== X-Received: by 2002:a05:6a00:92a0:b0:6d9:b417:e49 with SMTP id jw32-20020a056a0092a000b006d9b4170e49mr1422925pfb.49.1705610618907; Thu, 18 Jan 2024 12:43:38 -0800 (PST) Received: from brittons-large-Vivobook (mobile-166-176-186-78.mycingular.net. [166.176.186.78]) by smtp.gmail.com with ESMTPSA id lo11-20020a056a003d0b00b006d9bb753d2esm3703561pfb.166.2024.01.18.12.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 12:43:35 -0800 (PST) Received: by brittons-large-Vivobook (Postfix, from userid 1000) id 1F6C5520277; Thu, 18 Jan 2024 11:43:33 -0900 (AKST) From: Britton Leo Kerin To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , Britton Leo Kerin Subject: [PATCH v3 4/5] completion: custom git-bisect terms Date: Thu, 18 Jan 2024 11:43:22 -0900 Message-ID: <20240118204323.1113859-5-britton.kerin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118204323.1113859-1-britton.kerin@gmail.com> References: <03fe3371-2b0f-4590-90ad-166b8fa4cbbb@smtp-relay.sendinblue.com> <20240118204323.1113859-1-britton.kerin@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Britton Leo Kerin --- contrib/completion/git-completion.bash | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 63ca8082a4..ad80df6630 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1583,10 +1583,19 @@ _git_bisect () { __git_has_doubledash && return - local subcommands="start bad new good old terms skip reset visualize replay log run help" + __git_find_repo_path + + local term_bad term_good + if [ -f "$__git_repo_path"/BISECT_START ]; then + term_bad=`__git bisect terms --term-bad` + term_good=`__git bisect terms --term-good` + fi + + local subcommands="start bad new $term_bad good old $term_good terms skip reset visualize replay log run help" + local subcommand="$(__git_find_on_cmdline "$subcommands")" + if [ -z "$subcommand" ]; then - __git_find_repo_path if [ -f "$__git_repo_path"/BISECT_START ]; then __gitcomp "$subcommands" else @@ -1619,7 +1628,7 @@ _git_bisect () esac case "$subcommand" in - bad|new|good|old|reset|skip|start) + bad|new|"$term_bad"|good|old|"$term_good"|reset|skip|start) __git_complete_refs ;; *) From patchwork Thu Jan 18 20:43:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Britton Kerin X-Patchwork-Id: 13523216 Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E242831A81 for ; Thu, 18 Jan 2024 20:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705610623; cv=none; b=HGYofWNb9SMi+OZaLS6BYAJcWu4XrNc+ckum5WDWyYfhVVHfwOEiUIdYHMvRbakHxD3uUq+MD61zr6Syr6HHtVcZPRIaqiVP2v2h8VhYhAh3Po+DgmEt84pIar5WQUVUwNX1ytoil3WKi90dH+6PoOLMPQyis3S+gruO0t6zQ6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705610623; c=relaxed/simple; bh=Y0LqsRZe9AddaLl2Hx+ssJN+9u0l6PXT9I9qEqi4epg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AWlyfAHOCoCYZPXF5jcvHRX7Dpu8zD9MpCmAaI4KjMUdwvep7zL7j1GjrERdDBq33FxHljXP+E3xbXtvc3PtW0prd5Vc+NG0GE0sRb+Jt4octxRuldOUQWB2LRaBIFDCu4Bdu+YAe3A2dgXfKLgGa4Xgz32RCcUtOMXkhr96F4Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RnEVOcEP; arc=none smtp.client-ip=209.85.161.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RnEVOcEP" Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-59883168a83so29877eaf.2 for ; Thu, 18 Jan 2024 12:43:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705610621; x=1706215421; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CKgabg0f16EawRXq+one6wT4dEB3ongXPjWj2/hAruY=; b=RnEVOcEPcD4pT53fePTTTTwvC1qAGdJ1nnjV5rBpHnOFTGN7f5h+1hlhv1ESGsbZ87 nwAPu1Our653iITOCPRESktRXe8BWds4kFRrK3ch6F3+CBFi3iQXM5lzpZm4Na/omsKK fvZEzeYa+aL/I8OkAse9W8Wm57EhIGYsLLpOQMb3HWgi4zem3U5IFNSHjs6nrZrfkh1h bwlYB6ikWYL33Y6kF51v3+Jhz0EokNVhPtPuZM+TsiX0gBQhnb0JSUSZ9fNUwhRgfKQo S8QaA43zl39CsBceAACVif/ivDEVtwQfmM7VgABkCooEFiSRIhUUhpdnwlmsYdJj+1+1 FgHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705610621; x=1706215421; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CKgabg0f16EawRXq+one6wT4dEB3ongXPjWj2/hAruY=; b=h4D85XHiuR6puRwNICaejbQu1hCTc8xlOXP5zDdOPSNle63CkI7sFnGP8agM5mCbQe aUcByg2gety6g7LA0zfw4Sf5wkCz8hn2O1cPKI3gDjzXw9CnpoRoZgFf2az6RSbdhx4z qHhdl/ayRt6oB1jxpduuevSOSKL0wNz/s/tFuXaJ2vS3OmfQidd9vCYQnvsb9yflPqSJ GCwRJJCgUcLDI7mp7HubXRN3CPm2zrXLbwp1L9sRWOw2IdowUl99yj09qSMva8mneOt+ FVeIyOFAfp9k1ySkIB87KMo9ZtXdO6r74OxoTIzZAzptcKFj1GGdseI/Tyyt0ReXc5f0 qClQ== X-Gm-Message-State: AOJu0YzMU5jzMyd5vrFP2sLvC90OfZ9ormBow+JomxtdlWX1PZim1c4g g4hryDR2yAmMMxwJ+A2/xXSfXmBP473z/VeJzx5K9w1ijTMaS4fI X-Google-Smtp-Source: AGHT+IGeKoIL0vYmxYZ+CwsN2L4uKkMHrsGejLmmh11p8FOrvpEE7aV42sRT4z56BGXFGdd1n6ZvWg== X-Received: by 2002:a05:6358:8808:b0:175:4f3e:bd4d with SMTP id hv8-20020a056358880800b001754f3ebd4dmr1261580rwb.49.1705610620406; Thu, 18 Jan 2024 12:43:40 -0800 (PST) Received: from brittons-large-Vivobook ([2600:380:7029:85ba:9b09:b597:4ed2:ccfb]) by smtp.gmail.com with ESMTPSA id g5-20020a636b05000000b005bd980cca56sm2014699pgc.29.2024.01.18.12.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 12:43:39 -0800 (PST) Received: by brittons-large-Vivobook (Postfix, from userid 1000) id 20FFC520278; Thu, 18 Jan 2024 11:43:33 -0900 (AKST) From: Britton Leo Kerin To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , Britton Leo Kerin Subject: [PATCH v3 5/5] completion: git-bisect view recognized but not completed Date: Thu, 18 Jan 2024 11:43:23 -0900 Message-ID: <20240118204323.1113859-6-britton.kerin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118204323.1113859-1-britton.kerin@gmail.com> References: <03fe3371-2b0f-4590-90ad-166b8fa4cbbb@smtp-relay.sendinblue.com> <20240118204323.1113859-1-britton.kerin@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This allows the git-log options to be completed but avoids completion ambiguity between visualize and view. Signed-off-by: Britton Leo Kerin --- contrib/completion/git-completion.bash | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index ad80df6630..87cf7b2561 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1591,13 +1591,22 @@ _git_bisect () term_good=`__git bisect terms --term-good` fi - local subcommands="start bad new $term_bad good old $term_good terms skip reset visualize replay log run help" + # We will complete any custom terms, but still always complete the + # more usual bad/new/good/old because git bisect gives a good error + # message if these are given when not in use and that's better than + # silent refusal to complete if the user is confused. + # + # We want to recognize 'view' but not complete it, because it overlaps + # with 'visualize' too much and is just an alias for it. + # + local completable_subcommands="start bad new $term_bad good old $term_good terms skip reset visualize replay log run help" + local all_subcommands="$completable_subcommands view" - local subcommand="$(__git_find_on_cmdline "$subcommands")" + local subcommand="$(__git_find_on_cmdline "$all_subcommands")" if [ -z "$subcommand" ]; then if [ -f "$__git_repo_path"/BISECT_START ]; then - __gitcomp "$subcommands" + __gitcomp "$completable_subcommands" else __gitcomp "replay start" fi @@ -1615,7 +1624,7 @@ _git_bisect () ;; esac ;; - visualize) + visualize|view) case "$cur" in -*) __git_complete_log_opts