sha1_name: allow to add @{...} alias via config
PATCH 1/1 sha1_name: allow to add @{...} alias via config
This allows users to add new @{..} alias via ref-at.* config variables. The rewrite rule is printf-alike.
My itch is I usually work on a topic and only want to see commits in that topic. So I make a tag to the topic's base, then do
git log base/my-topic..
That is a lot of keystrokes, and my mind is small enough sometimes I don't even remember the topic name, stucking at "base/ what?"
Now I have "ref-at.base = base/%(tip)" in my gitconfig and I only need to do "git log @{base}..".
This is probably not the best way to do though. Any advice?
--- cache.h | 3 ++ config.c | 3 ++ sha1_name.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 101 insertions(+), 5 deletions(-)
cache.h +3 -0
@@ -1112,4 +1112,7 @@ extern struct startup_info *startup_info;/* builtin/merge.c */ int checkout_fast_forward (const unsigned char *from,const unsigned char *to); +/* sha1_name.c */ +extern int git_ref_at_config (const char *var,const char *value); +#endif /* CACHE_H */
config.c +3 -0
@@ -720,6 +720,9 @@ int git_default_config(const char *var, const char *value, void *dummy)if (!prefixcmp (var,"advice." ))return git_default_advice_config (var, value); +if (!strncmp (var,"ref-at." ,7 )) +return git_ref_at_config (var, value); +if (!strcmp (var,"pager.color" ) || !strcmp (var,"color.pager" )) { pager_use_color =git_config_bool (var,value);return 0 ;
sha1_name.c +95 -5
158 lines not on this page · raw message
Signature · 1 line
1.7.1.rc1.69.g24c2f7
2010/9/8 Nguyễn Thái Ngọc Duy <[email protected]>:
Quoted 6 lines
This allows users to add new @{..} alias via ref-at.* config variables. The rewrite rule is printf-alike.
My itch is I usually work on a topic and only want to see commits in that topic. So I make a tag to the topic's base, then do
Quoted 7 lines
git log base/my-topic..
That is a lot of keystrokes, and my mind is small enough sometimes I don't even remember the topic name, stucking at "base/ what?"
Now I have "ref-at.base = base/%(tip)" in my gitconfig and I only need to do "git log @{base}..".
I like the idea, but I would like something more generic, a ref transformation or expression (ref-exp?). Currently you can't say %(tip)@{1}, neither %(tip)^, nor origin/master..origin/%(tip).
Another issue is that it can shadow builtin @{}s, like @{upstream}.
Why %(tip) and not %(branchname), in line with other %() modifiers.
In particular I have a use case for this @{name}. I would like something like:
ref-exp.last = %(tip)@{1}..%(tip)@{0}
so I could do:
git log @{last}
git log origin/master@{last}
Although another way to get it could be:
git log @{1..0}
git log origin/master@{1..0}
Thanks,
Santi
2010/9/8 Santi Béjar <[email protected]>:
Quoted 12 lines
2010/9/8 Nguyễn Thái Ngọc Duy <[email protected]>:
Quoted 11 lines
This allows users to add new @{..} alias via ref-at.* config variables. The rewrite rule is printf-alike.
My itch is I usually work on a topic and only want to see commits in that topic. So I make a tag to the topic's base, then do
git log base/my-topic..
That is a lot of keystrokes, and my mind is small enough sometimes I don't even remember the topic name, stucking at "base/ what?"
Quoted 6 lines
Quoted 2 lines
Now I have "ref-at.base = base/%(tip)" in my gitconfig and I only need to do "git log @{base}..".
I like the idea, but I would like something more generic, a ref transformation or expression (ref-exp?). Currently you can't say %(tip)@{1}, neither %(tip)^, nor origin/master..origin/%(tip).
The idea is to nail down what kind of expression that should be used. Then implement it. My first thought was to use a hook, but I thought it was overkill for ref transformation.
Something like bash variable substitution is probably enough.
Quoted 1 line
Another issue is that it can shadow builtin @{}s, like @{upstream}.
Yes. I think @{upstream} can be put in to ref-transformation list at startup. That way it always gets precedence.
Quoted 1 line
Why %(tip) and not %(branchname), in line with other %() modifiers.
Oh.. I picked whatever name I had in my mind. @(branchname) of @(branch) sounds good.
Quoted 3 lines
In particular I have a use case for this @{name}. I would like something like:
ref-exp.last = %(tip)@{1}..%(tip)@{0}
Yeah I was tempted too after writing the patch. It's a revision range, not a reference anymore. But from user perspective it's pretty much the same. And transformation rule would be the same. Hmm.. tempting.
Signature · 1 line
Duy
2010/9/8 Santi Béjar <[email protected]>:
Quoted 5 lines
2010/9/8 Nguyễn Thái Ngọc Duy <[email protected]>:
Quoted 2 lines
This allows users to add new @{..} alias via ref-at.* config variables. The rewrite rule is printf-alike.
Another issue is that it can shadow builtin @{}s, like @{upstream}.
In fact this patch breaks @{upstream}.
Santi
2010/9/8 Santi Béjar <[email protected]>:
Quoted 8 lines
2010/9/8 Santi Béjar <[email protected]>:
Quoted 5 lines
2010/9/8 Nguyễn Thái Ngọc Duy <[email protected]>:
Quoted 2 lines
This allows users to add new @{..} alias via ref-at.* config variables. The rewrite rule is printf-alike.
Another issue is that it can shadow builtin @{}s, like @{upstream}.
In fact this patch breaks @{upstream}.
My fault. There should not be an equal in
if (substitute_ref_at(&new_str, str) >= 0)
Signature · 1 line
Duy