Skip to content

Commit 9994cd3

Browse files
committed
treewide: remove use of C++ style comments
C++ style comment ("//") are not specified by the ISO C90 standard and thus do not conform to it. While libgit2 aims to conform to C90, we did not enforce it until now, which is why quite a lot of these non-conforming comments have snuck into our codebase. Do a tree-wide conversion of all C++ style comments to the supported C style comments to allow us enforcing strict C90 compliance in a later commit.
1 parent f347a44 commit 9994cd3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+191
-182
lines changed

examples/general.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,13 @@ static void oid_parsing(git_oid *oid)
145145
*/
146146
git_oid_fromstr(oid, hex);
147147

148-
// Once we've converted the string into the oid value, we can get the raw
149-
// value of the SHA by accessing `oid.id`
150-
151-
// Next we will convert the 20 byte raw SHA1 value to a human readable 40
152-
// char hex value.
148+
/*
149+
* Once we've converted the string into the oid value, we can get the raw
150+
* value of the SHA by accessing `oid.id`
151+
*
152+
* Next we will convert the 20 byte raw SHA1 value to a human readable 40
153+
* char hex value.
154+
*/
153155
printf("\n*Raw to Hex*\n");
154156
out[GIT_OID_HEXSZ] = '\0';
155157

examples/network/clone.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void print_progress(const progress_data *pd)
4848

4949
static int sideband_progress(const char *str, int len, void *payload)
5050
{
51-
(void)payload; // unused
51+
(void)payload; /* unused */
5252

5353
printf("remote: %.*s", len, str);
5454
fflush(stdout);
@@ -82,15 +82,15 @@ int do_clone(git_repository *repo, int argc, char **argv)
8282
const char *path = argv[2];
8383
int error;
8484

85-
(void)repo; // unused
85+
(void)repo; /* unused */
8686

87-
// Validate args
87+
/* Validate args */
8888
if (argc < 3) {
8989
printf ("USAGE: %s <url> <path>\n", argv[0]);
9090
return -1;
9191
}
9292

93-
// Set up options
93+
/* Set up options */
9494
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
9595
checkout_opts.progress_cb = checkout_progress;
9696
checkout_opts.progress_payload = &pd;
@@ -100,7 +100,7 @@ int do_clone(git_repository *repo, int argc, char **argv)
100100
clone_opts.fetch_opts.callbacks.credentials = cred_acquire_cb;
101101
clone_opts.fetch_opts.callbacks.payload = &pd;
102102

103-
// Do the clone
103+
/* Do the clone */
104104
error = git_clone(&cloned_repo, url, path, &clone_opts);
105105
printf("\n");
106106
if (error != 0) {

examples/network/index-pack.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
#endif
2020
#include "common.h"
2121

22-
// This could be run in the main loop whilst the application waits for
23-
// the indexing to finish in a worker thread
22+
/*
23+
* This could be run in the main loop whilst the application waits for
24+
* the indexing to finish in a worker thread
25+
*/
2426
static int index_cb(const git_transfer_progress *stats, void *data)
2527
{
2628
(void)data;

examples/network/ls-remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static int use_remote(git_repository *repo, char *name)
1212
size_t refs_len, i;
1313
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
1414

15-
// Find the remote by name
15+
/* Find the remote by name */
1616
error = git_remote_lookup(&remote, repo, name);
1717
if (error < 0) {
1818
error = git_remote_create_anonymous(&remote, repo, name);

src/notes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static int note_write(
285285
git_oid oid;
286286
git_tree *tree = NULL;
287287

288-
// TODO: should we apply filters?
288+
/* TODO: should we apply filters? */
289289
/* create note object */
290290
if ((error = git_blob_create_frombuffer(&oid, repo, note, strlen(note))) < 0)
291291
goto cleanup;

src/refspec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
1818
{
19-
// Ported from https://github.com/git/git/blob/f06d47e7e0d9db709ee204ed13a8a7486149f494/remote.c#L518-636
19+
/* Ported from https://github.com/git/git/blob/f06d47e7e0d9db709ee204ed13a8a7486149f494/remote.c#L518-636 */
2020

2121
size_t llen;
2222
int is_glob = 0;

src/signature.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ int git_signature__parse(git_signature *sig, const char **buffer_out,
247247

248248
if ((tz_start[0] != '-' && tz_start[0] != '+') ||
249249
git__strtol32(&offset, tz_start + 1, &tz_end, 10) < 0) {
250-
//malformed timezone, just assume it's zero
250+
/* malformed timezone, just assume it's zero */
251251
offset = 0;
252252
}
253253

src/trailer.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static const char *next_line(const char *str)
3636
if (nl) {
3737
return nl + 1;
3838
} else {
39-
// return pointer to the NUL terminator:
39+
/* return pointer to the NUL terminator: */
4040
return str + strlen(str);
4141
}
4242
}
@@ -310,12 +310,12 @@ int git_message_trailers(git_message_trailer_array *trailer_arr, const char *mes
310310
}
311311

312312
if (isalnum(*ptr) || *ptr == '-') {
313-
// legal key character
313+
/* legal key character */
314314
NEXT(S_KEY);
315315
}
316316

317317
if (*ptr == ' ' || *ptr == '\t') {
318-
// optional whitespace before separator
318+
/* optional whitespace before separator */
319319
*ptr = 0;
320320
NEXT(S_KEY_WS);
321321
}
@@ -325,7 +325,7 @@ int git_message_trailers(git_message_trailer_array *trailer_arr, const char *mes
325325
NEXT(S_SEP_WS);
326326
}
327327

328-
// illegal character
328+
/* illegal character */
329329
GOTO(S_IGNORE);
330330
}
331331
case S_KEY_WS: {
@@ -341,7 +341,7 @@ int git_message_trailers(git_message_trailer_array *trailer_arr, const char *mes
341341
NEXT(S_SEP_WS);
342342
}
343343

344-
// illegal character
344+
/* illegal character */
345345
GOTO(S_IGNORE);
346346
}
347347
case S_SEP_WS: {
@@ -369,7 +369,7 @@ int git_message_trailers(git_message_trailer_array *trailer_arr, const char *mes
369369
}
370370
case S_VALUE_NL: {
371371
if (*ptr == ' ') {
372-
// continuation;
372+
/* continuation; */
373373
NEXT(S_VALUE);
374374
}
375375

src/transports/smart.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ static bool is_malformed_http_header(const char *http_header)
8282
const char *c;
8383
int name_len;
8484

85-
// Disallow \r and \n
85+
/* Disallow \r and \n */
8686
c = strchr(http_header, '\r');
8787
if (c)
8888
return true;
8989
c = strchr(http_header, '\n');
9090
if (c)
9191
return true;
9292

93-
// Require a header name followed by :
93+
/* Require a header name followed by : */
9494
name_len = http_header_name_length(http_header);
9595
if (name_len < 1)
9696
return true;
@@ -112,7 +112,7 @@ static bool is_forbidden_custom_header(const char *custom_header)
112112
unsigned long i;
113113
int name_len = http_header_name_length(custom_header);
114114

115-
// Disallow headers that we set
115+
/* Disallow headers that we set */
116116
for (i = 0; i < ARRAY_SIZE(forbidden_custom_headers); i++)
117117
if (strncmp(forbidden_custom_headers[i], custom_header, name_len) == 0)
118118
return true;

src/win32/posix_w32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ int p_mkstemp(char *tmp_path)
832832
return -1;
833833
#endif
834834

835-
return p_open(tmp_path, O_RDWR | O_CREAT | O_EXCL, 0744); //-V536
835+
return p_open(tmp_path, O_RDWR | O_CREAT | O_EXCL, 0744); /* -V536 */
836836
}
837837

838838
int p_access(const char* path, mode_t mode)

0 commit comments

Comments
 (0)