From 51c374e91737d66056f79f29b4b26fd95f23c1f8 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Wed, 7 Aug 2024 22:36:01 -0700 Subject: [PATCH] demo git_compat and README: repurpose the demo somewhat It is important to mention tracking branches and listing branches. This topic is important now that `jj log` does not show branches `jj git clone` says it fetched by default. The demo has become more about navigating a Git remote, so I reworded the README accordingly, shifting the focus more to "Git remote compatibility" and away from "We include a Git repo". Both are important, but these skills seem important for beginners. --- README.md | 7 ++- demos/demo_git_compat.sh | 20 ++++++- demos/git_compat.svg | 118 +++++++++++++++++++++++++-------------- 3 files changed, 100 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 3591853102..69597acf33 100644 --- a/README.md +++ b/README.md @@ -206,8 +206,11 @@ backend. The backend exists mainly to make sure that it's possible to eventually add functionality that cannot easily be added to the Git backend. The Git backend is fully featured and maintained, and allows you to use Jujutsu -as an alternative interface to Git. The commits you create will look like -regular Git commits. You can always switch back to Git. +with any Git remote. The commits you create will look like regular Git commits. +You can fetch branches from a regular Git remote and push branches to the +remote. You can always switch back to Git. + +Here is how you can explore a GitHub repository with `jj`. diff --git a/demos/demo_git_compat.sh b/demos/demo_git_compat.sh index b45e37578b..e2b328960d 100755 --- a/demos/demo_git_compat.sh +++ b/demos/demo_git_compat.sh @@ -8,10 +8,26 @@ comment "Clone a Git repo:" run_command "jj git clone https://github.com/octocat/Hello-World" run_command "cd Hello-World" -comment "Inspect it:" -run_command "jj log -r 'all()'" blank + +comment "By default, \"jj\" creates a local master branch tracking the remote master +branch. The other branches are only available as remote-tracking branches." +run_command "jj branch list --all" +comment "We can create a local branch tracking one of the remote branches we just +fetched." +run_command "jj branch track octocat-patch-1@origin" + +comment "By default, \"jj log\" excludes untracked remote branches to focus on +\"our\" commits." +run_command "jj log" + +comment "We can also ask \"jj\" to show all the commits." +run_command "jj log -r 'all()'" + +comment "We can look at the diffs of commits in the repo" run_command "jj diff -r b1" +blank +run_command "jj diff -r b3" comment "The repo is backed by the actual Git repo:" run_command "git --git-dir=.jj/repo/store/git log --graph --all --decorate --oneline" diff --git a/demos/git_compat.svg b/demos/git_compat.svg index 1e876fd48b..2767a86d4c 100644 --- a/demos/git_compat.svg +++ b/demos/git_compat.svg @@ -1,5 +1,5 @@ - + - + # Clone a Git repo: $ jj git clone https://github.com/octocat/Hello-World Fetching into new repo in "/private/var/folders/lj/rv4h95_d0mxb9ryztzpz4qph0000g -n/T/tmp.rCeLeGo5XE/Hello-World" +n/T/tmp.ExrIt6VdYc/Hello-World" branch: master@origin          [new] untracked branch: octocat-patch-1@origin [new] untracked branch: test@origin            [new] untracked Setting the revset alias "trunk()" to "master@origin" -Working copy now at: zvllqtky 715cf97c (empty) (no description set) -Parent commit      : orrkosyo 7fd1a60b master | (empty) Merge pull request #6 fr +Working copy now at: qyyypuyn 557a65b9 (empty) (no description set) +Parent commit      : orrkosyo 7fd1a60b master | (empty) Merge pull request #6 fr om Spaceghost/patch-1 Added 1 files, modified 0 files, removed 0 files $ cd Hello-World -# Inspect it: - -$ jj log -r 'all()' -@  zvllqtky jjfan@example.com 2024-09-04 19:21:07 715cf97c -│  (empty) (no description set) -│   tpstlust support+octocat@github.com 2018-05-10 10:55:19 -├─╯  octocat-patch-1@origin b1b3f972 -│    sentence case -│   kowxouwz octocat@nowhere.com 2014-06-10 15:22:26 test@origin b3cbd5bb -├─╯  Create CONTRIBUTING.md -    orrkosyo octocat@nowhere.com 2012-03-06 16:06:50 master 7fd1a60b -├─╮  (empty) Merge pull request #6 from Spaceghost/patch-1 -│   nznozkvv Johnneylee.rollins@gmail.com 2011-09-13 21:42:41 76294131 -├─╯  New line at end of file. --Signed off by Spaceghost -  syktoqts cameron@github.com 2011-01-26 12:06:08 553c2077 -│  first commit -  zzzzzzzz root() 00000000 - -$ jj diff -r b1 -Modified regular file README: -   1    1: Hello Worldworld! - -# The repo is backed by the actual Git repo: - -$ git --git-dir=.jj/repo/store/git log --graph --all --decorate --oneline -715cf97  -| * c74ad88  -| * b1b3f97 (origin/octocat-patch-1) sentence case -|/   -| * b3cbd5b (origin/test) Create CONTRIBUTING.md -|/   -*   7fd1a60 (origin/master) Merge pull request #6 from Spaceghost/patch-1 -|\   -| * 7629413 New line at end of file. --Signed off by Spaceghost -|/   -553c207 first commit + +# By default, "jj" creates a local master branch tracking the remote master +# branch. The other branches are only available as remote-tracking branches. + +$ jj branch list --all +masterorrkosyo 7fd1a60b (empty) Merge pull request #6 from Spaceghost/patch-1 +  @originorrkosyo 7fd1a60b (empty) Merge pull request #6 from Spaceghost/patch +-1 +octocat-patch-1@origintpstlust b1b3f972 sentence case +test@originkowxouwz b3cbd5bb Create CONTRIBUTING.md + +# We can create a local branch tracking one of the remote branches we just +# fetched. + +$ jj branch track octocat-patch-1@origin +Started tracking 1 remote branches. + +# By default, "jj log" excludes untracked remote branches to focus on +# "our" commits. + +$ jj log +@  qyyypuyn jjfan@example.com 2024-09-04 19:29:24 557a65b9 +│  (empty) (no description set) +│ ○  tpstlust support+octocat@github.com 2018-05-10 10:55:19 octocat-patch-1 +├─╯  b1b3f972 +│    sentence case +  orrkosyo octocat@nowhere.com 2012-03-06 16:06:50 master 7fd1a60b +│  (empty) Merge pull request #6 from Spaceghost/patch-1 +~ + +# We can also ask "jj" to show all the commits. + +$ jj log -r 'all()' +@  qyyypuyn jjfan@example.com 2024-09-04 19:29:24 557a65b9 +│  (empty) (no description set) +│ ○  tpstlust support+octocat@github.com 2018-05-10 10:55:19 octocat-patch-1 +├─╯  b1b3f972 +│    sentence case +│   kowxouwz octocat@nowhere.com 2014-06-10 15:22:26 test@origin b3cbd5bb +├─╯  Create CONTRIBUTING.md +    orrkosyo octocat@nowhere.com 2012-03-06 16:06:50 master 7fd1a60b +├─╮  (empty) Merge pull request #6 from Spaceghost/patch-1 +│   nznozkvv Johnneylee.rollins@gmail.com 2011-09-13 21:42:41 76294131 +├─╯  New line at end of file. --Signed off by Spaceghost +  syktoqts cameron@github.com 2011-01-26 12:06:08 553c2077 +│  first commit +  zzzzzzzz root() 00000000 + +# We can look at the diffs of commits in the repo + +$ jj diff -r b1 +Modified regular file README: +   1    1: Hello Worldworld! + +$ jj diff -r b3 +Added regular file CONTRIBUTING.md: +        1## Contributing + +# The repo is backed by the actual Git repo: + +$ git --git-dir=.jj/repo/store/git log --graph --all --decorate --oneline +557a65b  +| * 1ccbcd7  +| * b1b3f97 (origin/octocat-patch-1) sentence case +|/   +| * b3cbd5b (origin/test) Create CONTRIBUTING.md +|/   +*   7fd1a60 (origin/master) Merge pull request #6 from Spaceghost/patch-1 +|\   +| * 7629413 New line at end of file. --Signed off by Spaceghost +|/   +553c207 first commit