Re: [PATCH 1/2] completion: add a helper function to get config variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Quoting SZEDER Gábor <szeder@xxxxxxxxxx>:

Currently there are a few completion functions that perform similar 'git
config' queries and filtering to get config variable names: the completion
of pretty aliases, aliases, and remote groups for 'git remote update'.

Unify those 'git config' queries in a helper function to eliminate code
duplication.

Though the helper functions to get pretty aliases and alieses are reduced
to mere one-liner wrappers around the newly added function, keep these
helpers still, because users' completion functions out there might depend
on them.  And they keep their callers a tad easier to read, too.

Add tests for the pretty alias and alias helper to show that they work
as before; not for the remote groups query, though, because that's not
extracted into a helper function and it's not worth the effort to do so
for a sole callsite.

Signed-off-by: SZEDER Gábor <szeder@xxxxxxxxxx>
---
@@ -2260,12 +2259,7 @@ _git_remote ()
 		__git_complete_remote_or_refspec
 		;;
 	update)
-		local i c='' IFS=$'\n'
- for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
-			i="${i#remotes.}"
-			c="$c ${i/ */}"
-		done
-		__gitcomp "$c"
+		__gitcomp "$(__git_get_config_variables "remotes")"

I just noticed that this query for remote groups does lack that filtering case statement eliminated in the next patch and the regex is not limited to the beginning of the config variable name. So, let's suppose we have a branch named 'remotes', for which we add a branch description (and no remote groups, for symplicity's sake):

  $ git config branch.remotes.description uh-oh
  $ git remote update <TAB>

This will complete to:

  $ git remote update branch.remotes.description

and that's obviously bad.

This series fixes this.

Best,
Gábor
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]