Archive:
Subtopics:
Comments disabled |
Sun, 21 Sep 2025
My new git utility `what-changed-twice` needs a new name
As I have explained in the past, my typical workflow is to go
along commiting stuff that might or might not make sense, then clean it
all up at the end, doing multiple passes with What is Fred for? I have a couple of uses for it so far. Often as I work I'll produce a chain of commits that looks like this:
It often happens that I will modify a file on Monday, modify it some more on Tuesday, correct a spelling error on Wednesday. I might have made 7 sets of changes to the main file, of which 4 are related, 2 others are related to each other but not to the other 4, and the last one is unrelated to any of the rest. When a file has changed more than once, I need to see what changed and then group the changes into related sets. The Some files changed only once, and I don't need to think about those at this stage. Later I can go back and split up those commits if it seems to make the history clearer. Fred takes the output of
It finds which files were modified in which commits, and it prints a report about any file that was modified in more than one commit:
The report is in two parts. At the top, the path of each file that
changed more than once in the log, and the (highly-abbreviated) commit
IDs of the commits in which it changed. For example,
Now I can look to see what else changed in those three commits:
then look at the changes to
and then decide if there are any changes I might like to squash together. Many other files changed on the branch, but I only have to concern myself with four. There's bonus information too. If a commit is not mentioned in the report, then it only changed files that didn't change in any other commit. That means that in a rebase, I can move that commit literally anywhere else in the sequence without creating a conflict. Only the commits in the report can cause conflicts if they are reordered. I write most things in Python these days, but this one seemed to cry out for Perl. Here's the code. Hmm, maybe I'll call it [Other articles in category /prog/git] permanent link |