Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> I date them all. I have a Yasnippet for all the above, which expands "todo" into "TODO: $ -- My Name, 2019-12-30", $ being where the caret stops after expansion. Same for "fixme", "hack" and "note".

why is that necessary ? git blame gives it to you already



Because running git blame on code breaks the flow. Because git blame may give you wrong author and date (say someone edited the code around the note, changing its indentation level; EDIT: or rebased it, as 'daemin says). Because git blame is not a grep-friendly solution. Because code sometimes lives longer than version control systems (I've worked with codebases older than git). Because very often code lives longer than the repo it originated in, so you can easily lose history (many new projects get started by copy-pasting pieces of a previous project).


I agree with all your other points but I want to point out that if `git blame` breaks your flow I recommend that you look up how to better integrate git with your code editor, it's a huge time saver IMO. With vim-fugitive I can just ":Gblame" on any code I'm currently browsing and immediately I get a side-pane with the annotations for every line. ":Gdiffsplit" shows me the diff between my version and HEAD etc...

But beyond that I agree completely, `git blame` is not the right way to track the authorship of annotations in a file.


It's C-x M-g b in my Emacs, but doing this annotates the whole file, which gets distracting enough for this particular purpose. Still, I use it frequently.


You can rewrite the git history when you squash commits for example.

One case I've heard is that some people no longer have their names on git commits they made to various Google open source projects because their commit went inside, where it was rebased, merged, integrated, squashed, and then what the public sees is a single git commit by a Google insider that is the result of thousands of individual commits.


This is a beautiful example of the general case «why don’t you just use X tool that was designed for this?» but can’t because someone made a decision that makes X tool unusable.


Workflows are full of trade offs. Different people & teams value different features in different ways. It’s what makes software development such a vibrant ecosystem.


I don't understand the need to rewrite history. This is a good example against that practice.


Because it becomes more compact. Most of the time git commits are things that don’t make sense to have at a more macro level. Squashing into a single commit that represents a coherent improvement, particularly for large projects, is the best way to read its history.


I prefer a small branch with many individual commits (cleaned from fixups or not) and a merge with main branch which adds the whole feature. Then you can have two levels of reading.


Doesn't this still put all the commits on the main branch?


You can keep the branch commits for detailed history, and look only at merge commits the when you don't need details:

     git log --first-parent -m
This will show a linear history of merges, treating the merged code as being added in the merge commit. You can add -p to see the diffs.


No you commit in feature branches then merge to main branch.


Do you then keep the branch around forever?


The branch history is preserved in the commit graph of the main branch, so you don't need to keep the feature branch.


But then does it matter at all that the date of the comment was the day where you committed the todo, or two days after when you squashed it ?


At least these days co-authorship can be recorded in the commits.


That’s just conflating GitHub support of these tags with git. Similar "Signed-off-by" tags are in use by Linux kernel pretty much since forever.


But then cherrypicking doesn;t preserve commit metadata, does it?


There are many contexts where blame info is not visible by default: dumb editors, code review browsers, search results, etc. It's a low-effort signaling about the age of TODO as well as whether the person who left it is still around.

It's a similar reason for why you sometimes leave implementation comments in the code, not in git commit messages.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: