Open ernstki opened 1 year ago
Just for my own edification, here's the command I ran on the git-toolbelt repo as evidence that the output of git log --name-status
really does have more than two columns sometimes.
git log --oneline | awk '{print $1}' \
| xargs -I{} sh -c 'git log -1 --name-status --pretty=format:"" {}' \
| awk -F'\t' 'NF!=2'
# result:
# R100 git-aa git-stage-all
# R100 git-cc git-unstage-all
# R100 git-unmerge git-undo-merge
Today I learned!
would you be amenable to using awk for this, or is that a dependency you'd hoped to steer clear of?
The ... | rev | cut | rev
trick is a bit stupid, I agree, but it's a fairly common Unix idiom I've often seen in scripts when you want to use cut
in a shell script and want to pick fields from the end if you don't know how many fields are on a line.
I don't mind to switch it over to awk
, if you think awk
is more commonly available than cut
, but even cut
seems fairly common to me. Anway, as long as the implementation is solid, I'm happy to take the contribution 👍
The
... | rev | cut | rev
trick is a bit stupid, I agree, but it's a fairly common Unix idiom I've often seen in scripts when you want to usecut
in a shell script and want to pick fields from the end if you don't know how many fields are on a line.
No judgements from my side! It's just that rev
was a bit of a sticking point for Windows (Git Bash) users, as I recall.
I'll check again, though. Maybe the situation has changed. Certainly the landscape of Unix-on-Windows has changed, with WSL being fairly well established now.
I'm looking for a way to accomplish what
git-modified
is accomplishing withrev
, withoutrev
, as discussed in #29 and incorrectly implemented in #39.https://github.com/nvie/git-toolbelt/blob/2eec073a4e12b7f6e70f6d4713de75b8642c4e90/git-modified#L124
It looks like you had to do the
rev
stuff in 4ea5c29 to account for some change in the output ofgit log
circa 2018.I didn't understand what was going on with the
rev
s there for a good long while, but now I do[^fn1]; when a rename happens, there are three columns in the output, and you want the last one.@nvie, would you be amenable to using
awk
for this, or is that a dependency you'd hoped to steer clear of? People are likely to have a functionalawk
even if they're missingrev
, although I'll have to double-check if that's the case with Git Bash. On the other hand, some sort ofwhile IFS="$TAB" read
ing might do the trick, too, in plain shell script.[^fn1]: this SO question was helpful in that regard