commit - 3f9de99f9b4d3da34a06dfce54134ff891684df9
commit + 30837e32b8c05d75e429f5587a658d6df7ddfda8
blob - 59507d1863a1ad983bf5f3e0811d54e3c511f8f5
blob + 6bfe01e0cf9d122e717e568966eb3ac3f555b1f9
--- got/got.1
+++ got/got.1
.It Fl c Ar commit
Check out files from the specified
.Ar commit .
-The expected argument is a commit ID SHA1 hash.
+The expected argument is a commit ID SHA1 hash or an existing reference
+which will be resolved to a commit ID.
An abbreviated hash argument will be expanded to a full SHA1 hash
automatically, provided the abbreviation is unique.
If this option is not specified, the most recent commit on the selected
.It Fl c Ar commit
Update the work tree to the specified
.Ar commit .
-The expected argument is a commit ID SHA1 hash.
+The expected argument is a commit ID SHA1 hash or an existing reference
+which will be resolved to a commit ID.
An abbreviated hash argument will be expanded to a full SHA1 hash
automatically, provided the abbreviation is unique.
If this option is not specified, the most recent commit on the work tree's
.It Fl c Ar commit
Start traversing history at the specified
.Ar commit .
-The expected argument is the name of a branch or a commit ID SHA1 hash.
+The expected argument is a commit ID SHA1 hash or an existing reference
+which will be resolved to a commit ID.
An abbreviated hash argument will be expanded to a full SHA1 hash
automatically, provided the abbreviation is unique.
If this option is not specified, default to the work tree's current branch
.It Fl c Ar commit
Start traversing history at the specified
.Ar commit .
-The expected argument is the name of a branch or a commit ID SHA1 hash.
+The expected argument is a commit ID SHA1 hash or an existing reference
+which will be resolved to a commit ID.
An abbreviated hash argument will be expanded to a full SHA1 hash
automatically, provided the abbreviation is unique.
.It Fl r Ar repository-path
.It Fl c Ar commit
List files and directories as they appear in the specified
.Ar commit .
-The expected argument is the name of a branch or a commit ID SHA1 hash.
+The expected argument is a commit ID SHA1 hash or an existing reference
+which will be resolved to a commit ID.
An abbreviated hash argument will be expanded to a full SHA1 hash
automatically, provided the abbreviation is unique.
.It Fl r Ar repository-path
blob - b5341e17acdb3b81c77d3cce58a2ab5c6c010c6c
blob + a16ed7b70ecc012e088c02a4df0d6f13e4e268a6
--- got/got.c
+++ got/got.c
}
if (commit_id_str) {
- struct got_object_id *commit_id;
- error = got_repo_match_object_id_prefix(&commit_id,
- commit_id_str, GOT_OBJ_TYPE_COMMIT, repo);
- if (error != NULL)
+ struct got_object_id *commit_id = NULL;
+ struct got_reference *ref;
+ error = got_ref_open(&ref, repo, commit_id_str, 0);
+ if (error == NULL) {
+ error = got_ref_resolve(&commit_id, repo, ref);
+ got_ref_close(ref);
+ } else {
+ if (error->code != GOT_ERR_NOT_REF)
+ goto done;
+ error = got_repo_match_object_id_prefix(&commit_id,
+ commit_id_str, GOT_OBJ_TYPE_COMMIT, repo);
+ }
+ if (error)
goto done;
error = check_linear_ancestry(commit_id,
got_worktree_get_base_commit_id(worktree), repo);
if (error != NULL)
goto done;
} else {
- error = got_repo_match_object_id_prefix(&commit_id,
- commit_id_str, GOT_OBJ_TYPE_COMMIT, repo);
- if (error != NULL)
+ struct got_reference *ref;
+ error = got_ref_open(&ref, repo, commit_id_str, 0);
+ if (error == NULL) {
+ error = got_ref_resolve(&commit_id, repo, ref);
+ got_ref_close(ref);
+ }
+ else {
+ if (error->code != GOT_ERR_NOT_REF)
+ goto done;
+ error = got_repo_match_object_id_prefix(&commit_id,
+ commit_id_str, GOT_OBJ_TYPE_COMMIT, repo);
+ }
+ if (error)
goto done;
free(commit_id_str);
error = got_object_id_str(&commit_id_str, commit_id);
if (error != NULL)
goto done;
} else {
- error = got_repo_match_object_id_prefix(&commit_id,
- commit_id_str, GOT_OBJ_TYPE_COMMIT, repo);
- if (error != NULL)
+ struct got_reference *ref;
+ error = got_ref_open(&ref, repo, commit_id_str, 0);
+ if (error == NULL) {
+ error = got_ref_resolve(&commit_id, repo, ref);
+ got_ref_close(ref);
+ } else {
+ if (error->code != GOT_ERR_NOT_REF)
+ goto done;
+ error = got_repo_match_object_id_prefix(&commit_id,
+ commit_id_str, GOT_OBJ_TYPE_COMMIT, repo);
+ }
+ if (error)
goto done;
}
if (error != NULL)
goto done;
} else {
- error = got_repo_match_object_id_prefix(&commit_id,
- commit_id_str, GOT_OBJ_TYPE_COMMIT, repo);
- if (error != NULL)
+ struct got_reference *ref;
+ error = got_ref_open(&ref, repo, commit_id_str, 0);
+ if (error == NULL) {
+ error = got_ref_resolve(&commit_id, repo, ref);
+ got_ref_close(ref);
+ } else {
+ if (error->code != GOT_ERR_NOT_REF)
+ goto done;
+ error = got_repo_match_object_id_prefix(&commit_id,
+ commit_id_str, GOT_OBJ_TYPE_COMMIT, repo);
+ }
+ if (error)
goto done;
}