tj / tj/git-extras

git-browse doesn't check if a commit exists on upstream

Open
#1,153 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pull request is welcome
Dominant language
Shell
Stars
18.1k
Forks
1.2k
Avg merge
5d 17h
Merged PRs (30d)
1

Description

When using git-browse to generate a web link to a repo, it constructs a URL based on the commit at the HEAD of the local repo, but doesn't actually check if this HEAD exists on the remote. This means that if I have a local commit that I've yet to push, and I run git-browse, it will fail because the remote end doesn't know about the commit the URL references.

Ideally, we should test whether the commit exists upstream first, using:

git branch --remotes --contains "${commit_or_branch}" 2>/dev/null | grep -q "\<${remote}\>/"

Which will exit non-zero if there's no remote ref for this commit. We could then display an error to the user.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the git-browse entry point and trace how it builds a URL from the local HEAD commit. Check the proposed git branch --remotes --contains command against the selected remote, then verify that an unpushed commit produces a clear error instead of an unusable link.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, shell
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.