2012-07-13 116 views
3

我发现自己经常打字git st .(其中st已被别名为status)以获取当前目录文件的状态。git别名名称中可以包含句点(。)吗?

我经常输错那git st.这当然没有得到承认。

我很想能够别名st.,但它似乎并不像我可以。如果我将st. = status .添加到我的.gitconfig别名中,那么git调用中会出现fatal: bad config file错误。

是否可以创建一个带有句点的别名?

回答

6

不,这是不可能的(不改变和重新编译Git本身)。从git-config文档:

变量名是区分大小写的,只允许字母数字字符和-,并且必须以字母字符开始。

+0

啊,谢谢。我不确定别名是否是特殊情况,或者他们的名字是否可以以某种方式逃脱。 – 2012-07-13 22:40:37

5

否;如果你看看config.c,它必须是字母数字。

/* 
* Validate the key and while at it, lower case it for matching. 
*/ 
*store_key = xmalloc(strlen(key) + 1); 

dot = 0; 
for (i = 0; key[i]; i++) { 
    unsigned char c = key[i]; 
    if (c == '.') 
     dot = 1; 
    /* Leave the extended basename untouched.. */ 
    if (!dot || i > baselen) { 
     if (!iskeychar(c) || 
      (i == baselen + 1 && !isalpha(c))) { 
      error("invalid key: %s", key); 
      goto out_free_ret_1; 
     } 
     c = tolower(c); 
    } else if (c == '\n') { 
     error("invalid key (newline): %s", key); 
     goto out_free_ret_1; 
    } 
    (*store_key)[i] = c; 
} 
(*store_key)[i] = 0; 
+0

谢谢!不幸的是,我只能选择一个答案! – 2012-07-13 22:41:05

相关问题