jubobs / gitdags

A package for drawing educational Git history graphs
218 stars 29 forks source link

finer control of node placement #4

Open DrVanScott opened 9 years ago

DrVanScott commented 9 years ago

I wonder if there is a possibility to have more control in the placement of commit nodes. For an example please have a look at one of your images:

Alt Text

The two graphs in the bottom line are ment to clarify the difference between merge dev->master and merge master->dev. While the graphs are correct, the bottom-right graph would be more intuitive, if commit F' would be aligned right to E (and not to D).

Well, even if you don't agree with my opinion: Is it possible to generate the graph like this?

A <- B <- D             <- master
  \         \
     C <- E <- F'       <- dev
jubobs commented 9 years ago

I can understand why this would be more pleasing and less confusing. You can achieve the desired placement by inserting the node corresponding to the merge commit in the second group, rather than in the first one, like so:

screenshot

\documentclass{article}

\usepackage{gitdags}

\begin{document}

  % Original placement
  \begin{tikzpicture}
    \gitDAG[grow right sep = 2em]{
      A -- {
        B -- D -- F',
        C -- E -- F'
      }
    };
    \gitbranch
      {master}
      {above=of D}
      {D}
    \gitbranch
      {dev}
      {below=of F'}
      {F'}
    \gitHEAD
      {below=of dev}
      {dev}
  \end{tikzpicture}

\vspace{1em}

  % Improved placement
  \begin{tikzpicture}
    \gitDAG[grow right sep = 2em]{
      A -- {
        B -- D,
        C -- E -- F' % <--- insert F' in the second group of nodes
      },
      D -- F' %<--- then connect D to F'
    };
    \gitbranch
      {master}
      {above=of D}
      {D}
    \gitbranch
      {dev}
      {below=of F'}
      {F'}
    \gitHEAD
      {below=of dev}
      {dev}
  \end{tikzpicture}

\end{document}
DrVanScott commented 9 years ago

Thanks a lot. Do you have an idea how to render

    E - F
  /
A - B - C

EDIT:

i managed to render the following graph:

X   E - F
  /
A - B - C

So, making X invisible could be one solution. But how to do?