git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] sha1_name: try to use same abbrev length when core.abbrevguard is specified
@ 2011-03-08 10:59 Namhyung Kim
  2011-03-08 10:59 ` [PATCH 2/2] blame: introduce -u/--unique option Namhyung Kim
  2011-03-09 19:12 ` [PATCH 1/2] sha1_name: try to use same abbrev length when core.abbrevguard is specified Junio C Hamano
  0 siblings, 2 replies; 13+ messages in thread
From: Namhyung Kim @ 2011-03-08 10:59 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

If find_unique_abbrev() finds a ambiguous SHA1 name, it tries
to find again with increased length. In this case, result hex
strings could have different lengths even though the
core.abbrevguard config option is specified. But if the option
is specified and increased length (delta) is less than its
value, the result could be adjusted to the same length.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 sha1_name.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 709ff2e..6bb8942 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -197,6 +197,7 @@ const char *find_unique_abbrev(const unsigned char *sha1, int len)
 {
 	int status, exists;
 	static char hex[41];
+	int extra_len = unique_abbrev_extra_length;
 
 	exists = has_sha1_file(sha1);
 	memcpy(hex, sha1_to_hex(sha1), 40);
@@ -208,12 +209,14 @@ const char *find_unique_abbrev(const unsigned char *sha1, int len)
 		if (exists
 		    ? !status
 		    : status == SHORT_NAME_NOT_FOUND) {
-			int cut_at = len + unique_abbrev_extra_length;
+			int cut_at = len + extra_len;
 			cut_at = (cut_at < 40) ? cut_at : 40;
 			hex[cut_at] = 0;
 			return hex;
 		}
 		len++;
+		if (extra_len > 0)
+			extra_len--;
 	}
 	return hex;
 }
-- 
1.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-03-10 19:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-08 10:59 [PATCH 1/2] sha1_name: try to use same abbrev length when core.abbrevguard is specified Namhyung Kim
2011-03-08 10:59 ` [PATCH 2/2] blame: introduce -u/--unique option Namhyung Kim
2011-03-09 19:45   ` Junio C Hamano
2011-03-10  6:13     ` Namhyung Kim
2011-03-10  9:43       ` Junio C Hamano
2011-03-10 13:58         ` Namhyung Kim
2011-03-09 19:12 ` [PATCH 1/2] sha1_name: try to use same abbrev length when core.abbrevguard is specified Junio C Hamano
2011-03-09 19:20   ` Junio C Hamano
2011-03-10  9:19     ` Re* " Junio C Hamano
2011-03-10 11:52       ` Namhyung Kim
2011-03-10 11:54         ` Namhyung Kim
2011-03-10 19:11         ` Junio C Hamano
2011-03-10  5:27   ` Namhyung Kim

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).