Skip to content
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

fix CLI for single revisions #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

robhoes
Copy link

@robhoes robhoes commented Jan 18, 2018

The CLI unconditionally passes all argument to rev-list, even if the argument
is a single commit rather than a revision range. This causes the CLI to always
analyse the entire git history up to the given commit, rather than just that
commit.

Introduced in d601e35.


This change is Reviewable

Copy link
Owner

@aspiers aspiers left a comment

Choose a reason for hiding this comment

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

Firstly thanks a lot for the suggestion! Yes it does seem that this can be improved. I'm not 100% convinced by your exact approach here, since IIUC this would break passing in arguments like master~3 or mybranch^!. It seems that the web GUI code does an additional call to detector.get_commit to handle those, so maybe also reusing that logic is the answer? In which case, a new function should probably be refactored out in order to avoid duplicating code.

@robhoes
Copy link
Author

robhoes commented Jan 22, 2018

I appears that things like master~3 and mybranch^ still work, because they result in a single commit that is resolved by get_commit in find_dependencies.

I'm not sure about mybranch^!. It is explained (in the git-revisions man page) as specifying a range, but I believe it actually just means the commit at the head of mybranch. That doesn't work anymore (it doesn't work in the GUI either), but then you might as well just write mybranch?

To specify ranges, the current code still handles the .. and ... notations as you would expect.

I think that we want this to behave quite like git show:

  • Given a single commit, it acts on just that commit (unlike git log or git rev-list, which include the commit plus all commits that are reachable from it).
  • Given a range, it acts on all commits in the range.

I think that we could do that by first trying detector.get_commit, and if we catch InvalidCommitish, try GitUtils.rev_list.

The CLI unconditionally passes all argument to rev-list, even if the argument
is a single commit rather than a revision range. This causes the CLI to always
analyse the entire git history up to the given commit, rather than just that
commit.

Introduced in d601e35.
@aspiers
Copy link
Owner

aspiers commented Feb 11, 2018

@robhoes commented on 22 Jan 2018, 11:34 GMT:

I appears that things like master~3 and mybranch^ still work, because they result in a single commit that is resolved by get_commit in find_dependencies.

Correct.

I'm not sure about mybranch^!. It is explained (in the git-revisions man page)

I guess you mean the git-rev-parse man page here?

as specifying a range, but I believe it actually just means the commit at the head of mybranch.

Yes, that's a range containing a single commit.

That doesn't work anymore (it doesn't work in the GUI either) but then you might as well just write mybranch?

Ah, I think I see the confusion. I already changed this behaviour in 4caf25a but that's only the module branch right now, which I haven't yet gotten round to merging into master.

To specify ranges, the current code still handles the .. and ... notations as you would expect.

I think that we want this to behave quite like git show:

  • Given a single commit, it acts on just that commit (unlike git log or git rev-list, which include the commit plus all commits that are reachable from it).
  • Given a range, it acts on all commits in the range.

Yes, exactly - that's what 4caf25a does.

I think that we could do that by first trying detector.get_commit, and if we catch InvalidCommitish, try GitUtils.rev_list.

It looks like I made the odd decision to fork a git rev-list subprocess to do this, but since it was >=19 months ago, I can't remember why I did that :-/

@robhoes
Copy link
Author

robhoes commented Feb 12, 2018

@aspiers I'm not sure if you had seen my updated patch. It's quite straightforward and I believe that it does the right thing in all cases.

@aspiers
Copy link
Owner

aspiers commented Jan 20, 2019

Issue was reported in #82.

@aspiers aspiers added the UX Improving user experience label Apr 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UX Improving user experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants