@matheusbsbs / matheus-bagliano / commits / 2a5da75579
Fork 0

bash: support more 'git notes' subcommands and their options

The current completion function for 'git notes' only supported the 'edit' and 'show' subcommands and none of their options. This patch adds support for all missing subcommands, options, and their arguments (files or refs), if any. The code responsible for completing subcommand looks different compared to the completion functions of other git commands with subcommands. This is because of the '--ref <notes-ref>' option which comes before the subcommand (i.e. git notes --ref <notes-ref> add). Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Oct 10, 2010 at 23:43 UTC 2a5da75579310a674431e6b91fed1d712f4c24ae
1 file changed +41 -9
contrib/completion/git-completion.bash
+41 -9
@@ -1472,18 +1472,50 @@ _git_name_rev ()
1472
1473 _git_notes ()
1474 {
1475 - local subcommands="edit show"
1476 - if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
1477 - __gitcomp "$subcommands"
1478 - return
1479 - fi
1475 + local subcommands='add append copy edit list prune remove show'
1476 + local subcommand="$(__git_find_on_cmdline "$subcommands")"
1477 + local cur="${COMP_WORDS[COMP_CWORD]}"
1478
1481 - case "${COMP_WORDS[COMP_CWORD-1]}" in
1482 - -m|-F)
1483 - COMPREPLY=()
1479 + case "$subcommand,$cur" in
1480 + ,--*)
1481 + __gitcomp '--ref'
1482 + ;;
1483 + ,*)
1484 + case "${COMP_WORDS[COMP_CWORD-1]}" in
1485 + --ref)
1486 + __gitcomp "$(__git_refs)"
1487 + ;;
1488 + *)
1489 + __gitcomp "$subcommands --ref"
1490 + ;;
1491 + esac
1492 + ;;
1493 + add,--reuse-message=*|append,--reuse-message=*)
1494 + __gitcomp "$(__git_refs)" "" "${cur##--reuse-message=}"
1495 + ;;
1496 + add,--reedit-message=*|append,--reedit-message=*)
1497 + __gitcomp "$(__git_refs)" "" "${cur##--reedit-message=}"
1498 + ;;
1499 + add,--*|append,--*)
1500 + __gitcomp '--file= --message= --reedit-message=
1501 + --reuse-message='
1502 + ;;
1503 + copy,--*)
1504 + __gitcomp '--stdin'
1505 + ;;
1506 + prune,--*)
1507 + __gitcomp '--dry-run --verbose'
1508 + ;;
1509 + prune,*)
1510 ;;
1511 *)
1486 - __gitcomp "$(__git_refs)"
1512 + case "${COMP_WORDS[COMP_CWORD-1]}" in
1513 + -m|-F)
1514 + ;;
1515 + *)
1516 + __gitcomp "$(__git_refs)"
1517 + ;;
1518 + esac
1519 ;;
1520 esac
1521 }