@@ -43,6 +43,27 @@ __git_ps1 ()
4343 fi
4444}
4545
46+ __git_heads ()
47+ {
48+ local cmd i is_hash=y dir=" ${1:- $(__gitdir)} "
49+ if [ -d " $dir " ]; then
50+ for i in $( git --git-dir=" $dir " \
51+ for-each-ref --format=' %(refname)' \
52+ refs/heads ) ; do
53+ echo " ${i# refs/ heads/ } "
54+ done
55+ return
56+ fi
57+ for i in $( git-ls-remote " $dir " 2> /dev/null) ; do
58+ case " $is_hash ,$i " in
59+ y,* ) is_hash=n ;;
60+ n,* ^{}) is_hash=y ;;
61+ n,refs/heads/* ) is_hash=y; echo " ${i# refs/ heads/ } " ;;
62+ n,* ) is_hash=y; echo " $i " ;;
63+ esac
64+ done
65+ }
66+
4667__git_refs ()
4768{
4869 local cmd i is_hash=y dir=" ${1:- $(__gitdir)} "
@@ -91,6 +112,23 @@ __git_refs2 ()
91112 done
92113}
93114
115+ __git_refs_remotes ()
116+ {
117+ local cmd i is_hash=y
118+ for i in $( git-ls-remote " $1 " 2> /dev/null) ; do
119+ case " $is_hash ,$i " in
120+ n,refs/heads/* )
121+ is_hash=y
122+ echo " $i :refs/remotes/$1 /${i# refs/ heads/ } "
123+ ;;
124+ y,* ) is_hash=n ;;
125+ n,* ^{}) is_hash=y ;;
126+ n,refs/tags/* ) is_hash=y;;
127+ n,* ) is_hash=y; ;;
128+ esac
129+ done
130+ }
131+
94132__git_remotes ()
95133{
96134 local i ngoff IFS=$' \n ' d=" $( __gitdir) "
@@ -500,6 +538,119 @@ _git_rebase ()
500538 COMPREPLY=($( compgen -W " $( __git_refs) " -- " $cur " ) )
501539}
502540
541+ _git_repo_config ()
542+ {
543+ local cur=" ${COMP_WORDS[COMP_CWORD]} "
544+ local prv=" ${COMP_WORDS[COMP_CWORD-1]} "
545+ case " $prv " in
546+ branch.* .remote)
547+ COMPREPLY=($( compgen -W " $( __git_remotes) " -- " $cur " ) )
548+ return
549+ ;;
550+ branch.* .merge)
551+ COMPREPLY=($( compgen -W " $( __git_refs) " -- " $cur " ) )
552+ return
553+ ;;
554+ remote.* .fetch)
555+ local remote=" ${prv# remote.} "
556+ remote=" ${remote% .fetch} "
557+ COMPREPLY=($( compgen -W " $( __git_refs_remotes " $remote " ) " \
558+ -- " $cur " ) )
559+ return
560+ ;;
561+ remote.* .push)
562+ local remote=" ${prv# remote.} "
563+ remote=" ${remote% .push} "
564+ COMPREPLY=($( compgen -W " $( git --git-dir=" $( __gitdir) " \
565+ for-each-ref --format=' %(refname):%(refname)' \
566+ refs/heads) " -- " $cur " ) )
567+ return
568+ ;;
569+ * .* )
570+ COMPREPLY=()
571+ return
572+ ;;
573+ esac
574+ case " $cur " in
575+ --* )
576+ COMPREPLY=($( compgen -W "
577+ --global --list --replace-all
578+ --get --get-all --get-regexp
579+ --unset --unset-all
580+ " -- " $cur " ) )
581+ return
582+ ;;
583+ branch.* .* )
584+ local pfx=" ${cur% .* } ."
585+ cur=" ${cur##* .} "
586+ COMPREPLY=($( compgen -P " $pfx " -W " remote merge" -- " $cur " ) )
587+ return
588+ ;;
589+ branch.* )
590+ local pfx=" ${cur% .* } ."
591+ cur=" ${cur#* .} "
592+ COMPREPLY=($( compgen -P " $pfx " -S . \
593+ -W " $( __git_heads) " -- " $cur " ) )
594+ return
595+ ;;
596+ remote.* .* )
597+ local pfx=" ${cur% .* } ."
598+ cur=" ${cur##* .} "
599+ COMPREPLY=($( compgen -P " $pfx " -W " url fetch push" -- " $cur " ) )
600+ return
601+ ;;
602+ remote.* )
603+ local pfx=" ${cur% .* } ."
604+ cur=" ${cur#* .} "
605+ COMPREPLY=($( compgen -P " $pfx " -S . \
606+ -W " $( __git_remotes) " -- " $cur " ) )
607+ return
608+ ;;
609+ esac
610+ COMPREPLY=($( compgen -W "
611+ apply.whitespace
612+ core.fileMode
613+ core.gitProxy
614+ core.ignoreStat
615+ core.preferSymlinkRefs
616+ core.logAllRefUpdates
617+ core.repositoryFormatVersion
618+ core.sharedRepository
619+ core.warnAmbiguousRefs
620+ core.compression
621+ core.legacyHeaders
622+ i18n.commitEncoding
623+ diff.color
624+ diff.renameLimit
625+ diff.renames
626+ pager.color
627+ status.color
628+ log.showroot
629+ show.difftree
630+ showbranch.default
631+ whatchanged.difftree
632+ http.sslVerify
633+ http.sslCert
634+ http.sslKey
635+ http.sslCAInfo
636+ http.sslCAPath
637+ http.maxRequests
638+ http.lowSpeedLimit http.lowSpeedTime
639+ http.noEPSV
640+ pack.window
641+ repack.useDeltaBaseOffset
642+ pull.octopus pull.twohead
643+ merge.summary
644+ receive.unpackLimit
645+ receive.denyNonFastForwards
646+ user.name user.email
647+ tar.umask
648+ gitcvs.enabled
649+ gitcvs.logfile
650+ branch. remote.
651+ " -- " $cur " ) )
652+ }
653+
503654_git_reset ()
504655{
505656 local cur=" ${COMP_WORDS[COMP_CWORD]} "
@@ -552,6 +703,7 @@ _git ()
552703 pull) _git_pull ;;
553704 push) _git_push ;;
554705 rebase) _git_rebase ;;
706+ repo-config) _git_repo_config ;;
555707 reset) _git_reset ;;
556708 show) _git_log ;;
557709 show-branch) _git_log ;;
@@ -585,6 +737,7 @@ complete -o default -F _git_name_rev git-name-rev
585737complete -o default -o nospace -F _git_pull git-pull
586738complete -o default -o nospace -F _git_push git-push
587739complete -o default -F _git_rebase git-rebase
740+ complete -o default -F _git_repo_config git-repo-config
588741complete -o default -F _git_reset git-reset
589742complete -o default -F _git_log git-show
590743complete -o default -o nospace -F _git_log git-show-branch
@@ -606,6 +759,7 @@ complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
606759complete -o default -F _git_merge_base git-merge-base.exe
607760complete -o default -F _git_name_rev git-name-rev.exe
608761complete -o default -o nospace -F _git_push git-push.exe
762+ complete -o default -F _git_repo_config git-repo-config
609763complete -o default -o nospace -F _git_log git-show.exe
610764complete -o default -o nospace -F _git_log git-show-branch.exe
611765complete -o default -o nospace -F _git_log git-whatchanged.exe
0 commit comments