-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FR: jj diff --remote
#4756
Comments
I feel |
Landed here searching for "how to diff jj remote changes" I'm trying to replicate my old git flow, and when using git I got into the habit of always doing a This is even more relevant for me with |
I ran into this yesterday and came up with a goofy workaround. I'm sure there's a way to clean it up, and I'm sure there are lots of edge cases around, e.g., multiple bookmarks between function curr_bookmark { jj bookmark list --tracked -r 'trunk()..@' -T 'name++"\n"' | head -1 }
alias jdr='jj diff -f "$(curr_bookmark)@origin"' |
Since jj doesn't have a "currently-checked-out branch" (yet?), there's fundamentally no way to ask "what is the current branch" so that you can compare it to its remote counterpart. I think @david-crespo's solution above is the best you can do for now, where you have to heuristically determine what branch you're on. |
What you think about |
The point is to not have to figure out and type the bookmark name. |
Wrote a script to cover the case of "diff from my local commit to corresponding commit on remote". #!/usr/bin/env bash
set -eu -o pipefail
target=$1
# todo: configurable stream head
bookmark_names=$(jj log --no-graph -r 'heads(::@ & bookmarks())' -T 'local_bookmarks.map(|l| l.name()).join(" ")')
IFS=" " read -ra bookmarks <<<"$bookmark_names"
# todo: error message
[ ${#bookmarks[@]} -eq 1 ] || exit 1
bookmark=${bookmarks[0]}
all_refs=$(jj evolog --no-graph -T 'commit_id ++ "|"' -r "$target")
# todo: configurable remote
remote=$(jj log --no-graph -T 'commit_id' -n 1 -r "($all_refs none()) & ::$bookmark@origin")
jj diff --from "$remote" --to "$target" It gets somewhat confused if you split a commit, and you might want to use |
I'm was working on a PR to try to fix this. I followed @yuja comment and created a I wrote most of the code a while ago, but didn't get around to finish it due to university and work, but now that I see that more people would like to have this issue fixed, I might have the will to finish it. |
This can be used to find the remote bookmark tracked by a revset. It can be useful for diffing with the remote: `jj diff --from remote(@) --to @` Fixes: jj-vcs#4756
This can be used to find the remote bookmark tracked by a revset. It can be useful for diffing with the remote: `jj diff --from remote(@) --to @` Fixes: jj-vcs#4756
Is your feature request related to a problem? Please describe.
Sometimes I change my local branch and I want to see what changed on the remote before pushing. Currently, I've being doing
jj diff --from <bookmark-name>@<remote> --to <bookmark-name>
. I would find it much easier if I don't need to remember the bookmark name and type it twice.Describe the solution you'd like
I think that a new flag called
--remote
could solve this. If the head is on a tracked bookmark, it would diff the remote with the local.Describe alternatives you've considered
Maybe this could be solved with new revsets functions? Maybe a
bookmark_name()
to return the bookmark name of a revision, so you could use withremote_branches()
.The text was updated successfully, but these errors were encountered: