Skip to content

git fetch: add --verbose flag to show abandoned commit details#8571

Merged
sjawhar merged 1 commit intojj-vcs:mainfrom
sjawhar:git-fetch-verbose
Jan 17, 2026
Merged

git fetch: add --verbose flag to show abandoned commit details#8571
sjawhar merged 1 commit intojj-vcs:mainfrom
sjawhar:git-fetch-verbose

Conversation

@sjawhar
Copy link
Copy Markdown
Contributor

@sjawhar sjawhar commented Jan 10, 2026

Summary

Closes #3081

Abandoned commits are now shown with their change IDs and descriptions when fetching, matching the jj abandon output format.

Example output:

bookmark: main@origin [updated] tracked
Abandoned 2 commits that are no longer reachable:
  qpvuntsm 12345678 local work that was rebased
  kkmpptxz 87654321 another local commit

Changes

  • Abandoned commit details are now shown by default (limited to 10 commits)
  • Uses print_updated_commits() with commit_summary_template() for consistent formatting
  • When --quiet is specified, no abandoned commit information is shown

Test Plan

  • All 40 git fetch tests pass
  • Verified --quiet suppresses output
  • Clippy passes

@sjawhar sjawhar requested a review from a team as a code owner January 10, 2026 19:18
@google-cla
Copy link
Copy Markdown

google-cla bot commented Jan 10, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Copy Markdown
Contributor

@PhilipMetzger PhilipMetzger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the pluralization again, also I don't think that you can attribute the authorship to Claude since that will fail the CLA check.

Also the project has no AI policy yet, but it'd be helpful to know if you understand the code change you submitted.

Comment thread cli/src/git_util.rs Outdated
@joyously
Copy link
Copy Markdown

What does it do when the global --quiet flag is also present?

Comment thread cli/src/commands/git/fetch.rs Outdated
Copy link
Copy Markdown
Contributor Author

@sjawhar sjawhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed the code but I'm new to this project, so I won't claim to know all the implications downstream. 😅

@sjawhar
Copy link
Copy Markdown
Contributor Author

sjawhar commented Jan 11, 2026

When --quiet is specified, no abandoned commit information is shown (neither the count nor the details). The code checks ui.status_formatter() which returns None in quiet mode.

Copy link
Copy Markdown
Contributor

@PhilipMetzger PhilipMetzger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, thanks for your contribution. You need Yuya's approval though.

Comment thread cli/src/commands/git/fetch.rs Outdated
Comment thread cli/src/commands/git/fetch.rs Outdated
@sjawhar
Copy link
Copy Markdown
Contributor Author

sjawhar commented Jan 12, 2026

Done! Thanks for the quick review.

Comment thread cli/src/commands/git/fetch.rs Outdated
@sjawhar
Copy link
Copy Markdown
Contributor Author

sjawhar commented Jan 13, 2026

Sorry, still getting the hang of things 😅

Comment thread cli/src/git_util.rs
@sjawhar
Copy link
Copy Markdown
Contributor Author

sjawhar commented Jan 14, 2026

Restored the detailed: bool parameter as requested. The signature is now:

pub fn print_git_import_stats(
    ui: &Ui,
    tx: Option<&WorkspaceCommandTransaction<'_>>,
    stats: &GitImportStats,
    detailed: bool,
)

Call sites are now clearer:

  • print_git_import_stats(ui, Some(&tx), &stats, true)?; for detailed output
  • print_git_import_stats(ui, None, &stats, false)?; for summary only

Comment thread cli/src/git_util.rs Outdated
@sjawhar sjawhar force-pushed the git-fetch-verbose branch 2 times, most recently from eb75996 to ca7d8af Compare January 14, 2026 09:55
@sjawhar sjawhar requested a review from yuja January 14, 2026 12:51
@sjawhar
Copy link
Copy Markdown
Contributor Author

sjawhar commented Jan 14, 2026

Oops, sorry, I clicked request re-review but haven't fully done a self-review yet. Sorry for all the back and forth, but thank you for helping me get my bearing. I love jj!!

Comment thread cli/src/git_util.rs Outdated
Comment thread cli/src/git_util.rs Outdated
Comment thread cli/tests/test_git_fetch.rs Outdated
@sjawhar sjawhar force-pushed the git-fetch-verbose branch 2 times, most recently from 1e6ac3d to 5dfa3d0 Compare January 14, 2026 14:32
@sjawhar
Copy link
Copy Markdown
Contributor Author

sjawhar commented Jan 14, 2026

Done! I removed the test.

I'm curious - how do you think about when a new test is needed vs. when existing test coverage is sufficient? I initially added the test because it felt like a "new behavior" that deserved explicit coverage, but I can see now that the existing tests already exercise the same code path and verify the output.

Would love any tips on developing better intuition for this - trying to make future contributions smoother! 😅

@martinvonz
Copy link
Copy Markdown
Member

Nit: Please move (or copy) most of the PR description to the commit description so the information is available to anyone looking at the commit in the future (including if we move the repo off of GitHub)

@martinvonz
Copy link
Copy Markdown
Member

I'm curious - how do you think about when a new test is needed vs. when existing test coverage is sufficient?

As Yuya said, it's not needed because it's covered by existing tests. That means that if we have a regression in this code, we will notice it because those tests will fail. However, it's important that the tests don't just happen to test this functionality, because then the test might change in the future to no longer test this code. In this case, there are several tests that cover, and in particular the test_git_fetch_removed_bookmark() seems likely to always involve abandoning some commits, so I'm not worried that we will lose the testing.

Closes jj-vcs#3081

Abandoned commits are now shown with their change IDs and descriptions when
fetching, matching the `jj abandon` output format.

Example output:
  bookmark: main@origin [updated] tracked
  Abandoned 2 commits that are no longer reachable:
    qpvuntsm 12345678 local work that was rebased
    kkmpptxz 87654321 another local commit

Changes:
- Split print_git_import_stats() into two functions:
  - print_git_import_stats(ui, tx, stats) - detailed version with commit summaries
  - print_git_import_stats_summary(ui, stats) - summary only (for init/auto-import)
- Abandoned commit details shown by default (limited to 10 commits)
- Uses print_updated_commits() with commit_summary_template() for consistent formatting
- Failed refs are always shown, even in quiet mode (bug fix)
@sjawhar sjawhar enabled auto-merge January 17, 2026 04:22
@sjawhar sjawhar added this pull request to the merge queue Jan 17, 2026
Merged via the queue into jj-vcs:main with commit 675b34a Jan 17, 2026
29 checks passed
@sjawhar sjawhar deleted the git-fetch-verbose branch January 17, 2026 05:02
@magistau magistau mentioned this pull request Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR: Add a verbose option to jj git fetch, (jj git fetch --verbose)

5 participants