Find the oldest line in your repo
milofultz.com
milofultz.com
Oldest I found?
1986-06-17: Trygve glemte å sjekke om vi deler på null. Fikset.
(Trygve forgot to check whether we divide by zero. Fixed.)
The code was on at least its 4th language by that point and is probably still running robots today.
git rev-list --reverse --date-order HEAD | head -1 # or
git rev-list --reverse --author-date-order HEAD | head -1
To see the files in that commit: git ls-tree -lr <commit-id>
To see a particular file: git show <commit-id>:/path/to/file # or
git cat-file -p <commit-id>:/path/to/file
[1] Caveat: I suppose this doesn't account for files which no longer exist or that have been completely re-written.https://git-scm.com/docs/git-rev-list
https://git-scm.com/docs/git-ls-tree
https://git-scm.com/docs/git-show
But... that's the point of this? Finding the initial commit is not nearly as fun as looking at the oldest code that is still running.
Not sure how the article's algorithm deals with renames. If a file being renamed as a deletion and addition, then that conceals the age of the lines.
It's relying on `git blame`'s default behavior which is: "The origin of lines is automatically followed across whole-file renames (currently there is no option to turn the rename-following off). To follow lines moved from one file to another, or to follow lines that were copied and pasted from another file, etc., see the -C and -M options."
for ext in $(git ls-files | grep -vE 'node_modules|\.git' | awk -F. '{if (NF>1) print $NF}' | sort -u); do echo -e "\n.$ext:"; git ls-files | grep "\.$ext$" | xargs -I {} git blame -w {} 2>/dev/null | LC_ALL=C sort -t'(' -k2 | head -n1; done
A section header in a pylintrc or Cargo.toml, a Django settings.py var, etc. Or even an import/var in a file that's core enough to still exist, import logging and LOGGER = ... for example.
sigh..
lost probably 10+ years of history
I got my hands on the old SVN but it's a few TBs and so I had some trouble unzipping it. Maybe someday I'll patch a branch for blame archeology.
find . -name '*.java' | wc -l
), I shudder to think how long that would take. For large repos, I imagine you could get quite a bit faster by only considering files created before the oldest date you've found so far. git ls-files|xargs -n 1 git blame --date=format:%Y%m%d -f |grep -Eo '\d{8}.*' |sort -r | head -n 1 | sed 's/^[^)]*) \t//'
(on MacOSX) git ls-files -z|xargs -0 -n 1 git blame --date=format:%Y%m%d -f |grep -Eo '\d{8}.*' |sort -n | head -n 1 | sed 's/^[^)]*)*[ \t]//'
This also use a null delimiter for the files and fixes a small sed pattern bug. find: illegal option -- t
usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]Huh, TIL the birthdate of my business was actually a couple of days ago.
Not surprising but not insightful at all unfortunately
https://stackoverflow.com/questions/77446305/what-are-the-be...
It is SVN, though, and not Git.