Re: [PATCH v4 2/2] diff: generate pretty filenames in prep_temp_blob()
- From
Jeff King <peff@peff.net>
- Date
- May 29, 2009, 19:55 UTC
- Message-ID
- <20090529195537.GA13961@coredump.intra.peff.net>
- In-Reply-To
- <1243558164-74756-2-git-send-email-davvid@gmail.com>
On Thu, May 28, 2009 at 05:49:24PM -0700, David Aguilar wrote:
Show 6 quoted lines
> @@ -1964,8 +1964,24 @@ static void prep_temp_blob(const char *path, struct diff_tempfile *temp,
> {
> int fd;
> struct strbuf buf = STRBUF_INIT;
> + struct strbuf template = STRBUF_INIT;
> + char *basename = ((char*)path) + strlen(path) - 1;Why do you drop constness in this assignment?
Show 8 quoted lines
> + /* Windows lacks basename() */
> + while(*basename && basename > path) {
> + basename--;
> + if (is_dir_sep(*basename)) {
> + basename++;
> + break;
> + }
> + }This is such an easily-factorable bit, maybe it makes sense to add as basename() in compat/?
-Peff