Skip to contentSkip to conversation

refs.c: let fprintf handle the formatting

PATCH In review Stefan Beller 1 participant 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 refs.c: let fprintf handle the formatting

Instead of calculating, whether to put a plus or minus sign, offload the responsibilty to the fprintf function.

---
 refs.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
refs.c +2 -5
index 40c5591..1147216 100644
@@ -3972,12 +3972,9 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
 			printf("prune %s", message);
 	} else {
 		if (cb->newlog) {
-			char sign = (tz < 0) ? '-' : '+';
-			int zone = (tz < 0) ? (-tz) : tz;
-			fprintf(cb->newlog, "%s %s %s %lu %c%04d\t%s",
+			fprintf(cb->newlog, "%s %s %s %lu %+05d\t%s",
 				sha1_to_hex(osha1), sha1_to_hex(nsha1),
-				email, timestamp, sign, zone,
-				message);
+				email, timestamp, tz, message);
 			hashcpy(cb->last_kept_sha1, nsha1);
 		}
 		if (cb->flags & EXPIRE_REFLOGS_VERBOSE)
Signature · 1 line
2.2.0
#1 lore raw
Quoted 5 lines · Stefan Beller

Instead of calculating, whether to put a plus or minus sign, offload the responsibilty to the fprintf function.

---

Ah! I forgot the --notes switch when sending out the email:

Michael,

please queue this on top of your reflog series. More to come.

Thanks,
Stefan

Quoted 25 lines
 refs.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
refs.c +2 -6
index 40c5591..1147216 100644
@@ -3972,12 +3972,9 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
                        printf("prune %s", message);
        } else {
                if (cb->newlog) {
-                       char sign = (tz < 0) ? '-' : '+';
-                       int zone = (tz < 0) ? (-tz) : tz;
-                       fprintf(cb->newlog, "%s %s %s %lu %c%04d\t%s",
+                       fprintf(cb->newlog, "%s %s %s %lu %+05d\t%s",
                                sha1_to_hex(osha1), sha1_to_hex(nsha1),
-                               email, timestamp, sign, zone,
-                               message);
+                               email, timestamp, tz, message);
                        hashcpy(cb->last_kept_sha1, nsha1);
                }
                if (cb->flags & EXPIRE_REFLOGS_VERBOSE)
--

2.2.0