2

I want to list all commits 'since my last commit'.

Right now i use this log-alias variant:

[user]
    name = My Name
[alias]
    lg = !git log --since $(git log --pretty=format:'%ct' --author 'My Name' -1)

That works fine in general - but i would like to actually reference my username stated in the .gitconfig instead of hardcoding it.

Is it possible to access that value? (e.g.: $(GITCONFIG:User:Name))

Just in case: $(whoami) does not work because the usernames don't match.

FreedomTears
  • 93
  • 1
  • 6
  • Quick Solution: `lg =!git log --since $(git log --pretty=format:'%ct' --author \"$(git config --get user.name)\" -1)` -- Thanks to @torek – FreedomTears May 19 '17 at 11:54

1 Answers1

4

You can extract your name from your Git configuration:

me=$(git config --get user.name)

for instance. Once you have that in a variable, you can refer to the variable. (If you only need it once you can nest $(...) constructs, which is pretty clever-looking but may be hard to debug later :-) )

Hence:

[alias]
    lg = "!me=$(git config --get user.name); \
      git log --since $(git log --pretty=format:'%ct' --author \"$me\" -1)"

(you don't need the backslash-newline-indent sequence here, but you can use it if you like it: Git allows multi-line aliases using backslash-newline). Note: semicolon is a comment marker in a Git configuration file, so if using one, we need quotes.

torek
  • 448,244
  • 59
  • 642
  • 775
  • thanks a lot! yes it is harder to debug but this made my day: `lg =!git log --since $(git log --pretty=format:'%ct' --author \"$(git config --get user.name)\" -1)` – FreedomTears May 19 '17 at 11:52
  • 1
    I forgot to quote the whole outer thing - semicolons are comments in git config lines... – torek May 19 '17 at 11:59