jubobs / gitdags

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

How to visualize a more complex merge case? #9

Open szelpe opened 7 years ago

szelpe commented 7 years ago

Hi! I'd like to achieve the following diagram:

image

I marked the missing part with purple. Could you please help me extend the code below to reach my desired state?

\documentclass{article}

\usepackage{subcaption}
\usepackage{gitdags}

\begin{document}

\begin{figure}

  \begin{subfigure}[b]{\textwidth}
    \centering
    \begin{tikzpicture}
      % Commit DAG
      \gitDAG[grow right sep = 2em]{
        9189e99 -- {
         {
            {
              { 4ad9fb3 [fill=solarized-blue!20] -- b87d53c [fill=solarized-red!20] },
              { 3ad5ed5 },
            } --  3a45f5,
          } -- a89feb -- 6d8b67,
          { a37d92c [fill=solarized-red!20] -- 2bd8ea3 [fill=solarized-red!20] },
        } -- 589af1
      };
      % Branch
      \gitbranch
        {master}     % node name and text 
        {above=of 3a45f5} % node placement
        {3a45f5}          % target
      % Remote branch
      \gitremotebranch
        [origmaster]    % node name
        {origin/master} % node text
        {above=of 4ad9fb3}    % node placement
        {4ad9fb3}             % target
      % Remote branch
      \gitremotebranch
        [origfeature1]    % node name
        {origin/feature/commonName} % node text
        {above=of 589af1}    % node placement
        {589af1}             % target
      % HEAD reference
      \gitHEAD
        {above=of master} % node placement
        {master}          % target
    \end{tikzpicture}
    \subcaption{After rebase}
  \end{subfigure}

  \caption{Demonstrating a typical \texttt{rebase}}
\end{figure}

\end{document}

Thanks for your help.

othree commented 7 years ago

How about this

\documentclass{article}

\usepackage{subcaption}
\usepackage{gitdags}

\begin{document}

\begin{figure}

  \begin{subfigure}[b]{\textwidth}
    \centering
    \begin{tikzpicture}
      % Commit DAG
      \gitDAG[grow right sep = 2em]{
        9189e99 -- {
         {
            {
              { 4ad9fb3 [fill=solarized-blue!20] -- b87d53c [fill=solarized-red!20] -- a89feb },
              { 3ad5ed5 -- THIS },
            } --  3a45f5,
          } -- 6d8b67,
          { a37d92c [fill=solarized-red!20] -- 2bd8ea3 [fill=solarized-red!20] },
        } -- 589af1,
        3ad5ed5 -- 3a45f5
      };
      % Branch
      \gitbranch
        {master}     % node name and text 
        {above=of 3a45f5} % node placement
        {3a45f5}          % target
      % Remote branch
      \gitremotebranch
        [origmaster]    % node name
        {origin/master} % node text
        {above=of 4ad9fb3}    % node placement
        {4ad9fb3}             % target
      % Remote branch
      \gitremotebranch
        [origfeature1]    % node name
        {origin/feature/commonName} % node text
        {above=of 589af1}    % node placement
        {589af1}             % target
      % HEAD reference
      \gitHEAD
        {above=of master} % node placement
        {master}          % target
    \end{tikzpicture}
    \subcaption{After rebase}
  \end{subfigure}

  \caption{Demonstrating a typical \texttt{rebase}}
\end{figure}

\end{document}