name-rev: refactor logic to see if a new candidate is a better name
[gitweb.git] / builtin / rev-parse.c
index 1e5bdea0d5ba598b4191238fee761295bd8523ab..9e53a1a7ca4a4ffa0bd810673d432c6f2449f5a5 100644 (file)
@@ -228,9 +228,9 @@ static int show_file(const char *arg, int output_prefix)
        if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV)) {
                if (output_prefix) {
                        const char *prefix = startup_info->prefix;
-                       show(prefix_filename(prefix,
-                                            prefix ? strlen(prefix) : 0,
-                                            arg));
+                       char *fname = prefix_filename(prefix, arg);
+                       show(fname);
+                       free(fname);
                } else
                        show(arg);
                return 1;