summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2013-09-07 09:18:44 -0700
committerVicent Martí <vicent@github.com>2013-09-07 09:18:44 -0700
commitae49719a3bb25eef1efa13b9fb274057c057abde (patch)
tree480a5963d920cee022ca4eb0c195edc3887f5a3c /src
parent32e49929725a76d9871038f30e2ea67fe0e4a4f8 (diff)
parent1634df8c287da5acbe017ac786e2bb9fcd723eaa (diff)
downloadlibgit2-ae49719a3bb25eef1efa13b9fb274057c057abde.tar.gz
Merge pull request #1835 from libgit2/ntk/fix/less_backend_calls_on_revparsing
Some revparse love
Diffstat (limited to 'src')
-rw-r--r--src/revparse.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/revparse.c b/src/revparse.c
index 329b96dbc..3dde22ce1 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -93,11 +93,7 @@ static int revparse_lookup_object(
int error;
git_reference *ref;
- error = maybe_sha(object_out, repo, spec);
- if (!error)
- return 0;
-
- if (error < 0 && error != GIT_ENOTFOUND)
+ if ((error = maybe_sha(object_out, repo, spec)) != GIT_ENOTFOUND)
return error;
error = git_reference_dwim(&ref, repo, spec);
@@ -112,21 +108,14 @@ static int revparse_lookup_object(
return error;
}
- if (error < 0 && error != GIT_ENOTFOUND)
+ if (error != GIT_ENOTFOUND)
return error;
- error = maybe_abbrev(object_out, repo, spec);
- if (!error)
- return 0;
-
- if (error < 0 && error != GIT_ENOTFOUND)
- return error;
-
- error = maybe_describe(object_out, repo, spec);
- if (!error)
- return 0;
+ if ((strlen(spec) < GIT_OID_HEXSZ) &&
+ ((error = maybe_abbrev(object_out, repo, spec)) != GIT_ENOTFOUND))
+ return error;
- if (error < 0 && error != GIT_ENOTFOUND)
+ if ((error = maybe_describe(object_out, repo, spec)) != GIT_ENOTFOUND)
return error;
giterr_set(GITERR_REFERENCE, "Revspec '%s' not found.", spec);