Live data from Hacker News

Bttf is a command line datetime Swiss army knife

github.com

71–80 of 104 posts

Re: Bttf is a command line datetime Swiss army knife

#73
post #44

Respect for programming this. I did some date/time calculations a few years ago using Perl and it was full of corner cases and trouble. Did I enjoy it? I enjoyed seeing it work. Hopefully with the right answers! This tool looks great.

Perl's DateTime module was pretty solid, IIRC. One of the things I miss about using Perl.

Re: Bttf is a command line datetime Swiss army knife

#74
post #2

No, Biff informs the system whether you want to be notified when mail arrives during the current terminal session.

For those confused by this and a few similar threads/comments: the project name was originally "biff", but that was changed apparently due to the discussion on this submission, which has been retitled.

Re: Bttf is a command line datetime Swiss army knife

#75
post #44

Respect for programming this. I did some date/time calculations a few years ago using Perl and it was full of corner cases and trouble. Did I enjoy it? I enjoyed seeing it work. Hopefully with the right answers! This tool looks great.

Perl's DateTime module was pretty solid, IIRC. One of the things I miss about using Perl.

Yes, I agree. It was magic to me really. I still love Perl.

Re: Bttf is a command line datetime Swiss army knife

#76

I'm the author of Bttf. I just wanted to share a really cool example of something that Bttf can do that I _think_ is kinda hard to do otherwise. (And also, I want to make an assertion about it and I hope this will lead to me being wrong and learning something new.) The use case is: "I want to see a list of all files in a repository, sorted in ascending order of when it was most recently changed according to source co…

> I think [`git log -n1 -- `] is the fastest way to get the most recent commit time on a single file?

In terms of machine time? I'd guess so, but I'd also guess calling it for each of `git ls-files` is not the fastest way to get the most recent commit of all the files in a typical scenario (large repo, recent time of interest, most files not changed that recently). And especially if you're okay assuming the most recent commit by parentage is the one you want (even if parentage doesn't match chronological order); then filtering with `git log --name-only --since` (no path argument) seems better. A `git log` post-processing script could also stop early if it's seen a commit for each the files of interest (again, assuming you don't want to return a later date that is attached to an ancestor commit).

Anyway, cool tool, and it's rare that I would actually care about the machine efficiency of this pipeline enough to bother with the approach I just described.

Re: Bttf is a command line datetime Swiss army knife

#78

I'm the author of Bttf. I just wanted to share a really cool example of something that Bttf can do that I _think_ is kinda hard to do otherwise. (And also, I want to make an assertion about it and I hope this will lead to me being wrong and learning something new.) The use case is: "I want to see a list of all files in a repository, sorted in ascending order of when it was most recently changed according to source co…

[flagged]

Re: Bttf is a command line datetime Swiss army knife

#79

I'm the author of Bttf. I just wanted to share a really cool example of something that Bttf can do that I _think_ is kinda hard to do otherwise. (And also, I want to make an assertion about it and I hope this will lead to me being wrong and learning something new.) The use case is: "I want to see a list of all files in a repository, sorted in ascending order of when it was most recently changed according to source co…

> “If you run this on a big repository, it will take quite a lot of time because `git log -n1` takes a long time. I think this is the fastest way to get the most recent commit time on a single file? (That's the assertion that I hope someone can correct me on!) In any case, `bttf tag exec` is using parallelism under the hood to make this even faster.”

Instead of running `git log -n1` on every file, I think you can walk through the commits backwards, skipping any files that have been seen. Something like this (these two commands could be followed by bttf commands):

  git log --pretty=format:"DATE:%aI" --name-only |
  awk '/^DATE:/ {date=substr($0, 6); next} $0!="" && !seen[$0]++ {print date, $0}'
This seems to run much faster. The only problem is it'll include files that have been renamed or removed. I got an AI to fix that too, but it starts getting awkward (still fast though!):

  git ls-files |
  awk '
    # Read all existing files from git ls-files into an array
    NR==FNR { lsfiles[$0]; next }

    # Process the git log stream
    /^DATE:/ { date=substr($0, 6); next }
    $0!="" && ($0 in lsfiles) && !seen[$0]++ { print date, $0 }
  ' - 

Re: Bttf is a command line datetime Swiss army knife

#80

I'm the author of Bttf. I just wanted to share a really cool example of something that Bttf can do that I _think_ is kinda hard to do otherwise. (And also, I want to make an assertion about it and I hope this will lead to me being wrong and learning something new.) The use case is: "I want to see a list of all files in a repository, sorted in ascending order of when it was most recently changed according to source co…

Pretty recent Git versions have git-last-modified(1) which can list all files along with the last modified commit.
Post reply on HN