@matheusbsbs / matheus-bagliano / commits / e5f38ec3c5
Fork 0

ref-log: style fixes.

A few style fixes to get the code in line with the rest. - asterisk to make a type a pointer to something goes in front of the variable, not at the end of the base type. E.g. a pointer to an integer is "int *ip", not "int* ip". - open parenthesis for function parameter list, unlike syntactic constructs, comes immediately after the function name. E.g. "if (foo) bar();" not "if(foo) bar ();". - "else" does not come on the same line as the closing brace of corresponding "if". The style is mostly a matter of personal taste, and people may disagree, but consistency is important. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Jun 6, 2006 at 14:04 UTC e5f38ec3c5d8553413501e6141932b8ccc7aceb4
3 files changed +18 -13
fetch.c
+4 -2
@@ -150,7 +150,8 @@ static int process(struct object *obj)
150 if (has_sha1_file(obj->sha1)) {
151 /* We already have it, so we should scan it now. */
152 obj->flags |= TO_SCAN;
153 - } else {
153 + }
154 + else {
155 if (obj->flags & COMPLETE)
156 return 0;
157 prefetch(obj->sha1);
@@ -255,7 +256,8 @@ int pull(char *target)
256 if (write_ref_log_details) {
257 msg = xmalloc(strlen(write_ref_log_details) + 12);
258 sprintf(msg, "fetch from %s", write_ref_log_details);
258 - } else
259 + }
260 + else
261 msg = NULL;
262 ret = write_ref_sha1(lock, sha1, msg ? msg : "fetch (unknown)");
263 if (msg)
refs.c
+11 -8
@@ -259,7 +259,7 @@ int check_ref_format(const char *ref)
259 }
260 }
261
262 -static struct ref_lock* verify_lock(struct ref_lock *lock,
262 +static struct ref_lock *verify_lock(struct ref_lock *lock,
263 const unsigned char *old_sha1, int mustexist)
264 {
265 char buf[40];
@@ -285,7 +285,7 @@ static struct ref_lock* verify_lock(struct ref_lock *lock,
285 return lock;
286 }
287
288 -static struct ref_lock* lock_ref_sha1_basic(const char *path,
288 +static struct ref_lock *lock_ref_sha1_basic(const char *path,
289 int plen,
290 const unsigned char *old_sha1, int mustexist)
291 {
@@ -320,7 +320,7 @@ static struct ref_lock* lock_ref_sha1_basic(const char *path,
320 return old_sha1 ? verify_lock(lock, old_sha1, mustexist) : lock;
321 }
322
323 -struct ref_lock* lock_ref_sha1(const char *ref,
323 +struct ref_lock *lock_ref_sha1(const char *ref,
324 const unsigned char *old_sha1, int mustexist)
325 {
326 if (check_ref_format(ref))
@@ -329,14 +329,14 @@ struct ref_lock* lock_ref_sha1(const char *ref,
329 5 + strlen(ref), old_sha1, mustexist);
330 }
331
332 -struct ref_lock* lock_any_ref_for_update(const char *ref,
332 +struct ref_lock *lock_any_ref_for_update(const char *ref,
333 const unsigned char *old_sha1, int mustexist)
334 {
335 return lock_ref_sha1_basic(git_path("%s", ref),
336 strlen(ref), old_sha1, mustexist);
337 }
338
339 -void unlock_ref (struct ref_lock *lock)
339 +void unlock_ref(struct ref_lock *lock)
340 {
341 if (lock->lock_fd >= 0) {
342 close(lock->lock_fd);
@@ -384,7 +384,8 @@ static int log_ref_write(struct ref_lock *lock,
384 sha1_to_hex(sha1),
385 comitter,
386 msg);
387 - } else {
387 + }
388 + else {
389 maxlen = strlen(comitter) + 2*40 + 4;
390 logrec = xmalloc(maxlen);
391 len = snprintf(logrec, maxlen, "%s %s %s\n",
@@ -477,10 +478,12 @@ int read_ref_at(const char *ref, unsigned long at_time, unsigned char *sha1)
478 "warning: Log %s has gap after %s.\n",
479 logfile, show_rfc2822_date(date, tz));
480 }
480 - } else if (date == at_time) {
481 + }
482 + else if (date == at_time) {
483 if (get_sha1_hex(rec + 41, sha1))
484 die("Log %s is corrupt.", logfile);
483 - } else {
485 + }
486 + else {
487 if (get_sha1_hex(rec + 41, logged_sha1))
488 die("Log %s is corrupt.", logfile);
489 if (memcmp(logged_sha1, sha1, 20)) {
refs.h
+3 -3
@@ -24,13 +24,13 @@ extern int for_each_remote_ref(int (*fn)(const char *path, const unsigned char *
24 extern int get_ref_sha1(const char *ref, unsigned char *sha1);
25
26 /** Locks a "refs/" ref returning the lock on success and NULL on failure. **/
27 -extern struct ref_lock* lock_ref_sha1(const char *ref, const unsigned char *old_sha1, int mustexist);
27 +extern struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1, int mustexist);
28
29 /** Locks any ref (for 'HEAD' type refs). */
30 -extern struct ref_lock* lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1, int mustexist);
30 +extern struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1, int mustexist);
31
32 /** Release any lock taken but not written. **/
33 -extern void unlock_ref (struct ref_lock *lock);
33 +extern void unlock_ref(struct ref_lock *lock);
34
35 /** Writes sha1 into the ref specified by the lock. **/
36 extern int write_ref_sha1(struct ref_lock *lock, const unsigned char *sha1, const char *msg);