replace info: rename 'full' to 'long' and clarify in-code symbols

Enum names SHORT/MEDIUM/FULL were too broad to be descriptive. And they clashed with built-in symbols on platforms like Windows. Clarify by giving them REPLACE_FORMAT_ prefix. Rename 'full' format in "git replace --format=<name>" to 'long', to match others (i.e. 'short' and 'medium'). Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Dec 28, 2013 at 12:00 UTC 663a8566beb5387530641abe71a8d8b2dafd08b3
3 files changed +18 -14
Documentation/git-replace.txt
+2 -2
@@ -72,7 +72,7 @@ OPTIONS
72
73 --format=<format>::
74 When listing, use the specified <format>, which can be one of
75 - 'short', 'medium' and 'full'. When omitted, the format
75 + 'short', 'medium' and 'long'. When omitted, the format
76 defaults to 'short'.
77
78 FORMATS
@@ -84,7 +84,7 @@ The following format are available:
84 <replaced sha1>
85 * 'medium':
86 <replaced sha1> -> <replacement sha1>
87 -* 'full'
87 +* 'long':
88 <replaced sha1> (<replaced type>) -> <replacement sha1> (<replacement type>)
89
90 CREATING REPLACEMENT OBJECTS
builtin/replace.c
+14 -10
@@ -20,11 +20,15 @@ static const char * const git_replace_usage[] = {
20 NULL
21 };
22
23 -enum repl_fmt { SHORT, MEDIUM, FULL };
23 +enum replace_format {
24 + REPLACE_FORMAT_SHORT,
25 + REPLACE_FORMAT_MEDIUM,
26 + REPLACE_FORMAT_LONG
27 +};
28
29 struct show_data {
30 const char *pattern;
27 - enum repl_fmt fmt;
31 + enum replace_format format;
32 };
33
34 static int show_reference(const char *refname, const unsigned char *sha1,
@@ -33,11 +37,11 @@ static int show_reference(const char *refname, const unsigned char *sha1,
37 struct show_data *data = cb_data;
38
39 if (!fnmatch(data->pattern, refname, 0)) {
36 - if (data->fmt == SHORT)
40 + if (data->format == REPLACE_FORMAT_SHORT)
41 printf("%s\n", refname);
38 - else if (data->fmt == MEDIUM)
42 + else if (data->format == REPLACE_FORMAT_MEDIUM)
43 printf("%s -> %s\n", refname, sha1_to_hex(sha1));
40 - else { /* data->fmt == FULL */
44 + else { /* data->format == REPLACE_FORMAT_LONG */
45 unsigned char object[20];
46 enum object_type obj_type, repl_type;
47
@@ -64,14 +68,14 @@ static int list_replace_refs(const char *pattern, const char *format)
68 data.pattern = pattern;
69
70 if (format == NULL || *format == '\0' || !strcmp(format, "short"))
67 - data.fmt = SHORT;
71 + data.format = REPLACE_FORMAT_SHORT;
72 else if (!strcmp(format, "medium"))
69 - data.fmt = MEDIUM;
70 - else if (!strcmp(format, "full"))
71 - data.fmt = FULL;
73 + data.format = REPLACE_FORMAT_MEDIUM;
74 + else if (!strcmp(format, "long"))
75 + data.format = REPLACE_FORMAT_LONG;
76 else
77 die("invalid replace format '%s'\n"
74 - "valid formats are 'short', 'medium' and 'full'\n",
78 + "valid formats are 'short', 'medium' and 'long'\n",
79 format);
80
81 for_each_replace_ref(show_reference, (void *) &data);
t/t6050-replace.sh
+2 -2
@@ -306,7 +306,7 @@ test_expect_success 'test --format medium' '
306 test_cmp expected actual
307 '
308
309 -test_expect_success 'test --format full' '
309 +test_expect_success 'test --format long' '
310 {
311 echo "$H1 (commit) -> $BLOB (blob)" &&
312 echo "$BLOB (blob) -> $REPLACED (blob)" &&
@@ -314,7 +314,7 @@ test_expect_success 'test --format full' '
314 echo "$PARA3 (commit) -> $S (commit)" &&
315 echo "$MYTAG (tag) -> $HASH1 (commit)"
316 } | sort >expected &&
317 - git replace --format=full | sort > actual &&
317 + git replace --format=long | sort > actual &&
318 test_cmp expected actual
319 '
320