From: Han-Wen Nienhuys <hanwen@xs4all.nl>
To: git@vger.kernel.org
Subject: [PATCH] sanitize --abbrev option for describe
Date: Thu, 02 Nov 2006 02:15:30 +0100 [thread overview]
Message-ID: <eibgqu$rsh$1@sea.gmane.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 289 bytes --]
Hi,
the --abbrev option doesn't allow a 40 digit SHA1 output.
The following patch fixes this, and uses a IMHO more logical way to
compute the abbrev parameter, so --abbrev=52 will still yield a 40 digit
SHA1.
--
Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen
[-- Attachment #2: ps --]
[-- Type: text/plain, Size: 1059 bytes --]
commit 62ab49fb3a050cb2a4c96fa0ab8064742544369b
Author: Han-Wen Nienhuys <hanwen@lilypond.org>
Date: Thu Nov 2 02:12:11 2006 +0100
use constant variable for storing "--abbrev=". Use 40 and
MINIMUM_ABBREV as bounds for --abbrev= argument.
diff --git a/describe.c b/describe.c
index ab192f8..973520c 100644
--- a/describe.c
+++ b/describe.c
@@ -141,6 +141,7 @@ static void describe(const char *arg, in
int main(int argc, char **argv)
{
+ char const *abbrev_option = "--abbrev=";
int i;
for (i = 1; i < argc; i++) {
@@ -152,10 +153,10 @@ int main(int argc, char **argv)
all = 1;
else if (!strcmp(arg, "--tags"))
tags = 1;
- else if (!strncmp(arg, "--abbrev=", 9)) {
- abbrev = strtoul(arg + 9, NULL, 10);
- if (abbrev < MINIMUM_ABBREV || 40 < abbrev)
- abbrev = DEFAULT_ABBREV;
+ else if (!strncmp(arg, abbrev_option, strlen (abbrev_option))) {
+ abbrev = strtoul(arg + strlen (abbrev_option), NULL, 10);
+ abbrev = MAX(MINIMUM_ABBREV, abbrev);
+ abbrev = MIN(40, abbrev);
}
else
usage(describe_usage);
reply other threads:[~2006-11-02 1:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='eibgqu$rsh$1@sea.gmane.org' \
--to=hanwen@xs4all.nl \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).