-
Notifications
You must be signed in to change notification settings - Fork 41
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
diff, show (and others) need improved understanding of commits vs paths #706
Comments
I reused the The major issue is that we don't check which paths exist when parsing filter arguments. Git does this and so the equivalent Git commands don't do things unless they are sure what you mean: Since Kart doesn't do this, if you say This bug is worse lately due to spreading to show and diff, where this behaviour is even more surprising - eg We have a lot of options for how to fix this:
|
simpler: I think it actually only looks at whether the path exists at HEAD:
ie if you want to get log of a file that's already deleted, I think you have to use So, we could do what Git does I think (option 4, but corrected to only look at the paths available in HEAD). i.e. we could attempt to parse each argument as both a revision and a filter. Parsing filters might mean looking up via dataset schemas available at HEAD. Then we can throw errors for any of:
Which would match the git behaviour AFAIK |
Don't assume things are filters just because they seem not to be revisions - they may be a revision with a typo in them. Instead, check to make sure filters are present at HEAD, and fail with an error message if we can't decide if something is a revision or a filter. Also fixes up some naming.
Improve understanding of revisions vs filters [#706]
Git can understand all of the following forms:
git diff PATH PATH
git diff COMMIT PATH PATH
git diff COMMIT COMMIT PATH PATH
git diff COMMIT...COMMIT PATH PATH
git diff -- PATH PATH
git diff COMMIT -- PATH PATH
git diff COMMIT COMMIT -- PATH PATH
git diff COMMIT...COMMIT -- PATH PATH
log, show, and commit have similar (but not identical) patterns.
Since most words eg "foo" could potentially be a reference to a commit, or a path, many of these forms are ambiguous - does the user mean
git diff COMMIT COMMIT
orgit diff PATH PATH
?Git can tell them apart using the
--
marker if it is present, or failing that, checking to see if "foo" is a reference to a commit. If "foo" is both a reference to a commit and a path, it warns the user.Kart does not have this logic, for the most part.
kart log
is the exception - it works like Git - andkart diff COMMIT PATH PATH
at least checks if the first PATH should actually be promoted to COMMIT - but in general, Kart commands don't understand the--
at all, and in general Kart commands assume that the first argument, if present, is a commit, and all subsequent commands, if present, are paths.The logic for distinguishing commits and paths should be extracted from
kart log
and generalised for use for all of these commandsThe text was updated successfully, but these errors were encountered: