Zac
Zac

Reputation: 2081

git log what does ".../{ => Folder}/..." mean?

I was looking at a git log of a heavy branch-coordinated repo ( lots of merging and branching ) and when I ran my handy git log alias: git log --stat --pretty=short --graph

I see this weird syntax:

| | |  application/client/app/Admin/Templates/index.tsx                            |   2 +-
| | |  application/client/app/Awards/Templates/Create.tsx                          | 126 ++++++++++++++++++++++++++++++++++++++++++++++++

# here
| | |  application/client/app/Awards/{ => Templates}/Templates.scss                |   0
| | |  application/client/app/Awards/{ => Templates}/Templates.tsx                 |  12 ++---

| | |  application/client/app/components/DataTable/IndeterminateCheckbox/index.tsx |  10 ++--
| | |  application/client/app/components/DataTable/index.tsx                       | 258 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------
| | |  application/client/app/components/DataTable/styles.scss                     |  96 +++++++++++++++++++++++++++++++------
| | |  application/client/app/components/DropDownMenu/DropDownMenu.scss            |  26 +++++-----
| | |  application/client/app/components/DropDownMenu/index.tsx                    |  56 +++++++++++-----------
| | |  application/client/app/components/Header/Header.scss                        |  13 +++--
| | |  application/client/app/components/Header/index.tsx                          |  65 ++++++++++++++-----------
| | |  application/client/app/components/Inputs/Inputs.scss                        |  74 ++++++++++++++++++----------
| | |  application/client/app/components/Inputs/index.tsx                          |  58 +++++++++++++---------

The git diff isn't any help, I think it's a sub folder replace? Not sure.

any ideas?

Upvotes: 0

Views: 26

Answers (1)

torek
torek

Reputation: 488519

This is actually from git diff --stat, which the --stat option to git log --stat invokes.

The git diff isn't any help, I think it's a sub folder replace? Not sure.

The output you are looking at is from git diff (as built into git log), and you're correct. This is a shorthand way of showing folder (directory) name changes when summarizing the difference between some commit L (placed on the left) and some other commit R (placed on the right). Since git log is comparing a parent-and-child commit pair, the L (left-side) commit is the parent—the old commit that comes just before the child—and the R (right-side) commit is the child that comes just after that parent. Git was able to match up a file named:

application/client/app/Awards/Templates.scss

in the L commit against one named:

application/client/app/Awards/Templates/Templates.scss

in the R commit.

Note that you can run:

git diff --stat <left-side-commit-ID> <right-side-commit-ID>

yourself, to get the same kind of output; in this case you can pick any two commits you like. Let's say some very old commit has hash ID a123456 and some recent commit has hash ID 07fbdad. Then:

git diff --stat a123456 07fbdad

will show you this kind of summary of what it takes to change the contents of a123456 to match the contents of 07fbdad. This works because each commit has a full and complete snapshot of every file that Git knew about at the time you, or whoever, made the commit.

For commits before the left-side one (e.g., the parent of the parent), the file is likely to have the older name. For commits after it, the file is likely to have the newer name.

(In a sense, Git doesn't really have folders at all. The files are just stored with very long names that include embedded slashes. But Git knows that your operating system requires that these be treated as folder-and-file names, i.e., a series of slash-separated name components, so it tries to accommodate that, even though Git has a more flexible internal file naming system.)

Upvotes: 2

Related Questions