0

The problem is that I have this git command

git log --pretty=format:'%n{%n%d%n  "CommitHash": "%H",%n  "Author": 
    "%an",%n  "AuthorEmail": "%ae",%n  "Date": "%ad",%n  "Message": "%f"%n}'

` with it, I get a log with a JSON format, but I need to get the branches as fathers and the commits names as children, and those commits names must be fathers they respective info(author, date, email, etc.....)

The log output should be something like this:

[
  "Branch or Merge Name":"The Branch or Merge Name"[
       "Commit Name":"The Commit Name"{
               The commit info......
          }
   ]
]
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
Simpson G.
  • 111
  • 8

2 Answers2

1

I doubt this would be easy to do without a script, considering a commit can be part of multiple branches.

That means for any commit of your list, there is not "one father", but possibly multiple ones.

Reversing the model, and having for each commit, as a child, the list of branches each commit is part of, would make more sense.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • What I'm trying to do is a graph So I was thinking get a json file and go through it with a for loop and then use gitgraphjs.com to make an actual graph – Simpson G. Jul 19 '18 at 04:54
  • 1
    @SimpsonG. Agreed. I am merely suggested the initial hierarchy might not be the right one. – VonC Jul 19 '18 at 04:54
  • @SimpsonG. The one I mentioned in the answer: commits, and as children, the branches. – VonC Jul 19 '18 at 04:58
1

Look at this tool http://bit-booster.com/graph.html they pass the log to you in git format log --pretty = '% h |% p |% d' I'm trying to do apache echart. --pretty = "% H,% P,% D"

% H expands to show the commitId.

% P expands to show the parent commitIds.

% D expands to show the decorations (tags and branches).

But there are a few subtle problems with it:

% P will expand to all of% H's parent commits (separated by space), and so you'll need to run the output through a 2nd script to better normalize that into a format suitable for D3.

% P might expand to 3 or more commits (very rare). These are called octopus merges!

% D expands to a comma separated list of decorations (branch and tag labels), and there's no limit on how many branches and tags a single commit might have.